The skeleton of a man in the middle
Placing yourself in the middle comes in handy in all sorts of situations. The following skeleton of Tcl code is fully functional and easily extended. I've used it in one form or another for many years now:
socket -server accept listeningPort proc accept {client addr port} { if {[catch {socket -async destHost destPort} server]} then { shutdown $client } else { fconfigure $client -blocking 0 -buffering none -translation binary fconfigure $server -blocking 0 -buffering none -translation binary fileevent $client readable [list glue $client $server] fileevent $server readable [list glue $server $client] } } proc glue {src dst} { if {[catch {puts -nonewline $dst [read $src]}] || [eof $src] || [eof $dst]} then { shutdown $src $dst } } proc shutdown {args} { foreach sock $args {catch {close $sock}} } vwait forever
It's possible to get even more mileage out of it. With just another couple of lines you can bridge SSL coming and/or going.
I love Tcl's event-driven I/O.
—Michael A. Cleverly
Monday, March 12, 2007 at 23:03
https://linkvaov9bet.net/v9b/profile.php?id=15359 https://carnavalslot.com/cs/profile.php?id=13163 https://game-zombie.net/forum/profile.php?id=5711 http://nilinreading.com/home.php?mod=space&uid=56098&do=profile&from=space https://bonqdaso.com/bds/profile.php?id=12281 https://www.zhaoyuanedu.com/home.php?mod=space&uid=7558 https://celadonhcm.com/cct/profile.php?id=14198 http://forum.mountec.net/home.php?mod=space&uid=44743 http://friend-feed.com/user/judidepositviapulsa/ https://disqus.com/by/judidepositviapulsa/ https://www.pbase.com/profile/judidepositviapulsa
Mon, 07 Sep 2020, 03:11