zfl9 / ipt2socks

将 iptables/nftables 传入的透明代理流量转为 socks5 流量的实用工具
GNU Affero General Public License v3.0
411 stars 94 forks source link

Segmentation fault #9

Closed lxf1992521 closed 4 years ago

lxf1992521 commented 4 years ago

操作系统:CentOS 7.6 Tproxy规则:-p udp -j TPROXY --on-port 12345 --on-ip 0.0.0.0 --tproxy-mark 0x1/0x1 socks5代理:gost -L socks5://127.0.0.1:10801 启动方式:sudo -u nobody /usr/bin/ipt2socks -U -4 -s 127.0.0.1 -p 10801 -b 0.0.0.0 -l 12345 -o 5 -G -v 错误提示: ...... 2019-11-28 17:30:57 INF: [udp_socket_listen_cb] try to connect to socks5 server: 127.0.0.1#10801 Segmentation fault

zfl9 commented 4 years ago

see #8

unsciorg commented 4 years ago

同样的错误,感谢作者的付出~

zfl9 commented 4 years ago

周末在搞吧,有点打算用 libev 重构。

unsciorg commented 4 years ago

周末在搞吧,有点打算用 libev 重构。

谢谢,顺便另一个错误

src/unix/core.c:118: uv_close: Assertion `!uv__is_closing(handle)' failed

我网络和C语言学的不是很好,NAT那块有点不大理解,有空再看看

zfl9 commented 4 years ago

估计要一段时间,重构,最近没时间搞业余项目... 其实导致 ipt2socks 段错误的坑在于 https://github.com/libuv/libuv/issues/522。 思来想去还是决定用 libev 重写(恐怕要拖到春节了:sweat_smile:)。 如果忍受不了这个"小"问题,可以用回 redsocks/redsocks2。

ArchonLee commented 4 years ago

在用openwrt下的trojan做透明代理,tcp一切正常,大流量使用udp(使命召唤16加速)时候ipt2socks有时会段错误退出。

借地方问下用redsocks2做代替的时候,保持luci-app-ssr-plus的配置iptables不变,使用

redudp { bind = "0.0.0.0:31080"; relay = "127.0.0.1:10801"; type=socks5; } 31080是trojan nat方式的监听端口 10801是trojan client方式的监听端口 udp没办法转发,后来去redsocks2下找解答,尝试过为mangle表的OUTPUT增加-j MARK --set-mark 0x01,可是没什么效果。是需要特别设置某些地方吗?

谢谢!

最后发现可能是trojan提供的socks5代理服务问题…

zfl9 commented 4 years ago
base {
  daemon = on;
  log_info = on;
  reuseport = on;
  redirector = iptables;
  log = "file:/var/log/redsocks2.log";
}

redsocks {
  local_ip = 0.0.0.0;
  local_port = 60080;
  ip = 127.0.0.1;
  port = 61080;
  type = socks5;
}

redudp {
  local_ip = 0.0.0.0;
  local_port = 60080;
  ip = 127.0.0.1;
  port = 61080;
  type = socks5;
}
zfl9 commented 4 years ago

@ArchonLee

ArchonLee commented 4 years ago

@ArchonLee

感谢!最后排查到trojan的socks5代理上。在使用ipt2socks转发udp流量时候trojan的socks5代理工作正常,但是使用redsocks2转发udp流量到trojan时,trojan会抛出bad alloc的异常。

还是更期待最新版的ipt2socks!

zfl9 commented 4 years ago

redirect to https://github.com/zfl9/ipt2socks/issues/15