#!/bin/sh
#
# untunnel.tcl
#
# A basic port-forwarding, tunneling program I wrote for you. :^)
#
# Copyright (C) 2003, 2004
# Andy Goth <unununium@openverse.com>
#
# This code is available under the GNU General Public License; see COPYING.
#
# Restart with tclsh. \
exec tclsh "$0" "$@"

# Miscellaneous settings.
set untunnel_cmd  "untunnel/untunnel.tcl"
set rsh_cmd       "ssh -e none %HOST% %CMD%"
set version       "untunnel.tcl 0.1"
set clock_fmt     "%Y-%m-%d,%H:%M:%S "
set log_level     5
set chunk_size    4096
set be_quiet      0
set allow_tcl     1
set root_dir      [file normalize [file dirname $argv0]]

# Check basic command-line usage.
if {[llength $argv] == 0} {
    puts stderr "Usage: untunnel.tcl THOST LPORT:DHOST:DPORT\
                 \[LPORT:DHOST:DPORT] ..."
    exit 1
}

# Assorted junk used by everything...
source [file join $root_dir snit snit.tcl]
source [file join $root_dir lib misc.tcl]

# This program has three modes of operation, depending on the first parameter.
# Two of these modes, --server and --remote, are intended for internal use
# only.  Load the appropriate main procedure.
switch -- [lindex $argv 0] {
--server {source [file join $root_dir lib server.tcl]}
--remote {source [file join $root_dir lib remote.tcl]}
default  {source [file join $root_dir lib client.tcl]}}

# And run it.
main

# vim: set ts=4 sts=4 sw=4 tw=80 et:

