--- plugins/filetransfer/http.tcl.orig 2006-09-25 14:59:45.000000000 +0200 +++ plugins/filetransfer/http.tcl 2006-09-25 15:03:41.000000000 +0200 @@ -5,6 +5,8 @@ variable chunk_size 4096 variable options + variable defport 0 + variable defip "" custom::defgroup HTTP \ [::msgcat::mc "HTTP options."] \ @@ -13,10 +15,22 @@ custom::defvar options(enable) 1 \ [::msgcat::mc "Enable HTTP transport for outgoing file transfers."] \ -group HTTP -type boolean + + custom::defvar defport 0 \ + [::msgcat::mc "Port for outgoing HTTP file transfers (0 for assigned automatically).\ + This is useful when sending files from behind a NAT with a forwarded port."] \ + -group HTTP -type integer + + custom::defvar defip "" \ + [::msgcat::mc "Force advertising this IP address for outgoing HTTP file transfers."] \ + -group HTTP -type string + } proc http::send_file_dialog {user args} { variable winid + variable defport + variable defip foreach {opt val} $args { switch -- $opt { @@ -51,13 +65,17 @@ label $f.lip -text [::msgcat::mc "IP address:"] entry $f.ip -textvariable [list [namespace current]::ip$winid] variable ip$winid 127.0.0.1 - catch { - set ip$winid [info hostname] - set ip$winid [lindex [host_info addresses [set ip$winid]] 0] - } - catch { - set ip$winid [lindex [fconfigure $jlib::lib($connid,sck) -sockname] 0] + if { [string compare $defip ""] != 0 } { + set ip$winid [set defip] + } else { + catch { + set ip$winid [info hostname] + set ip$winid [lindex [host_info addresses [set ip$winid]] 0] + } + catch { + set ip$winid [lindex [fconfigure $jlib::lib($connid,sck) -sockname] 0] + } } ProgressBar $f.pb \ @@ -136,6 +154,7 @@ } proc http::send_file_offer {winid user filename desc ip args} { + variable defport foreach {opt val} $args { switch -- $opt { @@ -148,7 +167,7 @@ set servsock \ [socket -server \ - [list [namespace current]::send_file_accept $winid $filename] 0] + [list [namespace current]::send_file_accept $winid $filename] $defport] lassign [fconfigure $servsock -sockname] addr hostname port