mirror of
https://github.com/unraid/webgui.git
synced 2026-04-28 05:49:35 -05:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
@@ -75,13 +75,8 @@ LOG="/var/log/notify_${SCRIPTNAME%.*}"
|
||||
[[ -z "${TIMESTAMP}" ]] && TIMESTAMP=$(date +%s)
|
||||
# ensure link has a host
|
||||
if [[ -n "${LINK}" ]] && [[ ${LINK} != http* ]]; then
|
||||
source <(grep "NAME\|LOCAL_TLD\|PORT" /usr/local/emhttp/state/var.ini 2>/dev/null)
|
||||
HOST_NAME=${NAME,,}
|
||||
[[ -n ${LOCAL_TLD} ]] && LOCAL_TLD=".${LOCAL_TLD,,}"
|
||||
[[ "${PORT}" = "80" ]] && PORT=
|
||||
[[ -n ${PORT} ]] && PORT=":${PORT}"
|
||||
HOST="http://${HOST_NAME}${LOCAL_TLD}${PORT}"
|
||||
LINK=${HOST}${LINK}
|
||||
source <(grep "NGINX_DEFAULTURL" /usr/local/emhttp/state/nginx.ini 2>/dev/null)
|
||||
LINK=${NGINX_DEFAULTURL}${LINK}
|
||||
fi
|
||||
# note: there is no default for CONTENT
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ function generate_external_host($host, $ip) {
|
||||
return $host;
|
||||
}
|
||||
function verbose_output($httpcode, $result) {
|
||||
global $cli, $verbose, $anon, $plgversion, $post, $var, $certhostname, $isRegistered, $rebindDisabled, $remote, $reloadNginx;
|
||||
global $cli, $verbose, $anon, $plgversion, $post, $var, $certhostname, $isRegistered, $rebindDisabled, $remote, $reloadNginx, $nginx;
|
||||
global $remoteaccess;
|
||||
global $icon_warn, $icon_ok;
|
||||
if (!$cli || !$verbose) return;
|
||||
@@ -83,7 +83,7 @@ function verbose_output($httpcode, $result) {
|
||||
if ($anon) echo "(Output is anonymized, use '-vv' to see full details)".PHP_EOL;
|
||||
echo "Unraid OS {$var['version']}".((strpos($plgversion, "base-") === false) ? " with My Servers plugin version {$plgversion}" : '').PHP_EOL;
|
||||
echo ($isRegistered) ? "{$icon_ok}Signed in to Unraid.net as {$remote['username']}".PHP_EOL : "{$icon_warn}Not signed in to Unraid.net".PHP_EOL ;
|
||||
echo "Use SSL is {$var['USE_SSL']}".PHP_EOL;
|
||||
echo "Use SSL is {$nginx['NGINX_USESSL']}".PHP_EOL;
|
||||
echo ($rebindDisabled) ? "{$icon_ok}Rebind protection is disabled".PHP_EOL : "{$icon_warn}Rebind protection is enabled".PHP_EOL;
|
||||
if ($post) {
|
||||
$wanip = trim(@file_get_contents("https://wanip4.unraid.net/"));
|
||||
@@ -180,7 +180,7 @@ if ($cli && $argv[1] == "-vv") {
|
||||
}
|
||||
$var = parse_ini_file('/var/local/emhttp/var.ini');
|
||||
extract(parse_ini_file('/var/local/emhttp/network.ini',true));
|
||||
$nginx = parse_ini_file('/var/local/nginx/state.ini');
|
||||
$nginx = parse_ini_file('/var/local/emhttp/nginx.ini');
|
||||
$reloadNginx = false;
|
||||
$dnserr = false;
|
||||
$icon_warn = "⚠️ ";
|
||||
@@ -202,7 +202,7 @@ if (empty($remote['wanport'])) {
|
||||
}
|
||||
// remoteaccess, externalport
|
||||
if ($cli) {
|
||||
$remoteaccess = $remote['wanaccess'];
|
||||
$remoteaccess = (empty($nginx['NGINX_WANFQDN'])) ? 'no' : 'yes';
|
||||
$externalport = $remote['wanport'];
|
||||
} else {
|
||||
$remoteaccess = $_POST['remoteaccess'];
|
||||
@@ -238,35 +238,32 @@ $isRegistered = !empty($remote) && !empty($remote['username']);
|
||||
|
||||
// protocols, hostnames, ports
|
||||
$internalprotocol = 'http';
|
||||
$internalport = $var['PORT'];
|
||||
$internalhostname = $nginx['LANMDNS'];
|
||||
$internalport = $nginx['NGINX_PORT'];
|
||||
$internalhostname = $nginx['NGINX_LANMDNS'];
|
||||
$externalprotocol = 'https';
|
||||
// keyserver will expand *.hash.myunraid.net or add www to hash.unraid.net as needed
|
||||
$externalhostname = $nginx['CERTNAME'];
|
||||
$isLegacyCert = preg_match('/.*\.unraid\.net$/', $nginx['CERTNAME']);
|
||||
$isWildcardCert = preg_match('/.*\.myunraid\.net$/', $nginx['CERTNAME']);
|
||||
$externalhostname = $nginx['NGINX_CERTNAME'];
|
||||
$isLegacyCert = preg_match('/.*\.unraid\.net$/', $nginx['NGINX_CERTNAME']);
|
||||
$isWildcardCert = preg_match('/.*\.myunraid\.net$/', $nginx['NGINX_CERTNAME']);
|
||||
|
||||
// if not signed in, or if certs were deleted after configuring remote access, disable
|
||||
if (!$isRegistered || (!$isLegacyCert && !$isWildcardCert) || $remoteaccess != 'yes') $remoteaccess = 'no';
|
||||
|
||||
if ($var['USE_SSL']=='yes') {
|
||||
if ($nginx['NGINX_USESSL']=='yes') {
|
||||
// certificate assumed to exist
|
||||
// the subject of the certificate must match $var['NAME'].$var['LOCAL_TLD']
|
||||
// the subject of the certificate assumed to match $var['NAME'].$var['LOCAL_TLD']
|
||||
$internalprotocol = 'https';
|
||||
$internalport = $var['PORTSSL'];
|
||||
$internalport = $nginx['NGINX_PORTSSL'];
|
||||
}
|
||||
if ($var['USE_SSL']=='auto') {
|
||||
// certificate assumed to exist
|
||||
if ($nginx['NGINX_USESSL']=='auto' && $nginx['NGINX_CERTNAME']) {
|
||||
// for 6.9, check $nginx['NGINX_CERTNAME'] to ensure the cert exists
|
||||
$internalprotocol = 'https';
|
||||
$internalport = $var['PORTSSL'];
|
||||
$internalport = $nginx['NGINX_PORTSSL'];
|
||||
// keyserver will expand *.hash.myunraid.net as needed
|
||||
$internalhostname = $nginx['CERTNAME'];
|
||||
$internalhostname = $nginx['NGINX_CERTNAME'];
|
||||
}
|
||||
|
||||
// My Servers version
|
||||
$plgversion = file_exists("/var/log/plugins/dynamix.unraid.net.plg") ? trim(@exec('/usr/local/sbin/plugin version /var/log/plugins/dynamix.unraid.net.plg 2>/dev/null'))
|
||||
: file_exists("/var/log/plugins/dynamix.unraid.net.staging.plg") ? trim(@exec('/usr/local/sbin/plugin version /var/log/plugins/dynamix.unraid.net.staging.plg 2>/dev/null'))
|
||||
: 'base-'.$var['version'];
|
||||
: ( file_exists("/var/log/plugins/dynamix.unraid.net.staging.plg") ? trim(@exec('/usr/local/sbin/plugin version /var/log/plugins/dynamix.unraid.net.staging.plg 2>/dev/null'))
|
||||
: 'base-'.$var['version'] );
|
||||
|
||||
// DNS Rebind Protection - this checks the server but clients could still have issues
|
||||
$rebindDisabled = (host_lookup_ip("rebindtest.unraid.net") == "192.168.42.42");
|
||||
@@ -323,7 +320,7 @@ if ($isRegistered) {
|
||||
}
|
||||
|
||||
// if remoteaccess is enabled in 6.10.0-rc3+ and WANIP has changed since nginx started, reload nginx
|
||||
if ($post['_wanip'] && ($post['_wanip'] != $nginx['WANIP']) && version_compare($var['version'],"6.10.0-rc2",">")) $reloadNginx = true;
|
||||
if ($post['_wanip'] && ($post['_wanip'] != $nginx['NGINX_WANIP']) && version_compare($var['version'],"6.10.0-rc2",">")) $reloadNginx = true;
|
||||
if ($reloadNginx) {
|
||||
exec("/etc/rc.d/rc.nginx reload &>/dev/null");
|
||||
}
|
||||
|
||||
@@ -173,12 +173,6 @@ case 'add':
|
||||
$mailtest = false;
|
||||
$overrule = false;
|
||||
|
||||
$var = parse_ini_file('/var/local/emhttp/var.ini');
|
||||
$host_name = strtolower($var['NAME']);
|
||||
$host_tld = $var['LOCAL_TLD'] ? strtolower(".{$var['LOCAL_TLD']}") : "";
|
||||
$host_port = $var['PORT'] != 80 ? ":{$var['PORT']}" : "";
|
||||
$host = "http://{$host_name}{$host_tld}{$host_port}";
|
||||
|
||||
$options = getopt("l:e:s:d:i:m:r:xtb");
|
||||
foreach ($options as $option => $value) {
|
||||
switch ($option) {
|
||||
@@ -211,8 +205,9 @@ case 'add':
|
||||
$noBrowser = true;
|
||||
break;
|
||||
case 'l':
|
||||
$nginx = parse_ini_file('/var/local/emhttp/nginx.ini');
|
||||
$link = $value;
|
||||
$fqdnlink = (strpos($link,"http") === 0) ? $link : $host.$link;
|
||||
$fqdnlink = (strpos($link,"http") === 0) ? $link : $nginx['NGINX_DEFAULTURL'].$link;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user