fix: silly golang runtime exception
This commit is contained in:
parent
ed0fa7ff1f
commit
ba68c42b6f
@ -8,4 +8,5 @@ RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags '-s' -o ./s
|
||||
|
||||
FROM gcr.io/distroless/static:nonroot
|
||||
COPY --from=builder /go/src/github.com/serjs/socks5/socks5 /
|
||||
|
||||
ENTRYPOINT ["/socks5"]
|
||||
|
37
README.md
37
README.md
@ -9,26 +9,31 @@ Simple socks5 server using go-socks5 with authentication, allowed ips list and d
|
||||
|
||||
- Run docker container using default container port 1080 and expose it to world using host port 1080, with auth creds
|
||||
|
||||
```docker run -d --name socks5 -p 1080:1080 -e PROXY_USER=<PROXY_USER> -e PROXY_PASSWORD=<PROXY_PASSWORD> serjs/go-socks5-proxy```
|
||||
`docker run -d --name socks5 -p 1080:1080 -e PROXY_USER=<PROXY_USER> -e PROXY_PASSWORD=<PROXY_PASSWORD> serjs/go-socks5-proxy`
|
||||
|
||||
- Leave `PROXY_USER` and `PROXY_PASSWORD` empty for skip authentication options while running socks5 server, see example below
|
||||
- Leave `PROXY_USER` and `PROXY_PASSWORD` empty for skip authentication options while running socks5 server, see example below
|
||||
|
||||
- Run docker container using specifit container port and expose it to host port 1090, without auth creds
|
||||
|
||||
```docker run -d --name socks5 -p 1090:9090 -e PROXY_PORT=9090 serjs/go-socks5-proxy```
|
||||
`docker run -d --name socks5 -p 1090:9090 -e PROXY_PORT=9090 serjs/go-socks5-proxy`
|
||||
|
||||
- Run docker container using default container port 1080 and expose it to world using host port 1080, with PROXY_CREDENTIALS multi-user authentication
|
||||
|
||||
`docker run -d --name socks5 -p 1080:1080 -e PROXY_CREDENTIALS='[{"username":"TEST_USERNAME","password":"password123"}]' serjs/go-socks5-proxy`
|
||||
|
||||
# List of supported config parameters
|
||||
|
||||
|ENV variable|Type|Default|Description|
|
||||
|------------|----|-------|-----------|
|
||||
|PROXY_USER|String|EMPTY|Set proxy user (also required existed PROXY_PASS)|
|
||||
|PROXY_PASSWORD|String|EMPTY|Set proxy password for auth, used with PROXY_USER|
|
||||
|PROXY_PORT|String|1080|Set listen port for application inside docker container|
|
||||
|ALLOWED_DEST_FQDN|String|EMPTY|Allowed destination address regular expression pattern. Default allows all.|
|
||||
|ALLOWED_IPS|String|Empty|Set allowed IP's that can connect to proxy, separator `,`|
|
||||
|
||||
| ENV variable | Type | Default | Description |
|
||||
| ----------------- | ----------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| PROXY_CREDENTIALS | Json Object | EMPTY | Provide a JSON stringified object representing a list of allowed user/password credential pairs. The form of this object is `{ password: string, username: string }[]`. See |
|
||||
| PROXY_USER | String | EMPTY | Set proxy user (also required existed PROXY_PASS) |
|
||||
| PROXY_PASSWORD | String | EMPTY | Set proxy password for auth, used with PROXY_USER |
|
||||
| PROXY_PORT | String | 1080 | Set listen port for application inside docker container |
|
||||
| ALLOWED_DEST_FQDN | String | EMPTY | Allowed destination address regular expression pattern. Default allows all. |
|
||||
| ALLOWED_IPS | String | Empty | Set allowed IP's that can connect to proxy, separator `,` |
|
||||
|
||||
# Build your own image:
|
||||
|
||||
`docker-compose -f docker-compose.build.yml up -d`\
|
||||
Just don't forget to set parameters in the `.env` file.
|
||||
|
||||
@ -38,22 +43,22 @@ Assuming that you are using container on 1080 host docker port
|
||||
|
||||
## Without authentication
|
||||
|
||||
```curl --socks5 <docker host ip>:1080 https://ifcfg.co``` - result must show docker host ip (for bridged network)
|
||||
`curl --socks5 <docker host ip>:1080 https://ifcfg.co` - result must show docker host ip (for bridged network)
|
||||
|
||||
or
|
||||
|
||||
```docker run --rm curlimages/curl:7.65.3 -s --socks5 <docker host ip>:1080 https://ifcfg.co```
|
||||
`docker run --rm curlimages/curl:7.65.3 -s --socks5 <docker host ip>:1080 https://ifcfg.co`
|
||||
|
||||
## With authentication
|
||||
|
||||
```curl --socks5 <docker host ip>:1080 -U <PROXY_USER>:<PROXY_PASSWORD> http://ifcfg.co```
|
||||
`curl --socks5 <docker host ip>:1080 -U <PROXY_USER>:<PROXY_PASSWORD> http://ifcfg.co`
|
||||
|
||||
or
|
||||
|
||||
```docker run --rm curlimages/curl:7.65.3 -s --socks5 <PROXY_USER>:<PROXY_PASSWORD>@<docker host ip>:1080 http://ifcfg.co```
|
||||
`docker run --rm curlimages/curl:7.65.3 -s --socks5 <PROXY_USER>:<PROXY_PASSWORD>@<docker host ip>:1080 http://ifcfg.co`
|
||||
|
||||
# Authors
|
||||
|
||||
* **Sergey Bogayrets**
|
||||
- **Sergey Bogayrets**
|
||||
|
||||
See also the list of [contributors](https://github.com/serjs/socks5-server/graphs/contributors) who participated in this project.
|
||||
|
@ -2,26 +2,19 @@ package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/armon/go-socks5"
|
||||
)
|
||||
|
||||
type credentials struct {
|
||||
type Credentials struct {
|
||||
Username string `json:"username"`
|
||||
Password string `json:"password"`
|
||||
}
|
||||
|
||||
func parseCredentials(credsString string) (socks5.StaticCredentials, error) {
|
||||
var creds []credentials
|
||||
func parseCredentials(credsString string) ([]Credentials, error) {
|
||||
var creds []Credentials
|
||||
err := json.Unmarshal([]byte(credsString), &creds)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var credsMap socks5.StaticCredentials
|
||||
for _, cred := range creds {
|
||||
credsMap[cred.Username] = cred.Password
|
||||
}
|
||||
|
||||
return credsMap, nil
|
||||
return creds, nil
|
||||
}
|
||||
|
11
server.go
11
server.go
@ -31,12 +31,19 @@ func main() {
|
||||
Logger: log.New(os.Stdout, "", log.LstdFlags),
|
||||
}
|
||||
|
||||
log.Printf(cfg.Creds)
|
||||
|
||||
var creds socks5.StaticCredentials
|
||||
if cfg.Creds != "" {
|
||||
creds, err = parseCredentials(cfg.Creds)
|
||||
if err != nil {
|
||||
var uname_pw_pairs, creds_err = parseCredentials(cfg.Creds)
|
||||
|
||||
if creds_err != nil {
|
||||
log.Printf("%+v\n", err)
|
||||
}
|
||||
|
||||
for _, kv := range uname_pw_pairs {
|
||||
creds[kv.Username] = kv.Password
|
||||
}
|
||||
}
|
||||
if cfg.User+cfg.Password != "" {
|
||||
creds[cfg.User] = cfg.Password
|
||||
|
Loading…
Reference in New Issue
Block a user