mirror of
https://github.com/webmin/webmin.git
synced 2026-05-06 23:30:29 +01:00
Add configurable websocket origin exceptions (for weird cases)
This commit is contained in:
26
miniserv.pl
26
miniserv.pl
@@ -5818,6 +5818,16 @@ elsif ($origin =~ /^(https?):\/\/([^:\/]+)(?::(\d+))?\/?$/i) {
|
||||
return undef;
|
||||
}
|
||||
|
||||
sub parse_configured_websocket_origin
|
||||
{
|
||||
my ($origin) = @_;
|
||||
return undef if (!defined($origin));
|
||||
$origin =~ s/^\s+|\s+$//g;
|
||||
$origin =~ s/^ws:\/\//http:\/\//i; # if admin configures websocket URLs
|
||||
$origin =~ s/^wss:\/\//https:\/\//i;
|
||||
return &parse_websocket_origin($origin);
|
||||
}
|
||||
|
||||
sub forwarded_websocket_origin
|
||||
{
|
||||
my ($proto, $host, $port) = @_;
|
||||
@@ -5874,6 +5884,22 @@ if ($config{'websocket_host'}) {
|
||||
}
|
||||
}
|
||||
|
||||
# Extra public origins can be whitelisted explicitly for unusual edge proxy
|
||||
# configs where auto-detection cannot work
|
||||
if ($config{'websocket_extra_origins'}) {
|
||||
foreach my $origin (split(/\s+|,\s*/, $config{'websocket_extra_origins'})) {
|
||||
next if (!$origin);
|
||||
my $parsed = &parse_configured_websocket_origin($origin);
|
||||
if ($parsed) {
|
||||
&$add_origin($parsed);
|
||||
}
|
||||
else {
|
||||
print DEBUG "ignoring invalid websocket_extra_origins ".
|
||||
"entry $origin\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return @rv;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user