Phaethon Posted June 20, 2009 Share Posted June 20, 2009 Hello everyone! I am wanting to use AutoIt to make a simple program to manipulate my internet connection. However, I have not used AutoIt in some time and don't really know to start with this, nor do I know if it is even possible to do in this language.Here are the parameters for my project.Grab all current incoming IP addresses on a user button clickDeny all connections except those from the aforementioned IP addresses and some predefined IP ranges for a specified period of timeIf anyone could give me some guidance on how to go about this, it would be very appreciated. Coder's Helper >> Here[center][/center] Link to comment Share on other sites More sharing options...
Phaethon Posted June 20, 2009 Author Share Posted June 20, 2009 (edited) The port that all if this relates to is 3074 by the way. UDP. Edited June 20, 2009 by Phaethon Coder's Helper >> Here[center][/center] Link to comment Share on other sites More sharing options...
Phaethon Posted June 21, 2009 Author Share Posted June 21, 2009 I don't mean to spam, but I am still rather stuck on this. Starting to think it isn't even possible in AutoIt... Coder's Helper >> Here[center][/center] Link to comment Share on other sites More sharing options...
Drakthor Posted June 21, 2009 Share Posted June 21, 2009 Hello everyone! I am wanting to use AutoIt to make a simple program to manipulate my internet connection. However, I have not used AutoIt in some time and don't really know to start with this, nor do I know if it is even possible to do in this language. Here are the parameters for my project. Grab all current incoming IP addresses on a user button clickDeny all connections except those from the aforementioned IP addresses and some predefined IP ranges for a specified period of time If anyone could give me some guidance on how to go about this, it would be very appreciated.http://www.autoitscript.com/autoit3/docs/f...ons/TCPRecv.htm Func SocketToIP($SHOCKET) Local $sockaddr, $aRet $sockaddr = DllStructCreate("short;ushort;uint;char[8]") $aRet = DllCall("Ws2_32.dll", "int", "getpeername", "int", $SHOCKET, _ "ptr", DllStructGetPtr($sockaddr), "int*", DllStructGetSize($sockaddr)) If Not @error And $aRet[0] = 0 Then $aRet = DllCall("Ws2_32.dll", "str", "inet_ntoa", "int", DllStructGetData($sockaddr, 3)) If Not @error Then $aRet = $aRet[0] Else $aRet = 0 EndIf $sockaddr = 0 Return $aRet EndFunc ;==>SocketToIP Then just do something along the lines if If NOT $ip Then etc. I hope I understood you right. Link to comment Share on other sites More sharing options...
Phaethon Posted June 21, 2009 Author Share Posted June 21, 2009 Yes, I looked into this function in the documentation already. However, I am having trouble getting it to return anything besides 0. Coder's Helper >> Here[center][/center] Link to comment Share on other sites More sharing options...
Drakthor Posted June 21, 2009 Share Posted June 21, 2009 Yes, I looked into this function in the documentation already. However, I am having trouble getting it to return anything besides 0.expandcollapse popupGlobal $ip;Ip to listen on Global $ip2;Ip you expect to connect Global $port;port to listen on Global $sock[2] Global $sockip;Returned IP of the socket TCPStartup() $sock[0] = TCPListen($ip,$port) Do $sock[1] = TCPAccept($sock[0]) Until $sock[1] <> -1 While 1 $sockip = SockettoIP($sock[1]) If $sockip <> $ip2 Then TCPCloseSocket($sock[1]) EndIf Wend Func SocketToIP($SHOCKET) Local $sockaddr, $aRet $sockaddr = DllStructCreate("short;ushort;uint;char[8]") $aRet = DllCall("Ws2_32.dll", "int", "getpeername", "int", $SHOCKET, _ "ptr", DllStructGetPtr($sockaddr), "int*", DllStructGetSize($sockaddr)) If Not @error And $aRet[0] = 0 Then $aRet = DllCall("Ws2_32.dll", "str", "inet_ntoa", "int", DllStructGetData($sockaddr, 3)) If Not @error Then $aRet = $aRet[0] Else $aRet = 0 EndIf $sockaddr = 0 Return $aRet EndFunc ;==>SocketToIP This might work, I'm not at my computer so I cannot test. Link to comment Share on other sites More sharing options...
Phaethon Posted June 21, 2009 Author Share Posted June 21, 2009 expandcollapse popupGlobal $ip;Ip to listen on Global $ip2;Ip you expect to connect Global $port;port to listen on Global $sock[2] Global $sockip;Returned IP of the socket TCPStartup() $sock[0] = TCPListen($ip,$port) Do $sock[1] = TCPAccept($sock[0]) Until $sock[1] <> -1 While 1 $sockip = SockettoIP($sock[1]) If $sockip <> $ip2 Then TCPCloseSocket($sock[1]) EndIf Wend Func SocketToIP($SHOCKET) Local $sockaddr, $aRet $sockaddr = DllStructCreate("short;ushort;uint;char[8]") $aRet = DllCall("Ws2_32.dll", "int", "getpeername", "int", $SHOCKET, _ "ptr", DllStructGetPtr($sockaddr), "int*", DllStructGetSize($sockaddr)) If Not @error And $aRet[0] = 0 Then $aRet = DllCall("Ws2_32.dll", "str", "inet_ntoa", "int", DllStructGetData($sockaddr, 3)) If Not @error Then $aRet = $aRet[0] Else $aRet = 0 EndIf $sockaddr = 0 Return $aRet EndFunc;==>SocketToIP This might work, I'm not at my computer so I cannot test. I'm testing this now, however won't this only return 1 IP address? I am expecting to get multiple, and then store them so that I can check against them later. I want to know all of the IP addresses currently connected (on port 3074), store all of those (probably 4 of them) and then deny all other incoming connections for 10 seconds (BESIDES those 4 IP addresses and 3 other IP ranges) and after that, allow all connections again. I'm sorry if this is confusing lol. Coder's Helper >> Here[center][/center] Link to comment Share on other sites More sharing options...
Phaethon Posted June 24, 2009 Author Share Posted June 24, 2009 Just got back to my computer. Still not able to get this to work in any capacity.... Coder's Helper >> Here[center][/center] Link to comment Share on other sites More sharing options...
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