Overview
Comment: | A few changes to tclircd more usable |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
f0e00464c66a28e1dac0ed6e83cb6e98 |
User & Date: | rkeene on 2016-09-13 20:35:19 |
Other Links: | manifest | tags |
Context
2016-09-15
| ||
03:13 | Added additional NICK syntax support check-in: 658b5cfcc1 user: rkeene tags: trunk | |
2016-09-13
| ||
20:35 | A few changes to tclircd more usable check-in: f0e00464c6 user: rkeene tags: trunk | |
20:34 | Added tclircd-0.1a.tar.gz (sha1: adbd16a5d187f6e1b3c4c0c663920d6151061626) check-in: 84ca00fb7b user: rkeene tags: trunk | |
Changes
Modified ircd.tcl from [2540825ff6] to [1144d83de8].
︙ | ︙ | |||
152 153 154 155 156 157 158 159 160 161 162 163 164 165 | -> channel topic]} \ { handleClientTopic $fd $channel $topic } elseif {[regexp -nocase {^LIST *(.*)$} $line -> channel]} { handleClientList $fd $channel } elseif {[regexp -nocase {^WHOIS +(.+)$} $line -> nick]} { handleClientWhois $fd $nick } elseif {[regexp -nocase {^WHO +([^ ]+) *(.*)$} $line -> channel _]} { handleClientWho $fd $channel } elseif {[regexp -nocase {^MODE +([^ ]+) *(.*)$} $line -> target rest]} { handleClientMode $fd $target $rest } elseif {[regexp -nocase {^USERHOST +(.+)$} $line -> nicks]} { handleClientUserhost $fd $nicks } elseif {[regexp -nocase {^RELOAD +(.+)$} $line -> password]} { | > > | 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | -> channel topic]} \ { handleClientTopic $fd $channel $topic } elseif {[regexp -nocase {^LIST *(.*)$} $line -> channel]} { handleClientList $fd $channel } elseif {[regexp -nocase {^WHOIS +(.+)$} $line -> nick]} { handleClientWhois $fd $nick } elseif {[regexp -nocase {^WHO *$} $line ->]} { handleClientWho $fd "" } elseif {[regexp -nocase {^WHO +([^ ]+) *(.*)$} $line -> channel _]} { handleClientWho $fd $channel } elseif {[regexp -nocase {^MODE +([^ ]+) *(.*)$} $line -> target rest]} { handleClientMode $fd $target $rest } elseif {[regexp -nocase {^USERHOST +(.+)$} $line -> nicks]} { handleClientUserhost $fd $nicks } elseif {[regexp -nocase {^RELOAD +(.+)$} $line -> password]} { |
︙ | ︙ | |||
279 280 281 282 283 284 285 | set channels [clientChannels $fd] foreach channel $channels { userMessage $channel $fd $msg } } proc allChannels {} { | | > > > > > > > > | 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 | set channels [clientChannels $fd] foreach channel $channels { userMessage $channel $fd $msg } } proc allChannels {} { set retval [array names ::channelInfo] # Remove this hidden channel from the list set removeIdx [lsearch -exact $retval "#[config reloadpasswd]"] if {$removeIdx != -1} { set retval [lreplace $retval $removeIdx $removeIdx] } return $retval } # Note that this does not scale well if there are many # channels. For now data structures are designed to make # the code little. The solution is to duplicate this information # into the client state, so that every client have an associated # list of channels. |
︙ | ︙ | |||
418 419 420 421 422 423 424 | serverClientMsg $fd 319 "$nick :[join $chans]" } serverClientMsg $fd 312 "$nick [config hostname] :[config hostname]" serverClientMsg $fd 318 "$nick :End of /WHOIS list." } proc handleClientWho {fd channel} { | > > > > > | | | > | 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 | serverClientMsg $fd 319 "$nick :[join $chans]" } serverClientMsg $fd 312 "$nick [config hostname] :[config hostname]" serverClientMsg $fd 318 "$nick :End of /WHOIS list." } proc handleClientWho {fd channel} { if {$channel eq ""} { foreach {nick userfd} [array get ::nickToFd] { serverClientMsg $fd 352 "## ~[clientUser $userfd] [clientHost $userfd] [config hostname] [clientNick $userfd] H :0 [clientRealName $userfd]" } } else { foreach {topic userlist usermode} [channelInfoOrReturn $fd $channel] break foreach userfd $userlist mode $usermode { serverClientMsg $fd 352 "$channel ~[clientUser $userfd] [clientHost $userfd] [config hostname] $mode[clientNick $userfd] H :0 [clientRealName $userfd]" } } serverClientMsg $fd 315 "$channel :End of /WHO list." } # This is a work in progress. Support for OP/DEOP is implemented. proc handleClientMode {fd target rest} { set argv {} |
︙ | ︙ | |||
471 472 473 474 475 476 477 | append res "$nick=+~[clientUser $nickfd]@[clientHost $nickfd] " } serverClientMsg $fd 302 ":[string trim $res]" } proc handleClientReload {fd password} { if {$password eq [config reloadpasswd]} { | | | 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 | append res "$nick=+~[clientUser $nickfd]@[clientHost $nickfd] " } serverClientMsg $fd 302 ":[string trim $res]" } proc handleClientReload {fd password} { if {$password eq [config reloadpasswd]} { uplevel #0 [list source [info script]] } } proc sendTopicMessage {fd channel} { foreach {topic userlist usermode} [channelInfo $channel] break if {$topic ne {}} { serverClientMsg $fd 332 "$channel :$topic" |
︙ | ︙ | |||
495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 | foreach fd $userlist mode $usermode { append users "$mode[clientNick $fd] " } set users [string range $users 0 end-1] serverClientMsg $fd 353 "= $channel :$users" serverClientMsg $fd 366 "$channel :End of /NAMES list." } # Initialization proc init {} { set ::initialized 1 socket -server handleNewConnection [config tcpport] vwait forever } | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | < > > | > | | | > | | 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 | foreach fd $userlist mode $usermode { append users "$mode[clientNick $fd] " } set users [string range $users 0 end-1] serverClientMsg $fd 353 "= $channel :$users" serverClientMsg $fd 366 "$channel :End of /NAMES list." } proc handleLocalCommand {fd ofd} { if {$fd ne ""} { gets $fd line if {[eof $fd] && $line eq ""} { # Do not check for input any more once we get EOF fileevent $fd readable "" return } if {$line eq ""} { return } set cmd "" catch { set cmd [lindex $line 0] } switch -- $cmd { "reloadpasswd" { puts $ofd "Reload password is: [config reloadpasswd]" } "reload" { handleClientReload "" [config reloadpasswd] puts $ofd "Done" } "exit" { exit } default { puts $ofd "Unknown command" } } } puts -nonewline $ofd "> " flush $ofd } # Initialization proc init {} { set ::initialized 1 config reloadpasswd [exec openssl rand -hex 20] if {[config debugchannel]} { handleLocalCommand "" stdout fileevent stdin readable [list handleLocalCommand stdin stdout] } socket -server handleNewConnection [config tcpport] vwait forever } config hostname rkeene.org config tcpport 6667 config version "TclIRCD-0.1a" config debugchannel 0 config debugmessages 0 if {[lsearch -exact $argv "-debug"] != -1} { config debugchannel 1 config debugmessages 1 } # Initialize only if it is not a 'reload'. if {![info exists ::initialized]} { init } |