- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
sshuttle claims它解决了很多问题discussed problem的 TCP-over-TCP meltdown .
sshuttle assembles the TCP stream locally, multiplexes it statefully over an ssh session, and disassembles it back into packets at the other end. So it never ends up doing TCP-over-TCP. It’s just data-over-TCP, which is safe.
但从程序的角度来看,它维护与目标服务器的 TCP 连接及其附带的所有内容(读取指数超时),这是关于其他 TCP session 的分层,因为 SSH 还不能仅在 UDP
。这看起来很像 TCP-over-TCP。
这里有什么技巧? sshuttle真的解决问题了吗?
我尝试阅读 source code ,但至今没有找到答案。
更重要的是,他们究竟是怎么做到的?如果想在准系统中重新实现它,应该从哪里寻找灵感?
最佳答案
sshuttle
客户端设置防火墙规则(Linux 中的 iptables,这就是 sshuttle
客户端需要 root 权限的原因)将某些传出 TCP 连接重定向到本地端口(默认为 12300 ),启动sshuttle可以看到这个过程:
firewall manager: starting transproxy.
>> iptables -t nat -N sshuttle-12300
>> iptables -t nat -F sshuttle-12300
>> iptables -t nat -I OUTPUT 1 -j sshuttle-12300
>> iptables -t nat -I PREROUTING 1 -j sshuttle-12300
>> iptables -t nat -A sshuttle-12300 -j RETURN --dest 127.0.0.0/8 -p tcp
>> iptables -t nat -A sshuttle-12300 -j REDIRECT --dest 0.0.0.0/0 -p tcp --to-ports 12300 -m ttl ! --ttl 42
并在 sshuttle 退出时删除 iptables nat 规则,
>> iptables -t nat -D OUTPUT -j sshuttle-12300
>> iptables -t nat -D PREROUTING -j sshuttle-12300
>> iptables -t nat -F sshuttle-12300
>> iptables -t nat -X sshuttle-12300
TCP 内容被拾取并通过 ssh 连接多路复用到 sshuttle
服务器,然后再次解复用到连接中。 client.py 中的函数 onaccept_tcpin
做多路复用:
def onaccept_tcp(listener, method, mux, handlers):
global _extra_fd
try:
sock, srcip = listener.accept()
except socket.error as e:
if e.args[0] in [errno.EMFILE, errno.ENFILE]:
debug1('Rejected incoming connection: too many open files!\n')
# free up an fd so we can eat the connection
os.close(_extra_fd)
try:
sock, srcip = listener.accept()
sock.close()
finally:
_extra_fd = os.open('/dev/null', os.O_RDONLY)
return
else:
raise
dstip = method.get_tcp_dstip(sock)
debug1('Accept TCP: %s:%r -> %s:%r.\n' % (srcip[0], srcip[1],
dstip[0], dstip[1]))
if dstip[1] == sock.getsockname()[1] and islocal(dstip[0], sock.family):
debug1("-- ignored: that's my address!\n")
sock.close()
return
chan = mux.next_channel()
if not chan:
log('warning: too many open channels. Discarded connection.\n')
sock.close()
return
mux.send(chan, ssnet.CMD_TCP_CONNECT, b'%d,%s,%d' %
(sock.family, dstip[0].encode("ASCII"), dstip[1]))
outwrap = MuxWrapper(mux, chan)
handlers.append(Proxy(SockWrapper(sock, sock), outwrap))
expire_connections(time.time(), mux)
在ssnet.py中可以看到数据是如何打包的.
我在 redsocks 中看到了相同的策略(我的意思是设置防火墙规则)旨在将任何 TCP 连接重定向到 SOCKS 或 HTTPS 代理。
关于networking - sshuttle 如何避免 TCP-over-TCP 诅咒?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41427123/
我正在使用AWS中的VM设置Elasticsearch集群。 我知道每个节点都会自动尝试加入一个在同一网络中具有相同群集名称的现有群集。 但是,我无法理解“同一网络” 是什么。 为了了解同一网络,我发
我尝试部署一个已经存在于 Kovan 网络上的合约实例,以通过 web3 和 metamask 与其交互。 首先,我将 metamask 设置为我的当前提供者,然后我部署了一个合约实例,如下所示:
停止 docker 后,它拒绝重新启动。它提示另一个名为 docker0 的网桥已经存在: level=warning msg="devmapper: Base device already exis
我正在使用“docker network create --d bridge mynet”创建一个 docker 网络。我想获取与此 docker 网络关联的网桥名称。 我知道我可以使用“-o”来提供
我的一位同事的VPN连接有问题。似乎他的操作系统重设了代理设置,并且他需要手动将其更改回。有没有办法使用Powershell设置VPN和代理? 他正在使用Windows 7,因此可以使用Powersh
我在 Azure VM 中有一个虚拟机,我想获取网络输入/网络输出指标。 在 Azure 门户中,我将诊断设置和指标设置为存储到选定的存储表中。但存储的指标与我在 Azure 门户中看到的指标之间存在
我有一个用例,我的 Docker 容器的第二个接口(interface)需要共享主机的第二个网络接口(interface)的接口(interface)。这可能使用 docker network con
我在 Azure VM 中有一个虚拟机,我想获取网络输入/网络输出指标。 在 Azure 门户中,我将诊断设置和指标设置为存储到选定的存储表中。但存储的指标与我在 Azure 门户中看到的指标之间存在
我想了解一些关于 Docker 的事情: 如何找到我的容器所在的网络? 我可以动态分离我的容器并附加到其他网络吗?怎么样? 如果我有两个容器正在运行,如何检查这两个容器是否在同一个网络?我可以 pin
我已经开发了一款使用Reaction Native和世博会的应用程序,并想在它的末尾添加一个横幅广告。当我在Android模拟器上的开发版本上运行应用程序时,应用程序的其余部分在没有应用程序的情况下运
我已经编辑了 eth0,但我犯了一个错误,我的 VPS 现在处于脱机状态,甚至无法连接到 ssh,并在故障恢复控制台显示以下消息: “网络不可达”。 配置/编辑网络的命令是什么!? Photo 最佳答
今天早上我启动了我的 GCE 实例,并且 4/6 完全无法访问。所有这些都在同一个 us-east1-d 区域中。 SSH 连接也无法正常工作,因此我使用串行控制台连接到有问题的实例之一。 当我尝试
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 想改进这个问题?将问题更新为 on-topic对于堆栈溢出。 5年前关闭。 Improve this qu
我正在使用 Network.Browser 4000.0.9 检索网页: import Network.Browser import Network.HTTP main = do (uri
我正在尝试更新我在 docker 容器中的 apt 存储库,但我做不到。 docker run -it --dns 8.8.8.8 --dns 8.8.4.4 debian apt-get 更新 ..
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 这个问题似乎不是关于 a specific programming problem, a softwar
Axios 是否可以区分以下内容: 由于客户端没有网络连接而失败的请求发出请求的时间 - (ERR_CONNECTION_REFUSED)。 由于网络连接丢失而失败的请求之后已发出请求,但在收到响应之
Unity 已升级其网络系统,并将旧网络称为遗留网络。 那么我们如何将 RPC 调用更改为新的 Unity Networking?这种方法的等价物是什么?我们应该为它编写自己的方法吗? (发送字节数组
在机器学习工具 vowpal wabbit ( https://github.com/JohnLangford/vowpal_wabbit/ ) 中,通常训练线性估计器 y*=wx。但是,可以添加前向
我正在尝试将 Boost 用于某些 IPv6 和多播网络通信。我需要构建一个使用特定网络接口(interface)索引的 IPv6 多播套接字。 我能够在 boost/asio/ip/detail/s
我是一名优秀的程序员,十分优秀!