diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fbe3729 --- /dev/null +++ b/.gitignore @@ -0,0 +1,67 @@ +server + +### Linux ### +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +### macOS ### +*.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +ehthumbs.db +ehthumbs_vista.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msm +*.msp + +# Windows shortcuts +*.lnk + + +# End of https://www.gitignore.io/api/macos,linux,windows \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..92bc774 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,3 @@ +FROM scratch +ADD server . +CMD ["./server"] \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..9a7078d --- /dev/null +++ b/README.md @@ -0,0 +1,24 @@ +# Build +The following command will perform a build of a static binary for Linux. +The result of this build can be used by a scratch Docker image. This reduces container size drastically. + +```bash +CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o server . +``` + +# Docker image usage + +You can start Docker container with the following command (make sure to replace `` and `` placeholders with your own credentials). + +```bash +docker run -d --name socks5-proxy -p 1080:1080 -e USER= -e PASSWORD= ocassio/go-socks5-proxy +``` + +# Special thanks + +- The original idea. Actually this project is just a very lightweight variation of the serj's one: + https://github.com/serjs/socks5-server +- SOCKS 5 server implementation for Go: + https://github.com/armon/go-socks5 +- Article about building minimal Go containers with Docker by Nick Gauthier: + https://blog.codeship.com/building-minimal-docker-containers-for-go-applications/ diff --git a/server.go b/server.go new file mode 100644 index 0000000..44f1738 --- /dev/null +++ b/server.go @@ -0,0 +1,31 @@ +package main + +import ( + "log" + "os" + + "github.com/armon/go-socks5" +) + +func main() { + + creadentials := socks5.StaticCredentials{ + os.Getenv("USER"): os.Getenv("PASSWORD"), + } + authenticator := socks5.UserPassAuthenticator{Credentials: creadentials} + + // Create a SOCKS5 server + config := &socks5.Config{ + AuthMethods: []socks5.Authenticator{authenticator}, + Logger: log.New(os.Stdout, "", log.LstdFlags), + } + server, err := socks5.New(config) + if err != nil { + panic(err) + } + + // Create SOCKS5 proxy on localhost port 8000 + if err := server.ListenAndServe("tcp", "0.0.0.0:1080"); err != nil { + panic(err) + } +}