[bittorrent] encoding issue

Thad Ward coderjoe at grnet.com
Thu Aug 9 20:09:49 EDT 2007


the info hash you are using as an example is

6a ad 5c 1j 01 69 25 c4 5e ee 06 de a6 95 3b f5 48 d6 91 62

but when sending it in the http query, you can't send a raw binary
string, nor can you send other special characters, so those must be
converted to the %nn form. in Java, you'd use the URLEncoder class,
which would give you

j %ad %5c %1d %01 i %25 %c4 %5e %ee %06 %de %a9 %95 %3b %f5 H %d6 %91 b

you will notice that, since 0x6a, 0x69, 0x48, and 0x62 are printable
characters, they are sent as their ascii table values (j, i, H, and b,
respectively). 

See:

http://java.sun.com/j2se/1.5.0/docs/api/java/net/URLDecoder.html
http://java.sun.com/j2se/1.5.0/docs/api/java/net/URLEncoder.html

for more info

On Wed, Aug 08, 2007 at 03:10:36AM -0300, Dazen D wrote:
> ok. just to be fair, in fact i'm not working with any tracker
> package, i'm doing some experiments on my own.
> 
> On 8/8/07, Harold Feit <dwknight at depthstrike.com> wrote:
> > It's more of a tracker bug than a client feature.
> >
> > Most, if not all, other tracker packages are able to use the version
> > encoded with the url-friendly characters left unencoded.
> >
> > Dazen D wrote:
> > > all right, i got it. i don't think that java has a method to deal
> > > with this kind of "mixed" string, but knowing that it's a
> > > client feature it's easy to come up with something.
> > > thank you very much for the help.
> > >
> > > On 8/8/07, Harold Feit <dwknight at depthstrike.com> wrote:
> > >> You should have a language native urldecode function that converts the
> > >> urlencoded infohash into a byte array.
> > >>
> > >> The reason that the client is sending j instead of %6a is because j is
> > >> url-safe and saves bandwidth to send not encoded.
> > >>
> > >> Dazen D wrote:
> > >>> by the decoded one you mean what?
> > >>>
> > >>> for me the decoded one should be:
> > >>>
> > >>> %6a%ad%5c%1d%01%69%25%c4%5e%ee%06%de%a9%95%3b%f5%48%d6%91%62
> > >>>
> > >>> having that i can convert this string in the byte array representing
> > >>> the hash_info. but what i'm getting is:
> > >>>
> > >>> j%ad%5c%1d%01i%25%c4%5e%ee%06%de%a9%95%3b%f5H%d6%91b
> > >>>
> > >>> and i don't know how can i obtain my byte array from this one. am i
> > >>> missing the reason why the client is sending 'j' instead of '%6a' ?
> > >>>
> > >>> On 8/7/07, Harold Feit <dwknight at depthstrike.com> wrote:
> > >>>> Both are valid actually. You should not be using the urlencoded infohash
> > >>>> to identify the torrent. Use a decoded one (20 bytes).
> > >>>>
> > >>>>
> > >>>>
> > >>>> Dazen D wrote:
> > >>>>> Hi, i'm facing a strange problem trying to implement a tracker service
> > >>>>> using java servlet technology (with Tomcat 6.0.13). When a typical
> > >>>>> announce request arrives in the server, the info_hash parameter that i
> > >>>>> get is:
> > >>>>>
> > >>>>> info_hash=j%ad%5c%1d%01i%25%c4%5e%ee%06%de%a9%95%3b%f5H%d6%91b
> > >>>>>
> > >>>>> In fact it should be :
> > >>>>>
> > >>>>> %6a%ad%5c%1d%01%69%25%c4%5e%ee%06%de%a9%95%3b%f5%48%d6%91%62
> > >>>>>
> > >>>>> but apparently some of the hex are arriving incorrectly, like 'j'
> > >>>>> instead of '%6a'. When i send a similar request via browser like
> > >>>>>
> > >>>>> http://localhost?info_hash=%6a%ad%5c%1d%01%69%25%c4%5e%ee%06%de%a9%95%3b%f5%48%d6%91%62
> > >>>>>
> > >>>>> it works properly. I tested using uTorrent and Azureus and the problem
> > >>>>> was the same. Any ideas about it? thanks a lot.
> > >>>>>
> > >>>>> dazen
> > >>>>> _______________________________________________
> > >>>>> BitTorrent mailing list
> > >>>>> BitTorrent at lists.ibiblio.org
> > >>>>> http://lists.ibiblio.org/mailman/listinfo/bittorrent
> > >>>>
> > >>> _______________________________________________
> > >>> BitTorrent mailing list
> > >>> BitTorrent at lists.ibiblio.org
> > >>> http://lists.ibiblio.org/mailman/listinfo/bittorrent
> > >>>
> > >>>
> > >>
> > >
> > >
> >
> >
> _______________________________________________
> BitTorrent mailing list
> BitTorrent at lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/bittorrent
> 



More information about the BitTorrent mailing list