Code: Select all
package require http
namespace eval pchecker {
# proxycheck.io api key
variable pckey "xxxxxx-xxxxxx-xxxxxx-xxxxxxxx"
# min score to ban
variable score 10
# gzline message
variable gmsg "Sorry, VPN are not allowed"
# List of IP not checked
variable whitelist {"192.168.0.1" "10.0.0.*"}
# List of blacklisted IP
variable blacklist {}
# To enable on a chan, think to do
# .chanset #chan +scanip
setudef flag scanip
bind join - * ::pchecker::whois
bind raw - 378 ::pchecker::ipcheck
bind pub - !add ::pchecker::ipadd
bind pub - !rem ::pchecker::iprem
proc whois {nick uhost handle chan} {
if {![channel get $chan scanip]} { return }
if {[isbotnick $nick]} { return }
putquick "WHOIS $nick"
}
proc ipadd {nick uhost handle chan text} {
if {[lsearch $::rpchecker::whitelist $text] == -1} {
lappend ::rpchecker::whitelist $text
}
}
proc iprem {nick uhost handle chan text} {
set n [lsearch $::rpchecker::whitelist $text]
if {$n == -1} {
set ::rpchecker::whitelist [lreplace $::rpchecker::whitelist $n $n]
}
}
proc ipcheck {frm key text} {
set ip [lindex [split $text " "] end]
foreach w $::pchecker::whitelist {
if {[string match $w $text]} { return }
}
foreach b $::rpchecker::blacklist {
if {[string match $w $text]} {
putquick "GLINE *@$ip +7d :$::pchecker::gmsg"
return
}
}
::pchecker::isvpn $ip
}
proc json2dict {JSONtext} {
string range [string trim [string trimleft [string map {\t {} \n {} \r {} , { } : { } \[ \{ \] \}} $JSONtext] {\uFEFF}]] 1 end-1
}
proc isvpn {ip} {
::http::config -useragent "lynx"
set pcheck [::http::geturl http://api.isproxyip.com/v1/check.php?key=$::pchecker::pckey&ip=${ip}&format=json]
set data [json2dict [::http::data $pcheck]]
if {[dict get $data status] eq "success"} {
set proxy [dict get $data proxy]
if {$proxy == 1 } {
lappend $::pchecker::blacklist $ip
putquick "GLINE *@$ip +7d :$::pchecker::gmsg"
}
}
::http::cleanup $pcheck
}
}
Code: Select all
proc ipadd {nick uhost handle chan text} {
if {[lsearch $::rpchecker::whitelist $text] == -1} {
lappend ::rpchecker::whitelist $text
}
}
proc iprem {nick uhost handle chan text} {
set n [lsearch $::rpchecker::whitelist $text]
if {$n == -1} {
set ::rpchecker::whitelist [lreplace $::rpchecker::whitelist $n $n]
}
Code: Select all
proc ipadd {nick uhost handle chan text} {
if {[lsearch $::pchecker::whitelist $text] == -1} {
lappend ::pchecker::whitelist $text
}
}
proc iprem {nick uhost handle chan text} {
set n [lsearch $::pchecker::whitelist $text]
if {$n == -1} {
set ::pchecker::whitelist [lreplace $::pchecker::whitelist $n $n]
}
Code: Select all
proc ipadd {nick uhost handle chan text} {
if {[lsearch $::pchecker::whitelist $text] == -1} {
lappend ::pchecker::whitelist $text
}
}
proc iprem {nick uhost handle chan text} {
set n [lsearch $::pchecker::whitelist $text]
if {$n == -1} {
set ::pchecker::whitelist [lreplace $::pchecker::whitelist $n $n]
}
}
proc ipcheck {frm key text} {
set ip [lindex [split $text " "] end]
foreach w $::pchecker::whitelist {
if {[string match $w $text]} { return }
}
foreach b $::pchecker::blacklist {
if {[string match $w $text]} {
putquick "GLINE *@$ip +7d :$::pchecker::gmsg"
return
}
}
::pchecker::isvpn $ip
}
Code: Select all
package require http
namespace eval pchecker {
# proxycheck.io api key
variable pckey "xxxxxx-xxxxxx-xxxxxx-xxxxxxxx"
# gzline message
variable gmsg "Sorry, VPN are not allowed"
# List of IP not checked
variable whitelist {}
# List of blacklisted IP
variable blacklist {}
variable wlfile "scripts/pcheckerwl.txt"
# To enable on a chan, think to do
# .chanset #chan +scanip
setudef flag scanip
bind join - * ::pchecker::whois
bind raw - 378 ::pchecker::ipcheck
bind pub - !add ::pchecker::ipadd
bind pub - !rem ::pchecker::iprem
proc whois {nick uhost handle chan} {
if {![channel get $chan scanip]} { return }
if {[isbotnick $nick]} { return }
putquick "WHOIS $nick"
}
proc ipadd {nick uhost handle chan text} {
if {[lsearch $::pchecker::whitelist $text] == -1} {
lappend ::pchecker::whitelist $text
}
::pchecker::l2file $::pchecker::whitelist $::pchecker::pcheckerwl
}
proc iprem {nick uhost handle chan text} {
set n [lsearch $::pchecker::whitelist $text]
if {$n == -1} {
set ::pchecker::whitelist [lreplace $::pchecker::whitelist $n $n]
::pchecker::l2file $::pchecker::whitelist $::pchecker::pcheckerwl
}
}
proc ipcheck {frm key text} {
set ip [lindex [split $text " "] end]
foreach w $::pchecker::whitelist {
if {[string match $w $text]} { return }
}
foreach b $::pchecker::blacklist {
if {[string match $w $text]} {
putquick "GLINE *@$ip +7d :$::pchecker::gmsg"
return
}
}
::pchecker::isvpn $ip
}
proc json2dict {JSONtext} {
string range [string trim [string trimleft [string map {\t {} \n {} \r {} , { } : { } \[ \{ \] \}} $JSONtext] {\uFEFF}]] 1 end-1
}
proc isvpn {ip} {
::http::config -useragent "lynx"
set pcheck [::http::geturl http://api.isproxyip.com/v1/check.php?key=$::pchecker::pckey&ip=${ip}&format=json]
set data [json2dict [::http::data $pcheck]]
if {[dict get $data status] eq "success"} {
set proxy [dict get $data proxy]
if {$proxy == 1 } {
lappend $::pchecker::blacklist $ip
putquick "GLINE *@$ip +7d :$::pchecker::gmsg"
}
}
::http::cleanup $pcheck
}
proc l2file {olist dfile} {
set fo [open $dfile w]
puts $fo [join $olist "\n"]
close $fo
}
proc f2list {dfile} {
set fi [open $dfile r]
set olist [split [read -nonewline $fi] "\n"]
close $fi
return $olist
}
set ::pchecker::whitelist [::pchecker::f2list $::pchecker::pcheckerwl]
}
Code: Select all
if {$n == -1} {
Code: Select all
if {$n != -1} {