@@ -5,237 +5,99 @@ A high-performance SOCKS5 proxy server written in Go that rotates through multip
5
5
## Features
6
6
7
7
- SOCKS5 proxy server with username/password authentication
8
- - Support for multiple upstream proxy protocols:
9
- - HTTP proxies
10
- - HTTPS proxies (encrypted)
11
- - SOCKS5 proxies
12
- - SOCKS5H proxies (proxy performs DNS resolution)
8
+ - Multiple proxy protocol support (HTTP, HTTPS, SOCKS5, SOCKS5H)
13
9
- Round-robin proxy rotation
14
10
- Edge mode for fallback to direct connections
15
- - Multi-user support via configuration file
16
- - Docker and docker-compose support
17
- - Configurable port
11
+ - Multi-user support
12
+ - Docker support
18
13
- Zero runtime dependencies
19
- - Comments support in configuration files
20
- - Automatic proxy failover
21
14
- IPv6 support
22
15
23
- ## Quick Start with Docker Compose (Recommended)
16
+ ## Quick Start
24
17
25
18
1 . Clone the repository:
26
19
``` bash
27
- git clone https://github.com/ariadata /go-proxy-rotator.git
20
+ git clone https://github.com/yourusername /go-proxy-rotator.git
28
21
cd go-proxy-rotator
29
22
```
30
23
31
24
2 . Set up configuration files:
32
25
``` bash
33
- # Copy environment example
34
26
cp .env.example .env
35
-
36
- # Create users file
37
- echo " user1:password1" > users.conf
38
- echo " user2:password2" >> users.conf
39
-
40
- # Create proxies file (add your proxies)
41
- touch proxies.conf
27
+ cp users.conf.example users.conf
28
+ cp proxies.conf.example proxies.conf
42
29
```
43
30
44
- 3 . Create ` docker-compose.yml ` :
45
- ``` yaml
46
- version : ' 3.8'
47
-
48
- services :
49
- proxy-rotator :
50
- image : ' ghcr.io/ariadata/go-proxy-rotator:latest'
51
- ports :
52
- - " ${DC_SOCKS_PROXY_PORT}:1080"
53
- volumes :
54
- - ./proxies.conf:/app/proxies.conf:ro
55
- - ./users.conf:/app/users.conf:ro
56
- env_file :
57
- - .env
58
- restart : unless-stopped
59
- healthcheck :
60
- test : ["CMD", "nc", "-z", "localhost", "1080"]
61
- interval : 30s
62
- timeout : 10s
63
- retries : 3
64
- ` ` `
31
+ 3 . Edit the configuration files:
32
+ - ` users.conf ` : Add your username: password pairs
33
+ - ` proxies.conf ` : Add your proxy servers
34
+ - ` .env ` : Adjust settings if needed
65
35
66
- 4. Start the service :
36
+ 4 . Run with Docker :
67
37
``` bash
68
- docker-compose up -d
69
- ```
70
-
71
- 5 . Test your connection:
72
- ``` bash
73
- curl --proxy socks5h://user1:password1@localhost:60255 https://api.ipify.org? format=json
74
- ```
75
-
76
- ## Installation with Go
77
-
78
- 1 . Clone and enter the repository:
79
- ``` bash
80
- git clone https://github.com/ariadata/go-proxy-rotator.git
81
- cd go-proxy-rotator
82
- ```
83
-
84
- 2 . Install dependencies:
85
- ``` bash
86
- go mod download
87
- ```
88
-
89
- 3 . Set up configuration files:
90
- ``` bash
91
- cp .env.example .env
92
- # Edit users.conf and proxies.conf
93
- ```
94
-
95
- 4 . Build and run:
96
- ``` bash
97
- go build -o proxy-server
98
- ./proxy-server
38
+ docker compose up -d
99
39
```
100
40
101
41
## Configuration
102
42
103
43
### Environment Variables (.env)
104
-
105
44
``` env
106
- # Project name for docker-compose
107
45
COMPOSE_PROJECT_NAME=go-proxy-rotator
108
-
109
- # Port for the SOCKS5 server
110
46
DC_SOCKS_PROXY_PORT=60255
111
-
112
- # Enable direct connections when proxies fail
113
47
ENABLE_EDGE_MODE=true
114
48
```
115
49
116
50
### User Configuration (users.conf)
117
-
118
- Format:
119
51
```
120
52
username1:password1
121
53
username2:password2
122
- # Comments are supported
123
54
```
124
55
125
56
### Proxy Configuration (proxies.conf)
126
-
127
- The proxy configuration file supports various proxy formats:
128
-
129
57
```
130
- # HTTP proxies
58
+ # HTTP/HTTPS proxies
131
59
http://proxy1.example.com:8080
132
- http://user:[email protected] :8080
133
-
134
- # HTTPS proxies (encrypted connection to proxy)
135
- https://secure-proxy.example.com:8443
136
- https://user:[email protected] :8443
137
-
138
- # SOCKS5 proxies (standard)
139
- socks5://socks-proxy.example.com:1080
140
- socks5://user:[email protected] :1080
60
+ https://user:[email protected] :8443
141
61
142
- # SOCKS5H proxies (proxy performs DNS resolution)
143
- socks5h://socks-proxy3.example.com:1080
144
- socks5h://user:[email protected] :1080
145
-
146
- # IPv6 support
147
- http://[2001:db8::1]:8080
148
- socks5://user:password@[2001:db8::2]:1080
149
-
150
- # Real-world format examples
151
- http://proxy-user:[email protected] :8080
152
- https://proxy-user:[email protected] :8443
153
- socks5://socks-user:[email protected] :1080
62
+ # SOCKS5 proxies
63
+ socks5://proxy3.example.com:1080
64
+ socks5h://user:[email protected] :1080
154
65
```
155
66
156
- ## Edge Mode
157
-
158
- When edge mode is enabled (` ENABLE_EDGE_MODE=true ` ), the server will:
67
+ ## Testing
159
68
160
- 1 . First attempt a direct connection
161
- 2 . If direct connection fails, rotate through available proxies
162
- 3 . If all proxies fail, return an error
163
-
164
- This is useful for:
165
- - Accessing both internal and external resources
166
- - Reducing latency for local/fast connections
167
- - Automatic failover to direct connection
168
-
169
- ## Usage Examples
170
-
171
- ### With cURL
69
+ Test your connection:
172
70
``` bash
173
- # Basic usage
174
- curl --proxy socks5h://user:pass@localhost:60255 https://api.ipify.org? format=json
175
-
176
- # With specific DNS resolution
177
- curl --proxy socks5h://user:pass@localhost:60255 https://example.com
178
-
179
- # With insecure mode (skip SSL verification)
180
- curl --proxy socks5h://user:pass@localhost:60255 -k https://example.com
71
+ curl --proxy socks5h://username1:password1@localhost:60255 https://api.ipify.org? format=json
181
72
```
182
73
183
- ### With Python Requests
184
- ``` python
185
- import requests
186
-
187
- proxies = {
188
- ' http' : ' socks5h://user:pass@localhost:60255' ,
189
- ' https' : ' socks5h://user:pass@localhost:60255'
190
- }
74
+ ## Building from Source
191
75
192
- response = requests.get( ' https://api.ipify.org?format=json ' , proxies = proxies)
193
- print (response.json())
76
+ ``` bash
77
+ make build
194
78
```
195
79
196
- ### With Node.js
197
- ``` javascript
198
- const SocksProxyAgent = require (' socks-proxy-agent' );
199
-
200
- const proxyOptions = {
201
- hostname: ' localhost' ,
202
- port: 60255 ,
203
- userId: ' user' ,
204
- password: ' pass' ,
205
- protocol: ' socks5:'
206
- };
207
-
208
- const agent = new SocksProxyAgent (proxyOptions);
80
+ ## Docker Commands
209
81
210
- fetch ( ' https://api.ipify.org?format=json ' , { agent })
211
- . then ( res => res . json ())
212
- . then ( data => console . log (data));
82
+ Build image:
83
+ ``` bash
84
+ docker build -t go-proxy-rotator .
213
85
```
214
86
215
- ## Building for Production
216
-
217
- For production builds, use:
218
-
87
+ Run container:
219
88
``` bash
220
- CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o proxy-server .
89
+ docker run -d \
90
+ -p 60255:1080 \
91
+ -v $( pwd) /proxies.conf:/app/proxies.conf:ro \
92
+ -v $( pwd) /users.conf:/app/users.conf:ro \
93
+ -e ENABLE_EDGE_MODE=true \
94
+ go-proxy-rotator
221
95
```
222
96
223
- ## Security Notes
224
-
225
- - Always use strong passwords in ` users.conf `
226
- - Consider using HTTPS/SOCKS5 proxies for sensitive traffic
227
- - The server logs minimal information for privacy
228
-
229
- ## Contributing
230
-
231
- Contributions are welcome! Please feel free to submit a Pull Request.
232
-
233
97
## License
234
98
235
99
MIT License
236
100
237
- ## Acknowledgments
101
+ ## Contributing
238
102
239
- Built using:
240
- - [ go-socks5] ( https://github.com/armon/go-socks5 ) - SOCKS5 server implementation
241
- - Go's standard library for proxy and networking features
103
+ Contributions are welcome! Please feel free to submit a Pull Request.
0 commit comments