ruisu Posted July 12, 2009 Report Share Posted July 12, 2009 For example this is a known hash of a test torrent: DDEAB2A22896D5DBC8389D1F5514360C4B09BA7Ehowever when I receive the GET request from uTorrent, the info_hash parameter looks like:18겢(8U6K ~Does anyone have any ideas what is happening?Thank you Link to comment Share on other sites More sharing options...
DreadWingKnight Posted July 12, 2009 Report Share Posted July 12, 2009 You're not understanding the protocol. That's what's happening. Link to comment Share on other sites More sharing options...
ruisu Posted July 12, 2009 Author Report Share Posted July 12, 2009 Okay, well that's better I guess.Please help me understand what is happening.Does that parameter have to be decoded in a certain way? All of the other params seem to be simple strings (not sure about peer id). Link to comment Share on other sites More sharing options...
DreadWingKnight Posted July 12, 2009 Report Share Posted July 12, 2009 http://wiki.theory.org/BitTorrentSpecification Link to comment Share on other sites More sharing options...
ruisu Posted July 12, 2009 Author Report Share Posted July 12, 2009 I read that again...I am definitely not understanding something.The specs give this example:For a 20-byte hash of \x12\x34\x56\x78\x9a\xbc\xde\xf1\x23\x45\x67\x89\xab\xcd\xef\x12\x34\x56\x78\x9a,The right encoded form is %124Vx%9A%BC%DE%F1%23Eg%89%AB%CD%EF%124Vx%9A but when I actually try encoding \x12\x34\x56\x78\x9a\xbc\xde\xf1\x23\x45\x67\x89\xab\xcd\xef\x12\x34\x56\x78\x9aI get: %5Cx12%5Cx34%5Cx56%5Cx78%5Cx9a%5Cxbc%5Cxde%5Cxf1%5Cx23%5Cx45%5Cx67%5Cx89%5Cxab%5Cxcd%5Cxef%5Cx12%5Cx34%5Cx56%5Cx78%5Cx9aCan you give me a better idea of how to get the right encoded form? Link to comment Share on other sites More sharing options...
DreadWingKnight Posted July 12, 2009 Report Share Posted July 12, 2009 Something in your code isn't translating the bytes properly. Link to comment Share on other sites More sharing options...
ruisu Posted July 13, 2009 Author Report Share Posted July 13, 2009 I changed the code. Now I am able to pass the right encoded example:%124Vx%9A%BC%DE%F1%23Eg%89%AB%CD%EF%124Vx%9A through the byte translator and get:123456789abcdef123456789abcdef123456789aHowever when I pass the info_hash that the client sends as a GET, into the byte translator it comes out very strange. Some of the SHA1 hash is there, other parts of it don't make any sense to me.Can you make any sense of this?Actual hash as shown in uTorrent:DDEAB2A22896D5DBC8389D1F5514360C4B09BA7EAfter passing through the same byte translator:efbfbdeab2a228efbfbdefbfbdefbfbdefbfbd38efbfbd1f5514360c4b09efbfbd7eFor emphasis:efbfbd eab2a228e fbfbdefbfbdefbfbdefbfbd38efbfb d1f5514360c4b09 efbfbd7eDD EAB2A228 96D5DBC8389 D1F5514360C4B09 BA7EThanks again Link to comment Share on other sites More sharing options...
Ultima Posted July 13, 2009 Report Share Posted July 13, 2009 Look at the first unread character. If it is a %, pull the following two characters in the received info_hash out as the hex value of that byte. Else, convert that character into a two-character string representation of the character's hex value. Repeat until you reach the end of info_hash.If you're actually receiving a 20-byte string, then well... just look at the string one byte at a time, and individually convert each byte into its respective two-character hex string. Link to comment Share on other sites More sharing options...
ruisu Posted July 14, 2009 Author Report Share Posted July 14, 2009 Alright, thank you for the help. Slowly but surely, I was funneled into the problem.Surprisingly it was translating the bytes properly — I actually didn't have a byte translator before post one, so thanks for that.When I tried to follow Ultima's solution though, I was back at square (post) one, which eventually led me to discover that it was a code page issue on the server side. Well, this part works now. I hope the rest isn't so baffling =!Still have to read the code page wiki...wth... Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.