Total Pageviews

Monday 23 May 2022

socks5-server-c

 SOCKS V5 server in C, based on epoll, single thread, supports TCP and UDP. 这是 C 语言实现的 SOCKS V5代理服务器,基于 epoll,单线程,支持 TCP 和 UDP。

Platform License Lines of code GitHub code size in bytes GitHub last commit Travis (.com) branch

一个简易的 SOCKS V5 代理服务器。

Features

  • 支持 TCP 代理和 UDP 代理
  • 支持代理 DNS 查询
  • 支持用户名密码认证方式

Build

使用 make 完成编译和链接。

$ make

若跟上 CFLAG=-DDEBUG 则开启调试模式:

$ make CFLAG=-DDEBUG

Usage

不带任何选项启动,则监听 1080 端口,无需认证。

$ ./server
NO AUTHENTICATION REQUIRED
Listening at 0.0.0.0:1080

带上 -h 选项则显示帮助信息。

$ ./server -h
usage: ./server [options]
options: 
  -a <address>         Local Address to bind (default: 0.0.0.0).
  -p <port>            Port number to bind (default: 1080).
  -u <path/to/passwd>  The path to passwd.
  -d                   Run as a daemon.
  -h                   Show this help message.

选项 -a-p 分别用来指定服务器绑定的 IP 地址和端口号。

$ ./server -a 127.0.0.1 -p 8080
NO AUTHENTICATION REQUIRED
Listening at 127.0.0.1:8080

选项 -u 用于开启用户名密码认证方式,选项后面必须跟上一个文件的路径。该文件的每一行对应一个用户,用户名和密码之间用逗号 , 隔开,例如:

$ cat ./passwd
user1,123456
user2,666
user3,2333
$ ./server -u ./passwd
USERNAME/PASSWORD
3 users
Listening at 0.0.0.0:1080

若带上 -d 参数,服务器将脱离终端,成为守护进程。

$ ./server -d
NO AUTHENTICATION REQUIRED
Listening at 0.0.0.0:1080
PID is [xxxxx]
$ netstat -ntlp | grep xxxxx
tcp        0      0 0.0.0.0:1080                0.0.0.0:*  LISTEN      xxxxx/./server

 from https://github.com/totravel/socks5-server-c

No comments:

Post a Comment