b23r0 / rsocx Goto Github PK
View Code? Open in Web Editor NEWA bind/reverse Socks5 proxy server.
License: MIT License
A bind/reverse Socks5 proxy server.
License: MIT License
改了 bool BOOL 和int int 那两个错仍然不行,主要报错在这两个地方
src/socks/SocksMgr.cpp:158:15: error: cast from ‘void*’ to ‘int’ loses precision [-fpermissive]
int s = (int)lpParameter;
^
src/socks/SocksMgr.cpp: In member function ‘bool CSocksMgr::Begin(LPCSTR, int, LPCSTR, int)’:
src/socks/SocksMgr.cpp:291:34: error: cast from ‘CSocksMgr*’ to ‘uint32_t {aka unsigned int}’ loses precision [-fpermissive]
proxy->lpParameter = (uint32_t)this;
全部报错是
g++ -c src/Tunnel.cpp -o src/Tunnel.o -I./src -DLINUX
In file included from src/stdafx.h:52:0,
from src/Tunnel.cpp:1:
src/utils/AutoCleanup.h:105:38: warning: converting to non-pointer type ‘DWORD {aka long unsigned int}’ from NULL [-Wconversion-null]
bool WaitForEnd(DWORD dwTimeoutMS = INFINITE)
^
src/utils/AutoCleanup.h: In constructor ‘Thread::Thread()’:
src/utils/AutoCleanup.h:68:19: warning: converting to non-pointer type ‘HANDLE {aka long unsigned int}’ from NULL [-Wconversion-null]
, m_dwThreadId(0)
^
src/utils/AutoCleanup.h: In destructor ‘Thread::~Thread()’:
src/utils/AutoCleanup.h:74:15: warning: NULL used in arithmetic [-Wpointer-arith]
if (NULL != m_hThread)
^
src/utils/AutoCleanup.h: In member function ‘bool Thread::Start(LPTHREAD_START_ROUTINE, LPVOID)’:
src/utils/AutoCleanup.h:84:15: warning: NULL used in arithmetic [-Wpointer-arith]
if (NULL != m_hThread) return FALSE;
^
src/utils/AutoCleanup.h: In member function ‘bool Thread::WaitForEnd(DWORD)’:
src/utils/AutoCleanup.h:107:15: warning: NULL used in arithmetic [-Wpointer-arith]
if (NULL == m_hThread) return TRUE;
^
src/utils/AutoCleanup.h:118:22: warning: NULL used in arithmetic [-Wpointer-arith]
if (dwTimeoutMS == INFINITE)
^
src/utils/AutoCleanup.h:131:14: warning: converting to non-pointer type ‘HANDLE {aka long unsigned int}’ from NULL [-Wconversion-null]
m_hThread = NULL;
^
src/utils/AutoCleanup.h: In member function ‘void Thread::Terminate()’:
src/utils/AutoCleanup.h:148:13: warning: converting to non-pointer type ‘HANDLE {aka long unsigned int}’ from NULL [-Wconversion-null]
m_hThread = NULL;
^
src/Tunnel.cpp: In member function ‘DWORD CTunnel::TCPTunnelProc(LPVOID)’:
src/Tunnel.cpp:214:16: warning: converting to non-pointer type ‘DWORD {aka long unsigned int}’ from NULL [-Wconversion-null]
t1.WaitForEnd();
^
src/Tunnel.cpp:215:16: warning: converting to non-pointer type ‘DWORD {aka long unsigned int}’ from NULL [-Wconversion-null]
t2.WaitForEnd();
^
src/Tunnel.cpp: In member function ‘bool CTunnel::Begin(int, int)’:
src/Tunnel.cpp:247:16: warning: converting to non-pointer type ‘DWORD {aka long unsigned int}’ from NULL [-Wconversion-null]
t1.WaitForEnd();
^
src/Tunnel.cpp:248:16: warning: converting to non-pointer type ‘DWORD {aka long unsigned int}’ from NULL [-Wconversion-null]
t2.WaitForEnd();
^
g++ -c src/xsocks.cpp -o src/xsocks.o -I./src -DLINUX
In file included from src/stdafx.h:52:0,
from src/xsocks.cpp:1:
src/utils/AutoCleanup.h:105:38: warning: converting to non-pointer type ‘DWORD {aka long unsigned int}’ from NULL [-Wconversion-null]
bool WaitForEnd(DWORD dwTimeoutMS = INFINITE)
^
src/utils/AutoCleanup.h: In constructor ‘Thread::Thread()’:
src/utils/AutoCleanup.h:68:19: warning: converting to non-pointer type ‘HANDLE {aka long unsigned int}’ from NULL [-Wconversion-null]
, m_dwThreadId(0)
^
src/utils/AutoCleanup.h: In destructor ‘Thread::~Thread()’:
src/utils/AutoCleanup.h:74:15: warning: NULL used in arithmetic [-Wpointer-arith]
if (NULL != m_hThread)
^
src/utils/AutoCleanup.h: In member function ‘bool Thread::Start(LPTHREAD_START_ROUTINE, LPVOID)’:
src/utils/AutoCleanup.h:84:15: warning: NULL used in arithmetic [-Wpointer-arith]
if (NULL != m_hThread) return FALSE;
^
src/utils/AutoCleanup.h: In member function ‘bool Thread::WaitForEnd(DWORD)’:
src/utils/AutoCleanup.h:107:15: warning: NULL used in arithmetic [-Wpointer-arith]
if (NULL == m_hThread) return TRUE;
^
src/utils/AutoCleanup.h:118:22: warning: NULL used in arithmetic [-Wpointer-arith]
if (dwTimeoutMS == INFINITE)
^
src/utils/AutoCleanup.h:131:14: warning: converting to non-pointer type ‘HANDLE {aka long unsigned int}’ from NULL [-Wconversion-null]
m_hThread = NULL;
^
src/utils/AutoCleanup.h: In member function ‘void Thread::Terminate()’:
src/utils/AutoCleanup.h:148:13: warning: converting to non-pointer type ‘HANDLE {aka long unsigned int}’ from NULL [-Wconversion-null]
m_hThread = NULL;
^
g++ -c src/stdafx.cpp -o src/stdafx.o -I./src -DLINUX
In file included from src/stdafx.h:52:0,
from src/stdafx.cpp:5:
src/utils/AutoCleanup.h:105:38: warning: converting to non-pointer type ‘DWORD {aka long unsigned int}’ from NULL [-Wconversion-null]
bool WaitForEnd(DWORD dwTimeoutMS = INFINITE)
^
src/utils/AutoCleanup.h: In constructor ‘Thread::Thread()’:
src/utils/AutoCleanup.h:68:19: warning: converting to non-pointer type ‘HANDLE {aka long unsigned int}’ from NULL [-Wconversion-null]
, m_dwThreadId(0)
^
src/utils/AutoCleanup.h: In destructor ‘Thread::~Thread()’:
src/utils/AutoCleanup.h:74:15: warning: NULL used in arithmetic [-Wpointer-arith]
if (NULL != m_hThread)
^
src/utils/AutoCleanup.h: In member function ‘bool Thread::Start(LPTHREAD_START_ROUTINE, LPVOID)’:
src/utils/AutoCleanup.h:84:15: warning: NULL used in arithmetic [-Wpointer-arith]
if (NULL != m_hThread) return FALSE;
^
src/utils/AutoCleanup.h: In member function ‘bool Thread::WaitForEnd(DWORD)’:
src/utils/AutoCleanup.h:107:15: warning: NULL used in arithmetic [-Wpointer-arith]
if (NULL == m_hThread) return TRUE;
^
src/utils/AutoCleanup.h:118:22: warning: NULL used in arithmetic [-Wpointer-arith]
if (dwTimeoutMS == INFINITE)
^
src/utils/AutoCleanup.h:131:14: warning: converting to non-pointer type ‘HANDLE {aka long unsigned int}’ from NULL [-Wconversion-null]
m_hThread = NULL;
^
src/utils/AutoCleanup.h: In member function ‘void Thread::Terminate()’:
src/utils/AutoCleanup.h:148:13: warning: converting to non-pointer type ‘HANDLE {aka long unsigned int}’ from NULL [-Wconversion-null]
m_hThread = NULL;
^
g++ -c src/socks/SocksMgr.cpp -o src/socks/SocksMgr.o -I./src -DLINUX
In file included from ./src/stdafx.h:52:0,
from src/socks/SocksMgr.cpp:1:
./src/utils/AutoCleanup.h:105:38: warning: converting to non-pointer type ‘DWORD {aka long unsigned int}’ from NULL [-Wconversion-null]
bool WaitForEnd(DWORD dwTimeoutMS = INFINITE)
^
./src/utils/AutoCleanup.h: In constructor ‘Thread::Thread()’:
./src/utils/AutoCleanup.h:68:19: warning: converting to non-pointer type ‘HANDLE {aka long unsigned int}’ from NULL [-Wconversion-null]
, m_dwThreadId(0)
^
./src/utils/AutoCleanup.h: In destructor ‘Thread::~Thread()’:
./src/utils/AutoCleanup.h:74:15: warning: NULL used in arithmetic [-Wpointer-arith]
if (NULL != m_hThread)
^
./src/utils/AutoCleanup.h: In member function ‘bool Thread::Start(LPTHREAD_START_ROUTINE, LPVOID)’:
./src/utils/AutoCleanup.h:84:15: warning: NULL used in arithmetic [-Wpointer-arith]
if (NULL != m_hThread) return FALSE;
^
./src/utils/AutoCleanup.h: In member function ‘bool Thread::WaitForEnd(DWORD)’:
./src/utils/AutoCleanup.h:107:15: warning: NULL used in arithmetic [-Wpointer-arith]
if (NULL == m_hThread) return TRUE;
^
./src/utils/AutoCleanup.h:118:22: warning: NULL used in arithmetic [-Wpointer-arith]
if (dwTimeoutMS == INFINITE)
^
./src/utils/AutoCleanup.h:131:14: warning: converting to non-pointer type ‘HANDLE {aka long unsigned int}’ from NULL [-Wconversion-null]
m_hThread = NULL;
^
./src/utils/AutoCleanup.h: In member function ‘void Thread::Terminate()’:
./src/utils/AutoCleanup.h:148:13: warning: converting to non-pointer type ‘HANDLE {aka long unsigned int}’ from NULL [-Wconversion-null]
m_hThread = NULL;
^
src/socks/SocksMgr.cpp: In member function ‘DWORD CSocksMgr::TCPTunnelProc(LPVOID)’:
src/socks/SocksMgr.cpp:88:16: warning: converting to non-pointer type ‘DWORD {aka long unsigned int}’ from NULL [-Wconversion-null]
t1.WaitForEnd();
^
src/socks/SocksMgr.cpp:89:16: warning: converting to non-pointer type ‘DWORD {aka long unsigned int}’ from NULL [-Wconversion-null]
t2.WaitForEnd();
^
src/socks/SocksMgr.cpp: In member function ‘DWORD CSocksMgr::ForwardProc(void*)’:
src/socks/SocksMgr.cpp:158:15: error: cast from ‘void*’ to ‘int’ loses precision [-fpermissive]
int s = (int)lpParameter;
^
src/socks/SocksMgr.cpp: In member function ‘bool CSocksMgr::Begin(LPCSTR, int, LPCSTR, int)’:
src/socks/SocksMgr.cpp:291:34: error: cast from ‘CSocksMgr*’ to ‘uint32_t {aka unsigned int}’ loses precision [-fpermissive]
proxy->lpParameter = (uint32_t)this;
^
src/socks/SocksMgr.cpp: In member function ‘bool CSocksMgr::Begin(LPCSTR, int)’:
src/socks/SocksMgr.cpp:336:34: error: cast from ‘CSocksMgr*’ to ‘uint32_t {aka unsigned int}’ loses precision [-fpermissive]
proxy->lpParameter = (uint32_t)this;
^
src/socks/SocksMgr.cpp: In member function ‘bool CSocksMgr::Begin(int)’:
src/socks/SocksMgr.cpp:386:51: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
t.Start((LPTHREAD_START_ROUTINE)Forward,(void*)rs);
^
make: *** [src/socks/SocksMgr.o] Error 1
服务器运行xsocks -t -p1 8085 -p2 8086
远程客户端运行xsocks -r x.x.x.x:8085
本地客户端运行proxifier全局代理
使用20多分钟后就无法转发代理
下面是proxifier测试代理:
[50:09] 测试已开始。
代理服务器
地址: x.x.x.x:8086
协议: SOCKS 5
验证: 是
用户名: xxx
[50:09] 正在开始: 测试 1: 连接到代理服务器
[50:09] IP 地址: x.x.x.x
[50:09] 已建立连接
[50:09] 测试已通过。
[50:09] 正在开始: 测试 2: 通过代理服务器连接
转发不过去,求解
% make
g++ -c src/Tunnel.cpp -o src/Tunnel.o -I./src -DLINUX
In file included from src/Tunnel.cpp:1:0:
src/stdafx.h:13:15: error: redeclaration of C++ built-in type ‘bool’ [-fpermissive]
typedef bool bool;
^
src/stdafx.h:24:14: error: multiple types in one declaration
typedef int int;
^
src/stdafx.h:24:14: error: declaration does not declare anything [-fpermissive]
In file included from src/stdafx.h:53:0,
from src/Tunnel.cpp:1:
src/utils/AutoCleanup.h:105:38: warning: converting to non-pointer type ‘DWORD {aka long unsigned int}’ from NULL [-Wconversion-null]
bool WaitForEnd(DWORD dwTimeoutMS = INFINITE)
^
src/utils/AutoCleanup.h: In constructor ‘Thread::Thread()’:
src/utils/AutoCleanup.h:68:19: warning: converting to non-pointer type ‘HANDLE {aka long unsigned int}’ from NULL [-Wconversion-null]
, m_dwThreadId(0)
^
src/utils/AutoCleanup.h: In destructor ‘Thread::~Thread()’:
src/utils/AutoCleanup.h:74:15: warning: NULL used in arithmetic [-Wpointer-arith]
if (NULL != m_hThread)
^
src/utils/AutoCleanup.h: In member function ‘bool Thread::Start(LPTHREAD_START_ROUTINE, LPVOID)’:
src/utils/AutoCleanup.h:84:15: warning: NULL used in arithmetic [-Wpointer-arith]
if (NULL != m_hThread) return FALSE;
^
src/utils/AutoCleanup.h: In member function ‘bool Thread::WaitForEnd(DWORD)’:
src/utils/AutoCleanup.h:107:15: warning: NULL used in arithmetic [-Wpointer-arith]
if (NULL == m_hThread) return TRUE;
^
src/utils/AutoCleanup.h:118:22: warning: NULL used in arithmetic [-Wpointer-arith]
if (dwTimeoutMS == INFINITE)
^
src/utils/AutoCleanup.h:131:14: warning: converting to non-pointer type ‘HANDLE {aka long unsigned int}’ from NULL [-Wconversion-null]
m_hThread = NULL;
^
src/utils/AutoCleanup.h: In member function ‘void Thread::Terminate()’:
src/utils/AutoCleanup.h:148:13: warning: converting to non-pointer type ‘HANDLE {aka long unsigned int}’ from NULL [-Wconversion-null]
m_hThread = NULL;
^
In file included from src/stdafx.h:56:0,
from src/Tunnel.cpp:1:
src/socks/SocksParser.h: At global scope:
src/common/CommonDefines.h:19:3: error: ‘BOOL’ does not name a type
BOOL Init();
^
src/socks/SocksParser.h:38:2: note: in expansion of macro ‘DECLARE_SINGLETON’
DECLARE_SINGLETON(SocksParser)
^
src/common/CommonDefines.h:19:3: error: ‘BOOL’ does not name a type
BOOL Init();
^
src/Tunnel.h:27:2: note: in expansion of macro ‘DECLARE_SINGLETON’
DECLARE_SINGLETON(CTunnel)
^
src/Tunnel.cpp: In member function ‘DWORD CTunnel::TCPTunnelProc(LPVOID)’:
src/Tunnel.cpp:214:16: warning: converting to non-pointer type ‘DWORD {aka long unsigned int}’ from NULL [-Wconversion-null]
t1.WaitForEnd();
^
src/Tunnel.cpp:215:16: warning: converting to non-pointer type ‘DWORD {aka long unsigned int}’ from NULL [-Wconversion-null]
t2.WaitForEnd();
^
src/Tunnel.cpp: In member function ‘bool CTunnel::Begin(int, int)’:
src/Tunnel.cpp:247:16: warning: converting to non-pointer type ‘DWORD {aka long unsigned int}’ from NULL [-Wconversion-null]
t1.WaitForEnd();
^
src/Tunnel.cpp:248:16: warning: converting to non-pointer type ‘DWORD {aka long unsigned int}’ from NULL [-Wconversion-null]
t2.WaitForEnd();
^
makefile:10: recipe for target 'src/Tunnel.o' failed
make: *** [src/Tunnel.o] Error 1
编译环境
Linux #27-Ubuntu SMP Thu Dec 17 22:57:08 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
gcc version 5.2.1 20151010 (Ubuntu 5.2.1-22ubuntu2)
Hi, and thank you for contributing that socks5 project on github! I was just looking for a very simple cmdline proxy to learn with, and yours seems perfect for this.
However, I have a problem using the reverse proxy function. Maybe I'm doing something wrong, or there's a bug.
This is the scenario: 1 remote machine connects via reverse proxy to my local machine. I want then to connect my Firefox browser to the local proxy on my machine.
xsocks -t -p1 2404 -p2 2405
[+] BIND PORTS 2404 AND 2405...
[+] LISTENING...
xsocks -r 192.168.1.46:2404
[+] CONNECTING 192.168.1.46:2404
[+] CONNECT SUCCESS!
However, it doesn't manage to connect. When I use a normal forward proxy on my remote machine, on an open port, it works correctly though.
Is there a bug, or am I doing something wrong?
Thanks!!
该工具非常好用,希望能够发布docker镜像,以期能够在docker环境使用
2024-02-28T14:39:04.618Z INFO [rsocx::socks] proxy connect to rtb.openx.net:443
thread 'main' panicked at 'called Result::unwrap()
on an Err
value: Os { code: 24, kind: Uncategorized, message: "No file descriptors available" }', src/main.rs:80:56
note: run with RUST_BACKTRACE=1
environment variable to display a backtrace
类似于 指定
ipv4 192.168.1.0/24
ipv6 2408:333:c081:1100::/64
意思
就是从指定的ip段 随机生成 作为出口
客户端断开重连后,报错。
root@TS151213-daniao:/xsocks# make & sudo make install/xsocks# In file included from src/Tunnel.cpp:1:0:
[1] 5167
g++ -c src/Tunnel.cpp -o src/Tunnel.o -I./src -DLINUX
cp ./bin/xsocks /bin/xsocks
cp: cannot stat `./bin/xsocks': No such file or directory
make: *** [install] Error 1
root@TS151213-daniao:
src/stdafx.h:13:15: error: redeclaration of C++ built-in type 'bool' [-fpermissive]
src/stdafx.h:24:14: error: multiple types in one declaration
src/stdafx.h:24:14: error: declaration does not declare anything [-fpermissive]
In file included from src/stdafx.h:53:0,
from src/Tunnel.cpp:1:
src/utils/AutoCleanup.h: In constructor 'Thread::Thread()':
src/utils/AutoCleanup.h:68:19: warning: converting to non-pointer type 'HANDLE {aka long unsigned int}' from NULL [-Wconversion-null]
src/utils/AutoCleanup.h: In destructor 'Thread::~Thread()':
src/utils/AutoCleanup.h:74:15: warning: NULL used in arithmetic [-Wpointer-arith]
src/utils/AutoCleanup.h: In member function 'bool Thread::Start(LPTHREAD_START_ROUTINE, LPVOID)':
src/utils/AutoCleanup.h:84:15: warning: NULL used in arithmetic [-Wpointer-arith]
src/utils/AutoCleanup.h: In member function 'bool Thread::WaitForEnd(DWORD)':
src/utils/AutoCleanup.h:107:15: warning: NULL used in arithmetic [-Wpointer-arith]
src/utils/AutoCleanup.h:118:22: warning: NULL used in arithmetic [-Wpointer-arith]
src/utils/AutoCleanup.h:131:16: warning: converting to non-pointer type 'HANDLE {aka long unsigned int}' from NULL [-Wconversion-null]
src/utils/AutoCleanup.h: In member function 'void Thread::Terminate()':
src/utils/AutoCleanup.h:148:15: warning: converting to non-pointer type 'HANDLE {aka long unsigned int}' from NULL [-Wconversion-null]
In file included from src/Tunnel.h:6:0,
from src/Tunnel.cpp:2:
src/socks/SocksParser.h: At global scope:
src/socks/SocksParser.h:38:2: error: 'BOOL' does not name a type
In file included from src/Tunnel.cpp:2:0:
src/Tunnel.h:27:2: error: 'BOOL' does not name a type
src/Tunnel.cpp: In member function 'DWORD CTunnel::TCPTunnelProc(LPVOID)':
src/Tunnel.cpp:214:16: warning: converting to non-pointer type 'DWORD {aka long unsigned int}' from NULL [-Wconversion-null]
src/Tunnel.cpp:215:16: warning: converting to non-pointer type 'DWORD {aka long unsigned int}' from NULL [-Wconversion-null]
src/Tunnel.cpp: In member function 'bool CTunnel::Begin(int, int)':
src/Tunnel.cpp:247:16: warning: converting to non-pointer type 'DWORD {aka long unsigned int}' from NULL [-Wconversion-null]
src/Tunnel.cpp:248:16: warning: converting to non-pointer type 'DWORD {aka long unsigned int}' from NULL [-Wconversion-null]
make: *** [src/Tunnel.o] Error 1
环境:
Debian GNU/Linux 7 \n \l
内核:
Linux TS151213-daniao 2.6.32-042stab108.8 #1 SMP Wed Jul 22 17:23:23 MSK 2015 x86_64 GNU/Linux
Hi. I'm trying to check one example socks5 but i get this error:
[+] [SOCKSMGR.CPP:367] 6788 LISTENING 8082
[+] [SOCKSMGR.CPP:382] 6788 ACCEPT : 127.0.0.1
[D] [SOCKSMGR.CPP:28] 212 RECV ERROR! 10038
[D] [SOCKSMGR.CPP:65] 4744 SEND ERROR! 10038
[D] [SOCKSMGR.CPP:92] 5660 TUNNEL THREAD FINISH!
[+] [SOCKSMGR.CPP:382] 6788 ACCEPT : 127.0.0.1
[D] [SOCKSMGR.CPP:65] 6032 SEND ERROR! 10038
[D] [SOCKSMGR.CPP:28] 2424 RECV ERROR! 10038
[D] [SOCKSMGR.CPP:92] 7072 TUNNEL THREAD FINISH!
Why? I could use this to do my own socks5 proxy with my static ip? Thx a lot for this project it is very cool. And i need know about why and how i can run well.
Apologies for in-formalities. But I am looking to develop with this code. I would like to modify the the sock.rs to push to different routes or interfaces or connections in a round robin or random fashion. I understand how to do the round robin part, but I am very unfamiliar with rust. Was hoping if you knew off the top of your head any specific functions I could user to accomplish this goal. Thanks
Something like:
use tokio::net::TcpSocket;
use std::io;
#[tokio::main]
async fn main() -> io::Result<()> {
let addr = "127.0.0.1:8080".parse().unwrap();
let socket = TcpSocket::new_v4()?;
let stream = socket.connect(addr).await?;
Ok(())
}
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.