How to verify the validity of socks5 server?


Recently, goagent has been unable to use it. It was replaced by shadowsocks. ss clients need to specify ss server IP/PORT/PASSWORD and so on. This is more troublesome than goagent, but it also ensures the effectiveness of the wall climbing.

At present, some free ss servers can be found on the Internet, but these servers are basically disposable and cannot be used after a while. I wrote a python script to update the ss configuration every time I start the ss client to ensure that I can get the available server configuration.

However, when the client is running, if the server goes down or the password is changed, my script cannot perceive it and needs to manually modify the configuration or restart the ss client, thus the experience is very bad.

In order to solve this problem, my idea is to add a background thread to the client, check the availability of the server every once in a while, and update the configuration and restart the client if it is not available. I found some python socks libraries on the Internet, which can be directly connected to socks proxy, but what I want to verify now is shdowsocks server, which is equivalent to socks proxy server. How do I test its availability with scripts?

Ps. Although the connection socks proxy test can also achieve the purpose, I still want to know how to test the shadowsocks server.

Httpclient2, or requesocks, is an http client that can be used in socks agent, and can be verified directly using, for example,

Or, why not just put a supervisord on the server to monitor the shadowsocks process?