A high-performance, SOCKS5 proxy server written in Go. This server is designed for secure, low-latency data forwarding between clients and remote hosts, with robust error handling, connection monitoring, and customizable metrics tracking.
- SOCKS5 Protocol Support: Handles basic SOCKS5 commands for TCP connections.
- Connection Management: Manages concurrent client connections with monitoring for active and idle timeouts.
- Error Handling: Detailed error logging and filtering for non-critical errors.
- Metrics Tracking: Real-time monitoring for:
- Active connections
- Data sent and received
- Connection duration and errors
- Bandwidth usage
- DNS Resolution: Supports resolving domain names to IP addresses.
- Customizable Settings: Easily configure network, address, and monitoring intervals.
-
Clone the repository:
git clone https://github.com/devem-tech/socks.git cd socks
-
Install dependencies: Ensure you have Go installed (version 1.17 or higher).
go mod download
-
Build the server:
go build -o server cmd/main.go
Start the server with the following command:
./server
By default, the server listens on 127.0.0.1:1080
. This can be configured in the New
function by passing in custom options.
You can configure the server using options
struct in the code, which allows customizing:
- Network and Address: Specify the network protocol (
tcp
,udp
) and address. - DNS Resolver: Set up a custom DNS resolver.
- Metrics: Configure metrics tracking for connection monitoring.
The server tracks key metrics using a metrics
interface:
- Active Connections: The current number of active connections.
- Data Sent and Received: Bytes sent to and received from clients.
- Error Counts: Counts for various error types, including connection and copy errors.
- Bandwidth Usage: Total data transferred per second.
package main
import (
"log"
"github.com/devem-tech/socks/server"
)
func main() {
// Initialize and configure server
srv := server.New(
server.Network("tcp"),
server.Address("127.0.0.1:1080"),
)
// Start the server
log.Println("Starting SOCKS5 server on 127.0.0.1:1080...")
srv.Serve()
}
We welcome contributions! If you have suggestions for improvements or find any issues, please open an issue or submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.