Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ocassio committed Apr 12, 2018
0 parents commit 5e149e9
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 0 deletions.
67 changes: 67 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM scratch
ADD server .
CMD ["./server"]
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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 `<USER>` and `<PASSWORD>` placeholders with your own credentials).

```bash
docker run -d --name socks5-proxy -p 1080:1080 -e USER=<USER> -e PASSWORD=<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/
31 changes: 31 additions & 0 deletions server.go
Original file line number Diff line number Diff line change
@@ -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)
}
}

0 comments on commit 5e149e9

Please sign in to comment.