Last active
August 29, 2018 06:02
-
-
Save jxinging/47048f2928c80ca7140c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 生成 socks5 协议的连接命令16进制数据,用于 haproxy的 tcp-check send-binary | |
# 参考: | |
# - <https://zh.wikipedia.org/wiki/SOCKS#SOCKS5>, "SOCKS5请求格式" 部分 | |
# - <http://cbonte.github.io/haproxy-dconv/configuration-1.7.html#4.2-tcp-check%20send-binary> | |
socks5_connect_binary = lambda domain, port: "05010003"+"%02x" % len(domain)+"".join(["%02x" % ord(x) for x in domain])+"%04x" % int(port) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment