Sign in to follow this  
Followers 0
VioFX

Issue, program GUI freezing and stops responding during WhoIs search

3 posts in this topic

#1 ·  Posted (edited)

Alright so I've been using this source code:

WhoIsSearch.au3:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=D:\wmi\icons\network.ico
#AutoIt3Wrapper_outfile=c_whois.exe
#AutoIt3Wrapper_Compression=4
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUIConstants.au3>
#include "_WhoIs.au3"
#include <GUIConstantsEx.au3>
#include <GuiButton.au3>
#include <WindowsConstants.au3>
#include <GuiEdit.au3>

resource()

#region ### START Koda GUI section ###
Global $Form1 = GUICreate("WhoIs", 404, 445, -1, -1)
Global $Label1 = GUICtrlCreateLabel("Domain:", 5, 7, 43, 17)
Global $txtDomain = GUICtrlCreateInput("", 48, 4, 273, 21)
Global $btnSearch = GUICtrlCreateButton("Search", 332, 4, 65, 25, $BS_DEFPUSHBUTTON)
Global $btnExit = GUICtrlCreateButton("Exit", 332, 48, 65, 25)
Global $txtResults = GUICtrlCreateEdit("", 4, 80, 393, 357, BitOR($ES_AUTOVSCROLL, $WS_VSCROLL, $ES_MULTILINE, $ES_WANTRETURN))
GUICtrlSetData(-1, "")
GUICtrlSetFont(-1, 8, 400, 0, "Courier")
Global $Label2 = GUICtrlCreateLabel("Query Time:", 5, 32, 312, 17)
Global $Label3 = GUICtrlCreateLabel("Queried Domain", 4, 56, 152, 17)
Global $Label4 = GUICtrlCreateLabel("Domain Created on", 164, 56, 156, 17)
#endregion ### END Koda GUI section ###

;~ $Form1 = GUICreate("WhoIs", 434, 480, -1, -1)
;~ $Label1 = GUICtrlCreateLabel("Domain:", 5, 11, 43, 17)
;~ $txtDomain = GUICtrlCreateInput("", 8, 32, 345, 21)
;~ $Label2 = GUICtrlCreateLabel("Query Time: ", 5, 60, 400, 17)
;~ $txtResults = GUICtrlCreateEdit("", 8, 88, 417, 353, BitOR($ES_AUTOVSCROLL, $WS_VSCROLL, $ES_MULTILINE, $ES_WANTRETURN))
;~ GUICtrlSetData(-1, "")
;~ GUICtrlSetFont(-1, 8, 400, 0, "Courier")
;~ $btnExit = GUICtrlCreateButton("&Exit", 352, 448, 73, 25, 0)
;~ $btnSearch = GUICtrlCreateButton("&Search", 360, 32, 65, 25, $BS_DEFPUSHBUTTON)
GUISetState(@SW_SHOW)


_setOriginalGUI()

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $btnExit
            Exit
        Case $btnSearch
            _setBusyGUI()
            $begin = TimerInit()
            $retWhoIS = _WhoIs(GUICtrlRead($txtDomain))
            GUICtrlSetData($Label2, "Query Time: " & TimerDiff($begin) / 1000 & ' secs')
            $res_ar = StringRegExp($retWhoIS, '[\d]{4}-[\d]{2}-[\d]{2}', 3)
            If IsArray($res_ar) Then _ArrayDisplay($res_ar)
            $res_ar = StringRegExp($retWhoIS, '[\d]{2}-[\d]{2}-[\d]{4}', 3)
            If IsArray($res_ar) Then _ArrayDisplay($res_ar)

            $res_ar = StringRegExp($retWhoIS, '[\d]{4}-[\D]{3}-[\d]{2}', 3)
            If IsArray($res_ar) Then _ArrayDisplay($res_ar)
            $res_ar = StringRegExp($retWhoIS, '[\d]{2}-[\D]{3}-[\d]{4}', 3)
            If IsArray($res_ar) Then _ArrayDisplay($res_ar)


            $res_ar = StringRegExp($retWhoIS, '[\d]{4}/[\d]{2}/[\d]{2}', 3)
            If IsArray($res_ar) Then _ArrayDisplay($res_ar)
            $res_ar = StringRegExp($retWhoIS, '[\d]{2}/[\d]{2}/[\d]{4}', 3)
            If IsArray($res_ar) Then _ArrayDisplay($res_ar)

            $res_ar = StringRegExp($retWhoIS, '[\d]{4}\.[\d]{2}\.[\d]{2}', 3)
            If IsArray($res_ar) Then _ArrayDisplay($res_ar)
            $res_ar = StringRegExp($retWhoIS, '[\d]{2}\.[\d]{2}\.[\d]{4}', 3)
            If IsArray($res_ar) Then _ArrayDisplay($res_ar)
            GUICtrlSetData($txtResults, $retWhoIS)
            GUICtrlSetState($txtResults, $GUI_ENABLE)
            GUICtrlSetState($btnExit, $GUI_ENABLE)
    EndSwitch

    If GUICtrlRead($txtDomain) <> "" And GUICtrlGetState($btnSearch) = 144 Then
        GUICtrlSetState($btnSearch, $GUI_ENABLE)
    EndIf
WEnd

Func _setOriginalGUI()
    GUICtrlSetState($btnSearch, $GUI_DISABLE)
    GUICtrlSetState($txtResults, $GUI_DISABLE)
    GUICtrlSetState($txtDomain, $GUI_FOCUS)
EndFunc   ;==>_setOriginalGUI

Func _setBusyGUI()
    GUICtrlSetState($btnSearch, $GUI_DISABLE)
    GUICtrlSetState($txtResults, $GUI_DISABLE)
    GUICtrlSetState($btnExit, $GUI_DISABLE)
EndFunc   ;==>_setBusyGUI


Func resource()

    _Crypt_Startup()
    $hash = _Crypt_HashFile('sTLD.ini', $CALG_MD5)
    If StringCompare($hash, IniRead('hash.ini', 'md5', 'sTLD.ini', 0)) <> 0 Then
        SplashTextOn('', 'Creating sTLD Database', 200, 50)
        RunWait(@ComSpec & ' /c wget http://mxr.mozilla.org/mozilla-central/source/netwerk/dns/effective_tld_names.dat?raw=1 -O sTLD.txt', @ScriptDir, @SW_HIDE)
        $hash = _Crypt_HashFile('sTLD.txt', $CALG_MD5)
        If StringCompare($hash, IniRead('hash.ini', 'md5', 'sTLD.txt', 0)) <> 0 Or StringCompare($hash, IniRead('hash.ini', 'md5', 'sTLD.ini', 0)) <> 0 Then ;FileExists('sTLD.ini') == 0  Then
            FileDelete('stld.ini')
            IniWrite('hash.ini', 'md5', 'sTLD.txt', $hash)
            $f_count = _FileCountLines('sTLD.txt')
            $file = FileOpen('sTLD.txt', 16384)
            $line_count = 1
            While $line_count <= $f_count
                $line = StringStripWS(FileReadLine($file, $line_count), 8)
                $str = StringLeft($line, 1)
                Select
                    Case $str = '/'
                    Case $str = '*'
                        $str_arr = StringSplit(StringTrimLeft($line, 1), '.', 1)
                        IniWrite('stld.ini', $str_arr[$str_arr[0]], StringTrimLeft($line, 2), '*')
                    Case $str = '!'
                        $str_arr = StringSplit(StringTrimLeft($line, 1), '.', 1)
                        IniWrite('stld.ini', $str_arr[$str_arr[0]], StringTrimLeft($line, 2), '!')
                    Case Else
                        $str_arr = StringSplit($line, '.', 1)
                        If $str_arr[$str_arr[0]] <> '' Then
                            IniWrite('stld.ini', $str_arr[$str_arr[0]], $line, '0')
                        EndIf
                EndSelect
                $line_count += 1
            WEnd
            FileClose($file)
        EndIf
;~      IniWrite('sTLD.ini', 'in', 'nic.in', '!')

;~      RunWait(@ComSpec & ' /c wget http://dnsbl.invaluement.com/domainroots.txt -O domainroots.txt', @ScriptDir, @SW_HIDE)
;~      $hash = _Crypt_HashFile('domainroots.txt', $CALG_MD5)
;~      If StringCompare($hash, IniRead('hash.ini', 'md5', 'domainroots.txt', 0)) <> 0 Then
;~          IniWrite('hash.ini', 'md5', 'domainroots.txt', $hash)
;~          $f_count = _FileCountLines('domainroots.txt')
;~          $file = FileOpen('domainroots.txt', 16384)
;~          $line_count = 1
;~          While $line_count <= $f_count
;~              $line = StringStripWS(FileReadLine($file, $line_count), 8)
;~              $str_arr = StringSplit($line, '.', 1)
;~              If $str_arr[$str_arr[0]] <> 'com' Then
;~                  If IniRead('stld.ini', $str_arr[$str_arr[0]], $line, '') == '' Then
;~                      IniWrite('stld.ini', $str_arr[$str_arr[0]], $line, '!')
;~                  EndIf
;~              EndIf
;~              $line_count += 1
;~          WEnd
;~          FileClose($file)
;~      EndIf
        $hash = _Crypt_HashFile('sTLD.ini', $CALG_MD5)
        IniWrite('hash.ini', 'md5', 'sTLD.ini', $hash)
        _Crypt_Shutdown()
        FileDelete('sTLD.txt')
;~      FileDelete('domainroots.txt')
        SplashOff()
    EndIf

EndFunc   ;==>resource


;~ http://dnsbl.invaluement.com/domainroots.txt

_WhoIs.au3:

;-- WHOIS -----------------------------------------------------------------------------------------
;
;-- Autor: Eusebio Pérez Hurtado
;-- Fecha: 03-11-2006
;
;--------------------------------------------------------------------------------------------------
#include-once
#include <Array.au3>
#include <Crypt.au3>
#include <file.au3>

Func _WhoIs($cDomain_req)
    Local $cTLD = ""
    Local $cServerDomain = ""
    Local $cServerIp = ""
    Local $cRedirectTo = ""
    Local $nPort
    Local $cParameters = ""
    Local $result = ""
    Local $nn
    TCPStartup()
    $cDomain_req = StringLower($cDomain_req)
    $cDomain_req = StringReplace($cDomain_req, "http:", "")
    $cDomain_req = StringReplace($cDomain_req, "/", "")
    $cDomain_req = StringReplace($cDomain_req, "www.", "")
    $ret_val = _getTLD($cDomain_req)
    $ret_val = StringSplit($ret_val, '|-|', 1)
;~  _ArrayDisplay($ret_val)
    $cTLD = $ret_val[3]
    $cDomain = $ret_val[2]
    $act_domain = $ret_val[1]
    $sec_arr = IniReadSectionNames("WhoIs.INI")
    $ar_ret = _ArraySearch($sec_arr, $cTLD)
    If $ar_ret == -1 Then
        $cTLD = _getTLDDet($cTLD)
    EndIf
    If $cTLD == '' Then
        $result = "Domain Registrar's whois server not found " & $cTLD
        TCPShutdown()
        Return ($result)
    EndIf
    $cServerDomain = IniRead("WhoIs.INI", $cTLD, "ServerDomain", "")
    $cServerIp = IniRead("WhoIs.INI", $cTLD, "ServerIp", "")
    $cRedirectTo = IniRead("WhoIs.INI", $cTLD, "RedirectTo", "")
    $nPort = IniRead("WhoIs.INI", $cTLD, "Port", "43")
    $cParameters = IniRead("WhoIs.INI", $cTLD, "Parameters", "")

    If $cServerDomain = "" Then
        $result = "server not defined in WhoIS.ini"
        Return $result
    Else
        If $cServerIp = "" Then
            $cServerIp = TCPNameToIP($cServerDomain)
            IniWrite("WhoIs.INI", $cTLD, "ServerIp", $cServerIp)
        EndIf
        If $cServerIp = "" Then
            $result = "error retrieving whois server IP"
            Return $result
        Else
            $result = _ConectaServerWhoIs($cServerIp, $nPort, $cDomain, $cParameters, 1)
        EndIf
    EndIf
    If $cRedirectTo <> "" Then
        $nn = StringInStr($result, $cRedirectTo)
        If $nn > 0 Then
            $cServerDomain = StringMid($result, $nn + StringLen($cRedirectTo))
            $cServerDomain = StringMid($cServerDomain, 1, StringInStr($cServerDomain, @CRLF) - 1)
            $cServerDomain = StringStripWS($cServerDomain, 1)
            $cServerDomain = StringStripWS($cServerDomain, 2)
            $cServerIp = IniRead("WhoIs.INI", "Redirect", $cServerDomain, "")
            If $cServerIp = "" Then
                $cServerIp = TCPNameToIP($cServerDomain)
                IniWrite("WhoIs.INI", "Redirect", $cServerDomain, $cServerIp)
            EndIf
            $result = _ConectaServerWhoIs($cServerIp, $nPort, $cDomain, $cParameters, 2)
        EndIf
    EndIf

    $result = _StripUnwanted($result, $cDomain)
;~ MsgBox(0,'',$result)
    If StringInStr($result, ':', 0, 2) == 0 Then
        $compare = StringCompare($cDomain_req, $cDomain)
        If $compare > 0 Then ; $cDomain_req can never be smaller than $cDomain as $cDomain is a derived entity
            $result = _ConectaServerWhoIs($cServerIp, $nPort, $cDomain_req, $cParameters, 2)
            $result = _StripUnwanted($result, $cDomain)
            If StringInStr($result, ':', 0, 1) <> 0 Then
                _Crypt_Startup()
                $dom_arr = StringSplit($cDomain, '.')
                IniWrite('sTLD.ini', $dom_arr[$dom_arr[0]], $cDomain, '*')
                $hash = _Crypt_HashFile('sTLD.ini', $CALG_MD5)
                IniWrite('hash.ini', 'md5', 'sTLD.ini', $hash)
                _Crypt_Shutdown()
            Else
                Return 'Domain Registrant not found'
            EndIf
        ElseIf $compare == 0 And StringInStr($act_domain, '.', 0, 1) <> 0 Then ;StringInStr($cDomain_req, '.', 0, 1) <> 0
            If StringInStr($result, 'found') > 0 Or StringInStr($result, 'match') > 0 Then
                If StringInStr($cDomain, 'found', 2) == 0 And StringInStr($cDomain, 'match', 2) == 0 Then
                    If StringInStr($act_domain, '.', 2) <> 0 Then
                        $dom_arr = StringReplace($cDomain, $act_domain, '')
                        $dom_arr = StringSplit($dom_arr, '.')
                        If $dom_arr[0] > 1 Then
                            $cDomain = $dom_arr[$dom_arr[0]] & $act_domain
                            $result = _WhoIs($cDomain)
                            _Crypt_Startup()
                            $dom_arr = StringSplit($cDomain, '.')
                            IniWrite('sTLD.ini', $dom_arr[$dom_arr[0]], $cDomain, '!')
                            $hash = _Crypt_HashFile('sTLD.ini', $CALG_MD5)
                            IniWrite('hash.ini', 'md5', 'sTLD.ini', $hash)
                            _Crypt_Shutdown()
                        EndIf

                    EndIf
                    Return $result
                EndIf
            Else
                Return $result
            EndIf
        Else
            Return 'Domain does not exist'
        EndIf
    Else
        If StringInStr($result, 'found') > 0 Or StringInStr($result, 'match') > 0 Then
            If StringInStr($cDomain, 'found', 2) == 0 And StringInStr($cDomain, 'match', 2) == 0 Then
                If StringInStr($act_domain, '.', 2) <> 0 Then
                    $dom_arr = StringReplace($cDomain, '.' & $act_domain, '')
                    MsgBox(0, '', $dom_arr & @CRLF & $act_domain)
                    $dom_arr = StringSplit($dom_arr, '.')
                    If $dom_arr[0] > 1 Then
                        $cDomain = $dom_arr[$dom_arr[0]] & $act_domain
                    Else
                        $cDomain = $act_domain
                    EndIf
                    MsgBox(0, '2', $result)
                    $result = _WhoIs($cDomain)
                    _Crypt_Startup()
                    $dom_arr = StringSplit($cDomain, '.')
                    IniWrite('sTLD.ini', $dom_arr[$dom_arr[0]], $cDomain, '!')
                    $hash = _Crypt_HashFile('sTLD.ini', $CALG_MD5)
                    IniWrite('hash.ini', 'md5', 'sTLD.ini', $hash)
                    _Crypt_Shutdown()
                EndIf
                Return $result
            EndIf
        Else
            Return $result
        EndIf
    EndIf
    TCPShutdown()
    Return ($result)
EndFunc   ;==>_WhoIs

Func _ConectaServerWhoIs($cServerIp, $nPort, $cDomain, $cParameters, $type)
    Local $socket
    Local $recv
    Local $result = ""
    While 1
        $socket = TCPConnect($cServerIp, $nPort)
        If $socket <> -1 Then
            ExitLoop
        EndIf
        Sleep(10)
    WEnd
    If $type == 2 Then $cParameters = ''
    If $cParameters <> "" Then
        TCPSend($socket, $cParameters & " " & $cDomain & @CRLF)
    Else
        TCPSend($socket, $cDomain & @CRLF)
    EndIf
    While 1
        $recv = TCPRecv($socket, 2048)
        If @error Then ExitLoop
        If $recv <> "" Then
            $result = $result & $recv
        EndIf
        Sleep(10)
    WEnd
    $result = StringReplace($result, @LF, @CRLF)
    Return ($result)
EndFunc   ;==>_ConectaServerWhoIs

Func _getTLD($cDomain)
    Local $nn
    Local $TLD = '', $sTLD = '', $tTLD = '', $ret = ''
    $dom_arr = StringSplit($cDomain, '.')
    $TLD = IniRead('sTLD.ini', $dom_arr[$dom_arr[0]], $dom_arr[$dom_arr[0]], '')
    If $TLD == '' Then
        $ret = ''
    ElseIf $TLD == '0' Then
        $ret = $dom_arr[$dom_arr[0] - 1] & '.' & $dom_arr[$dom_arr[0]]
        $cDomain = $ret
    ElseIf $TLD == '*' Then
        $ret = $dom_arr[$dom_arr[0] - 1] & '.' & $dom_arr[$dom_arr[0]]
        $cDomain = $ret
    EndIf
    $sTLD = IniRead('sTLD.ini', $dom_arr[$dom_arr[0]], $dom_arr[$dom_arr[0] - 1] & '.' & $dom_arr[$dom_arr[0]], '')
    If $sTLD == '0' Then
        If $dom_arr[0] > 2 Then
            $ret = $dom_arr[$dom_arr[0] - 2] & '.' & $dom_arr[$dom_arr[0] - 1] & '.' & $dom_arr[$dom_arr[0]]
            $cDomain = $dom_arr[$dom_arr[0] - 1] & '.' & $dom_arr[$dom_arr[0]]
        ElseIf $dom_arr < 3 Then
            $ret = $dom_arr[$dom_arr[0] - 1] & '.' & $dom_arr[$dom_arr[0]]
            $cDomain = $dom_arr[$dom_arr[0] - 1] & '.' & $dom_arr[$dom_arr[0]]
        EndIf
    ElseIf $sTLD == '*' Then
        If $dom_arr[0] > 2 Then
            $ret = $dom_arr[$dom_arr[0] - 2] & '.' & $dom_arr[$dom_arr[0] - 1] & '.' & $dom_arr[$dom_arr[0]]
            $cDomain = $dom_arr[$dom_arr[0] - 1] & '.' & $dom_arr[$dom_arr[0]]
        ElseIf $dom_arr < 3 Then
            $ret = $dom_arr[$dom_arr[0] - 1] & '.' & $dom_arr[$dom_arr[0]]
            $cDomain = $dom_arr[$dom_arr[0]]
        EndIf
    ElseIf $sTLD == '!' Then
        $ret = $dom_arr[$dom_arr[0] - 1] & '.' & $dom_arr[$dom_arr[0]]
        $cDomain = $dom_arr[$dom_arr[0]]
        Return $cDomain & '|-|' & $ret & '|-|' & $dom_arr[$dom_arr[0]]
    ElseIf $sTLD == '' Then
        $ret = $dom_arr[$dom_arr[0] - 1] & '.' & $dom_arr[$dom_arr[0]]
        $cDomain = $dom_arr[$dom_arr[0]]
        Return $cDomain & '|-|' & $ret & '|-|' & $dom_arr[$dom_arr[0]]
    EndIf
    If $dom_arr[0] > 2 Then
        $tTLD = IniRead('sTLD.ini', $dom_arr[$dom_arr[0]], $dom_arr[$dom_arr[0] - 2] & '.' & $dom_arr[$dom_arr[0] - 1] & '.' & $dom_arr[$dom_arr[0]], '')
        If $tTLD <> '' Then
            $ret = $dom_arr[$dom_arr[0] - 2] & '.' & $dom_arr[$dom_arr[0] - 1] & '.' & $dom_arr[$dom_arr[0]]
            $cDomain = $dom_arr[$dom_arr[0] - 1] & '.' & $dom_arr[$dom_arr[0]]
        EndIf
    EndIf

    Return $cDomain & '|-|' & $ret & '|-|' & $dom_arr[$dom_arr[0]]
EndFunc   ;==>_getTLD

Func _getTLDDet($cTLD)
    If FileExists('WhoIs.ini') == 0 Then
        MsgBox(0, 'Error', 'WhoIs.ini not found. Cannot proceed.')
        $cTLD = ''
        Return $cTLD
    EndIf
    $cServerIp = IniRead('WhoIs.INI', 'tld', 'ServerIp', '')
    $cRedirectTo = IniRead("WhoIs.INI", 'tld', "RedirectTo", "")
    $cParameters = ''
    $type = 3
    $nPort = 43
    $result = _ConectaServerWhoIs($cServerIp, $nPort, $cTLD, $cParameters, $type)
    If $cRedirectTo <> "" Then
        $nn = StringInStr($result, $cRedirectTo)
        If $nn > 0 Then
            $cServerDomain = StringMid($result, $nn + StringLen($cRedirectTo))
            $cServerDomain = StringMid($cServerDomain, 1, StringInStr($cServerDomain, @CRLF) - 1)
            $cServerDomain = StringStripWS($cServerDomain, 1)
            $cServerDomain = StringStripWS($cServerDomain, 2)
            $cServerIp = TCPNameToIP($cServerDomain)
            IniWrite("WhoIs.ini", $cTLD, 'ServerDomain', $cServerDomain)
            IniWrite("WhoIs.INI", $cTLD, 'ServerIp', $cServerIp)
            IniWrite("WhoIs.INI", $cTLD, 'Port', 43)
        Else
            $cTLD = ''
        EndIf
    EndIf
    Return $cTLD
EndFunc   ;==>_getTLDDet

Func _StripUnwanted($result, $cDomain)
    Local $string
    $string = StringMid($result, 1, StringInStr($result, $cDomain, 2) - 1 - 20)
    If StringLen($string) > 1 Then
        If StringCompare($result, $string) <> 0 Then $result = StringReplace($result, $string, '')
    EndIf
    $string = StringMid($result, StringInStr($result, 'notice', 2))
    If StringLen($string) > 1 Then
        $result = StringReplace($result, $string, '')
    EndIf

    $result = StringReplace($result, 'http://', '')
;~  $res_ar = StringRegExp($result, '[\d]{2}:[\d]{2}:[\d]{2}', 3)
    $result = StringRegExpReplace($result, '[\d]{2}:[\d]{2}:[\d]{2}', '')
    If StringInStr($result, '%', 2) > 0 Then
        $ar_ret = StringSplit($result, @CRLF)
        $i = 1
        While $i <= $ar_ret[0]
            If StringLeft($ar_ret[$i], 1) == '%' Then $ar_ret[$i] = ''
            $i += 1
        WEnd
        $result = _ArrayToString($ar_ret, @CRLF)
        $result = StringStripCR($result)
        $result = StringStripWS($result, 7)
        $result = StringReplace($result, @LF, @CRLF)
    EndIf
    Return $result
EndFunc   ;==>_StripUnwanted

;-- END WHOIS -------------------------------------------------------------------------------------

WhoIs.ini:

[tld]
ServerDomain=whois.iana.org
ServerIp=192.0.47.59
RedirectTo=whois:
Port=43
[com]
ServerDomain=whois.crsnic.net
ServerIp= 199.7.57.74
RedirectTo=Whois Server:
Port=43
Parameters=domain
[Redirect]
whois.entorno.es=195.77.116.122
whois.opensrs.net=216.40.33.170
whois.corenic.net=151.11.83.123
whois.godaddy.com=68.178.211.43
whois.enom.com=72.5.232.19
whois.nameking.com=204.13.162.8
whois.networksolutions.com=205.178.188.12
whois.libris.com=66.45.254.250
whois.dreamhost.com=66.33.201.141
whois.nicline.com=217.76.128.229
whois.interdomain.net=213.4.108.70
whois.nominalia.com=213.229.188.165
whois.belgiumdomains.com=64.94.51.73
whois.domaindoorman.com=64.94.51.80
whois.markmonitor.com=64.124.14.21
whois.hostingservicesinc.net=67.15.47.4
whois.melbourneit.com=203.27.227.114
whois.schlund.info=195.20.224.146
whois.namesdirect.com=64.85.73.17
whois.tucows.com=64.99.62.11
whois.moniker.com=208.73.208.99
whois.iana.org=192.0.32.59
whois.domainca.com=211.106.65.103
whois.psi-usa.info=62.116.162.100
whois.discount-domain.com=210.172.133.120
[in]
ServerDomain=whois.inregistry.net
ServerIp=203.119.49.72
Port=43
Parameters=domain
[hk]
ServerDomain=whois.hkirc.hk
ServerIp=203.119.2.19
Port=43
[sa]
ServerDomain=whois.nic.net.sa
ServerIp=86.111.196.99
Port=43
[ru]
ServerDomain=whois.tcinet.ru
ServerIp=212.193.111.1
Port=43
[gov]
ServerDomain=whois.dotgov.gov
ServerIp=199.7.48.77
Port=43
[pro]
ServerDomain=whois.registrypro.pro
ServerIp=192.149.62.16
Port=43
[asia]
ServerDomain=whois.nic.asia
ServerIp=149.17.192.112
Port=43
[tr]
ServerDomain=whois.nic.tr
ServerIp=144.122.95.15
Port=43
[uk]
ServerDomain=whois.nic.uk
ServerIp=213.248.201.163
Port=43
[jp]
ServerDomain=whois.jprs.jp
ServerIp=202.11.16.169
Port=43
[aero]
ServerDomain=whois.aero
ServerIp=69.46.107.47
Port=43
[au]
ServerDomain=whois.audns.net.au
ServerIp=202.65.12.25
Port=43
[us]
ServerDomain=whois.nic.us
ServerIp=209.173.57.13
Port=43
[org]
ServerDomain=whois.pir.org
ServerIp=149.17.192.7
Port=43
[mobi]
ServerDomain=whois.dotmobiregistry.net
ServerIp=69.46.107.31
Port=43
[biz]
ServerDomain=whois.biz
ServerIp=209.173.53.169
Port=43
[co]
ServerDomain=whois.nic.co
ServerIp=156.154.17.94
Port=43
[pt]
ServerDomain=whois.dns.pt
ServerIp=193.137.196.34
Port=43
[br]
ServerDomain=whois.registro.br
ServerIp=200.160.2.3
Port=43
[be]
ServerDomain=whois.dns.be
ServerIp=195.22.138.105
Port=43
[de]
ServerDomain=whois.denic.de
ServerIp=81.91.170.6
Port=43
[net]
ServerDomain=whois.verisign-grs.com
ServerIp=199.7.57.74
Port=43
RedirectTo=Whois Server:
[it]
ServerDomain=whois.nic.it
ServerIp=192.12.192.242
Port=43
[info]
ServerDomain=whois.afilias.net
ServerIp=149.17.192.13
Port=43
[fr]
ServerDomain=whois.nic.fr
ServerIp=192.134.4.25
Port=43

However I've found a problem, I'm not sure exactly where it is. But when I search for certain domains, the whole program freezes, I think it's because it can't find the registrar's whois server, however I'm not exactly sure or how to fix it if that's the problem.

Example: Compile and run the program, search for www.google.com, comes up fine. Now search for www.alamedacity.com. As you can see, the program will freeze. Not exactly sure why, hopefully can get a fix on this as I've already PM'ed both of the people in the other topic.

EDIT:

I thought the issue could be that the whois server wasn't included in the WhoIs.ini, so I searched for what that servers specific one is and couldn't find it inside the .ini, so I think I added it correctly and still am getting the issue.

Wherever the issue is, would there be any way to just forget that search query if this problem arises

EDIT #2:

I found the problem! It seems to pause for a long time when it reaches a whois.xxxxx.com that's not defined in my WhoIs.ini or has the IP incorrect. Seems it just keeps trying until it works, which if it can never connect it'll never work. So any idea how to add a timeout in the code if it takes too long?

Credits:

Edited by VioFX

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I don't know (I'm not going to spend the time trying at the moment) but I suspect that the function _ConectaServerWhoIs is where your script hangs. There is also an error in the function in my opinion.

I think a change something like this might fix it.

Func _ConectaServerWhoIs($cServerIp, $nPort, $cDomain, $cParameters, $type)
    Local $socket
    Local $recv
    Local $result = ""
    Local $twait
    Local $MaxTimeConnect, $MaxTimeRecv;these could be parameters

    $MaxTimeConnect = 10;10 seconds before giving up trying to connect
    $MaxTimeRecv = 10;10 sec max time to wait without getting any data

    $twait = TimerInit();start timer
    While 1
        $socket = TCPConnect($cServerIp, $nPort)
        If not @error Then ExitLoop
           
        If TimerDiff($twait) > $MaxTimeConnect * 1000 Then Return SetError(-1, 0, '')
        Sleep(200);10 is too short I think
    WEnd

    If $type == 2 Then $cParameters = ''

    If $cParameters <> "" Then
        TCPSend($socket, $cParameters & " " & $cDomain & @CRLF)
    Else
        TCPSend($socket, $cDomain & @CRLF)
    EndIf

    $twait = TimerInit();restart timer
    While 1
        $recv = TCPRecv($socket, 2048)
        If  @error Then ExitLoop
        If $recv <> "" Then
            $twait = TimerInit();restart timer
            $result = $result & $recv
        EndIf
        If TimerDiff($twait) > $MaxTimeRecv * 1000 Then Return SetError(-2, 0, '')
        Sleep(200)
    WEnd

    $result = StringReplace($result, @LF, @CRLF)
    Return ($result)
EndFunc   ;==>_ConectaServerWhoIs

This might not help with your problem though, in which case you need to add some debuging code so you can see when a function is called and when it returns so you can see which function is taking forever. Then in that fubction add some code to note the time on entry, and add some condition to the function so that it the time afetr entry is more than some amount then return, preferably with some meaningful value and set @error so the calling code can see what's wrong.

Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Wow that was perfect, totally fixed my problem. I was able to integrate it into my script very nicely, thanks a lot!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0