From 93554c03aaa1927e9d2bbf0dcf2ddb0f13802901 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 11 Oct 2023 22:23:38 +0000 Subject: [PATCH 01/10] Bump golang.org/x/net from 0.1.0 to 0.17.0 Bumps [golang.org/x/net](https://github.com/golang/net) from 0.1.0 to 0.17.0. - [Commits](https://github.com/golang/net/compare/v0.1.0...v0.17.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: indirect ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 +-- vendor/github.com/armon/go-socks5/socks5.go | 32 --------------------- vendor/modules.txt | 2 +- 4 files changed, 4 insertions(+), 36 deletions(-) diff --git a/go.mod b/go.mod index 3a29ddb1..8d190a2f 100644 --- a/go.mod +++ b/go.mod @@ -7,4 +7,4 @@ require ( github.com/caarlos0/env/v6 v6.10.1 ) -require golang.org/x/net v0.1.0 // indirect +require golang.org/x/net v0.17.0 diff --git a/go.sum b/go.sum index 95fdbdc5..49b7c697 100644 --- a/go.sum +++ b/go.sum @@ -2,5 +2,5 @@ github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPd github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= github.com/caarlos0/env/v6 v6.10.1 h1:t1mPSxNpei6M5yAeu1qtRdPAK29Nbcf/n3G7x+b3/II= github.com/caarlos0/env/v6 v6.10.1/go.mod h1:hvp/ryKXKipEkcuYjs9mI4bBCg+UI0Yhgm5Zu0ddvwc= -golang.org/x/net v0.1.0 h1:hZ/3BUoy5aId7sCpA/Tc5lt8DkFgdVS2onTpJsZ/fl0= -golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= +golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= +golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= diff --git a/vendor/github.com/armon/go-socks5/socks5.go b/vendor/github.com/armon/go-socks5/socks5.go index 2d630fb4..a17be68f 100644 --- a/vendor/github.com/armon/go-socks5/socks5.go +++ b/vendor/github.com/armon/go-socks5/socks5.go @@ -55,7 +55,6 @@ type Config struct { type Server struct { config *Config authMethods map[uint8]Authenticator - isIPAllowed func(net.IP) bool } // New creates a new Server and potentially returns an error @@ -94,11 +93,6 @@ func New(conf *Config) (*Server, error) { server.authMethods[a.GetCode()] = a } - // Set default IP whitelist function - server.isIPAllowed = func(ip net.IP) bool { - return true // default allow all IPs - } - return server, nil } @@ -123,37 +117,11 @@ func (s *Server) Serve(l net.Listener) error { return nil } -// SetIPWhitelist sets the function to check if a given IP is allowed -func (s *Server) SetIPWhitelist(allowedIPs []net.IP) { - s.isIPAllowed = func(ip net.IP) bool { - for _, allowedIP := range allowedIPs { - if ip.Equal(allowedIP) { - return true - } - } - return false - } -} - // ServeConn is used to serve a single connection. func (s *Server) ServeConn(conn net.Conn) error { defer conn.Close() bufConn := bufio.NewReader(conn) - // Check client IP against whitelist - clientIP, _, err := net.SplitHostPort(conn.RemoteAddr().String()) - if err != nil { - s.config.Logger.Printf("[ERR] socks: Failed to get client IP address: %v", err) - return err - } - ip := net.ParseIP(clientIP) - if s.isIPAllowed(ip) { - s.config.Logger.Printf("[INFO] socks: Connection from allowed IP address: %s", clientIP) - } else { - s.config.Logger.Printf("[WARN] socks: Connection from not allowed IP address: %s", clientIP) - return fmt.Errorf("connection from not allowed IP address") - } - // Read the version byte version := []byte{0} if _, err := bufConn.Read(version); err != nil { diff --git a/vendor/modules.txt b/vendor/modules.txt index 6129cc3f..39993320 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -4,6 +4,6 @@ github.com/armon/go-socks5 # github.com/caarlos0/env/v6 v6.10.1 ## explicit; go 1.17 github.com/caarlos0/env/v6 -# golang.org/x/net v0.1.0 +# golang.org/x/net v0.17.0 ## explicit; go 1.17 golang.org/x/net/context From 8cf68ff9d4e43d7f65ee8ac3a6d0c03228db2945 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 23 Sep 2025 13:13:01 +0000 Subject: [PATCH 02/10] Bump golang.org/x/net from 0.17.0 to 0.38.0 Bumps [golang.org/x/net](https://github.com/golang/net) from 0.17.0 to 0.38.0. - [Commits](https://github.com/golang/net/compare/v0.17.0...v0.38.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-version: 0.38.0 dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- go.mod | 4 +- go.sum | 4 +- vendor/golang.org/x/net/LICENSE | 4 +- vendor/golang.org/x/net/context/context.go | 112 +++++++- vendor/golang.org/x/net/context/go17.go | 73 ----- vendor/golang.org/x/net/context/go19.go | 21 -- vendor/golang.org/x/net/context/pre_go17.go | 301 -------------------- vendor/golang.org/x/net/context/pre_go19.go | 110 ------- vendor/modules.txt | 4 +- 9 files changed, 108 insertions(+), 525 deletions(-) delete mode 100644 vendor/golang.org/x/net/context/go17.go delete mode 100644 vendor/golang.org/x/net/context/go19.go delete mode 100644 vendor/golang.org/x/net/context/pre_go17.go delete mode 100644 vendor/golang.org/x/net/context/pre_go19.go diff --git a/go.mod b/go.mod index 8d190a2f..2319da92 100644 --- a/go.mod +++ b/go.mod @@ -1,10 +1,10 @@ module github.com/serjs/socks5-server -go 1.19 +go 1.23.0 require ( github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 github.com/caarlos0/env/v6 v6.10.1 ) -require golang.org/x/net v0.17.0 +require golang.org/x/net v0.38.0 diff --git a/go.sum b/go.sum index 49b7c697..90cec29e 100644 --- a/go.sum +++ b/go.sum @@ -2,5 +2,5 @@ github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPd github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= github.com/caarlos0/env/v6 v6.10.1 h1:t1mPSxNpei6M5yAeu1qtRdPAK29Nbcf/n3G7x+b3/II= github.com/caarlos0/env/v6 v6.10.1/go.mod h1:hvp/ryKXKipEkcuYjs9mI4bBCg+UI0Yhgm5Zu0ddvwc= -golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= -golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= +golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8= +golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= diff --git a/vendor/golang.org/x/net/LICENSE b/vendor/golang.org/x/net/LICENSE index 6a66aea5..2a7cf70d 100644 --- a/vendor/golang.org/x/net/LICENSE +++ b/vendor/golang.org/x/net/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2009 The Go Authors. All rights reserved. +Copyright 2009 The Go Authors. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -10,7 +10,7 @@ notice, this list of conditions and the following disclaimer. copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of Google Inc. nor the names of its + * Neither the name of Google LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. diff --git a/vendor/golang.org/x/net/context/context.go b/vendor/golang.org/x/net/context/context.go index cf66309c..db1c95fa 100644 --- a/vendor/golang.org/x/net/context/context.go +++ b/vendor/golang.org/x/net/context/context.go @@ -3,29 +3,31 @@ // license that can be found in the LICENSE file. // Package context defines the Context type, which carries deadlines, -// cancelation signals, and other request-scoped values across API boundaries +// cancellation signals, and other request-scoped values across API boundaries // and between processes. // As of Go 1.7 this package is available in the standard library under the -// name context. https://golang.org/pkg/context. +// name [context], and migrating to it can be done automatically with [go fix]. // -// Incoming requests to a server should create a Context, and outgoing calls to -// servers should accept a Context. The chain of function calls between must -// propagate the Context, optionally replacing it with a modified copy created -// using WithDeadline, WithTimeout, WithCancel, or WithValue. +// Incoming requests to a server should create a [Context], and outgoing +// calls to servers should accept a Context. The chain of function +// calls between them must propagate the Context, optionally replacing +// it with a derived Context created using [WithCancel], [WithDeadline], +// [WithTimeout], or [WithValue]. // // Programs that use Contexts should follow these rules to keep interfaces // consistent across packages and enable static analysis tools to check context // propagation: // // Do not store Contexts inside a struct type; instead, pass a Context -// explicitly to each function that needs it. The Context should be the first +// explicitly to each function that needs it. This is discussed further in +// https://go.dev/blog/context-and-structs. The Context should be the first // parameter, typically named ctx: // // func DoSomething(ctx context.Context, arg Arg) error { // // ... use ctx ... // } // -// Do not pass a nil Context, even if a function permits it. Pass context.TODO +// Do not pass a nil [Context], even if a function permits it. Pass [context.TODO] // if you are unsure about which Context to use. // // Use context Values only for request-scoped data that transits processes and @@ -34,9 +36,30 @@ // The same Context may be passed to functions running in different goroutines; // Contexts are safe for simultaneous use by multiple goroutines. // -// See http://blog.golang.org/context for example code for a server that uses +// See https://go.dev/blog/context for example code for a server that uses // Contexts. -package context // import "golang.org/x/net/context" +// +// [go fix]: https://go.dev/cmd/go#hdr-Update_packages_to_use_new_APIs +package context + +import ( + "context" // standard library's context, as of Go 1.7 + "time" +) + +// A Context carries a deadline, a cancellation signal, and other values across +// API boundaries. +// +// Context's methods may be called by multiple goroutines simultaneously. +type Context = context.Context + +// Canceled is the error returned by [Context.Err] when the context is canceled +// for some reason other than its deadline passing. +var Canceled = context.Canceled + +// DeadlineExceeded is the error returned by [Context.Err] when the context is canceled +// due to its deadline passing. +var DeadlineExceeded = context.DeadlineExceeded // Background returns a non-nil, empty Context. It is never canceled, has no // values, and has no deadline. It is typically used by the main function, @@ -49,8 +72,73 @@ func Background() Context { // TODO returns a non-nil, empty Context. Code should use context.TODO when // it's unclear which Context to use or it is not yet available (because the // surrounding function has not yet been extended to accept a Context -// parameter). TODO is recognized by static analysis tools that determine -// whether Contexts are propagated correctly in a program. +// parameter). func TODO() Context { return todo } + +var ( + background = context.Background() + todo = context.TODO() +) + +// A CancelFunc tells an operation to abandon its work. +// A CancelFunc does not wait for the work to stop. +// A CancelFunc may be called by multiple goroutines simultaneously. +// After the first call, subsequent calls to a CancelFunc do nothing. +type CancelFunc = context.CancelFunc + +// WithCancel returns a derived context that points to the parent context +// but has a new Done channel. The returned context's Done channel is closed +// when the returned cancel function is called or when the parent context's +// Done channel is closed, whichever happens first. +// +// Canceling this context releases resources associated with it, so code should +// call cancel as soon as the operations running in this [Context] complete. +func WithCancel(parent Context) (ctx Context, cancel CancelFunc) { + return context.WithCancel(parent) +} + +// WithDeadline returns a derived context that points to the parent context +// but has the deadline adjusted to be no later than d. If the parent's +// deadline is already earlier than d, WithDeadline(parent, d) is semantically +// equivalent to parent. The returned [Context.Done] channel is closed when +// the deadline expires, when the returned cancel function is called, +// or when the parent context's Done channel is closed, whichever happens first. +// +// Canceling this context releases resources associated with it, so code should +// call cancel as soon as the operations running in this [Context] complete. +func WithDeadline(parent Context, d time.Time) (Context, CancelFunc) { + return context.WithDeadline(parent, d) +} + +// WithTimeout returns WithDeadline(parent, time.Now().Add(timeout)). +// +// Canceling this context releases resources associated with it, so code should +// call cancel as soon as the operations running in this [Context] complete: +// +// func slowOperationWithTimeout(ctx context.Context) (Result, error) { +// ctx, cancel := context.WithTimeout(ctx, 100*time.Millisecond) +// defer cancel() // releases resources if slowOperation completes before timeout elapses +// return slowOperation(ctx) +// } +func WithTimeout(parent Context, timeout time.Duration) (Context, CancelFunc) { + return context.WithTimeout(parent, timeout) +} + +// WithValue returns a derived context that points to the parent Context. +// In the derived context, the value associated with key is val. +// +// Use context Values only for request-scoped data that transits processes and +// APIs, not for passing optional parameters to functions. +// +// The provided key must be comparable and should not be of type +// string or any other built-in type to avoid collisions between +// packages using context. Users of WithValue should define their own +// types for keys. To avoid allocating when assigning to an +// interface{}, context keys often have concrete type +// struct{}. Alternatively, exported context key variables' static +// type should be a pointer or interface. +func WithValue(parent Context, key, val interface{}) Context { + return context.WithValue(parent, key, val) +} diff --git a/vendor/golang.org/x/net/context/go17.go b/vendor/golang.org/x/net/context/go17.go deleted file mode 100644 index 2cb9c408..00000000 --- a/vendor/golang.org/x/net/context/go17.go +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build go1.7 -// +build go1.7 - -package context - -import ( - "context" // standard library's context, as of Go 1.7 - "time" -) - -var ( - todo = context.TODO() - background = context.Background() -) - -// Canceled is the error returned by Context.Err when the context is canceled. -var Canceled = context.Canceled - -// DeadlineExceeded is the error returned by Context.Err when the context's -// deadline passes. -var DeadlineExceeded = context.DeadlineExceeded - -// WithCancel returns a copy of parent with a new Done channel. The returned -// context's Done channel is closed when the returned cancel function is called -// or when the parent context's Done channel is closed, whichever happens first. -// -// Canceling this context releases resources associated with it, so code should -// call cancel as soon as the operations running in this Context complete. -func WithCancel(parent Context) (ctx Context, cancel CancelFunc) { - ctx, f := context.WithCancel(parent) - return ctx, f -} - -// WithDeadline returns a copy of the parent context with the deadline adjusted -// to be no later than d. If the parent's deadline is already earlier than d, -// WithDeadline(parent, d) is semantically equivalent to parent. The returned -// context's Done channel is closed when the deadline expires, when the returned -// cancel function is called, or when the parent context's Done channel is -// closed, whichever happens first. -// -// Canceling this context releases resources associated with it, so code should -// call cancel as soon as the operations running in this Context complete. -func WithDeadline(parent Context, deadline time.Time) (Context, CancelFunc) { - ctx, f := context.WithDeadline(parent, deadline) - return ctx, f -} - -// WithTimeout returns WithDeadline(parent, time.Now().Add(timeout)). -// -// Canceling this context releases resources associated with it, so code should -// call cancel as soon as the operations running in this Context complete: -// -// func slowOperationWithTimeout(ctx context.Context) (Result, error) { -// ctx, cancel := context.WithTimeout(ctx, 100*time.Millisecond) -// defer cancel() // releases resources if slowOperation completes before timeout elapses -// return slowOperation(ctx) -// } -func WithTimeout(parent Context, timeout time.Duration) (Context, CancelFunc) { - return WithDeadline(parent, time.Now().Add(timeout)) -} - -// WithValue returns a copy of parent in which the value associated with key is -// val. -// -// Use context Values only for request-scoped data that transits processes and -// APIs, not for passing optional parameters to functions. -func WithValue(parent Context, key interface{}, val interface{}) Context { - return context.WithValue(parent, key, val) -} diff --git a/vendor/golang.org/x/net/context/go19.go b/vendor/golang.org/x/net/context/go19.go deleted file mode 100644 index 64d31ecc..00000000 --- a/vendor/golang.org/x/net/context/go19.go +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build go1.9 -// +build go1.9 - -package context - -import "context" // standard library's context, as of Go 1.7 - -// A Context carries a deadline, a cancelation signal, and other values across -// API boundaries. -// -// Context's methods may be called by multiple goroutines simultaneously. -type Context = context.Context - -// A CancelFunc tells an operation to abandon its work. -// A CancelFunc does not wait for the work to stop. -// After the first call, subsequent calls to a CancelFunc do nothing. -type CancelFunc = context.CancelFunc diff --git a/vendor/golang.org/x/net/context/pre_go17.go b/vendor/golang.org/x/net/context/pre_go17.go deleted file mode 100644 index 7b6b6851..00000000 --- a/vendor/golang.org/x/net/context/pre_go17.go +++ /dev/null @@ -1,301 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build !go1.7 -// +build !go1.7 - -package context - -import ( - "errors" - "fmt" - "sync" - "time" -) - -// An emptyCtx is never canceled, has no values, and has no deadline. It is not -// struct{}, since vars of this type must have distinct addresses. -type emptyCtx int - -func (*emptyCtx) Deadline() (deadline time.Time, ok bool) { - return -} - -func (*emptyCtx) Done() <-chan struct{} { - return nil -} - -func (*emptyCtx) Err() error { - return nil -} - -func (*emptyCtx) Value(key interface{}) interface{} { - return nil -} - -func (e *emptyCtx) String() string { - switch e { - case background: - return "context.Background" - case todo: - return "context.TODO" - } - return "unknown empty Context" -} - -var ( - background = new(emptyCtx) - todo = new(emptyCtx) -) - -// Canceled is the error returned by Context.Err when the context is canceled. -var Canceled = errors.New("context canceled") - -// DeadlineExceeded is the error returned by Context.Err when the context's -// deadline passes. -var DeadlineExceeded = errors.New("context deadline exceeded") - -// WithCancel returns a copy of parent with a new Done channel. The returned -// context's Done channel is closed when the returned cancel function is called -// or when the parent context's Done channel is closed, whichever happens first. -// -// Canceling this context releases resources associated with it, so code should -// call cancel as soon as the operations running in this Context complete. -func WithCancel(parent Context) (ctx Context, cancel CancelFunc) { - c := newCancelCtx(parent) - propagateCancel(parent, c) - return c, func() { c.cancel(true, Canceled) } -} - -// newCancelCtx returns an initialized cancelCtx. -func newCancelCtx(parent Context) *cancelCtx { - return &cancelCtx{ - Context: parent, - done: make(chan struct{}), - } -} - -// propagateCancel arranges for child to be canceled when parent is. -func propagateCancel(parent Context, child canceler) { - if parent.Done() == nil { - return // parent is never canceled - } - if p, ok := parentCancelCtx(parent); ok { - p.mu.Lock() - if p.err != nil { - // parent has already been canceled - child.cancel(false, p.err) - } else { - if p.children == nil { - p.children = make(map[canceler]bool) - } - p.children[child] = true - } - p.mu.Unlock() - } else { - go func() { - select { - case <-parent.Done(): - child.cancel(false, parent.Err()) - case <-child.Done(): - } - }() - } -} - -// parentCancelCtx follows a chain of parent references until it finds a -// *cancelCtx. This function understands how each of the concrete types in this -// package represents its parent. -func parentCancelCtx(parent Context) (*cancelCtx, bool) { - for { - switch c := parent.(type) { - case *cancelCtx: - return c, true - case *timerCtx: - return c.cancelCtx, true - case *valueCtx: - parent = c.Context - default: - return nil, false - } - } -} - -// removeChild removes a context from its parent. -func removeChild(parent Context, child canceler) { - p, ok := parentCancelCtx(parent) - if !ok { - return - } - p.mu.Lock() - if p.children != nil { - delete(p.children, child) - } - p.mu.Unlock() -} - -// A canceler is a context type that can be canceled directly. The -// implementations are *cancelCtx and *timerCtx. -type canceler interface { - cancel(removeFromParent bool, err error) - Done() <-chan struct{} -} - -// A cancelCtx can be canceled. When canceled, it also cancels any children -// that implement canceler. -type cancelCtx struct { - Context - - done chan struct{} // closed by the first cancel call. - - mu sync.Mutex - children map[canceler]bool // set to nil by the first cancel call - err error // set to non-nil by the first cancel call -} - -func (c *cancelCtx) Done() <-chan struct{} { - return c.done -} - -func (c *cancelCtx) Err() error { - c.mu.Lock() - defer c.mu.Unlock() - return c.err -} - -func (c *cancelCtx) String() string { - return fmt.Sprintf("%v.WithCancel", c.Context) -} - -// cancel closes c.done, cancels each of c's children, and, if -// removeFromParent is true, removes c from its parent's children. -func (c *cancelCtx) cancel(removeFromParent bool, err error) { - if err == nil { - panic("context: internal error: missing cancel error") - } - c.mu.Lock() - if c.err != nil { - c.mu.Unlock() - return // already canceled - } - c.err = err - close(c.done) - for child := range c.children { - // NOTE: acquiring the child's lock while holding parent's lock. - child.cancel(false, err) - } - c.children = nil - c.mu.Unlock() - - if removeFromParent { - removeChild(c.Context, c) - } -} - -// WithDeadline returns a copy of the parent context with the deadline adjusted -// to be no later than d. If the parent's deadline is already earlier than d, -// WithDeadline(parent, d) is semantically equivalent to parent. The returned -// context's Done channel is closed when the deadline expires, when the returned -// cancel function is called, or when the parent context's Done channel is -// closed, whichever happens first. -// -// Canceling this context releases resources associated with it, so code should -// call cancel as soon as the operations running in this Context complete. -func WithDeadline(parent Context, deadline time.Time) (Context, CancelFunc) { - if cur, ok := parent.Deadline(); ok && cur.Before(deadline) { - // The current deadline is already sooner than the new one. - return WithCancel(parent) - } - c := &timerCtx{ - cancelCtx: newCancelCtx(parent), - deadline: deadline, - } - propagateCancel(parent, c) - d := deadline.Sub(time.Now()) - if d <= 0 { - c.cancel(true, DeadlineExceeded) // deadline has already passed - return c, func() { c.cancel(true, Canceled) } - } - c.mu.Lock() - defer c.mu.Unlock() - if c.err == nil { - c.timer = time.AfterFunc(d, func() { - c.cancel(true, DeadlineExceeded) - }) - } - return c, func() { c.cancel(true, Canceled) } -} - -// A timerCtx carries a timer and a deadline. It embeds a cancelCtx to -// implement Done and Err. It implements cancel by stopping its timer then -// delegating to cancelCtx.cancel. -type timerCtx struct { - *cancelCtx - timer *time.Timer // Under cancelCtx.mu. - - deadline time.Time -} - -func (c *timerCtx) Deadline() (deadline time.Time, ok bool) { - return c.deadline, true -} - -func (c *timerCtx) String() string { - return fmt.Sprintf("%v.WithDeadline(%s [%s])", c.cancelCtx.Context, c.deadline, c.deadline.Sub(time.Now())) -} - -func (c *timerCtx) cancel(removeFromParent bool, err error) { - c.cancelCtx.cancel(false, err) - if removeFromParent { - // Remove this timerCtx from its parent cancelCtx's children. - removeChild(c.cancelCtx.Context, c) - } - c.mu.Lock() - if c.timer != nil { - c.timer.Stop() - c.timer = nil - } - c.mu.Unlock() -} - -// WithTimeout returns WithDeadline(parent, time.Now().Add(timeout)). -// -// Canceling this context releases resources associated with it, so code should -// call cancel as soon as the operations running in this Context complete: -// -// func slowOperationWithTimeout(ctx context.Context) (Result, error) { -// ctx, cancel := context.WithTimeout(ctx, 100*time.Millisecond) -// defer cancel() // releases resources if slowOperation completes before timeout elapses -// return slowOperation(ctx) -// } -func WithTimeout(parent Context, timeout time.Duration) (Context, CancelFunc) { - return WithDeadline(parent, time.Now().Add(timeout)) -} - -// WithValue returns a copy of parent in which the value associated with key is -// val. -// -// Use context Values only for request-scoped data that transits processes and -// APIs, not for passing optional parameters to functions. -func WithValue(parent Context, key interface{}, val interface{}) Context { - return &valueCtx{parent, key, val} -} - -// A valueCtx carries a key-value pair. It implements Value for that key and -// delegates all other calls to the embedded Context. -type valueCtx struct { - Context - key, val interface{} -} - -func (c *valueCtx) String() string { - return fmt.Sprintf("%v.WithValue(%#v, %#v)", c.Context, c.key, c.val) -} - -func (c *valueCtx) Value(key interface{}) interface{} { - if c.key == key { - return c.val - } - return c.Context.Value(key) -} diff --git a/vendor/golang.org/x/net/context/pre_go19.go b/vendor/golang.org/x/net/context/pre_go19.go deleted file mode 100644 index 1f971534..00000000 --- a/vendor/golang.org/x/net/context/pre_go19.go +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build !go1.9 -// +build !go1.9 - -package context - -import "time" - -// A Context carries a deadline, a cancelation signal, and other values across -// API boundaries. -// -// Context's methods may be called by multiple goroutines simultaneously. -type Context interface { - // Deadline returns the time when work done on behalf of this context - // should be canceled. Deadline returns ok==false when no deadline is - // set. Successive calls to Deadline return the same results. - Deadline() (deadline time.Time, ok bool) - - // Done returns a channel that's closed when work done on behalf of this - // context should be canceled. Done may return nil if this context can - // never be canceled. Successive calls to Done return the same value. - // - // WithCancel arranges for Done to be closed when cancel is called; - // WithDeadline arranges for Done to be closed when the deadline - // expires; WithTimeout arranges for Done to be closed when the timeout - // elapses. - // - // Done is provided for use in select statements: - // - // // Stream generates values with DoSomething and sends them to out - // // until DoSomething returns an error or ctx.Done is closed. - // func Stream(ctx context.Context, out chan<- Value) error { - // for { - // v, err := DoSomething(ctx) - // if err != nil { - // return err - // } - // select { - // case <-ctx.Done(): - // return ctx.Err() - // case out <- v: - // } - // } - // } - // - // See http://blog.golang.org/pipelines for more examples of how to use - // a Done channel for cancelation. - Done() <-chan struct{} - - // Err returns a non-nil error value after Done is closed. Err returns - // Canceled if the context was canceled or DeadlineExceeded if the - // context's deadline passed. No other values for Err are defined. - // After Done is closed, successive calls to Err return the same value. - Err() error - - // Value returns the value associated with this context for key, or nil - // if no value is associated with key. Successive calls to Value with - // the same key returns the same result. - // - // Use context values only for request-scoped data that transits - // processes and API boundaries, not for passing optional parameters to - // functions. - // - // A key identifies a specific value in a Context. Functions that wish - // to store values in Context typically allocate a key in a global - // variable then use that key as the argument to context.WithValue and - // Context.Value. A key can be any type that supports equality; - // packages should define keys as an unexported type to avoid - // collisions. - // - // Packages that define a Context key should provide type-safe accessors - // for the values stores using that key: - // - // // Package user defines a User type that's stored in Contexts. - // package user - // - // import "golang.org/x/net/context" - // - // // User is the type of value stored in the Contexts. - // type User struct {...} - // - // // key is an unexported type for keys defined in this package. - // // This prevents collisions with keys defined in other packages. - // type key int - // - // // userKey is the key for user.User values in Contexts. It is - // // unexported; clients use user.NewContext and user.FromContext - // // instead of using this key directly. - // var userKey key = 0 - // - // // NewContext returns a new Context that carries value u. - // func NewContext(ctx context.Context, u *User) context.Context { - // return context.WithValue(ctx, userKey, u) - // } - // - // // FromContext returns the User value stored in ctx, if any. - // func FromContext(ctx context.Context) (*User, bool) { - // u, ok := ctx.Value(userKey).(*User) - // return u, ok - // } - Value(key interface{}) interface{} -} - -// A CancelFunc tells an operation to abandon its work. -// A CancelFunc does not wait for the work to stop. -// After the first call, subsequent calls to a CancelFunc do nothing. -type CancelFunc func() diff --git a/vendor/modules.txt b/vendor/modules.txt index 39993320..c664b3ce 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -4,6 +4,6 @@ github.com/armon/go-socks5 # github.com/caarlos0/env/v6 v6.10.1 ## explicit; go 1.17 github.com/caarlos0/env/v6 -# golang.org/x/net v0.17.0 -## explicit; go 1.17 +# golang.org/x/net v0.38.0 +## explicit; go 1.23.0 golang.org/x/net/context From 7cabaad45155dbd1e3f2ff4b4a3425c8b3c03a71 Mon Sep 17 00:00:00 2001 From: serj Date: Tue, 23 Sep 2025 18:38:10 +0300 Subject: [PATCH 03/10] Bump golang version --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 46965486..7bd3c774 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -ARG GOLANG_VERSION="1.19.1" +ARG GOLANG_VERSION="1.25" FROM golang:$GOLANG_VERSION-alpine as builder RUN apk --no-cache add tzdata From 4298d972a95af8ff3f40172c8358314be482d13d Mon Sep 17 00:00:00 2001 From: serj Date: Tue, 23 Sep 2025 19:05:44 +0300 Subject: [PATCH 04/10] Comment out IP limits for futhure vendoring refactoring --- server.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server.go b/server.go index 921f1ac9..96c9c84f 100644 --- a/server.go +++ b/server.go @@ -2,7 +2,6 @@ package main import ( "log" - "net" "os" "github.com/armon/go-socks5" @@ -46,7 +45,7 @@ func main() { if err != nil { log.Fatal(err) } - + {{/* // Set IP whitelist if len(cfg.AllowedIPs) > 0 { whitelist := make([]net.IP, len(cfg.AllowedIPs)) @@ -55,6 +54,7 @@ func main() { } server.SetIPWhitelist(whitelist) } + */}} log.Printf("Start listening proxy service on port %s\n", cfg.Port) if err := server.ListenAndServe("tcp", ":"+cfg.Port); err != nil { From f0eb61962ebd127e1f81b99894dc19e013e3e670 Mon Sep 17 00:00:00 2001 From: serj Date: Tue, 23 Sep 2025 21:39:33 +0300 Subject: [PATCH 05/10] Moving armon/go-socks5 to forked repo with additional changes --- go.mod | 2 ++ go.sum | 6 ++-- server.go | 5 ++-- vendor/github.com/armon/go-socks5/socks5.go | 32 +++++++++++++++++++++ vendor/modules.txt | 3 +- 5 files changed, 42 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 2319da92..38c9ffb0 100644 --- a/go.mod +++ b/go.mod @@ -8,3 +8,5 @@ require ( ) require golang.org/x/net v0.38.0 + +replace github.com/armon/go-socks5 => github.com/serjs/go-socks5 v0.0.0-20250923183437-3920b97ee0d2 diff --git a/go.sum b/go.sum index 90cec29e..a10cf3c4 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,8 @@ -github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= -github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= github.com/caarlos0/env/v6 v6.10.1 h1:t1mPSxNpei6M5yAeu1qtRdPAK29Nbcf/n3G7x+b3/II= github.com/caarlos0/env/v6 v6.10.1/go.mod h1:hvp/ryKXKipEkcuYjs9mI4bBCg+UI0Yhgm5Zu0ddvwc= +github.com/serjs/go-socks5 v0.0.0-20250923182028-346d18438915 h1:fgMfP6jRY4Dq+CFFNpC0hu/tyJj35tlcJphNkutvO98= +github.com/serjs/go-socks5 v0.0.0-20250923182028-346d18438915/go.mod h1:N2PhU16m3olAb71DduLys4mYR3oQboD4uLJmSXCSuMA= +github.com/serjs/go-socks5 v0.0.0-20250923183437-3920b97ee0d2 h1:dIXY/Lrkd1rGXcN60Fc0M2x0p5/C2XcbBbtPCvVvAa4= +github.com/serjs/go-socks5 v0.0.0-20250923183437-3920b97ee0d2/go.mod h1:N2PhU16m3olAb71DduLys4mYR3oQboD4uLJmSXCSuMA= golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8= golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= diff --git a/server.go b/server.go index 96c9c84f..9e3568bb 100644 --- a/server.go +++ b/server.go @@ -2,8 +2,8 @@ package main import ( "log" + "net" "os" - "github.com/armon/go-socks5" "github.com/caarlos0/env/v6" ) @@ -45,7 +45,7 @@ func main() { if err != nil { log.Fatal(err) } - {{/* + // Set IP whitelist if len(cfg.AllowedIPs) > 0 { whitelist := make([]net.IP, len(cfg.AllowedIPs)) @@ -54,7 +54,6 @@ func main() { } server.SetIPWhitelist(whitelist) } - */}} log.Printf("Start listening proxy service on port %s\n", cfg.Port) if err := server.ListenAndServe("tcp", ":"+cfg.Port); err != nil { diff --git a/vendor/github.com/armon/go-socks5/socks5.go b/vendor/github.com/armon/go-socks5/socks5.go index a17be68f..6d589029 100644 --- a/vendor/github.com/armon/go-socks5/socks5.go +++ b/vendor/github.com/armon/go-socks5/socks5.go @@ -55,6 +55,7 @@ type Config struct { type Server struct { config *Config authMethods map[uint8]Authenticator + isIPAllowed func(net.IP) bool } // New creates a new Server and potentially returns an error @@ -93,6 +94,11 @@ func New(conf *Config) (*Server, error) { server.authMethods[a.GetCode()] = a } + // Set default IP whitelist function + server.isIPAllowed = func(ip net.IP) bool { + return true // default allow all IPs + } + return server, nil } @@ -117,11 +123,37 @@ func (s *Server) Serve(l net.Listener) error { return nil } +// SetIPWhitelist sets the function to check if a given IP is allowed +func (s *Server) SetIPWhitelist(allowedIPs []net.IP) { + s.isIPAllowed = func(ip net.IP) bool { + for _, allowedIP := range allowedIPs { + if ip.Equal(allowedIP) { + return true + } + } + return false + } +} + // ServeConn is used to serve a single connection. func (s *Server) ServeConn(conn net.Conn) error { defer conn.Close() bufConn := bufio.NewReader(conn) + // Check client IP against whitelist + clientIP, _, err := net.SplitHostPort(conn.RemoteAddr().String()) + if err != nil { + s.config.Logger.Printf("[ERR] socks: Failed to get client IP address: %v", err) + return err + } + ip := net.ParseIP(clientIP) + if s.isIPAllowed(ip) { + s.config.Logger.Printf("[INFO] socks: Connection from allowed IP address: %s", clientIP) + } else { + s.config.Logger.Printf("[WARN] socks: Connection from not allowed IP address: %s", clientIP) + return fmt.Errorf("connection from not allowed IP address") + } + // Read the version byte version := []byte{0} if _, err := bufConn.Read(version); err != nil { diff --git a/vendor/modules.txt b/vendor/modules.txt index c664b3ce..7429c126 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,4 +1,4 @@ -# github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 +# github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 => github.com/serjs/go-socks5 v0.0.0-20250923183437-3920b97ee0d2 ## explicit github.com/armon/go-socks5 # github.com/caarlos0/env/v6 v6.10.1 @@ -7,3 +7,4 @@ github.com/caarlos0/env/v6 # golang.org/x/net v0.38.0 ## explicit; go 1.23.0 golang.org/x/net/context +# github.com/armon/go-socks5 => github.com/serjs/go-socks5 v0.0.0-20250923183437-3920b97ee0d2 From 14bdfbb6a256fe12bec194f168419a37d1d96967 Mon Sep 17 00:00:00 2001 From: serj Date: Tue, 23 Sep 2025 21:48:10 +0300 Subject: [PATCH 06/10] Add PROXY_LISTEN_IP env variable to set listen interface --- server.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/server.go b/server.go index 9e3568bb..7b1d633a 100644 --- a/server.go +++ b/server.go @@ -14,6 +14,7 @@ type params struct { Port string `env:"PROXY_PORT" envDefault:"1080"` AllowedDestFqdn string `env:"ALLOWED_DEST_FQDN" envDefault:""` AllowedIPs []string `env:"ALLOWED_IPS" envSeparator:"," envDefault:""` + ListenIP string `env:"PROXY_LISTEN_IP" envDefault:"0.0.0.0"` } func main() { @@ -55,8 +56,14 @@ func main() { server.SetIPWhitelist(whitelist) } - log.Printf("Start listening proxy service on port %s\n", cfg.Port) - if err := server.ListenAndServe("tcp", ":"+cfg.Port); err != nil { + listenAddr := ":" + cfg.Port + if cfg.ListenIP != "" { + listenAddr = cfg.ListenIP + ":" + cfg.Port + } + + + log.Printf("Start listening proxy service on %s\n", listenAddr) + if err := server.ListenAndServe("tcp", listenAddr); err != nil { log.Fatal(err) } } From 1f5e188a14b64221dd96c29e81188c38e96b7981 Mon Sep 17 00:00:00 2001 From: Sergey Bogatyrets Date: Tue, 23 Sep 2025 21:58:56 +0300 Subject: [PATCH 07/10] Create LICENSE --- LICENSE | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..c0c6ba4e --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 Sergey Bogatyrets + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. From 1cdfcea4ad9dfca3305149038a3ae81edcc35e76 Mon Sep 17 00:00:00 2001 From: serj Date: Thu, 25 Sep 2025 14:40:25 +0300 Subject: [PATCH 08/10] Add new REQUIRE_AUTH config parameter, to disable running socks5 server without auth by default --- .env => .env.example | 1 - README.md | 18 ++++++++---------- server.go | 12 +++++++++--- 3 files changed, 17 insertions(+), 14 deletions(-) rename .env => .env.example (73%) diff --git a/.env b/.env.example similarity index 73% rename from .env rename to .env.example index 0100bdb3..8946001f 100644 --- a/.env +++ b/.env.example @@ -1,3 +1,2 @@ PROXY_USER=someuser PROXY_PASSWORD=somepass -PROXY_PORT=1080 diff --git a/README.md b/README.md index 79bfca0f..b31124df 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # go-socks5-proxy ![Latest tag from master branch](https://github.com/serjs/socks5-server/workflows/Latest%20tag%20from%20master%20branch/badge.svg) -![Release tag](https://github.com/serjs/socks5-server/workflows/Release%20tag/badge.svg) Simple socks5 server using go-socks5 with authentication, allowed ips list and destination FQDNs filtering @@ -11,16 +10,15 @@ Simple socks5 server using go-socks5 with authentication, allowed ips list and d ```docker run -d --name socks5 -p 1080:1080 -e PROXY_USER= -e PROXY_PASSWORD= serjs/go-socks5-proxy``` - - Leave `PROXY_USER` and `PROXY_PASSWORD` empty for skip authentication options while running socks5 server, see example below +- Run docker container using specific container port and expose it to host port 1090 -- 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_USER= -e PROXY_PASSWORD= -e PROXY_PORT=9090 serjs/go-socks5-proxy``` # List of supported config parameters |ENV variable|Type|Default|Description| |------------|----|-------|-----------| +|REQUIRE_AUTH|String|true|Allow accepting socks5 connections without auth creds. Not recommended untill you use other protections mechanisms like Whitelists Subnets using Firewall or Proxy itself| |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| @@ -30,7 +28,7 @@ Simple socks5 server using go-socks5 with authentication, allowed ips list and d # Build your own image: `docker-compose -f docker-compose.build.yml up -d`\ -Just don't forget to set parameters in the `.env` file. +Just don't forget to set parameters in the `.env` file (`cp .env.example .env)` and edit it with your config parameters # Test running service @@ -38,19 +36,19 @@ Assuming that you are using container on 1080 host docker port ## Without authentication -```curl --socks5 :1080 https://ifcfg.co``` - result must show docker host ip (for bridged network) +```curl --socks5 :1080 https://ipinfo.io``` - result must show docker host ip (for bridged network) or -```docker run --rm curlimages/curl:7.65.3 -s --socks5 :1080 https://ifcfg.co``` +```docker run --rm curlimages/curl:7.65.3 -s --socks5 :1080 https://ipinfo.io``` ## With authentication -```curl --socks5 :1080 -U : http://ifcfg.co``` +```curl --socks5 :1080 -U : https://ipinfo.io``` or -```docker run --rm curlimages/curl:7.65.3 -s --socks5 :@:1080 http://ifcfg.co``` +```docker run --rm curlimages/curl:7.65.3 -s --socks5 :@:1080 https://ipinfo.io``` # Authors diff --git a/server.go b/server.go index 7b1d633a..93e77ba2 100644 --- a/server.go +++ b/server.go @@ -14,7 +14,8 @@ type params struct { Port string `env:"PROXY_PORT" envDefault:"1080"` AllowedDestFqdn string `env:"ALLOWED_DEST_FQDN" envDefault:""` AllowedIPs []string `env:"ALLOWED_IPS" envSeparator:"," envDefault:""` - ListenIP string `env:"PROXY_LISTEN_IP" envDefault:"0.0.0.0"` + ListenIP string `env:"PROXY_LISTEN_IP" envDefault:"0.0.0.0"` + RequireAuth bool `env:"REQUIRE_AUTH" envDefault:"true"` } func main() { @@ -30,12 +31,17 @@ func main() { Logger: log.New(os.Stdout, "", log.LstdFlags), } - if cfg.User+cfg.Password != "" { + if cfg.RequireAuth { + if cfg.User == "" || cfg.Password == "" { + log.Fatalln("Error: REQUIRE_AUTH is true, but PROXY_USER and PROXY_PASSWORD are not set. The application will now exit.") + } creds := socks5.StaticCredentials{ - os.Getenv("PROXY_USER"): os.Getenv("PROXY_PASSWORD"), + cfg.User: cfg.Password, } cator := socks5.UserPassAuthenticator{Credentials: creds} socks5conf.AuthMethods = []socks5.Authenticator{cator} + } else { + log.Println("Warning: Running the proxy server without authentication. This is NOT recommended for public servers.") } if cfg.AllowedDestFqdn != "" { From f1cd03ff761447d5fc3042988750d697a74d7103 Mon Sep 17 00:00:00 2001 From: serj Date: Tue, 7 Oct 2025 13:10:58 +0300 Subject: [PATCH 09/10] Update changelog --- Changelog.md | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Changelog.md b/Changelog.md index 32d402f6..49667779 100644 --- a/Changelog.md +++ b/Changelog.md @@ -3,12 +3,21 @@ All notable changes to this project will be documented in this file. ## [Unreleased - available on :latest tag for docker image] ### Changed -- Migrate to distroless docker image from scratch -- ### Added -- New ALLOWED_DEST_FQDN config env paramteter for filtering dest FQND based on regex patterns -- New SetIPWhitelist config env paramteter for setting whitelist set of ip addresses which allowed to use proxy connection -- Dependabot version updates automation + +## [v0.0.4] - 2025-10-07 + +**Important:** :warning: Starting with this release, the proxy requires authentication by default. The `REQUIRE_AUTH` parameter is now set to `true` by default. Please refer to the documentation for details on this change. + +### Changed +- Migrated to a distroless Docker image from scratch. +- Moved go-socks5 to a modified forked repository at https://github.com/serjs/go-socks5 as a dependency. + +### Added +- Added `REQUIRE_AUTH` parameter with a default value of `true` to enforce authentication for the proxy. +- Added `ALLOWED_DEST_FQDN` config environment parameter for filtering destination FQDNs based on regex patterns. +- Added `SetIPWhitelist` config environment parameter for setting a whitelist of IP addresses allowed to use the proxy connection. +- Implemented Dependabot version updates automation. ## [v0.0.3] - 2021-07-07 ### Added From 38627992d93e603322483c6c8b07593a5ab35a79 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 9 Oct 2025 08:06:55 +0000 Subject: [PATCH 10/10] Bump golang.org/x/net from 0.38.0 to 0.46.0 Bumps [golang.org/x/net](https://github.com/golang/net) from 0.38.0 to 0.46.0. - [Commits](https://github.com/golang/net/compare/v0.38.0...v0.46.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-version: 0.46.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 4 +-- go.sum | 6 ++-- vendor/golang.org/x/net/context/context.go | 35 +++++++++++++--------- vendor/modules.txt | 4 +-- 4 files changed, 27 insertions(+), 22 deletions(-) diff --git a/go.mod b/go.mod index 38c9ffb0..ba581e00 100644 --- a/go.mod +++ b/go.mod @@ -1,12 +1,12 @@ module github.com/serjs/socks5-server -go 1.23.0 +go 1.24.0 require ( github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 github.com/caarlos0/env/v6 v6.10.1 ) -require golang.org/x/net v0.38.0 +require golang.org/x/net v0.46.0 replace github.com/armon/go-socks5 => github.com/serjs/go-socks5 v0.0.0-20250923183437-3920b97ee0d2 diff --git a/go.sum b/go.sum index a10cf3c4..cd809d22 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,6 @@ github.com/caarlos0/env/v6 v6.10.1 h1:t1mPSxNpei6M5yAeu1qtRdPAK29Nbcf/n3G7x+b3/II= github.com/caarlos0/env/v6 v6.10.1/go.mod h1:hvp/ryKXKipEkcuYjs9mI4bBCg+UI0Yhgm5Zu0ddvwc= -github.com/serjs/go-socks5 v0.0.0-20250923182028-346d18438915 h1:fgMfP6jRY4Dq+CFFNpC0hu/tyJj35tlcJphNkutvO98= -github.com/serjs/go-socks5 v0.0.0-20250923182028-346d18438915/go.mod h1:N2PhU16m3olAb71DduLys4mYR3oQboD4uLJmSXCSuMA= github.com/serjs/go-socks5 v0.0.0-20250923183437-3920b97ee0d2 h1:dIXY/Lrkd1rGXcN60Fc0M2x0p5/C2XcbBbtPCvVvAa4= github.com/serjs/go-socks5 v0.0.0-20250923183437-3920b97ee0d2/go.mod h1:N2PhU16m3olAb71DduLys4mYR3oQboD4uLJmSXCSuMA= -golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8= -golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= +golang.org/x/net v0.46.0 h1:giFlY12I07fugqwPuWJi68oOnpfqFnJIJzaIIm2JVV4= +golang.org/x/net v0.46.0/go.mod h1:Q9BGdFy1y4nkUwiLvT5qtyhAnEHgnQ/zd8PfU6nc210= diff --git a/vendor/golang.org/x/net/context/context.go b/vendor/golang.org/x/net/context/context.go index db1c95fa..d3cb9517 100644 --- a/vendor/golang.org/x/net/context/context.go +++ b/vendor/golang.org/x/net/context/context.go @@ -6,7 +6,7 @@ // cancellation signals, and other request-scoped values across API boundaries // and between processes. // As of Go 1.7 this package is available in the standard library under the -// name [context], and migrating to it can be done automatically with [go fix]. +// name [context]. // // Incoming requests to a server should create a [Context], and outgoing // calls to servers should accept a Context. The chain of function @@ -38,8 +38,6 @@ // // See https://go.dev/blog/context for example code for a server that uses // Contexts. -// -// [go fix]: https://go.dev/cmd/go#hdr-Update_packages_to_use_new_APIs package context import ( @@ -51,36 +49,37 @@ import ( // API boundaries. // // Context's methods may be called by multiple goroutines simultaneously. +// +//go:fix inline type Context = context.Context // Canceled is the error returned by [Context.Err] when the context is canceled // for some reason other than its deadline passing. +// +//go:fix inline var Canceled = context.Canceled // DeadlineExceeded is the error returned by [Context.Err] when the context is canceled // due to its deadline passing. +// +//go:fix inline var DeadlineExceeded = context.DeadlineExceeded // Background returns a non-nil, empty Context. It is never canceled, has no // values, and has no deadline. It is typically used by the main function, // initialization, and tests, and as the top-level Context for incoming // requests. -func Background() Context { - return background -} +// +//go:fix inline +func Background() Context { return context.Background() } // TODO returns a non-nil, empty Context. Code should use context.TODO when // it's unclear which Context to use or it is not yet available (because the // surrounding function has not yet been extended to accept a Context // parameter). -func TODO() Context { - return todo -} - -var ( - background = context.Background() - todo = context.TODO() -) +// +//go:fix inline +func TODO() Context { return context.TODO() } // A CancelFunc tells an operation to abandon its work. // A CancelFunc does not wait for the work to stop. @@ -95,6 +94,8 @@ type CancelFunc = context.CancelFunc // // Canceling this context releases resources associated with it, so code should // call cancel as soon as the operations running in this [Context] complete. +// +//go:fix inline func WithCancel(parent Context) (ctx Context, cancel CancelFunc) { return context.WithCancel(parent) } @@ -108,6 +109,8 @@ func WithCancel(parent Context) (ctx Context, cancel CancelFunc) { // // Canceling this context releases resources associated with it, so code should // call cancel as soon as the operations running in this [Context] complete. +// +//go:fix inline func WithDeadline(parent Context, d time.Time) (Context, CancelFunc) { return context.WithDeadline(parent, d) } @@ -122,6 +125,8 @@ func WithDeadline(parent Context, d time.Time) (Context, CancelFunc) { // defer cancel() // releases resources if slowOperation completes before timeout elapses // return slowOperation(ctx) // } +// +//go:fix inline func WithTimeout(parent Context, timeout time.Duration) (Context, CancelFunc) { return context.WithTimeout(parent, timeout) } @@ -139,6 +144,8 @@ func WithTimeout(parent Context, timeout time.Duration) (Context, CancelFunc) { // interface{}, context keys often have concrete type // struct{}. Alternatively, exported context key variables' static // type should be a pointer or interface. +// +//go:fix inline func WithValue(parent Context, key, val interface{}) Context { return context.WithValue(parent, key, val) } diff --git a/vendor/modules.txt b/vendor/modules.txt index 7429c126..f36dd205 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -4,7 +4,7 @@ github.com/armon/go-socks5 # github.com/caarlos0/env/v6 v6.10.1 ## explicit; go 1.17 github.com/caarlos0/env/v6 -# golang.org/x/net v0.38.0 -## explicit; go 1.23.0 +# golang.org/x/net v0.46.0 +## explicit; go 1.24.0 golang.org/x/net/context # github.com/armon/go-socks5 => github.com/serjs/go-socks5 v0.0.0-20250923183437-3920b97ee0d2