blob: 8d858a196975669c8638490e5e4bca8a104ccf86 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
--- 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
|