A SOCKS (SOCKS4, SOCKS4A and SOCKS5) Proxy Package for Go
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
Matt Baer 5be269b4e6 Move socks package to code.as/core/socks vor 5 Jahren
spec Add spec of SOCKS protocols. vor 11 Jahren
.gitignore Initial commit vor 11 Jahren
LICENSE Add the license file. vor 11 Jahren
README.md Move socks package to code.as/core/socks vor 5 Jahren
socks.go Move socks package to code.as/core/socks vor 5 Jahren

README.md

SOCKS

GoDoc

SOCKS is a SOCKS4, SOCKS4A and SOCKS5 proxy package for Go, forked from h12w/socks and patched so it’s go getable.

Quick Start

Get the package

go get -u "code.as/core/socks"

Import the package

import "code.as/core/socks"

Create a SOCKS proxy dialing function

dialSocksProxy := socks.DialSocksProxy(socks.SOCKS5, "127.0.0.1:1080")
tr := &http.Transport{Dial: dialSocksProxy}
httpClient := &http.Client{Transport: tr}

Example

package main

import (
	"fmt"
	"io/ioutil"
	"log"
	"net/http"

	"code.as/core/socks"
)

func main() {
	dialSocksProxy := socks.DialSocksProxy(socks.SOCKS5, "127.0.0.1:1080")
	tr := &http.Transport{Dial: dialSocksProxy}
	httpClient := &http.Client{Transport: tr}
	resp, err := httpClient.Get("http://www.google.com")
	if err != nil {
		log.Fatal(err)
	}
	defer resp.Body.Close()
	if resp.StatusCode != http.StatusOK {
		log.Fatal(resp.StatusCode)
	}
	buf, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(string(buf))
}

Alternatives

http://godoc.org/golang.org/x/net/proxy