Label wireguard tunnels in LQM (#1068)

This commit is contained in:
Tim Wilkinson 2024-01-17 14:02:20 -08:00 committed by GitHub
parent fb0f9a4b56
commit e83af37894
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 4 deletions

View File

@ -136,7 +136,7 @@ end
function update_block(track) function update_block(track)
if should_block(track) then if should_block(track) then
track.blocked = true track.blocked = true
if track.type == "Tunnel" then if track.type == "Tunnel" or track.type == "Wireguard" then
if not nft_handle("input_lqm", "iifname \\\"" .. track.device .. "\\\" udp dport 698 drop") then if not nft_handle("input_lqm", "iifname \\\"" .. track.device .. "\\\" udp dport 698 drop") then
os.execute(NFT .. " insert rule ip fw4 input_lqm iifname \\\"" .. track.device .. "\\\" udp dport 698 drop 2> /dev/null") os.execute(NFT .. " insert rule ip fw4 input_lqm iifname \\\"" .. track.device .. "\\\" udp dport 698 drop 2> /dev/null")
return "blocked" return "blocked"
@ -149,7 +149,7 @@ function update_block(track)
end end
else else
track.blocked = false track.blocked = false
if track.type == "Tunnel" then if track.type == "Tunnel" or track.type == "Wireguard" then
local handle = nft_handle("input_lqm", "iifname \\\"" .. track.device .. "\\\" udp dport 698 drop") local handle = nft_handle("input_lqm", "iifname \\\"" .. track.device .. "\\\" udp dport 698 drop")
if handle then if handle then
os.execute(NFT .. " delete rule ip fw4 input_lqm handle " .. handle) os.execute(NFT .. " delete rule ip fw4 input_lqm handle " .. handle)
@ -398,7 +398,7 @@ function lqm()
local a, b, c, d = s.clientip:match("^(%d+)%.(%d+)%.(%d+)%.(%d+):") local a, b, c, d = s.clientip:match("^(%d+)%.(%d+)%.(%d+)%.(%d+):")
d = tonumber(d) + 1 d = tonumber(d) + 1
stations[#stations + 1] = { stations[#stations + 1] = {
type = "Tunnel", type = "Wireguard",
device = "wgc" .. wgc, device = "wgc" .. wgc,
signal = nil, signal = nil,
ip = string.format("%d.%d.%d.%d", a, b, c, d), ip = string.format("%d.%d.%d.%d", a, b, c, d),
@ -419,7 +419,7 @@ function lqm()
if s.enabled == "1" and s.netip:match(":") then if s.enabled == "1" and s.netip:match(":") then
local a, b, c, d, _ = s.netip:match("^(%d+)%.(%d+)%.(%d+)%.(%d+):(%d+)$") local a, b, c, d, _ = s.netip:match("^(%d+)%.(%d+)%.(%d+)%.(%d+):(%d+)$")
stations[#stations + 1] = { stations[#stations + 1] = {
type = "Tunnel", type = "Wireguard",
device = "wgs" .. wgs, device = "wgs" .. wgs,
signal = nil, signal = nil,
ip = string.format("%d.%d.%d.%d", a, b, c, d), ip = string.format("%d.%d.%d.%d", a, b, c, d),