diff --git a/apps/walletshield/main.go b/apps/walletshield/main.go index 112b10e..ac73d9e 100644 --- a/apps/walletshield/main.go +++ b/apps/walletshield/main.go @@ -30,7 +30,7 @@ import ( ) var ( - timeout = time.Second * 45 + timeout = 20 // (default) context timeout ProxyHTTPService = "http_proxy" // Note: UserForwardPayloadLength should match the same value passed to genconfig. @@ -51,7 +51,7 @@ func sendRequest(thin *thin.ThinClient, payload []byte) ([]byte, error) { } nodeId := hash.Sum256(target.MixDescriptor.IdentityKey) - timeoutCtx, _ := context.WithTimeout(context.TODO(), timeout) + timeoutCtx, _ := context.WithTimeout(context.TODO(), time.Duration(timeout)*time.Second) return thin.BlockingSendMessage(timeoutCtx, payload, &nodeId, target.RecipientQueueID) } @@ -70,6 +70,7 @@ func main() { var testProbe bool var testProbeCount int var testProbeResponseDelay int + var testProbeSendDelay int flag.StringVar(&configPath, "config", "", "file path of the client configuration TOML file") flag.IntVar(&delayStart, "delay_start", 0, "max random seconds to delay start") @@ -79,6 +80,8 @@ func main() { flag.BoolVar(&testProbe, "probe", false, "send test probes instead of handling requests") flag.IntVar(&testProbeCount, "probe_count", 1, "number of test probes to send") flag.IntVar(&testProbeResponseDelay, "probe_response_delay", 0, "test probe response deplay") + flag.IntVar(&testProbeSendDelay, "probe_send_delay", 10, "test probe delay between probes") + flag.IntVar(&timeout, "timeout", timeout, "seconds to wait for a request") flag.Parse() if listenAddr == "" && !testProbe { @@ -139,7 +142,7 @@ func main() { } if testProbe { - server.SendTestProbes(10*time.Second, testProbeCount, testProbeResponseDelay) + server.SendTestProbes(testProbeSendDelay, testProbeCount, testProbeResponseDelay) } else { http.HandleFunc("/", server.Handler) err := http.ListenAndServe(listenAddr, nil) @@ -217,7 +220,7 @@ func (s *Server) Handler(w http.ResponseWriter, req *http.Request) { fmt.Fprintf(w, string(response.Payload)) } -func (s *Server) SendTestProbes(d time.Duration, testProbeCount int, testProbeResponseDelay int) { +func (s *Server) SendTestProbes(testProbeSendDelay int, testProbeCount int, testProbeResponseDelay int) { url := fmt.Sprintf("http://nowhere/_/probe/%d", testProbeResponseDelay) req, err := http.NewRequest("GET", url, nil) buf := new(bytes.Buffer) @@ -265,6 +268,6 @@ func (s *Server) SendTestProbes(d time.Duration, testProbeCount int, testProbeRe os.Exit(0) } - time.Sleep(d) + time.Sleep(time.Duration(testProbeSendDelay) * time.Second) } }