Add param to force a hostname

This commit is contained in:
Jamie Cameron
2020-12-18 15:21:34 -08:00
parent 47fcc8e18c
commit ba9334250e
2 changed files with 13 additions and 9 deletions

View File

@@ -45,10 +45,7 @@ foreach $t (@todo) {
if ($tellcount) {
# Add link to Webmin
&get_miniserv_config(\%miniserv);
$proto = $miniserv{'ssl'} ? 'https' : 'http';
$port = $miniserv{'port'};
$url = $proto."://".&get_system_hostname().":".$port."/$module_name/";
$url = &get_webmin_email_url($module_name);
$body .= "Updates can be installed at $url\n\n";
}

View File

@@ -11207,14 +11207,14 @@ $referer =~ s/\/\//\//g;
return $referer;
}
=head2 get_webmin_email_url([module], [cgi], [force-default])
=head2 get_webmin_email_url([module], [cgi], [force-default], [force-host])
Returns the base URL for accessing this Webmin system, for use in URLs.
=cut
sub get_webmin_email_url
{
my ($mod, $cgi, $def) = @_;
my ($mod, $cgi, $def, $forcehost) = @_;
# Work out the base URL
my $url;
@@ -11226,7 +11226,7 @@ else {
&get_miniserv_config(\%miniserv);
my $proto = $miniserv{'ssl'} ? 'https' : 'http';
my $port = $miniserv{'port'};
my $host = &get_system_hostname();
my $host = $forcehost || &get_system_hostname();
my $defport = $proto eq 'https' ? 443 : 80;
$url = $proto."://".$host.($port == $defport ? "" : ":".$port);
$url .= $gconfig{'webprefix'} if ($gconfig{'webprefix'});
@@ -11234,8 +11234,15 @@ else {
# Append module if needed
$url =~ s/\/$//;
$url .= "/".$mod if ($mod);
$url .= "/".$cgi if ($cgi);
if ($mod && $cgi) {
$url .= "/".$mod."/".$cgi;
}
elsif ($mod) {
$url .= "/".$mod."/";
}
elsif ($cgi) {
$url .= "/".$cgi;
}
return $url;
}