Page MenuHomeDevCentral

D672.id1691.diff
No OneTemporary

D672.id1691.diff

diff --git a/Core.tcl b/Core.tcl
--- a/Core.tcl
+++ b/Core.tcl
@@ -1,12 +1,36 @@
+package require http
+package require tls
+
#
# HTTP support
#
-package require http
-package require tls
::tls::init -ssl2 false -ssl3 false -tls1 true
::http::register https 443 ::tls::socket
+# Determines if a specified page's source code contains the specified string
+proc http_contains {pattern url} {
+ try {
+ set fd [::http::geturl $url -timeout 600]
+ } on error {result} {
+ return 0
+ }
+
+ if {[::http::status $fd] != "ok"} {
+ set result 0
+ } elseif {[::http::ncode $fd] != 200} {
+ set result 0
+ } elseif {[string first $pattern [::http::data $fd]] > -1} {
+ set result 1
+ } {
+ set result 0
+ }
+
+ ::http::cleanup $fd
+ return $result
+}
+
+
#
# TCL helpers
#
@@ -665,3 +689,33 @@
proc isip {string} {
expr [isipv4 $string] || [isipv6 $string]
}
+
+###
+### IP helper procedures
+###
+
+# Extracts an IP address from a Freenode cloak
+# Freenode tends to add IPs as suffix for gateway cloaks.
+proc extract_addr_from_cloak {host} {
+ if {[string first gateway/web/cgi-irc/kiwiirc.com/ip. $host] == 0} {
+ return [string range $host 35 end]
+ }
+
+ # Finds an IPv4
+ # Regexp from http://www.jamesoff.net/site/projects/eggdrop-scripts/proxycheck
+ if {[regexp {[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$} $host ip]} {
+ return $ip
+ }
+
+ return ""
+}
+
+# Extracts an IP or hostname from an IRC host
+# If the host is a cloak not parseable, returns "".
+proc extract_addr {host} {
+ if {[string first / $host] > -1} {
+ return [extract_addr_from_cloak $host]
+ }
+
+ return $host
+}
diff --git a/Daeghrefn/Channel.tcl b/Daeghrefn/Channel.tcl
--- a/Daeghrefn/Channel.tcl
+++ b/Daeghrefn/Channel.tcl
@@ -1,6 +1,7 @@
# #wolfplex
bind pubm - "#wolfplex *" pubm:url
bind pubm - "#fauve *" pubm:url
+bind join - "#wikipedia-fr *!*@*" join:vandalism
bind sign - "#wikipedia-fr *!*@*" sign:excessflood
#
@@ -88,3 +89,25 @@
sql "INSERT INTO log_flood (host, `count`) VALUES ('[sqlescape $host]', 1) ON DUPLICATE KEY UPDATE `count` = `count` + 1;"
}
}
+
+#
+# Check HTTP site to detect pattern
+#
+
+# Checks on join if the user can't be identified through an HTTP check
+proc join:vandalism {nick uhost handle channel} {
+ global botname
+
+ if {[matchattr $handle fov|fov $channel]} {
+ return
+ }
+
+ set addr [extract_addr $uhost]
+ if {$addr == ""} {
+ return
+ }
+
+ if {[http_contains [registry get protection.http.pattern] http://$addr/]} {
+ newchanban $channel *!*@*$addr $botname [registry get protection.http.banreason] [registry get protection.http.banduration] sticky
+ }
+}

File Metadata

Mime Type
text/plain
Expires
Tue, Nov 26, 12:30 (13 h, 12 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2264607
Default Alt Text
D672.id1691.diff (2 KB)

Event Timeline