support for custom interfaces on Keenetic
This commit is contained in:
parent
797b85b03a
commit
76bc0822ef
@ -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
|
||||
|
10
group.go
10
group.go
@ -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),
|
||||
}
|
||||
|
@ -4,5 +4,6 @@ type Group struct {
|
||||
ID int
|
||||
Name string
|
||||
Interface string
|
||||
FixProtect bool
|
||||
Domains []*Domain
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user