support for custom interfaces on Keenetic

This commit is contained in:
Vladimir Avtsenov 2024-09-06 17:06:17 +03:00
parent 797b85b03a
commit 76bc0822ef
3 changed files with 15 additions and 6 deletions

View File

@ -18,7 +18,7 @@ Realized features:
- [ ] HTTP API
- [ ] HTTP GUI
- [ ] CLI
- [ ] (Keenetic) Support for custom interfaces [1]
- [X] (Keenetic) Support for custom interfaces [1]
- [ ] It is not a concept now... REFACTORING TIME!!!
- [ ] (Keenetic) Getting readable names of interfaces from Keenetic NDMS
- [ ] HTTP Auth

View File

@ -2,11 +2,13 @@ package main
import (
"fmt"
netfilterHelper "kvas2-go/netfilter-helper"
"net"
"time"
"kvas2-go/models"
"kvas2-go/netfilter-helper"
"github.com/coreos/go-iptables/iptables"
)
type Group struct {
@ -14,6 +16,7 @@ type Group struct {
Enabled bool
iptables *iptables.IPTables
ipset *netfilterHelper.IPSet
ifaceToIPSet *netfilterHelper.IfaceToIPSet
}
@ -48,6 +51,10 @@ func (g *Group) Enable() error {
}
}()
if g.FixProtect {
g.iptables.AppendUnique("filter", "_NDM_SL_FORWARD", "-o", g.Interface, "-m", "state", "--state", "NEW", "-j", "_NDM_SL_PROTECT")
}
err := g.ipset.Create()
if err != nil {
return err
@ -94,6 +101,7 @@ func (a *App) AddGroup(group *models.Group) error {
a.Groups[group.ID] = &Group{
Group: group,
iptables: a.NetfilterHelper.IPTables,
ipset: a.NetfilterHelper.IPSet(ipsetName),
ifaceToIPSet: a.NetfilterHelper.IfaceToIPSet(fmt.Sprintf("%sROUTING_%d", a.Config.ChainPostfix, group.ID), group.Interface, ipsetName, false),
}

View File

@ -1,8 +1,9 @@
package models
type Group struct {
ID int
Name string
Interface string
Domains []*Domain
ID int
Name string
Interface string
FixProtect bool
Domains []*Domain
}