Skip to content

Commit 44fea4f

Browse files
committed
_Tor_CheckVersion can work without the git hash now
1 parent 07fa1ed commit 44fea4f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Tor.au3

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,18 @@ Global $g__sTorPath = "" ; Path to Tor.exe
5555
; Author ........: Damon Harris (TheDcoder)
5656
; Remarks .......: $TOR_VERSION Format : x.x.x.x (git-a1b2c3d4e5f6g7h8)
5757
; Example: 0.2.9.10 (git-1f6c8eda0073f464)
58+
; The git hash may not be present at all times.
5859
; Example .......: No
5960
; ===============================================================================================================================
6061
Func _Tor_CheckVersion($sTorPath = $g__sTorPath)
6162
Local $sOutput = _Process_RunCommand($PROCESS_RUNWAIT, $sTorPath & ' --version')
6263
If @error Then Return SetError($TOR_ERROR_PROCESS, @error, False)
63-
Local $aTorVersion = StringRegExp($sOutput, '([0-9]*\.[0-9]*\.[0-9]*\.[0-9]*) \(git-([a-z0-9]{16})\)', $STR_REGEXPARRAYFULLMATCH)
64+
Local $aTorVersion[3]
65+
Local $aRegEx = StringRegExp($sOutput, '(\d*\.\d*\.\d*\.\d*)(?: \(git-([a-z0-9]{16})\))?', $STR_REGEXPARRAYFULLMATCH)
6466
If @error Then Return SetError($TOR_ERROR_VERSION, @error, False)
67+
$aTorVersion[$TOR_VERSION] = $aRegEx[0]
68+
$aTorVersion[$TOR_VERSION_NUMBER] = $aRegEx[1]
69+
If UBound($aRegEx) = 3 Then $aTorVersion[$TOR_VERSION_GIT] = $aRegEx[2]
6570
Return $aTorVersion
6671
EndFunc
6772

0 commit comments

Comments
 (0)