Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add new env DIAL_TIMEOUT to set dial timeout #17

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
go.sum
/*.exe
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
ARG GOLANG_VERSION="1.12"
ARG GOLANG_VERSION="1.14.2"

FROM golang:$GOLANG_VERSION-alpine as builder
WORKDIR /go/src/github.com/olebedev/socks5
WORKDIR /go/src/github.com/serjs/socks5-server
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags '-s' -o ./socks5
RUN CGO_ENABLED=0 GOOS=linux go build --ldflags "-s -w" -a -installsuffix cgo -o socks5 .

FROM scratch
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /go/src/github.com/olebedev/socks5/socks5 /
COPY --from=builder /go/src/github.com/serjs/socks5/socks5 /
ENTRYPOINT ["/socks5"]
27 changes: 0 additions & 27 deletions Gopkg.lock

This file was deleted.

30 changes: 0 additions & 30 deletions Gopkg.toml

This file was deleted.

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Leave `PROXY_USER` and `PROXY_PASSWORD` empty for skip authentication options wh
|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|
|DIAL_TIMEOUT|String|3s|Set dial connect timeout,default 3s|

## Test running service

Expand Down
9 changes: 9 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module github.com/serjs/socks5-server

go 1.13

require (
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5
github.com/caarlos0/env v3.3.1-0.20180521112546-3e0f30cbf50b+incompatible
golang.org/x/net v0.0.0-20200506145744-7e3656a0809f // indirect
)
16 changes: 13 additions & 3 deletions server.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
package main

import (
"context"
"log"
"net"
"os"
"time"

"github.com/armon/go-socks5"
"github.com/caarlos0/env"
)

type params struct {
User string `env:"PROXY_USER" envDefault:""`
Password string `env:"PROXY_PASSWORD" envDefault:""`
Port string `env:"PROXY_PORT" envDefault:"1080"`
User string `env:"PROXY_USER" envDefault:""`
Password string `env:"PROXY_PASSWORD" envDefault:""`
Port string `env:"PROXY_PORT" envDefault:"1080"`
Timeout time.Duration `env:"DIAL_TIMEOUT" envDefault:"3s"`
}

func main() {
Expand All @@ -25,6 +29,12 @@ func main() {
//Initialize socks5 config
socsk5conf := &socks5.Config{
Logger: log.New(os.Stdout, "", log.LstdFlags),
Dial: func(ctx context.Context, network, addr string) (net.Conn, error) {
d := net.Dialer{
Timeout: cfg.Timeout,
}
return d.DialContext(ctx, network, addr)
},
}

if cfg.User+cfg.Password != "" {
Expand Down
22 changes: 0 additions & 22 deletions vendor/github.com/armon/go-socks5/.gitignore

This file was deleted.

4 changes: 0 additions & 4 deletions vendor/github.com/armon/go-socks5/.travis.yml

This file was deleted.

20 changes: 0 additions & 20 deletions vendor/github.com/armon/go-socks5/LICENSE

This file was deleted.

45 changes: 0 additions & 45 deletions vendor/github.com/armon/go-socks5/README.md

This file was deleted.

151 changes: 0 additions & 151 deletions vendor/github.com/armon/go-socks5/auth.go

This file was deleted.

Loading