Version 18 of Tunnel IRC through HTTP proxies

Updated 2002-10-28 16:47:32

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.

 set useproxy    1
 set proxyserver your.local.proxy
 set proxyport   8888
 set ircserver
 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
    } 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