Skip to content

Instantly share code, notes, and snippets.

@inhies
Created December 16, 2016 19:28
Show Gist options
  • Select an option

  • Save inhies/cd88b4147e18c1f5376a2beea3ffd2fc to your computer and use it in GitHub Desktop.

Select an option

Save inhies/cd88b4147e18c1f5376a2beea3ffd2fc to your computer and use it in GitHub Desktop.

Revisions

  1. inhies created this gist Dec 16, 2016.
    13 changes: 13 additions & 0 deletions useproxy.go
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@

    // create a socks5 dialer
    dialer, err := proxy.SOCKS5("tcp", PROXY_ADDR, nil, proxy.Direct)
    if err != nil {
    fmt.Fprintln(os.Stderr, "can't connect to the proxy:", err)
    os.Exit(1)
    }
    // setup a http client
    httpTransport := &http.Transport{}
    // set our socks5 as the dialer
    httpTransport.Dial = dialer.Dial
    http.DefaultClient = &http.Client{Transport: httpTransport}