mirror of
https://github.com/webmin/webmin.git
synced 2026-02-03 14:13:29 +00:00
Add API to get WebSocket URL
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -13558,6 +13558,25 @@ $miniserv{'websockets_'.$wspath} = "host=127.0.0.1 port=$port wspath=/ user=$rem
|
||||
return $port;
|
||||
}
|
||||
|
||||
# get_miniserv_websocket_url(port, [host])
|
||||
# Returns the URL for a websocket
|
||||
sub get_miniserv_websocket_url
|
||||
{
|
||||
my ($port, $host) = @_;
|
||||
my $ws_proto = lc($ENV{'HTTPS'}) eq 'on' ? 'wss' : 'ws';
|
||||
my %miniserv;
|
||||
&get_miniserv_config(\%miniserv);
|
||||
my $http_host_conf = &trim($miniserv{'websocket_host'} || $host);
|
||||
if ($http_host_conf) {
|
||||
if ($http_host_conf !~ /^wss?:\/\//) {
|
||||
$http_host_conf = "$ws_proto://$http_host_conf";
|
||||
}
|
||||
$http_host_conf =~ s/[\/]+$//g;
|
||||
}
|
||||
my $http_host = $http_host_conf || "$ws_proto://$ENV{'HTTP_HOST'}";
|
||||
return "$http_host/$module_name/ws-$port";
|
||||
}
|
||||
|
||||
# remove_miniserv_websocket(port)
|
||||
# Remove old websocket
|
||||
# from miniserv.conf
|
||||
|
||||
@@ -200,18 +200,7 @@ $ENV{'SESSION_ID'} = $main::session_id;
|
||||
" >$module_var_directory/websocket-connection-$port.out 2>&1 </dev/null");
|
||||
|
||||
# Open the terminal
|
||||
my $ws_proto = lc($ENV{'HTTPS'}) eq 'on' ? 'wss' : 'ws';
|
||||
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";
|
||||
}
|
||||
$http_host_conf =~ s/[\/]+$//g;
|
||||
}
|
||||
my $http_host = $http_host_conf || "$ws_proto://$ENV{'HTTP_HOST'}";
|
||||
my $url = "$http_host/$module_name/ws-$port";
|
||||
my $url = &get_miniserv_websocket_url($port, $config{'host'});
|
||||
my $canvasAddon = $termlinks->{'js'}[3];
|
||||
my $webGLAddon = $termlinks->{'js'}[4];
|
||||
my $term_script = <<EOF;
|
||||
|
||||
Reference in New Issue
Block a user