Decipher Posted June 10, 2012 Posted June 10, 2012 (edited) I would like to programmatically check to see if a given tracker has information on the torrent I specify. This requires that the SHA-1 Info Hash of a torrent be encoded to make valid requests. I read from: http://nakkaya.com/2009/12/03/bittorrent-tracker-protocol/ If you don't pay attention to the spec and send this directly to tracker you will get an error this should be in URL Encoded form. Padding every two chars with % sign also doesn't work, been there done that don't waste your time. Any hex in the hash that corresponds to a unreserved character should be replaced,a-z A-Z 0-9 -_.~Partition the hex in to chunks of two and check if the hex corresponds to any of these values, if they do replace them with the unreserved char.So that a hash such as,123456789abcdef123456789abcdef123456789abecomes,%124Vx%9a%bc%de%f1%23Eg%89%ab%cd%ef%124Vx%9anotice that hex 34 became 4 which is what it is in ASCII. You can test the correctness of your hashes using the tracker url but don't request from announce request from file,http://some.tracker.com/file?info_hash=hashIf you get a torrent back that means you have the correct hash.I have tried the above and failed. Here's my code: $testStr = "123456789abcdef123456789abcdef123456789a" ConsoleWrite(_EncodeHash($testStr) & @CRLF) Func _EncodeHash($sString) If (Not IsString($sString)) Or $sString = "" Then Return SetError(1, 0, 0) Local $aArray = StringRegExp($sString, "(?s).{1," & 2 & "}", 3), $sEncodedHash For $i = 0 To UBound($aArray) -1 If StringInStr($sString, Chr(Dec($aArray[$i]))) Then $sEncodedHash &= Chr(Dec($aArray[$i])) Else $sEncodedHash &= "%" & $aArray[$i] EndIf Next Return $sEncodedHash EndFuncIf you follow the first link in my post there is an example but I'm unfamiliar with the language being used. Thanks for any help. Edited June 10, 2012 by Decipher Spoiler
Decipher Posted June 10, 2012 Author Posted June 10, 2012 (edited) I'm actually stuck on this. I'd appreciate any help or general suggestions that appropriately pertain to this topic. Edited June 10, 2012 by Decipher Spoiler
JohnOne Posted June 10, 2012 Posted June 10, 2012 General suggestion #1 Don't bump your threads after only a few hours, unless you think you are important enough. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Decipher Posted June 10, 2012 Author Posted June 10, 2012 Hey JohnOne, you're absolutely correct. I consider myself to be an important individual. I would usually have something negative to say but I'm being humble. I'll wait until after I've made six thousand posts and never decide to suggest not bumping threads unless the OP feels important. Thanks for your first suggestion. I can't wait to endure number two but I'd rather stay on topic. Spoiler
JohnOne Posted June 10, 2012 Posted June 10, 2012 Ask and you shall receive. Decipher 1 AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
guinness Posted June 10, 2012 Posted June 10, 2012 Decipher, This is forum etiquette. Plus the support you get is from people who want to help not have to help, so learn how to be patient. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018
Decipher Posted June 10, 2012 Author Posted June 10, 2012 I understand that you bumped the thread repeating what was already said by JohnOne and that neither of you would like to help but instead litter. Spoiler
JohnOne Posted June 10, 2012 Posted June 10, 2012 Believe it or not, we did help, you will wind up in the forum naughty box for bumping like that. Now you know. You're welcome. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Decipher Posted June 10, 2012 Author Posted June 10, 2012 Thanks I solved the problem at hand. $Topic = 1 $Reponse = 0 $Help = 0 Dim $Bump If $Topic = 1 And $Reponse = 0 Then $Bump = 1 EndIf If $Bump >= 1 Then $Unnecessary_Posts = Random(2, 10) Exit Spoiler
JohnOne Posted June 10, 2012 Posted June 10, 2012 $iPost += 1 Decipher 1 AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Decipher Posted June 10, 2012 Author Posted June 10, 2012 I just took this from the spec:Note that all binary data in the URL (particularly info_hash and peer_id) must be properly escaped. This means any byte not in the set 0-9, a-z, A-Z, '.', '-', '_' and '~', must be encoded using the "%nn" format, where nn is the hexadecimal value of the byte. (See RFC1738 for details.)For a 20-byte hash of x12x34x56x78x9axbcxdexf1x23x45x67x89xabxcdxefx12x34x56x78x9a,The right encoded form is %124Vx%9A%BC%DE%F1%23Eg%89%AB%CD%EF%124Vx%9AI think I realize what I'm doing wrong....... I'm still waiting for help guies and no, I'm not trying to bump this thread it is relevant information. Spoiler
Moderators Melba23 Posted June 10, 2012 Moderators Posted June 10, 2012 Decipher, I do not like the tone you have taken so far in this thread - please alter it in future. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
JohnOne Posted June 10, 2012 Posted June 10, 2012 What I think you are doing wrong is trying to escape characters that do not need escaping. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Decipher Posted June 10, 2012 Author Posted June 10, 2012 (edited) Yes ma'am, I have solved my problem by myself. Heres the code: #include <array.au3> $INFOHASH = "123456789abcdef123456789abcdef123456789a" ConsoleWrite(_EncodeHash($INFOHASH) & @CRLF) Func _EncodeHash($sString) If (Not IsString($sString)) Or $sString = "" Then Return SetError(1, 0, 0) Local $aArray = StringRegExp($sString, "(?s).{1," & 2 & "}", 3), $sEncodedHash For $i = 0 To UBound($aArray) -1 If StringInStr("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-_~", Chr(Dec($aArray[$i]))) Then $sEncodedHash &= Chr(Dec($aArray[$i])) Else $sEncodedHash &= "%" & $aArray[$i] EndIf Next Return $sEncodedHash EndFunc ;%124Vx%9a%bc%de%f1%23Eg%89%ab%cd%ef%124Vx%9a ;%124Vx%9a%bc%de%f1%23Eg%89%ab%cd%ef%124Vx%9a Would you mind telling exactly how long I shall wait in the future before bumping, if it is even allowed. Edited June 10, 2012 by Decipher Spoiler
JohnOne Posted June 10, 2012 Posted June 10, 2012 24 hours more or less AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Moderators Melba23 Posted June 10, 2012 Moderators Posted June 10, 2012 Decipher, I am a "Sir", thank you! Like most public forums we prefer you not to bump your own thread within 24 hours. Remember this is not a 24/7 support forum - those who answer are only here because they like helping others and have some time to spare. You just have to wait until someone who knows something about your particular problem, and is willing to help, comes online. Be patient and someone will answer eventually. Or if not - tough! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Maffe811 Posted June 10, 2012 Posted June 10, 2012 I think you should wait atleast a day before bumping. Some people have a thing called "A life", you've probably heard of it, and therefore can't be online all the time. Post, wait, and if nothing, bump after 24 hours. [font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]
Decipher Posted June 10, 2012 Author Posted June 10, 2012 (edited) I think you should wait atleast a day before bumping.Some people have a thing called "A life", you've probably heard of it, and therefore can't be online all the time.Post, wait, and if nothing, bump after 24 hours.@Maffe811,Seriously, You have to bored out of your mind taking the time out of your precious life to say what has been said once than again by a mod.Sorry Melba32 I had to tell this poor guy. Edited June 10, 2012 by Decipher Spoiler
Maffe811 Posted June 11, 2012 Posted June 11, 2012 Well, not really, i was reading the topic and was quite entertained by your behaviour and i took my time even finding some snacks.So when i finally got arround to post a reply, some had beaten me to it.But from the post you made answearing JohnOne i was just waiting for you to step over the line and get thrown out.You should read the forum rules, they mention:Do not be obnoxious, rude or in general a nuisance to the smooth operation of the forum. [font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]
Recommended Posts