mirror of
https://github.com/webmin/webmin.git
synced 2026-03-20 08:40:24 +00:00
Factor out WebSockets port and host options to global config
This commit is contained in:
@@ -64,6 +64,18 @@ else {
|
||||
$miniserv{'bind'} = $first->[0];
|
||||
}
|
||||
$miniserv{'sockets'} = join(" ", map { "$_->[0]:$_->[1]" } @sockets);
|
||||
if ($in{'websocket_base_port_def'}) {
|
||||
delete($miniserv{'websocket_base_port'});
|
||||
}
|
||||
else {
|
||||
$miniserv{'websocket_base_port'} = $in{'websocket_base_port'};
|
||||
}
|
||||
if ($in{'websocket_host_def'}) {
|
||||
delete($miniserv{'websocket_host'});
|
||||
}
|
||||
else {
|
||||
$miniserv{'websocket_host'} = $in{'websocket_host'};
|
||||
}
|
||||
$miniserv{'ipv6'} = $in{'ipv6'};
|
||||
if ($in{'listen_def'}) {
|
||||
delete($miniserv{'listen'});
|
||||
|
||||
@@ -47,6 +47,22 @@ if (&foreign_check("firewall")) {
|
||||
}
|
||||
print &ui_table_row($text{'bind_sockets'}, $stable);
|
||||
|
||||
# WebSocket based port
|
||||
print &ui_table_row($text{'bind_websocport'},
|
||||
&ui_radio("websocket_base_port_def",
|
||||
$miniserv{"websocket_base_port"} ? 0 : 1,
|
||||
[ [ 1, $text{'bind_websocport_none'} ],
|
||||
[ 0, &ui_textbox("websocket_base_port",
|
||||
$miniserv{"websocket_base_port"}, 6) ] ]));
|
||||
|
||||
# Hostname for WebSocket connections
|
||||
print &ui_table_row($text{'bind_websoc_host'},
|
||||
&ui_radio("websocket_host_def",
|
||||
$miniserv{"websocket_host"} ? 0 : 1,
|
||||
[ [ 1, $text{'bind_websoc_host_auto'} ],
|
||||
[ 0, &ui_textbox("websocket_host",
|
||||
$miniserv{"websocket_host"}, 25) ] ]));
|
||||
|
||||
# IPv6 enabled?
|
||||
print &ui_table_row($text{'bind_ipv6'},
|
||||
&ui_yesno_radio("ipv6", $miniserv{'ipv6'}));
|
||||
|
||||
@@ -13539,7 +13539,7 @@ foreach my $k (keys %miniserv) {
|
||||
}
|
||||
|
||||
# Pick a port and configure Webmin to proxy it
|
||||
my $port = $config{'base_port'} || 555;
|
||||
my $port = $miniserv{'websocket_base_port'} || 555;
|
||||
while(1) {
|
||||
if (!$inuse{$port}) {
|
||||
&open_socket("127.0.0.1", $port, my $fh, \$err);
|
||||
|
||||
@@ -84,6 +84,18 @@ else {
|
||||
$miniserv{'bind'} = $first->[0];
|
||||
}
|
||||
$miniserv{'sockets'} = join(" ", map { "$_->[0]:$_->[1]" } @sockets);
|
||||
if ($in{'websocket_base_port_def'}) {
|
||||
delete($miniserv{'websocket_base_port'});
|
||||
}
|
||||
else {
|
||||
$miniserv{'websocket_base_port'} = $in{'websocket_base_port'};
|
||||
}
|
||||
if ($in{'websocket_host_def'}) {
|
||||
delete($miniserv{'websocket_host'});
|
||||
}
|
||||
else {
|
||||
$miniserv{'websocket_host'} = $in{'websocket_host'};
|
||||
}
|
||||
$miniserv{'ipv6'} = $in{'ipv6'};
|
||||
if ($in{'listen_def'}) {
|
||||
delete($miniserv{'listen'});
|
||||
|
||||
@@ -44,6 +44,22 @@ if (&foreign_check("firewall")) {
|
||||
}
|
||||
print &ui_table_row($text{'bind_sockets'}, $stable);
|
||||
|
||||
# WebSocket based port
|
||||
print &ui_table_row($text{'bind_websocport'},
|
||||
&ui_radio("websocket_base_port_def",
|
||||
$miniserv{"websocket_base_port"} ? 0 : 1,
|
||||
[ [ 1, $text{'bind_websocport_none'} ],
|
||||
[ 0, &ui_textbox("websocket_base_port",
|
||||
$miniserv{"websocket_base_port"}, 6) ] ]));
|
||||
|
||||
# Hostname for WebSocket connections
|
||||
print &ui_table_row($text{'bind_websoc_host'},
|
||||
&ui_radio("websocket_host_def",
|
||||
$miniserv{"websocket_host"} ? 0 : 1,
|
||||
[ [ 1, $text{'bind_websoc_host_auto'} ],
|
||||
[ 0, &ui_textbox("websocket_host",
|
||||
$miniserv{"websocket_host"}, 25) ] ]));
|
||||
|
||||
# IPv6 enabled?
|
||||
print &ui_table_row($text{'bind_ipv6'},
|
||||
&ui_yesno_radio("ipv6", $miniserv{'ipv6'}));
|
||||
|
||||
@@ -46,6 +46,10 @@ bind_sport0=Same as first
|
||||
bind_sport1=Specific port ..
|
||||
bind_listen=Listen for broadcasts on UDP port
|
||||
bind_none=Don't listen
|
||||
bind_websocport=Base port number for WebSockets connections
|
||||
bind_websocport_none=Default (555)
|
||||
bind_websoc_host=Hostname for WebSocket connections
|
||||
bind_websoc_host_auto=Automatic
|
||||
bind_hostname=Web server hostname
|
||||
bind_auto=Work out from browser
|
||||
bind_err=Failed to change address
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
xterm=Set <tt>TERM</tt> environmental variable to,4,xterm+256color-xterm-256color,xterm+16color-xterm-16color,xterm-xterm,vt102-vt102,vt100-vt100,vt52-vt52,rxvt-rxvt,nsterm-nsterm,dtterm-dtterm,ansi-ansi
|
||||
base_port=Base port number for WebSockets connections,0,5
|
||||
host=Hostname for WebSocket connections,3,Automatic,32,,,Manual
|
||||
size=Terminal width and height in characters,3,Automatic,5,,,Static (80x24)
|
||||
locale=Set shell character encoding,10,0-Shell default,1-<tt>en_US.UTF-8</tt>,Custom
|
||||
rcfile=Execute initialization commands from file,10,0-Shell default,1-Module default,Custom
|
||||
|
||||
@@ -201,7 +201,9 @@ $ENV{'SESSION_ID'} = $main::session_id;
|
||||
|
||||
# Open the terminal
|
||||
my $ws_proto = lc($ENV{'HTTPS'}) eq 'on' ? 'wss' : 'ws';
|
||||
my $http_host_conf = &trim($config{'host'});
|
||||
my %miniserv;
|
||||
&get_miniserv_config(\%miniserv);
|
||||
my $http_host_conf = &trim($miniserv{'websocket_host'} || $config{'host'});
|
||||
if ($http_host_conf) {
|
||||
if ($http_host_conf !~ /^wss?:\/\//) {
|
||||
$http_host_conf = "$ws_proto://$http_host_conf";
|
||||
|
||||
Reference in New Issue
Block a user