Skip to content

Commit

Permalink
[api] Reduce error logs
Browse files Browse the repository at this point in the history
  • Loading branch information
lts-rad committed Oct 21, 2024
1 parent 25d1b61 commit e9f9f56
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion api/code/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -2681,7 +2681,7 @@ func main() {
migrateMDNS()
//v0.3.7 migration of groups into policies
migrateDevicePolicies()

loadConfig()

migrateDNSSettings()
Expand Down
13 changes: 8 additions & 5 deletions api/code/firewall.go
Original file line number Diff line number Diff line change
Expand Up @@ -1170,7 +1170,7 @@ func refreshDeviceGroupsAndPolicy(dev DeviceEntry) {

device_disabled := slices.Contains(dev.Policies, "disabled") || dev.DeviceDisabled == true
if !device_disabled {
//add this MAC and IP to the ethernet filter
//add this MAC and IP to the ethernet filter. wg is a no-op
addVerdictMac(ipv4, dev.MAC, ifname, "ethernet_filter", "return")

//and re-add
Expand Down Expand Up @@ -2244,6 +2244,11 @@ func flushRouteFromArp(MAC string) {
}

func addVerdictMac(IP string, MAC string, Iface string, Table string, Verdict string) {

if Iface == "wg0" || entry.MAC == "" {
return
}

err := exec.Command("nft", "add", "element", "inet", "filter", Table, "{", IP, ".", Iface, ".", MAC, ":", Verdict, "}").Run()
if err != nil {
log.Println("addVerdictMac Failed", MAC, Iface, Table, err)
Expand Down Expand Up @@ -2711,10 +2716,8 @@ func establishDevice(entry DeviceEntry, new_iface string, established_route_devi
}

//6. add entry to appropriate verdict maps
if new_iface != "wg0" && entry.MAC != "" {
//add this MAC and IP to the ethernet filter
addVerdictMac(entry.RecentIP, entry.MAC, new_iface, "ethernet_filter", "return")
}
//add this MAC and IP to the ethernet filter. wg will be a no-op
addVerdictMac(entry.RecentIP, entry.MAC, new_iface, "ethernet_filter", "return")

Devicesmtx.Lock()
defer Devicesmtx.Unlock()
Expand Down

0 comments on commit e9f9f56

Please sign in to comment.