Compare commits

...

4 Commits

Author SHA1 Message Date
Vincent Wiemann ada9624708
Merge ebb30426ec into 53ea3b8977 2024-01-01 17:22:30 +01:00
Matthias Schiffer 53ea3b8977 libplatforminfo: update bcm27xx target name
The RPi targets were renamed in OpenWrt 21.02 (Gluon 2022.1). As
libplatforminfo was not adjusted, image names were using autodetected
model names including a revision number again, requiring additional
manifest aliases.
2023-12-19 18:40:02 +01:00
Matthias Schiffer 28a35ea2c9 libplatforminfo: drop obsolete ar71xx-mikrotik target
The obsolete ar71xx-mikrotik.c was symlinked to template/nosysupgrade.c.
As all new mikrotik targets have sysupgrade support, we can just remove
the symlink and use the default handling of libplatforminfo.

nosysupgrade.c becomes unused, but it left in the repository for future
experimental targets without sysupgrade support.
2023-12-19 18:40:02 +01:00
Vincent Wiemann ebb30426ec
wgpeerselector: expect actual traffic flow
Situations may happen in which handshakes are being received, but no actual traffic flows.
This commit adds checks on whether the tx/rx byte values have changed.
If not the connection is handled as being broken.
2022-01-13 20:44:14 +01:00
3 changed files with 12 additions and 4 deletions

View File

@ -1 +0,0 @@
template/nosysupgrade.c

View File

@ -54,6 +54,8 @@ function WGPeer:new(o)
-- some defaults
o.rx_bytes = 0
o.tx_bytes = 0
o.prev_rx_bytes = 0
o.prev_tx_bytes = 0
o.latest_handshake = 0
o.established_at = 0
-- terminology:
@ -175,10 +177,17 @@ function WGPeer:established_time()
return (time.time() - self.established_at)
end
function WGPeer:has_recent_handshake()
function WGPeer:has_recent_success()
-- WireGuard handshakes are sent at least every 2 minutes, if there is
-- payload traffic.
return (time.time() - self.latest_handshake) < 150
if 150 < (time.time() - self.latest_handshake) then return false end
-- Check if actually traffic was able to be received
if 0 == (self.rx_bytes - self.prev_rx_bytes) then return false end
self.prev_rx_bytes = self.rx_bytes
-- Check if actually traffic was able to be sent
if 0 == (self.tx_bytes - self.prev_tx_bytes) then return false end
self.prev_tx_bytes = self.tx_bytes
return true
end
local WGPeerSelector = {}
@ -236,7 +245,7 @@ function WGPeerSelector:try_connect_to_peer(peer, timeout)
sleep(timeout)
peer:update_stats_from_kernel()
local connection_successful = peer:has_recent_handshake()
local connection_successful = peer:has_recent_success()
if not connection_successful then
peer:uninstall_from_kernel()