Closed Ch4ttY closed 1 year ago
Hi, Telethon is not built to be used with my library, so using their built-in proxy system will probably not work, however you can probably achieve the same result with monkeypatching. Be warned that this will cause all sockets opened to be proxied.
Here is an example usage (Of course substituting whatnot to make your code work)
import sockslib
import socket
authentication = [
sockslib.NoAuth(), # No authentication
sockslib.UserPassAuth('username', 'password'), # Username / Password authentication
]
sockslib.set_default_proxy(
('proxy IP', proxy_port),
sockslib.Socks.SOCKS5,
socket.AF_INET6, # This sets it to IPv6
authentication
)
original_socket = socket.socket # Save the original socket
socket.socket = sockslib.SocksSocket # Make the default socket object a SocksSocket
async with await TelegramClient.FromTDesktop(
account=tdesk,
connection_retries=10,
timeout=2,
flag=UseCurrentSession
) as app:
socket.socket = original_socket # Not neccesary but will probably cause less buggy behavior if you have anything else making connections
# your code
Could you help me to find out, pls?
For some reasons it didn't help to me. ubuntu==22.04 python==3.10.12 telethon==1.24 sockslib==1.7.6
Attempt 1 at connecting failed: gaierror: [Errno -9] Address family for hostname not supported
You told the socket to connect to your proxy with IPv6 but the IP address you entered is a v4 address. Simply remove the ip_protocol argument. Also, for set_default_proxy, you must not include the variable names. e.g replace socktype=sockslib.Socks.SOCKS5
with just sockslib.Socks.SOCKS5
.
It is not necessary to include the ip_protocol parameter in the proxy definition so long as the server is accessible via ipv4, because socks5 proxies will automatically work with ipv6 so long as the socks server itself supports it.
No, it was ipv6 address. Even with ipv6 proxy format it doesn't work, look.
You are mistaken, That IPv6 address is NOT the proxy address. Use the ip and port that says "Proxy" and use ipv4. If you dont have ipv4 for some reason, you're going to have to find a different proxy service because that proxy is not hosted on ipv6.
I did so in the previous post but with IPv6 settings.
I tried without AF_INET6 and it worked. I'm not sure if it used the proxy(Could you help me how to check that the connection uses a proxy?)
So, should I find another provider to use ipv6? And what should the correct ip:port look like in this case?
P.S. This proxy in the format 45.32.117.124:12761 works in telegram portable with the "connect via ipv6" checkbox enabled
I don't see what issue you're having. The connection will be using the proxy otherwise it will simply not connect. If the proxy is working what is the issue then? You'll still be able to connect to ipv6 addresses through the proxy
Got it, I will try and share the result later, thank you!
If I need to use 10 accounts with telethon, I can't use set_default_proxy, I need to use set_proxy, right?
set_default_proxy applies to all proxy connections you make from then on, if you want to change what proxy you’re using, just run it again before you make the connection.
On Saturday, Sep 09, 2023 at 1:15 AM, Ch4ttY @. @.)> wrote:
If I need to use 10 accounts with telethon, I can't use set_default_proxy, I need to use set_proxy, right?
— Reply to this email directly, view it on GitHub (https://github.com/woo200/sockslib/issues/3#issuecomment-1712454268), or unsubscribe (https://github.com/notifications/unsubscribe-auth/AT2COKBX3FWESU6WPE54SKDXZQQRBANCNFSM6AAAAAA4ANPZZY). You are receiving this because you modified the open/close state.Message ID: @.***>
Hi, could you help me to use ur library with telethon with ipv6? It's opentele library(telethon fork). Thank you!
async with await TelegramClient.FromTDesktop(account=tdesk, use_ipv6=True, proxy={'proxy_type': sockslib.Socks.SOCKS5, 'addr': proxy.split(':')[0], 'port': int(proxy.split(':')[1]), 'username': proxy.split(':')[2], 'password': proxy.split(':')[3].replace('\n', ''), 'rdns': True }, connection_retries=10, timeout=2, flag=UseCurrentSession ) as app: