Skip to content
/ socks5 Public
forked from txthinking/socks5

SOCKS Protocol Version 5 Library in Go

License

Notifications You must be signed in to change notification settings

NOED7I/socks5

Repository files navigation

socks5

Go Report Card GoDoc

SOCKS Protocol Version 5 Library

Install

$ go get github.com/txthinking/socks5

Example

func ExampleServer() {
	socks5.Debug = true // enable socks5 debug log

	l, err := net.Listen("tcp", ":1980")
	if err != nil {
		log.Println(err)
		return
	}
	defer l.Close()

	for {
		c, err := l.Accept()
		if err != nil {
			log.Println(err)
			return
		}
		go func(c net.Conn) {
			defer c.Close()
			s5s := socks5.NewClassicServer(c)
			if err := s5s.Negotiate(); err != nil {
				log.Println(err)
				return
			}
			r, err := s5s.GetRequest()
			if err != nil {
				log.Println(err)
				return
			}
			rc, err := r.Connect(c)
			if err != nil {
				log.Println(err)
				return
			}
			defer rc.Close()
			go func() {
				_, _ = io.Copy(c, rc)
			}()
			_, _ = io.Copy(rc, c)
		}(c)
	}
}

Now you have a socks5 proxy listen on :1980

You can test with curl: curl --socks5-hostname YOUR_SERVER_IP:1980 http://httpbin.org/ip

About

SOCKS Protocol Version 5 Library in Go

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%