summaryrefslogtreecommitdiff
path: root/localwebsite/handlers/ModemHandler.php
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2023-09-27 00:54:34 +0300
committerEvgeny Zinoviev <me@ch1p.io>2023-09-27 00:54:34 +0300
commitb7cbc2571c1870b4582ead45277d0aa7f961bec8 (patch)
tree2e90c5bb00284d603ca73bc4a2253ff0e5ee51f4 /localwebsite/handlers/ModemHandler.php
parent3e3753d726f8a02d98368f20f77dd9fa739e3d80 (diff)
lws: routing updates
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
+}