tclserv

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit cdc4e3d2a84e603753e3c54d45a5e2a91c43a437
parent ad9e313a654e9b02b36a3a5fdc03fe0340a27f9b
Author: Ellenor Malik <ellenor@umbrellix.net>
Date:   Fri, 22 Jun 2018 23:42:02 +0000

ugh problems

Diffstat:
Mcore/0000-conn.tcl | 4++++
Mcore/2003-ts6.tcl | 14++++++++------
Mlanguage.txt | 8++++++++
Mmain.tcl | 2++
Mmodules/debugserv.tcl | 46+++++++++++++++++++++++++++++++++++++++++-----
5 files changed, 63 insertions(+), 11 deletions(-)

diff --git a/core/0000-conn.tcl b/core/0000-conn.tcl @@ -11,6 +11,10 @@ proc connect {addr port script} { proc mknetwork {a} { set headlines [lrange $a 0 end-1] set block [lindex $a end] + if {[catch {set ::sock($servername)} result] == 0} { + puts stdout "probably rehashing (duplicate network block, [tnda get rehashing], $result)" + return + } if {[llength $headlines]<2} { puts stdout "fuck it, block's invalid ($headlines)" return diff --git a/core/2003-ts6.tcl b/core/2003-ts6.tcl @@ -253,7 +253,7 @@ proc ::ts6::irc-main {sck} { global sid sock socksid if {[eof $sck]} {close $sck} gets $sck line - #putcmdlog $line + puts stdout $line set line [string trim $line "\r\n"] set one [string match ":*" $line] set line [string trimleft $line ":"] @@ -399,8 +399,8 @@ proc ::ts6::irc-main {sck} { } "MODE" { - if {[lindex $comd 3] == [tnda get "nick/$::netname($sck)/[lindex $comd 0]"]} { - foreach {c} [split [lindex $comd 4] {}] { + if {[lindex $comd 2] == [tnda get "nick/$::netname($sck)/[lindex $comd 0]"] || [lindex $comd 2] == [lindex $comd 0]} { + foreach {c} [split [lindex $comd 3] {}] { switch -- $c { "+" {set state 1} "-" {set state 0} @@ -506,8 +506,10 @@ proc ::ts6::irc-main {sck} { set oper 0 set loggedin [lindex $comd 11] set realhost [lindex $comd 10] - set modes [lindex $comd 4] - if {[string match "*o*" $modes]} {set oper 1} + set modes [lindex $comd 5] + puts stdout $comd + puts stdout $modes + if {[string first "o" $modes] != -1} {set oper 1} if {"*"!=$loggedin} { tnda set "login/$::netname($sck)/[lindex $comd $num]" $loggedin } @@ -523,7 +525,7 @@ proc ::ts6::irc-main {sck} { tnda set "ipaddr/$::netname($sck)/[lindex $comd $num]" [lindex $comd 8] tnda set "ts/$::netname($sck)/[lindex $comd $num]" [lindex $comd 4] tnda set "rname/$::netname($sck)/[lindex $comd $num]" $payload - putloglev j * [format "New user at %s %s %s!%s@%s (IP address %s, vhost %s) :%s" $::netname($sck) [lindex $comd $num] [lindex $comd 2] [lindex $comd 6] [tnda get "rhost/$::netname($sck)/[lindex $comd $num]"] [lindex $comd 8] [tnda get "vhost/$::netname($sck)/[lindex $comd $num]"] $payload] + #putloglev j * [format "New user at %s %s %s!%s@%s (IP address %s, vhost %s) :%s" $::netname($sck) [lindex $comd $num] [lindex $comd 2] [lindex $comd 6] [tnda get "rhost/$::netname($sck)/[lindex $comd $num]"] [lindex $comd 8] [tnda get "vhost/$::netname($sck)/[lindex $comd $num]"] $payload] callbind $sck conn "-" "-" [lindex $comd $num] } diff --git a/language.txt b/language.txt @@ -1,2 +1,10 @@ debugserv.metadata 14/2/12/ Metadata %s for %s: %s +debugserv.nometadata 14/7/8/ %s, you do not have any metadata set by the ircd. continuant 14/2/12/ %s +debugserv.rehashed 14/3/9/ As you so politely demand, %s. +debugserv.isoper 14/3/9/ %s (UID %s) is an oper on this network. +debugserv.isntoper 14/5/4/ %s (UID %s) is 4NOT an oper on this network. +debugserv.youreoper 14/3/9/ YOU (UID %s) are an oper on this network. +debugserv.yourentoper 14/5/4/ YOU (UID %s) are 4NOT an oper on this network. +debugserv.youvenoprivs 14/5/4/ YOU (UID %s) do 4NOT have the required privileges to execute the commanded action. +debugserv.youvenoprivs2 14/5/4/ YOU (UID %s) do 4NOT have the required privileges to execute the commanded action. (Requires %s) diff --git a/main.tcl b/main.tcl @@ -99,6 +99,7 @@ foreach {file} [lsort [glob ./core/*.tcl]] { proc svc.rehash {} { global gettext + tnda set rehashing 1 if {[file exists $::globwd/language.txt]} { set languagefile [split [readfile [format "%s/%s" $::globwd language.txt]] "\n"] foreach {line} $languagefile { @@ -109,6 +110,7 @@ proc svc.rehash {} { } tnda set "openconf" [list] mysrc $::globwd/services.conf + tnda set rehashing 0 } svc.rehash diff --git a/modules/debugserv.tcl b/modules/debugserv.tcl @@ -12,22 +12,53 @@ proc debugserv.connect {arg} { proc debugserv.oneintro {headline block} { set net [lindex $headline 0] set nsock $::sock($net) - dictassign $block logchan logchan nick nick ident ident host host modes modes realname realname + dictassign $block logchan logchan nick nick ident ident host host modes modes realname realname rehashprivs rehashprivs + tnda set "debugserv/$net/rehashprivs" $rehashprivs setctx $net $::nettype($net) sendUid $nsock $nick $ident $host $host [set ourid [$::nettype($net) getfreeuid $net]] [expr {($realname == "") ? "* Debug Service *" : $realname}] $modes tnda set "debugserv/$net/ourid" $ourid bind $nsock pub - ".metadata" [list debugserv.pmetadata $net] +# bind $nsock pub - ".rehash" [list debugserv.crehash $net] $::nettype($net) putjoin $nsock $ourid $logchan after 500 [list $::nettype($net) putmode $nsock $ourid $logchan "+ao" [format "%s %s" [$::nettype($net) intclient2uid $net $ourid] [$::nettype($net) intclient2uid $net $ourid]]] bind $nsock msg [tnda get "debugserv/$net/ourid"] "metadata" [list debugserv.metadata $net] - bind $nsock pub - "gettext" [list debugserv.gettext $net] +# bind $nsock msg [tnda get "debugserv/$net/ourid"] "rehash" [list debugserv.rehash $net] +# bind $nsock pub - "gettext" [list debugserv.gettext $net] puts stdout "bind $nsock msg [tnda get "debugserv/$net/ourid"] metadata [list debugserv.metdata $net]" puts stdout [format "Connected for %s: %s %s %s" $net $nick $ident $host] } -proc debugserv.gettext {n c i m} { - setctx $n - catch {$::nettype($n) privmsg [curctx sock] [tnda get "debugserv/$n/ourid"] $c [gettext {*}[split $m " "]]} +proc debugserv.rehash {n i m} {debugserv.crehash $n $i $i $m} + +proc operHasPrivilege {n i p} { + # this bit requires irca. + set metadatum [tnda get "metadata/$n/$i/[ndcenc PRIVS]"] + set md [split $metadatum " "] + set pl [split $p " ,"] + foreach {pv} $pl { + if {[lsearch $md $pv] != -1} {return 1} + } + return 0 +} + +proc operHasAllPrivileges {n i p} { + # this bit requires irca. + set metadatum [tnda get "metadata/$n/$i/[ndcenc PRIVS]"] + set md [split $metadatum " "] + set pl [split $p " ,"] + foreach {pv} $pl { + if {[lsearch $md $pv] == -1} {return 0} + } + return 1 +} + +proc debugserv.crehash {n c i m} { + if {![operHasPrivilege $n $i [tnda get "debugserv/$n/rehashprivs"]]} { + $::nettype($n) [expr {$c != $i ? "privmsg" : "notice"}] [curctx sock] [tnda get "debugserv/$n/ourid"] $c [gettext debugserv.youvenoprivs2 $i [join [split [tnda get "debugserv/$n/rehashprivs"] ", "] ", or "]] + } { + after 500 [list uplevel #0 [list svc.rehash]] + $::nettype($n) [expr {$c != $i ? "privmsg" : "notice"}] [curctx sock] [tnda get "debugserv/$n/ourid"] $c [gettext debugserv.rehashed [$::nettype($n) uid2nick $n $i]] + } } proc debugserv.pmetadata {n c i m} { @@ -36,11 +67,16 @@ proc debugserv.pmetadata {n c i m} { catch [set command { setctx $n set metadatalist [tnda get "metadata/$n/$i"] + if {[llength $metadatalist] < 2} { + $::nettype($n) [expr {$c != $i ? "privmsg" : "notice"}] [curctx sock] [tnda get "debugserv/$n/ourid"] $c [gettext debugserv.nometadata [$::nettype($n) uid2nick $n $i]] + } # puts stdout $metadatalist foreach {.datum value} $metadatalist { set datum [ndcdec ${.datum}] $::nettype($n) [expr {$c != $i ? "privmsg" : "notice"}] [curctx sock] [tnda get "debugserv/$n/ourid"] $c [set totmsg [gettext debugserv.metadata $datum [$::nettype($n) uid2nick $n $i] $value]] } }] zere + puts stdout [tnda get "oper/$n"] + $::nettype($n) [expr {$c != $i ? "privmsg" : "notice"}] [curctx sock] [tnda get "debugserv/$n/ourid"] $c [gettext [expr {[tnda get "oper/$n/$i"] == 1 ? "debugserv.isoper" : "debugserv.isntoper"}] [$::nettype($n) uid2nick $n $i] $i] # puts stdout [curctx sock] # puts stdout $command # puts stdout $zere