summaryrefslogtreecommitdiff
path: root/localwebsite/handlers/ModemHandler.php
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2024-02-17 02:43:49 +0300
committerEvgeny Zinoviev <me@ch1p.io>2024-02-17 02:43:49 +0300
commitc4ace358182d1f58724336714490e3caac6b60df (patch)
treea519d29e87e26d60c67e8646ebe133e5438d3986 /localwebsite/handlers/ModemHandler.php
parent17b447646752cb141c30684046906961e8d0af9f (diff)
parentd3a295872c49defb55fc8e4e43e55550991e0927 (diff)
Merge branch 'master' of ch1p.io:homekit
Diffstat (limited to 'localwebsite/handlers/ModemHandler.php')
-rw-r--r--localwebsite/handlers/ModemHandler.php27
1 files changed, 15 insertions, 12 deletions
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
+}