Page MenuHomeDevCentral

No OneTemporary

diff --git a/Nasqueron/MediaWiki.tcl b/Nasqueron/MediaWiki.tcl
index 8f32552..fc1d10d 100644
--- a/Nasqueron/MediaWiki.tcl
+++ b/Nasqueron/MediaWiki.tcl
@@ -1,40 +1,44 @@
#
# MediaWiki RC
#
#
# Configuration
#
+set MediaWikiRC(source) 127.0.0.1
set MediaWikiRC(port) 8675
set MediaWikiRC(channel) #wolfplex
set MediaWikiRC(color) 0
# This code implements "A simple UDP server"
# sample from http://tcludp.sourceforge.net/
package require udp
#Handles UDP event from $sock
proc mediawiki_rc_udp_event_handler {sock} {
global MediaWikiRC
set pkt [read $sock]
set peer [fconfigure $sock -peer]
- #TODO check if peer is 127.0.0.1 if there is somme flood
- #putdebug "$peer: [string length $pkt] {$pkt}"
- if $MediaWikiRC(color) {
- puthelp "PRIVMSG $MediaWikiRC(channel) :$pkt"
+ #Check if peer is source IP to avoid flood
+ if {[string range $peer 0 [string length $MediaWikiRC(source)]-1] == $MediaWikiRC(source)} {
+ if $MediaWikiRC(color) {
+ puthelp "PRIVMSG $MediaWikiRC(channel) :$pkt"
+ } {
+ puthelp "PRIVMSG $MediaWikiRC(channel) :[stripcodes abcgru $pkt]"
+ }
} {
- puthelp "PRIVMSG $MediaWikiRC(channel) :[stripcodes abcgru $pkt]"
+ putdebug "$peer: [string length $pkt] {$pkt}"
}
return
}
#Listens UDP on $port
proc mediawiki_rc_udp_listen {port} {
set srv [udp_open $port]
fconfigure $srv -buffering none -translation binary
fileevent $srv readable [list ::mediawiki_rc_udp_event_handler $srv]
#putdebug "Listening on udp port: [fconfigure $srv -myport]"
return $srv
}
mediawiki_rc_udp_listen $MediaWikiRC(port)

File Metadata

Mime Type
text/x-diff
Expires
Mon, Nov 25, 07:24 (1 d, 14 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2259716
Default Alt Text
(1 KB)

Event Timeline