通过 SOCKS 服务器使用 ping 吗?
我想定期检查我的 SOCKS 服务器是否工作正常。为了做到这一点,我想到通过 SOCKS 服务器 ping 8.8.8.8(google DNS 服务器)。
还有其他推荐的方式吗? 如果是最佳的,我如何使用 python ping 通 SOCKS?
I'd like to periodicity check if my SOCKS server is working fine. In order to do that, I thought of pinging 8.8.8.8 (google DNS server) through the SOCKS server.
Is there other recommended way?
If it's optimal, how can I ping through SOCKS with python?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
SOCKS代理提供TCP代理服务(SOCKS 5添加了UDP支持)。您无法“通过”SOCKS 代理服务执行 ICMP Echo。
即使可以,您也将测试 ICMP Echo 和 Echo Reply,而不是您的 SOCKS 服务器运行良好。
如果您想测试您的 SOCKS 服务器是否“运行良好”,我建议您打开本地侦听端口,然后尝试通过 SOCKS 服务连接到它。
A SOCKS proxy provides a TCP proxy service (SOCKS 5 added UDP Support). You cannot perform an ICMP Echo "via" a SOCKS proxy service.
Even if you could, you would be testing ICMP Echo and Echo Reply, and not that your SOCKS server is running fine.
If you want to test that your SOCKS server is "running fine" I'd suggest that you open local listening port and then try to connect to it via the SOCKS service.
您可以使用
httping
通过SOCKS服务器来检查网络,而不是普通的ping
。ICMP 工作在 OSI 模型的第 3 层(网络层),SOCKS 工作在第 5 层(会话层),httping 工作在第 7 层(应用层),因此
ping< /code> 消息无法通过 SOCKS,但
httping
消息可以。例如,我在VPS中设置了一个shadowsocks(SOCKS5代理)服务器,使用我的macbook pro作为客户端,使用127.0.0.1:1080,我想检查google的网络是否良好。
httping -x 127.0.0.1:1080 -g http://www.google.com -5
通过 SOCKS5 httping google 的屏幕截图
httping 使用情况
httping [选项]
-5 选择的代理服务器是 SOCKS5 服务器。
-g url 这选择要探测的 url。例如:http://localhost/
-x proxyhost[:port] 使用代理服务器进行探测。
You can use
httping
to check the network through the SOCKS server instead of the ordinaryping
.ICMP works at Layer3(the Network Layer) of the OSI model, SOCKS works at Layer5(the Session Layer), httping works at Layer7(the Application Layer), so
ping
message cannot pass though the SOCKS, buthttping
message can.For example, I setup a shadowsocks(a SOCKS5 proxy) server in a VPS, use my macbook pro as a client using 127.0.0.1:1080, and I want to check if the network to google is good.
httping -x 127.0.0.1:1080 -g http://www.google.com -5
screen capture of httping google through SOCKS5
httping usage
httping [options]
-5 The proxy server selected is a SOCKS5 server.
-g url This selects the url to probe. E.g.: http://localhost/
-x proxyhost[:port] Probe using a proxyserver.
你可以使用curl通过socks访问一些网站,如果有正确的答案那么socks代理就可以了。例如
,如果您收到警告,则说明您的袜子无法使用
you can use curl to get some website through that socks, if have the right answer then the socks proxy is all right. For example
if you got the warning, then you have unusable socks
这就是我要解决的方法,使用子进程执行操作系统的 ping 命令并使用正则表达式解析输出可能是最简单的。
编辑
activestate< 上有一个示例/a> 大部分都在那里,你只需要更改套接字以某种方式指定你的代理,但这不是我真正的领域,所以我不确定你会如何去做。
This is the way I would go about it, and it would probably be most simple to execute your operating system's ping command using a subprocess and parse the output with a regex.
edit
There is an example on activestate that goes most of the way there, you would just have to change the socket to somehow specify your proxy, however that isn't really my area so I'm not sure how you'd go about it.