View previous topic :: View next topic |
Author |
Message |
PeLL Voice
Joined: 04 Mar 2011 Posts: 14 Location: spain
|
Posted: Fri Apr 29, 2022 2:40 pm Post subject: |
|
|
Honestly, it turned out very well.
Again I want to ask if it is possible to generate a file to add ips to exception.
example : !add IP
that can add ips to exception from the same channel.
Thank you very much and I hope it is possible. |
|
Back to top |
|
 |
CrazyCat Revered One

Joined: 13 Jan 2002 Posts: 1108 Location: France
|
Posted: Fri Apr 29, 2022 3:58 pm Post subject: |
|
|
If you want to add complete IP and not range (or mask), it's quite simple.
Confirm that point and I'll make the addition to the script. _________________ https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community. |
|
Back to top |
|
 |
PeLL Voice
Joined: 04 Mar 2011 Posts: 14 Location: spain
|
Posted: Fri Apr 29, 2022 4:07 pm Post subject: |
|
|
Currently if I add any IP, eg: 80.20.10.*
other ips yes 80.10.20.30
I currently use both ways.
If it is difficult for you, let's put only the entire IP.
Thank you very much for answering |
|
Back to top |
|
 |
CrazyCat Revered One

Joined: 13 Jan 2002 Posts: 1108 Location: France
|
Posted: Sat Apr 30, 2022 7:49 am Post subject: |
|
|
Here is a small modification of the script:
Code: | 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
}
} |
Note that ips (whitelist and blacklist) are stored only in eggdrop memory, but you can easily add a save to file (or DB) _________________ https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community. |
|
Back to top |
|
 |
PeLL Voice
Joined: 04 Mar 2011 Posts: 14 Location: spain
|
Posted: Sat Apr 30, 2022 9:36 am Post subject: |
|
|
again I thank you.
It works but I had to edit a detail.
you:
Code: | 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]
} |
i edit :
Code: | 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]
} |
thist "r" the rpcheker no works ,remove the "r" if works .
it is true that it is better to create a .txt or .db to better see the ips added to review what happened in the future.
Right now I can't see the added ips but it works.
can you add to add ips in a .txt (for example) and see the ips when added?
again I tell you that thank you very much for the work. |
|
Back to top |
|
 |
CrazyCat Revered One

Joined: 13 Jan 2002 Posts: 1108 Location: France
|
Posted: Sat Apr 30, 2022 9:49 am Post subject: |
|
|
I don't know why I added the "r".
You have other occurences, replace all rpchecker with pchecker :
Code: | 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
} |
_________________ https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community. |
|
Back to top |
|
 |
CrazyCat Revered One

Joined: 13 Jan 2002 Posts: 1108 Location: France
|
Posted: Sat Apr 30, 2022 10:42 am Post subject: |
|
|
Not tested (the write/read file come from another of my scripts):
Code: | 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]
} |
_________________ https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community. |
|
Back to top |
|
 |
PeLL Voice
Joined: 04 Mar 2011 Posts: 14 Location: spain
|
Posted: Sat Apr 30, 2022 4:07 pm Post subject: |
|
|
Ok, I have modified the wlfile variable
It gave an error and I put: pcheckerwl
Quote: | variable wlfile "scripts/pcheckerwl.txt"
|
modify:
Quote: | variable pcheckerwl "scripts/pcheckerwl.txt" |
right now I add ip and it works.
But delete doesn't work.
thank you very much again for your time. |
|
Back to top |
|
 |
CrazyCat Revered One

Joined: 13 Jan 2002 Posts: 1108 Location: France
|
|
Back to top |
|
 |
PeLL Voice
Joined: 04 Mar 2011 Posts: 14 Location: spain
|
Posted: Sun May 01, 2022 1:56 pm Post subject: |
|
|
I just tried everything again, and now everything works perfectly.
the bot is a bit laggy but that's another topic
thank you very much really . |
|
Back to top |
|
 |
TimeRider Voice

Joined: 07 Jul 2020 Posts: 27
|
Posted: Mon Dec 19, 2022 9:51 am Post subject: |
|
|
Thanks, CrazyCat for the more detailed script.
However, I was curious to know if the script could be made not to ban a specific geo-location or country. The reason for this is due to false positives with the scanner.
Actually, If you could make the TCL exclude the scan from the geolocation from Nepal as there is no VPN connection in this country? Also, I would like to exclude Nepal from scans for my chat room.
So, is it possible to do it?
Thank you! _________________ Online chat
Nepal chat
Pakistan chat
Indian chat |
|
Back to top |
|
 |
CrazyCat Revered One

Joined: 13 Jan 2002 Posts: 1108 Location: France
|
|
Back to top |
|
 |
TimeRider Voice

Joined: 07 Jul 2020 Posts: 27
|
|
Back to top |
|
 |
CrazyCat Revered One

Joined: 13 Jan 2002 Posts: 1108 Location: France
|
|
Back to top |
|
 |
TimeRider Voice

Joined: 07 Jul 2020 Posts: 27
|
|
Back to top |
|
 |
|