Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/3wille/socks5
Forked from github.com/oov/socks5
https://github.com/3wille/socks5
Last synced: about 2 months ago
JSON representation
Forked from github.com/oov/socks5
- Host: GitHub
- URL: https://github.com/3wille/socks5
- Owner: 3wille
- License: mit
- Created: 2017-10-14T19:32:04.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-02-11T15:11:28.000Z (almost 7 years ago)
- Last Synced: 2024-06-19T14:57:57.583Z (7 months ago)
- Language: Go
- Homepage:
- Size: 18.6 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
socks5
======Package socks5 implements a "SOCKS Protocol Version 5" server.
This server supports a subset of RFC 1928:
* auth methods: "NO AUTHENTICATION REQUIRED", "USERNAME/PASSWORD"
* commands: "CONNECT"
* address types: "IP V4 address", "DOMAINNAME", "IP V6 address"
(but tested "DOMAINNAME" only)INSTALL
-------```sh
go get -u github.com/oov/socks5
```USAGE
-----```go
package mainimport (
"github.com/oov/socks5"
"log"
)func main() {
srv := socks5.New()
srv.AuthUsernamePasswordCallback = func(c *socks5.Conn, username, password []byte) error {
user := string(username)
if user != "guest" {
return socks5.ErrAuthenticationFailed
}log.Printf("Welcome %v!", user)
c.Data = user
return nil
}
srv.HandleConnectFunc(func(c *socks5.Conn, host string) (newHost string, err error) {
if host == "example.com:80" {
return host, socks5.ErrConnectionNotAllowedByRuleset
}
if user, ok := c.Data.(string); ok {
log.Printf("%v connecting to %v", user, host)
}
return host, nil
})
srv.HandleCloseFunc(func(c *socks5.Conn) {
if user, ok := c.Data.(string); ok {
log.Printf("Goodbye %v!", user)
}
})srv.ListenAndServe(":12345")
}
```