Version 20 of Tunnel IRC through HTTP proxies

Updated 2002-10-28 16:55:16

by Reinhard Max

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

It is only useful within networks that don't allow direct access to IRC, but have a proxy that allows HTTP/1.1 CONNECTs to the outside. CONNECT might be restricted to certain ports such as 443 (https). In that case you can only connect to IRC servers that listen on a port that is allowed by your local proxy.

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.


 # These settings are only examples.
 # There is no need to 'fix' this page by adding your local settings

 set useproxy    1
 set proxyserver your.local.proxy
 set proxyport   8888
 set ircserver   rucus.zanet.net
 set ircport     443
 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
            return
        }
    } 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]
 }

 proc proxy {sock1 sock2} {
    if {[gets $sock1 line] > 0} {
        puts $sock2 $line
    }
    if {[eof $sock1]} {
        puts "closing $sock1 $sock2"
        close $sock1
        close $sock2
    }
    return
 }

 proc main {} {
    set server [socket -server server $::localport]
    vwait ::forever
 }
 main

[ Category Internet | tunnel ]