Skip to content

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

License

Notifications You must be signed in to change notification settings

totravel/socks5-server-c

Repository files navigation

SOCKS V5 server

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

License

本项目采用 MIT 开源许可协议。

MIT License

Copyright (c) 2019-2021 totravel

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.

About

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

Topics

Resources

License

Stars

Watchers

Forks