Better managed offline devices asking for a vpn

parent 3f0e4e5e
......@@ -28,7 +28,8 @@ proxy_ports = {
5301: 'tun10',
5302: 'tun11',
5303: 'tun12',
5304: 'tun14'
5304: 'tun14',
5305: 'tun800'
}
# Customize the address and port of the external DNS server
......
......@@ -20,6 +20,10 @@ function vpnNeeded($name) {
return(str_replace("\n", "", shell_exec("sudo -u root /usr/local/bin/vpn_needed $name")));
}
function vpnUsers($name) {
return(explode("\n", shell_exec("sudo -u root /usr/local/bin/vpn_needed $name list")));
}
foreach($hosts as $line) {
$part = explode(" ", $line);
if(count($part) > 4 && str_starts_with($part[2], $localnet)) {
......@@ -45,9 +49,18 @@ foreach($fixed as $host => $ip) {
foreach($vpns as $vpnname => $vpnvars) {
$vpnvars['vpnstatus'] = vpnStatus($vpnname);
$vpnvars['vpnneeded'] = vpnNeeded($vpnname);
$vpnvars['vpnusers'] = array_filter(vpnUsers($vpnname));
$VPN[$vpnname] = $vpnvars;
foreach($vpnvars['vpnusers'] as $$uip) {
if(!in_array($uip, array_keys($DHCPIP)) && !in_array($uip, array_keys($FIXEDIP))) {
$ip = $uip;
$route = getRoute($ip);
$name = 'OFFLINE DEVICE';
$DHCPIP[$ip] = array("name" => $name, "ip" => $ip, "route" => $route);
$ROUTESTRING.=$route;
}
}
}
print(
json_encode(
array(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment