I have this script, that make the bot to add gline to all vpns if is !on and show all vpns connection if is !off.
But something doesn`t work properly. The bot show me all connections in that channel, doesn`t matter are they vpn or not.
I need a help to fix it.
Code: Select all
package require http
package require json
namespace eval pchecker {
# proxycheck.io api key
variable pckey "xxxxx xxxxx xxxxx xxxxx"
# min score to ban
variable score 10
# gzline message
variable gmsg "VPN is not allowed at the moment!"
# List of IP not checked
# they are regexp style
variable whitelist {"192.168.0.1" "10.0.0.*"}
# List of blacklisted IP
# regexp too :)
variable blacklist {}
# Control channel
set cchan #vpn
# internal variable : status of VPN search
set onoff 0
bind raw - NOTICE ::pchecker::ipcheck
bind pub - "!on" ::pchecker::on
bind pub - "!off" ::pchecker::off
proc on {nick uhost handle chan text} {
if {$chan ne $::pchecker::cchan} { return }
if {$::pchecker::onoff == 1} {
putserv "PRIVMSG $::pchecker::cchan :\00303VPN HUNTER is tutn ON"
return
}
set ::pchecker::onoff 1
}
proc off {nick uhost handle chan text} {
if {$chan ne $::pchecker::cchan} { return }
if {$::pchecker::onoff == 0} {
putserv "PRIVMSG $::pchecker::cchan :\00304VPN HUNTER is turn OFF\003"
return
}
set ::pchecker::onoff 0
}
proc ipcheck {frm key text} {
if {[string match *!*@* $frm] || ![string match -nocase "*client connecting*" $text]} { return }
regexp {:\s.*?:\s(.*?)!(.*?)@(.*?)\s\((.*?)\)} $text - unick ident host ip
putserv "PRIVMSG $::pchecker::cchan :\00304VPN Detected\003 : \00303$unick\003 \00307is connecting with ip\003 $ip"
if {[lsearch -regexp $::pchecker::whitelist $ip] ne -1} { return }
if {[lsearch -regexp $::pchecker::blacklist $ip] ne -1} {
putquick "GLINE *@$ip 7d :$::pchecker::gmsg"
return
}
if {$::pchecker::onoff == 1 } { ::pchecker::isvpn $ip }
}
proc isvpn {ip} {
::http::config -useragent "lynx"
set pcheck [::http::geturl http://proxycheck.io/v2/${ip}?key=$::pchecker::pckey&vpn=1&risk=1]
set data [::json::json2dict [::http::data $pcheck]]
if {[dict get $data status] == "ok"} {
set proxy [dict get [dict get $data $ip] proxy]
set risk [dict get [dict get $data $ip] risk]
if {[expr $risk - $::pchecker::score] >= 0 } {
lappend $::pchecker::blacklist [string map {. \.} $ip]
putquick "GLINE *@$ip 7d :$::pchecker::gmsg"
}
}
::http::cleanup $pcheck
}
}