mirror of
https://github.com/daeuniverse/dae.git
synced 2025-07-13 17:29:09 +07:00
fix: preprocess wan_interface 'auto' before ebpf program loading to avoid to fail to insert filter
This commit is contained in:
@ -6,6 +6,8 @@
|
|||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
"github.com/daeuniverse/dae/common"
|
||||||
"github.com/daeuniverse/dae/common/consts"
|
"github.com/daeuniverse/dae/common/consts"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -13,6 +15,7 @@ type patch func(params *Config) error
|
|||||||
|
|
||||||
var patches = []patch{
|
var patches = []patch{
|
||||||
patchEmptyDns,
|
patchEmptyDns,
|
||||||
|
patchWanInterfaceAuto,
|
||||||
}
|
}
|
||||||
|
|
||||||
func patchEmptyDns(params *Config) error {
|
func patchEmptyDns(params *Config) error {
|
||||||
@ -24,3 +27,21 @@ func patchEmptyDns(params *Config) error {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func patchWanInterfaceAuto(params *Config) error {
|
||||||
|
// preprocess "auto".
|
||||||
|
ifs := make([]string, 0, len(params.Global.WanInterface)+2)
|
||||||
|
for _, ifname := range params.Global.WanInterface {
|
||||||
|
if ifname == "auto" {
|
||||||
|
defaultIfs, err := common.GetDefaultIfnames()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to convert 'auto': %w", err)
|
||||||
|
}
|
||||||
|
ifs = append(ifs, defaultIfs...)
|
||||||
|
} else {
|
||||||
|
ifs = append(ifs, ifname)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
params.Global.WanInterface = common.Deduplicate(ifs)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
@ -203,20 +203,6 @@ func NewControlPlane(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Bind to WAN
|
// Bind to WAN
|
||||||
// preprocess "auto".
|
|
||||||
ifs := make([]string, 0, len(global.WanInterface)+2)
|
|
||||||
for _, ifname := range global.WanInterface {
|
|
||||||
if ifname == "auto" {
|
|
||||||
defaultIfs, err := common.GetDefaultIfnames()
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to convert 'auto': %w", err)
|
|
||||||
}
|
|
||||||
ifs = append(ifs, defaultIfs...)
|
|
||||||
} else {
|
|
||||||
ifs = append(ifs, ifname)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
global.WanInterface = common.Deduplicate(ifs)
|
|
||||||
if len(global.WanInterface) > 0 {
|
if len(global.WanInterface) > 0 {
|
||||||
if err = core.setupSkPidMonitor(); err != nil {
|
if err = core.setupSkPidMonitor(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
Reference in New Issue
Block a user