about summary refs log tree commit diff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/main.go b/main.go
index 35f32dc..466ee21 100644
--- a/main.go
+++ b/main.go
@@ -8,8 +8,10 @@ import (
 	"net/http"
 	"os"
 	"strings"
+	"time"
 
 	"gopkg.in/h2non/gentleman.v2"
+    "gopkg.in/h2non/gentleman.v2/plugins/timeout"
 )
 
 var session = flag.String("session", "9e8831af-ce30-48c3-8663-4b27262f43f1.pjKPVCYufDhuA9GPJAlc_xh45M8", "The session (the value of the cookie named 'session')")
@@ -65,6 +67,10 @@ func fetchAllChallenges() (Challenges, error) {
 	cli := gentleman.New()
 	cli.URL(*rootURL)
 
+	// define the timeouts outrageously long, as some CTFs hosted using CTFd are incredibly inresponsive.
+	cli.Use(timeout.Request(1000 * time.Second))
+	cli.Use(timeout.Dial(1000 * time.Second, 2000 * time.Second))
+
 	req := cli.Request()
 	req.Path("/api/v1/challenges")
 
@@ -84,6 +90,8 @@ func fetchAllChallenges() (Challenges, error) {
 	// unmarshal the resulting json into a Challenges struct
 	var challenges Challenges
 	if err := json.Unmarshal(res.Bytes(), &challenges); err != nil {
+		fmt.Printf("Challenge unmarshal error: %d\n", res.StatusCode)
+		fmt.Println(res.String())
 		return Challenges{}, err
 	}
 	fmt.Println("Done fetching all challenges")