Version 29 of Tunnel IRC through HTTP proxies

Updated 2004-11-19 18:07:42

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.

PT 21-Jul-2003: See also SSL Tunnel for a version that supports an authenticating web proxy server.

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

 set useproxy    1
 set proxyserver
 set proxyport   3128
 set ircserver
 set ircport     6667
 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]

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

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

[ Category Internet | tunnel ]