hmgle / socks5_c Goto Github PK
View Code? Open in Web Editor NEW一个轻量级的 socks5 代理, 带简单加密传输功能, 可穿透 GFW
License: MIT License
一个轻量级的 socks5 代理, 带简单加密传输功能, 可穿透 GFW
License: MIT License
fd_set
is no available on Mac
➜ socks5_c git:(master) make
cc -Wall -O0 -DDEBUG=1 -g -c -o local.o local.c
cc -Wall -O0 -DDEBUG=1 -g -c -o buffer.o buffer.c
cc -Wall -O0 -DDEBUG=1 -g -c -o encrypt.o encrypt.c
cc -Wall -O0 -DDEBUG=1 -g -c -o socket_wrap.o socket_wrap.c
cc -Wall -O0 -DDEBUG=1 -g -c -o socks.o socks.c
In file included from socks.c:1:
./socks.h:24:2: error: unknown type name 'fd_set'
fd_set rfds, wfds;
^
./socks.h:27:2: error: unknown type name 'fd_set'
fd_set _rfds, _wfds;
^
2 errors generated.
make: *** [socks.o] Error 1
select/poll/epoll 的阻塞io会严重影响性能.
socket_wrap.c 中的 client_connect() 函数中, 当某个套接字阻塞在 gethostbyname() 或 connect() 时, 其他连接事件得不到及时处理, 一个打不开的网页就导致了其他正常页面都不能及时打开.
应改为非阻塞实现.
假如 conn_fd 和 remote_fd 在一个 select() 返回后都可读, 而且都是关闭文件事件, 事件循环处理器稍后执行到 client_fo_remote() -> recv(conn_fd, ...) -> ss_server_del_conn() 会把这个 conn 结构体释放掉, 但在同一轮的事件循环处理中, 就要执行到 ss_remote_io_handle() -> recv(remote_fd, ...) -> ss_server_del_conn(), 这个 conn 在前面已经释放掉, 于是 segmentation fault (core dumped)!!!
root@ar:~/socks5_c# debug_print: socks.c: 347: ss_request_handle():ss_get_requests() failed: Success
debug_print: server.c: 101: ss_io_handle():close
debug_print: socks.c: 347: ss_request_handle():ss_get_requests() failed: Success
debug_print: server.c: 101: ss_io_handle():close
debug_print: socks.c: 347: ss_request_handle():ss_get_requests() failed: Success
debug_print: server.c: 101: ss_io_handle():close
debug_print: socks.c: 347: ss_request_handle():ss_get_requests() failed: Success
debug_print: server.c: 101: ss_io_handle():close
debug_print: socks.c: 347: ss_request_handle():ss_get_requests() failed: Success
debug_print: server.c: 101: ss_io_handle():close
debug_print: socks.c: 347: ss_request_handle():ss_get_requests() failed: Success
debug_print: server.c: 101: ss_io_handle():close
debug_print: socks.c: 347: ss_request_handle():ss_get_requests() failed: Success
debug_print: server.c: 101: ss_io_handle():close
debug_print: socks.c: 347: ss_request_handle():ss_get_requests() failed: Success
debug_print: server.c: 101: ss_io_handle():close
debug_print: socks.c: 347: ss_request_handle():ss_get_requests() failed: Success
debug_print: server.c: 101: ss_io_handle():close
debug_print: socks.c: 347: ss_request_handle():ss_get_requests() failed: Success
debug_print: server.c: 101: ss_io_handle():close
debug_print: socks.c: 347: ss_request_handle():ss_get_requests() failed: Success
debug_print: server.c: 101: ss_io_handle():close
debug_print: socks.c: 347: ss_request_handle():ss_get_requests() failed: Success
debug_print: server.c: 101: ss_io_handle():close
debug_print: socks.c: 347: ss_request_handle():ss_get_requests() failed: Success
debug_print: server.c: 101: ss_io_handle():close
debug_print: socks.c: 347: ss_request_handle():ss_get_requests() failed: Success
debug_print: server.c: 101: ss_io_handle():close
root@ar:~/socks5_c#
gethostbyname(3) 是阻塞的, 而且不支持 IPv6. 非阻塞 DNS 查询可以参考 TADNS
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.