]> de.git.xonotic.org Git - xonotic/xonstat.git/blobdiff - xonstat/util/xs_interceptor/xs_interceptor.go
Sanitize the scope at the endpoint level.
[xonotic/xonstat.git] / xonstat / util / xs_interceptor / xs_interceptor.go
index 88eda745149e13aba8ffc9a4d9865f9eef53d979..a968c2c7ecd12ecd75ac9cd1b68b6a062c61f471 100644 (file)
@@ -7,6 +7,7 @@ import "html/template"
 import "net/http"\r
 import "os"\r
 import "strings"\r
+import "time"\r
 import _ "github.com/mattn/go-sqlite3"\r
 \r
 // HTML templates\r
@@ -115,7 +116,10 @@ func serve(port int) {
        // serving\r
        fmt.Printf("Serving on port %d...\n", port)\r
        addr := fmt.Sprintf(":%d", port)\r
-       http.ListenAndServe(addr, nil)\r
+  for true {\r
+    http.ListenAndServe(addr, nil)\r
+    time.Sleep(100*time.Millisecond)\r
+  }\r
 }\r
 \r
 // intercepts all URLs, displays a landing page\r
@@ -211,7 +215,9 @@ func resubmit(url string) {
                }\r
 \r
                req, _ := http.NewRequest("POST", url, strings.NewReader(body))\r
-               req.ContentLength = int64(bodylength)\r
+               //req.ContentLength = int64(bodylength)\r
+    //req.ContentLength = 0\r
+               req.ContentLength = int64(len([]byte(body)))\r
 \r
                header := map[string][]string{\r
                        "X-D0-Blind-Id-Detached-Signature": {blind_id_header},\r
@@ -222,13 +228,16 @@ func resubmit(url string) {
                res, err := http.DefaultClient.Do(req)\r
                if err != nil {\r
                        fmt.Printf("Error submitting request #%d. Continuing...\n", request_id)\r
+                       fmt.Println(err)\r
                        continue\r
                }\r
                defer res.Body.Close()\r
 \r
                fmt.Printf("Request #%d: %s\n", request_id, res.Status)\r
 \r
-               if res.StatusCode < 500 {\r
+    // undeliverables requests will still live in the database,\r
+    // but we can clear out the 200 ones for sure\r
+               if res.StatusCode == 200 {\r
                        successfulRequests = append(successfulRequests, request_id)\r
                }\r
        }\r