support for custom interfaces on Keenetic
This commit is contained in:
parent
797b85b03a
commit
76bc0822ef
@ -18,7 +18,7 @@ Realized features:
|
|||||||
- [ ] HTTP API
|
- [ ] HTTP API
|
||||||
- [ ] HTTP GUI
|
- [ ] HTTP GUI
|
||||||
- [ ] CLI
|
- [ ] CLI
|
||||||
- [ ] (Keenetic) Support for custom interfaces [1]
|
- [X] (Keenetic) Support for custom interfaces [1]
|
||||||
- [ ] It is not a concept now... REFACTORING TIME!!!
|
- [ ] It is not a concept now... REFACTORING TIME!!!
|
||||||
- [ ] (Keenetic) Getting readable names of interfaces from Keenetic NDMS
|
- [ ] (Keenetic) Getting readable names of interfaces from Keenetic NDMS
|
||||||
- [ ] HTTP Auth
|
- [ ] HTTP Auth
|
||||||
|
10
group.go
10
group.go
@ -2,11 +2,13 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
netfilterHelper "kvas2-go/netfilter-helper"
|
|
||||||
"net"
|
"net"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"kvas2-go/models"
|
"kvas2-go/models"
|
||||||
|
"kvas2-go/netfilter-helper"
|
||||||
|
|
||||||
|
"github.com/coreos/go-iptables/iptables"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Group struct {
|
type Group struct {
|
||||||
@ -14,6 +16,7 @@ type Group struct {
|
|||||||
|
|
||||||
Enabled bool
|
Enabled bool
|
||||||
|
|
||||||
|
iptables *iptables.IPTables
|
||||||
ipset *netfilterHelper.IPSet
|
ipset *netfilterHelper.IPSet
|
||||||
ifaceToIPSet *netfilterHelper.IfaceToIPSet
|
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()
|
err := g.ipset.Create()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -94,6 +101,7 @@ func (a *App) AddGroup(group *models.Group) error {
|
|||||||
|
|
||||||
a.Groups[group.ID] = &Group{
|
a.Groups[group.ID] = &Group{
|
||||||
Group: group,
|
Group: group,
|
||||||
|
iptables: a.NetfilterHelper.IPTables,
|
||||||
ipset: a.NetfilterHelper.IPSet(ipsetName),
|
ipset: a.NetfilterHelper.IPSet(ipsetName),
|
||||||
ifaceToIPSet: a.NetfilterHelper.IfaceToIPSet(fmt.Sprintf("%sROUTING_%d", a.Config.ChainPostfix, group.ID), group.Interface, ipsetName, false),
|
ifaceToIPSet: a.NetfilterHelper.IfaceToIPSet(fmt.Sprintf("%sROUTING_%d", a.Config.ChainPostfix, group.ID), group.Interface, ipsetName, false),
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
type Group struct {
|
type Group struct {
|
||||||
ID int
|
ID int
|
||||||
Name string
|
Name string
|
||||||
Interface string
|
Interface string
|
||||||
Domains []*Domain
|
FixProtect bool
|
||||||
|
Domains []*Domain
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user