xlgjjff / libtorrent

Automatically exported from code.google.com/p/libtorrent
Other
0 stars 0 forks source link

dht socks5 proxy negotiation error #36

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.proxy_settings.type=lt.proxy_type.socks5
proxy_settings.hostname='127.0.0.1'
proxy_settings.port=1080 
2.session.set_dht_proxy(proxy_settings)

What is the expected output? What do you see instead?
wait for a little time, call ses.status().dht_nodes, expect return a >0 int
number, and ses.dht_state()['nodes'] isnot null list.
but ht_nodes==0 and dht_state()['nodes']==[] always.

What version of the product are you using? On what operating system?
python-libtorrent-0.14.8.win32, windows xp pro sp3

Please provide any additional information below.
my socks5 proxy use the 3proxy's socks.exe
socks -l -f"L%Y%m%d %H:%M:%S.%. %N.%p %E %U %C:%c %R:%r %O %I %h %T"
-i127.0.0.1 -e192.168.1.14
set libtorrent dht proxy 127.0.0.1 1080
then dht node number always 0. disable dht proxy, work fine. try another
client, like utorrent, and set same proxy, work fine.
run socketsniff to captrue socks.exe, got some below packets:
1. libtorrent send "05 01 00" to proxy
2. proxy respond "05 00"
3. libtorrent send request "05 01 00 01 8B 9D 40 00 A5 00"
4. proxy get a unknown error
read rfc1928, "05 01 00 01 8B 9D 40 00 A5 00" mean "connect
139.157.64.0:42240",here 139.157.64.0 is a wrong ip-addr. try utorrent, it
would be "05 01 00 01 43 D7 E9 82 00 50", is 67.215.233.130:80 and work
fine. it is a bug?

Original issue reported on code.google.com by smm...@gmail.com on 16 Feb 2010 at 9:34

GoogleCodeExporter commented 8 years ago
I'm working on a fix. Thanks for the report!

Original comment by arvid.no...@gmail.com on 16 Feb 2010 at 4:22

GoogleCodeExporter commented 8 years ago
python idle:
>>> import libtorrent as lt
>>> ses = lt.session()
>>> ses.add_extension(lt.create_ut_pex_plugin)
>>> settings = lt.session_settings()
>>> settings.use_dht_as_fallback=False
>>> ses.set_settings(settings)
>>> pe_settings = lt.pe_settings()
>>> pe_settings.in_enc_policy=lt.enc_policy.enabled
>>> pe_settings.out_enc_policy=lt.enc_policy.enabled
>>> pe_settings.allowed_enc_level=lt.enc_level.both
>>> ses.set_pe_settings(pe_settings)
>>> ses.listen_on(6881, 6889, interface='127.0.0.1')
True
>>> ses.start_lsd()
>>> ses.start_upnp()
>>> ses.start_dht(None)
>>> proxy_settings=lt.proxy_settings()
>>> proxy_settings.type=lt.proxy_type.socks5
>>> proxy_settings.hostname='127.0.0.1'
>>> proxy_settings.port=1080
>>> ses.set_dht_proxy(proxy_settings) #this line, proxy get a unknown error
>>> ses.dht_state() #program has not any return and wait it, no >>> prompt, 
must kill
process. expect return a dict like {'node-id':
"\xa6'O\x02\x01+\x1b'\xbb\x94\xff\x94g\x86\xfb\xb1\xbc3l\\"}

another way:   
>>> import libtorrent as lt
... # same as above
>>> ses.listen_on(6881, 6889, interface='127.0.0.1')
True
>>> ses.start_lsd()
>>> proxy_settings=lt.proxy_settings()
>>> proxy_settings.type=lt.proxy_type.socks5
>>> proxy_settings.hostname='127.0.0.1'
>>> proxy_settings.port=1080
>>> ses.set_dht_proxy(proxy_settings) #this line, proxy get a unknown error
>>> ses.add_dht_router("router.bittorrent.com", 6881)
>>> ses.add_dht_router("router.utorrent.com", 6881)
>>> ses.add_dht_router("router.bitcomet.com", 6881)
>>> ses.start_dht(None)
>>> ses.dht_state() #program has not any return and wait it, same as above

Original comment by smm...@gmail.com on 17 Feb 2010 at 7:32

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
I can't explain the SOCKS connect command you see. Since this is UDP, it should 
be using the UDP-ASSOCIATE 
command. I've fixed a few issues related to the UDP support in my SOCKS5 
implementation. I've checked this 
into all active branches (RC_0_14, RC_0_15 and trunk). Do you think you could 
see if this issue is fixed?

Original comment by arvid.no...@gmail.com on 18 Feb 2010 at 6:57

GoogleCodeExporter commented 8 years ago

Original comment by arvid.no...@gmail.com on 21 Feb 2010 at 10:57