Reputation: 305
Hello today i posted some Socks5 proxies on a forum and some person went in discussion with me and said many of the proxies where "connect" proxies and socks4 proxies but i don't think my code is checking for any socks4 proxies:
def process(self, task):
global alive
global dead
global tested
proxy = task
ip,port = proxy.split(":")
socket.setdefaulttimeout(timeout_value)
log_msg = str("Trying Socks5 proxy%21s " % proxy)
socks.set_default_proxy(socks.SOCKS5, ip, int(port))
socket.socket = socks.socksocket
try:
t1 = time.time()
response = requests.get(test_url, timeout=timeout_value)
tested += 1
t2 = time.time()
except Exception as e:
log_msg += "%s " % fail_msg
print(Fore.LIGHTRED_EX + log_msg + " " + str(tested))
dead += 1
tested += 1
return None
if "Connection working" in response.text:
log_msg += ok_msg + "Response time: %d" % (int((t2-t1)*1000))
print(Fore.LIGHTGREEN_EX + log_msg)
text_file = open(out_filename, "a")
text_file.write(proxy + "\r\n")
text_file.close()
alive += 1
return proxy
else:
log_msg += "%s " % fail_msg
print(Fore.LIGHTRED_EX + log_msg + " " + str(tested))
dead += 1
tested += 1
return None
I don't know what i could be doing wrong, the person said he has been checking proxies since 2002 and he is the first person out of thousands to complain about it.
Upvotes: 0
Views: 800
Reputation: 123320
A proxy could in theory handle socks4, socks5 and connect (i.e. HTTP proxy) at the same time and on the same port, which means both of you might be right. With all of these protocols the client sends the first message and these messages differ significantly between socks4, socks5 and connect. Thus a proxy can decide based on this first message what kind of protocol the client is asking for. And, while I'm not aware of any proxy which handles all three protocols on the same port it is at least common to handle both socks4 and socks5 at the same port by the same proxy.
Upvotes: 1