package windscribe import ( "io" "net/http" "net/http/cookiejar" ) const ( ReadLimit int64 = 128 * 1024 ) type Client interface { Auth(Auth) error } type client struct { hc *http.Client auth Auth } func New() Client { jar, err := cookiejar.New(nil) if err != nil { panic(err) } c := &client{ hc: &http.Client{ Jar: jar, Transport: &http.Transport{ Proxy: http.ProxyFromEnvironment, }, }, } return c } func fillReq(r *http.Request) { r.Header.Set("Connection", "keep-alive") hdr := map[string]string{ "cache-control": `max-age=0`, "sec-ch-ua": `"Not/A)Brand";v="99", "Google Chrome";v="115", "Chromium";v="115"`, "sec-ch-ua-mobile": `?0`, "sec-ch-ua-platform": `"macOS"`, "origin": `https://windscribe.com`, "dnt": `1`, "upgrade-insecure-requests": `1`, "content-type": `application/x-www-form-urlencoded`, "user-agent": `Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36`, "accept": `text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7`, "sec-fetch-site": `same-origin`, "sec-fetch-mode": `navigate`, "sec-fetch-user": `?1`, "sec-fetch-dest": `document`, "referer": `https://windscribe.com/login`, "accept-language": `en-US,en;q=0.9,fr;q=0.8`, "sec-gpc": `1`, } for k, v := range hdr { r.Header.Set(k, v) } } func cleanupBody(body io.ReadCloser) { io.Copy(io.Discard, &io.LimitedReader{ R: body, N: ReadLimit, }) body.Close() }