Couby Posted February 27, 2007 Posted February 27, 2007 I'd like to build a fonction which would check specific port forwarding. This is to automate a check before launching a specific game, to ensure port forwarding which is necessary is correct. At the moment I have no idea on how to code that. If someone has any idea...
Developers Jos Posted February 27, 2007 Developers Posted February 27, 2007 I'd like to build a fonction which would check specific port forwarding.This is to automate a check before launching a specific game, to ensure port forwarding which is necessary is correct.At the moment I have no idea on how to code that. If someone has any idea...Port forwarding ? On A PC or a Router ? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
daslick Posted February 27, 2007 Posted February 27, 2007 You need to get the external ip of the computer... You could have your script download whatismyip.com and check the source for your ip... (there may be a built in function for the same purpose). After you get your external ip ping and try to open a tpc/udp connection to that port.
Shevilie Posted February 27, 2007 Posted February 27, 2007 I know that utorrent have the ability to check if a port is forwardet (You can get other utils that can do the same) Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit
Couby Posted February 27, 2007 Author Posted February 27, 2007 You need to get the external ip of the computer... You could have your script download whatismyip.com and check the source for your ip... (there may be a built in function for the same purpose).That's done, I got it with autoit udf . After you get your external ip ping and try to open a tpc/udp connection to that port.How do you do that ?
Couby Posted February 27, 2007 Author Posted February 27, 2007 Port forwarding ? On A PC or a Router ?Made by a router or a PC, the interest of the check is just to know if it is effectiv on the computer checked, just to warn the user if there is a problem. Then if it is not wroking it is the user responsability to do the necessary on his PC or router to get it working.I just want to check the port .
Shevilie Posted February 27, 2007 Posted February 27, 2007 http://www.voipuser.org/port_forward_tester.html Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit
Couby Posted February 28, 2007 Author Posted February 28, 2007 No way to code it directly with AutoIt ?
jvanegmond Posted February 28, 2007 Posted February 28, 2007 (edited) Sure there is! Lmao, my pet monkey can code this #include <INet.au3> If $CmdLine[0] = 2 Then TCPStartup() TCPConnect($CmdLine[1],$CmdLine[2]) Exit EndIf MsgBox(0, "Manadar #1", "1 indicates open and 0 indicates closed: " & CheckPortForwarding(3725)) Func CheckPortForwarding($sPort) $WAN = _GetIP() TCPStartup() $MainSocket = TCPListen(@IPAddress1,$sPort) Run(@AutoItExe & " " & @ScriptName & " " & $WAN & " " & $sPort) $Timeout = TimerInit() While TimerDiff($Timeout) < 3000 $Socket = TCPAccept($MainSocket) If $Socket <> -1 Then Return 1 WEnd Return 0 EndFunc Multithreading is necessary. Edited February 28, 2007 by Manadar github.com/jvanegmond
jvanegmond Posted February 28, 2007 Posted February 28, 2007 (edited) I made a little application with this, it's good stuff. CODEexpandcollapse popup#NoTrayIcon #include <INet.au3> #include <GUIConstants.au3> If $CmdLine[0] = 2 Then TCPStartup() TCPConnect($CmdLine[1],$CmdLine[2]) Exit EndIf #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("WAN Port Forwarding Check", 232, 142, 193, 115) $Input1 = GUICtrlCreateInput("", 5, 5, 223, 21, BitOR($ES_RIGHT,$ES_AUTOHSCROLL,$ES_NUMBER)) $Label1 = GUICtrlCreateLabel("Enter a port to check for..", 5, 30, 223, 107, -1, $WS_EX_CLIENTEDGE) GUICtrlSetFont(-1,10,400,0,"Verdana") GUICtrlSetBkColor(-1, 0xFFFFFF) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Input1 GUICtrlSetState($Input1,$GUI_DISABLE) $Port = GUICtrlRead($Input1) If $Port < 0 OR $Port > 65536 Then GUICtrlSetData($Label1,"Enter a port in the range 0-65536.") GUICtrlSetState($Input1,$GUI_ENABLE) Else $IP = _GetIP() If @error Then GUICtrlSetData($Label1,"Error: Could not get your ip.." & @CRLF & @CRLF & "Make sure you are connected to the internet!") Else GUICtrlSetData($Label1,"Checking port: " & $Port & "...") If CheckPortForwarding($Port,$IP) Then GUICtrlSetData($Label1,GUICtrlRead($Label1) & @CRLF & @CRLF & "NAT OK.") Else GUICtrlSetData($Label1,GUICtrlRead($Label1) & @CRLF & @CRLF & "Could not connect!" & @CRLF & "You have a NAT problem.") EndIf GUICtrlSetState($Input1,$GUI_ENABLE) EndIf EndIf EndSwitch WEnd Func CheckPortForwarding($sPort,$WAN) TCPStartup() $MainSocket = TCPListen(@IPAddress1,$sPort) $sPID = Run(@AutoItExe & " """ & @ScriptName & """ " & $WAN & " " & $sPort) $Timeout = TimerInit() While TimerDiff($Timeout) < 3000 $Socket = TCPAccept($MainSocket) If $Socket <> -1 Then Return 1 WEnd ProcessClose($sPID) Return 0 EndFunc Edited February 28, 2007 by Manadar github.com/jvanegmond
nitekram Posted February 28, 2007 Posted February 28, 2007 I made a little application with this, it's good stuff. CODEexpandcollapse popup#NoTrayIcon #include <INet.au3> #include <GUIConstants.au3> If $CmdLine[0] = 2 Then TCPStartup() TCPConnect($CmdLine[1],$CmdLine[2]) Exit EndIf #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("WAN Port Forwarding Check", 232, 142, 193, 115) $Input1 = GUICtrlCreateInput("", 5, 5, 223, 21, BitOR($ES_RIGHT,$ES_AUTOHSCROLL,$ES_NUMBER)) $Label1 = GUICtrlCreateLabel("Enter a port to check for..", 5, 30, 223, 107, -1, $WS_EX_CLIENTEDGE) GUICtrlSetFont(-1,10,400,0,"Verdana") GUICtrlSetBkColor(-1, 0xFFFFFF) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Input1 GUICtrlSetState($Input1,$GUI_DISABLE) $Port = GUICtrlRead($Input1) If $Port < 0 OR $Port > 65536 Then GUICtrlSetData($Label1,"Enter a port in the range 0-65536.") GUICtrlSetState($Input1,$GUI_ENABLE) Else $IP = _GetIP() If @error Then GUICtrlSetData($Label1,"Error: Could not get your ip.." & @CRLF & @CRLF & "Make sure you are connected to the internet!") Else GUICtrlSetData($Label1,"Checking port: " & $Port & "...") If CheckPortForwarding($Port,$IP) Then GUICtrlSetData($Label1,GUICtrlRead($Label1) & @CRLF & @CRLF & "NAT OK.") Else GUICtrlSetData($Label1,GUICtrlRead($Label1) & @CRLF & @CRLF & "Could not connect!" & @CRLF & "You have a NAT problem.") EndIf GUICtrlSetState($Input1,$GUI_ENABLE) EndIf EndIf EndSwitch WEnd Func CheckPortForwarding($sPort,$WAN) TCPStartup() $MainSocket = TCPListen(@IPAddress1,$sPort) $sPID = Run(@AutoItExe & " """ & @ScriptName & """ " & $WAN & " " & $sPort) $Timeout = TimerInit() While TimerDiff($Timeout) < 3000 $Socket = TCPAccept($MainSocket) If $Socket <> -1 Then Return 1 WEnd ProcessClose($sPID) Return 0 EndFunc I cannot wait to try this. 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator
Couby Posted February 28, 2007 Author Posted February 28, 2007 That's exactly what I needed ! Thank you very much :"> .
jvanegmond Posted March 1, 2007 Posted March 1, 2007 That's exactly what I needed ! Thank you very much :"> .Sure, Couby. It was time someone showed you how to do this.. github.com/jvanegmond
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now