Skip to content

Commit

Permalink
Fix nil pointer dereference
Browse files Browse the repository at this point in the history
  • Loading branch information
web-flow committed Mar 1, 2021
1 parent 951ed75 commit defa30c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions pkg/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var (
anyway = "0"
scheme = "http"
onion = "archivecaslytosk.onion" // archiveiya74codqgiixo33q62qlrqtkgmcitqx5u2oeqnmn5bpcbiyd.onion
cookie = "cf_clearance=dd7e157eb2d43acf2decfafd13c650dd80d825b5-1600696752-KXZXFYWE"
cookie = ""
timeout = 120 * time.Second
baseuri *url.URL
domains = []string{
Expand Down Expand Up @@ -90,14 +90,15 @@ func (wbrc *Archiver) fetch(s string, ch chan<- string) {
data := url.Values{
"submitid": {wbrc.submitid},
"anyway": {anyway},
"url": {s},
"url": {url.QueryEscape(s)},
}
uri := baseuri.String()
req, err := http.NewRequest("POST", baseuri.String()+"/submit/", strings.NewReader(data.Encode()))
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
req.Header.Add("Content-Length", strconv.Itoa(len(data.Encode())))
req.Header.Add("User-Agent", userAgent)
req.Header.Add("Referer", baseuri.String())
req.Header.Add("Origin", baseuri.String())
req.Header.Add("Referer", uri)
req.Header.Add("Origin", uri)
req.Header.Add("Host", baseuri.Hostname())
req.Header.Add("Cookie", wbrc.getCookie())
resp, err := wbrc.httpClient.Do(req)
Expand All @@ -109,7 +110,7 @@ func (wbrc *Archiver) fetch(s string, ch chan<- string) {

code := resp.StatusCode / 100
if code == 1 || code == 4 || code == 5 {
final := fmt.Sprintf("%v?url=%s", baseuri.String(), s)
final := fmt.Sprintf("%s?url=%s", uri, s)
ch <- final
return
}
Expand Down Expand Up @@ -168,7 +169,6 @@ func (wbrc *Archiver) getSubmitID(url string) (string, error) {
if err != nil {
return "", err
}

defer resp.Body.Close()

if resp.StatusCode != http.StatusOK {
Expand Down

0 comments on commit defa30c

Please sign in to comment.