alias sockopen {
var %address = $+($gettok($1-,-2,32),$chr(58),$gettok($1-,-1,32)), %action = $readini(firewall.ini,firewall,%address)
var %permitmessage = echo 3 -s %address making contact with the internet!, %blockmessage = echo 4 -s %address blocked!
%action = $iif(%action,%action,0)
goto %action
;Action 0: Ask to open
:0 | var %a = $?!="Allow %address to be opened?", %b = $?!="Always use this action for %address ?"
if (%b) writeini firewall.ini firewall %address $iif(%a,1,2)
if (%a) { %permitmessage | !sockopen $1- } | else %blockmessage
return
;Action 1: Permit
:1 | %permitmessage | !sockopen $1- | return
;Action 2: Block
:2 | %blockmessage | halt
}
/*
This script can be upgraded in many many ways (it can still be avoided). Well heres already a small upgrade. It isnt really necessarry but what it does is when you load a script file it does an easy search for sockopen commands and if it finds 1 asks if you want to load the file anyway:
*/
alias load {
if ($1 = -rs) && ($isfile($2)) {
if ($read($2, wn, *sockopen*)) {
var %popupmsg = This script *possibly* contains a sockopen command on line $+($readn,: $read($2,n,$readn),$crlf,This $&
means the script has the ability to open an internet connection. Load script $2 anyway?)
if (!$?!=" $+ %popupmsg $+ ") { echo -s 4Script $2 was not loaded! | halt }
}
}
!load $1-
}