summaryrefslogtreecommitdiff
path: root/localwebsite/handlers
diff options
context:
space:
mode:
Diffstat (limited to 'localwebsite/handlers')
-rw-r--r--localwebsite/handlers/InverterHandler.php4
-rw-r--r--localwebsite/handlers/MiscHandler.php5
-rw-r--r--localwebsite/handlers/ModemHandler.php27
3 files changed, 22 insertions, 14 deletions
diff --git a/localwebsite/handlers/InverterHandler.php b/localwebsite/handlers/InverterHandler.php
index 7098e2c..5fa269f 100644
--- a/localwebsite/handlers/InverterHandler.php
+++ b/localwebsite/handlers/InverterHandler.php
@@ -93,10 +93,12 @@ class InverterHandler extends RequestHandler
protected function getClient(): InverterdClient {
global $config;
+ if (isset($_GET['alt']) && $_GET['alt'] == 1)
+ $config['inverterd_host'] = '192.168.5.223';
$inv = new InverterdClient($config['inverterd_host'], $config['inverterd_port']);
$inv->setFormat('json');
return $inv;
}
-} \ No newline at end of file
+}
diff --git a/localwebsite/handlers/MiscHandler.php b/localwebsite/handlers/MiscHandler.php
index 10b4426..4c5a25e 100644
--- a/localwebsite/handlers/MiscHandler.php
+++ b/localwebsite/handlers/MiscHandler.php
@@ -33,6 +33,9 @@ class MiscHandler extends RequestHandler
public function GET_pump_page() {
global $config;
+ if (isset($_GET['alt']) && $_GET['alt'] == 1)
+ $config['pump_host'] = '192.168.5.223';
+
list($set) = $this->input('set');
$client = new GPIORelaydClient($config['pump_host'], $config['pump_port']);
@@ -165,4 +168,4 @@ class MiscHandler extends RequestHandler
phpinfo();
}
-} \ No newline at end of file
+}
diff --git a/localwebsite/handlers/ModemHandler.php b/localwebsite/handlers/ModemHandler.php
index b54b82c..23e4c9a 100644
--- a/localwebsite/handlers/ModemHandler.php
+++ b/localwebsite/handlers/ModemHandler.php
@@ -76,7 +76,7 @@ class ModemHandler extends RequestHandler
global $config;
list($error) = $this->input('error');
- $upstream = self::getCurrentSmallHomeUpstream();
+ $upstream = self::getCurrentUpstream();
$current_upstream = [
'key' => $upstream,
@@ -98,12 +98,13 @@ class ModemHandler extends RequestHandler
if (!isset($config['modems'][$new_upstream]))
redirect('/routing/?error='.urlencode('invalid upstream'));
- $current_upstream = self::getCurrentSmallHomeUpstream();
+ $current_upstream = self::getCurrentUpstream();
if ($current_upstream != $new_upstream) {
- if ($current_upstream != $config['routing_default'])
- MyOpenWrtUtils::ipsetDel($current_upstream, $config['routing_smallhome_ip']);
- if ($new_upstream != $config['routing_default'])
- MyOpenWrtUtils::ipsetAdd($new_upstream, $config['routing_smallhome_ip']);
+ if ($new_upstream == 'mts-il')
+ $new_upstream_ip = '192.168.88.1';
+ else
+ $new_upstream_ip = $config['modems'][$new_upstream]['ip'];
+ MyOpenWrtUtils::setUpstream($new_upstream_ip);
}
redirect('/routing/');
@@ -264,14 +265,16 @@ class ModemHandler extends RequestHandler
}
}
- protected static function getCurrentSmallHomeUpstream() {
+ protected static function getCurrentUpstream() {
global $config;
+ $default_route = MyOpenWrtUtils::getDefaultRoute();
+ if ($default_route == '192.168.88.1')
+ $default_route = $config['modems']['mts-il']['ip'];
$upstream = null;
- $ip_sets = MyOpenWrtUtils::ipsetListAll();
- foreach ($ip_sets as $set => $ips) {
- if (in_array($config['routing_smallhome_ip'], $ips)) {
- $upstream = $set;
+ foreach ($config['modems'] as $modem_name => $modem_data) {
+ if ($default_route == $modem_data['ip']) {
+ $upstream = $modem_name;
break;
}
}
@@ -294,4 +297,4 @@ class ModemHandler extends RequestHandler
redirect('/routing/ipsets/?error='.urlencode('invalid ip/network: '.$ip));
}
-} \ No newline at end of file
+}