A tun2socks implementation written in C/C++ 2015 + Lwip-win32k.
liulilittle / tun2socks Goto Github PK
View Code? Open in Web Editor NEWIf commercial application please use "liulilittle@VEthernet" this is a test project has no practical value.
If commercial application please use "liulilittle@VEthernet" this is a test project has no practical value.
最近也在搞全局代理相关的,看了您的代码发现有些地方不是很明白
inline static tcp_pcb* tcp_listen_any() {
auto pcb = lwip_tcp_new();
auto any = ip_addr_any;
lwip_tcp_bind(pcb, &any, 0);
return lwip_tcp_listen(pcb);
}
假如虚拟网卡地址是 192.18.0.1, 我把192.18.0.1/24网段路由到192.18.0.1,这个时候如果我用curl 192.18.0.2:9090 测试,虚拟网卡检测到 192.18.0.1 -> 192.18.0.2, 数据给到lwip处理时lwip在 ip4_input
的时候提示 ip4_input: packet not for us.
, 检查 ip4_input_accept
函数发现lwip的判断就是目标地址不是netif的地址就不会接受这个ip包
/** Return true if the current input packet should be accepted on this netif */
static int
ip4_input_accept(struct netif *netif)
{
LWIP_DEBUGF(IP_DEBUG, ("ip_input: iphdr->dest 0x%"X32_F" netif->ip_addr 0x%"X32_F" (0x%"X32_F", 0x%"X32_F", 0x%"X32_F")\n",
ip4_addr_get_u32(ip4_current_dest_addr()), ip4_addr_get_u32(netif_ip4_addr(netif)),
ip4_addr_get_u32(ip4_current_dest_addr()) & ip4_addr_get_u32(netif_ip4_netmask(netif)),
ip4_addr_get_u32(netif_ip4_addr(netif)) & ip4_addr_get_u32(netif_ip4_netmask(netif)),
ip4_addr_get_u32(ip4_current_dest_addr()) & ~ip4_addr_get_u32(netif_ip4_netmask(netif))));
/* interface is up and configured? */
if ((netif_is_up(netif)) && (!ip4_addr_isany_val(*netif_ip4_addr(netif)))) {
/* unicast to this interface address? */
if (ip4_addr_eq(ip4_current_dest_addr(), netif_ip4_addr(netif)) ||
/* or broadcast on this interface network address? */
ip4_addr_isbroadcast(ip4_current_dest_addr(), netif)
#if LWIP_NETIF_LOOPBACK && !LWIP_HAVE_LOOPIF
|| (ip4_addr_get_u32(ip4_current_dest_addr()) == PP_HTONL(IPADDR_LOOPBACK))
#endif /* LWIP_NETIF_LOOPBACK && !LWIP_HAVE_LOOPIF */
) {
LWIP_DEBUGF(IP_DEBUG, ("ip4_input: packet accepted on interface %c%c\n",
netif->name[0], netif->name[1]));
/* accept on this netif */
return 1;
}
#if LWIP_AUTOIP
/* connections to link-local addresses must persist after changing
the netif's address (RFC3927 ch. 1.9) */
if (autoip_accept_packet(netif, ip4_current_dest_addr())) {
LWIP_DEBUGF(IP_DEBUG, ("ip4_input: LLA packet accepted on interface %c%c\n",
netif->name[0], netif->name[1]));
/* accept on this netif */
return 1;
}
#endif /* LWIP_AUTOIP */
}
return 0;
}
netif开启LWIP_HAVE_LOOPIF 后默认地址就是回环地址127.0.0.1, 这里代码判断确实没问题,不知道您这边是用了什么黑科技能够让lwip监听到任意其他ip地址的tcp请求?
auto act = _auth->next();
while (act != SUCCESS && act != FAILURE) {
if (act == SEND) {
size_t len;
auto p = _auth->construct_send(len);
_socket.send(boost::asio::buffer(p.get(), len));
_auth->sent();
}
else if (act == RECV) {
size_t len;
auto p = _auth->construct_receive(len);
_socket.receive(boost::asio::buffer(p.get(), len));
_auth->received(p.get(), len);
}
**//act = _auth->next(); 缺这句???**
}
能留个联系方式吗?
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.