Version 10 of Tunnel IRC through HTTP proxies

Updated 2002-06-08 08:40:29

by Reinhard Max

There is not much error checking yet, but it already works for me.

Please fill in the name and port number of your proxy server and set up your IRC client to connect to port 6667 of the machine this proxy is running on.

Feel free to add any improvements.

 set useproxy    1
 set proxyserver
 set proxyport   3128
 set ircserver
 set ircport     7000
 set localport   6667

 proc server {sock host port} {
    puts "connection from $host $port on $sock"
    set irc [socket $::proxyserver $::proxyport]
    if {$::useproxy} {
        puts $irc "CONNECT $::ircserver:$::ircport HTTP/1.1"
        puts $irc "Host: $::ircserver"
        puts $irc ""
        flush $irc
        while {[gets $irc line] > -1 && $line != ""} {
            puts $line
        if {[eof $irc]} {
            close $irc
            close $sock
    } else {
        set socket [socket $::ircserver $::ircport]
    fconfigure $sock -blocking no -buffering line
    fconfigure $irc -blocking no -buffering line

    fileevent $sock readable [list proxy $sock $irc ]
    fileevent $irc  readable [list proxy $irc  $sock]

    set server [socket -server server $::localport]
    vwait ::forever