Update w/ common public_ip function

This commit is contained in:
billz 2021-07-07 23:25:23 +01:00
parent 84fcedc203
commit 8374d032b3
3 changed files with 10 additions and 4 deletions

View file

@ -42,11 +42,9 @@ function DisplayOpenVPNConfig()
} }
exec('pidof openvpn | wc -l', $openvpnstatus); exec('pidof openvpn | wc -l', $openvpnstatus);
exec('wget https://ipinfo.io/ip -qO -', $return);
$serviceStatus = $openvpnstatus[0] == 0 ? "down" : "up"; $serviceStatus = $openvpnstatus[0] == 0 ? "down" : "up";
$auth = file(RASPI_OPENVPN_CLIENT_LOGIN, FILE_IGNORE_NEW_LINES); $auth = file(RASPI_OPENVPN_CLIENT_LOGIN, FILE_IGNORE_NEW_LINES);
$public_ip = $return[0]; $public_ip = get_public_ip();
// parse client auth credentials // parse client auth credentials
if (!empty($auth)) { if (!empty($auth)) {

View file

@ -58,12 +58,14 @@ function DisplayWireGuardConfig()
exec('pidof wg-crypt-wg0 | wc -l', $wgstatus); exec('pidof wg-crypt-wg0 | wc -l', $wgstatus);
$serviceStatus = $wgstatus[0] == 0 ? "down" : "up"; $serviceStatus = $wgstatus[0] == 0 ? "down" : "up";
$wg_state = ($wgstatus[0] > 0); $wg_state = ($wgstatus[0] > 0);
$public_ip = get_public_ip();
echo renderTemplate( echo renderTemplate(
"wireguard", compact( "wireguard", compact(
"status", "status",
"wg_state", "wg_state",
"serviceStatus", "serviceStatus",
"public_ip",
"optRules", "optRules",
"wg_log", "wg_log",
"peer_id", "peer_id",
@ -132,7 +134,7 @@ function SaveWireGuardUpload($status, $file, $optRules)
file_put_contents($tmp_wgconfig, $tmp_contents); file_put_contents($tmp_wgconfig, $tmp_contents);
} }
// Move uploaded file from to destination // Move processed file from tmp to destination
system("sudo mv $tmp_wgconfig ". RASPI_WIREGUARD_CONFIG, $return); system("sudo mv $tmp_wgconfig ". RASPI_WIREGUARD_CONFIG, $return);
if ($return ==0) { if ($return ==0) {

View file

@ -3,6 +3,12 @@
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-6">
<h4 class="mt-3"><?php echo _("Tunnel settings"); ?></h4> <h4 class="mt-3"><?php echo _("Tunnel settings"); ?></h4>
<div class="col-lg-12 mt-2">
<div class="row mt-3 mb-2">
<div class="info-item col-xs-3"><?php echo _("IPv4 Address"); ?></div>
<div class="info-value col-xs-3"><?php echo htmlspecialchars($public_ip, ENT_QUOTES); ?><a class="text-gray-500" href="https://ipapi.co/<?php echo($public_ip); ?>" target="_blank" rel="noopener noreferrer"><i class="fas fa-external-link-alt ml-2"></i></a></div>
</div>
</div>
<div class="input-group"> <div class="input-group">
<div class="custom-control custom-switch"> <div class="custom-control custom-switch">
<input class="custom-control-input" id="server_enabled" type="checkbox" name="wg_senabled" value="1" <?php echo $wg_senabled ? ' checked="checked"' : "" ?> aria-describedby="server-description"> <input class="custom-control-input" id="server_enabled" type="checkbox" name="wg_senabled" value="1" <?php echo $wg_senabled ? ' checked="checked"' : "" ?> aria-describedby="server-description">