fix: rebinding wg/tun not work (#271)

This commit is contained in:
mzz 2023-08-11 09:19:32 +08:00 committed by GitHub
parent a32bd81637
commit e7f774001a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

View File

@ -8,7 +8,6 @@ package control
import (
"context"
"fmt"
"github.com/daeuniverse/softwind/transport/meek"
"net"
"net/netip"
"os"
@ -36,6 +35,7 @@ import (
"github.com/daeuniverse/softwind/pool"
"github.com/daeuniverse/softwind/protocol/direct"
"github.com/daeuniverse/softwind/transport/grpc"
"github.com/daeuniverse/softwind/transport/meek"
dnsmessage "github.com/miekg/dns"
"github.com/mohae/deepcopy"
"github.com/sirupsen/logrus"
@ -190,11 +190,6 @@ func NewControlPlane(
}
/// Bind to links. Binding should be advance of dialerGroups to avoid un-routable old connection.
// Add clsact qdisc
for _, ifname := range common.Deduplicate(append(append([]string{}, global.LanInterface...), global.WanInterface...)) {
_ = core.addQdisc(ifname)
_ = core.mapLinkType(ifname)
}
// Bind to LAN
if len(global.LanInterface) > 0 {
if err = core.setupRoutingPolicy(); err != nil {

View File

@ -425,6 +425,8 @@ func (c *controlPlaneCore) _bindLan(ifname string) error {
if err = CheckSendRedirects(ifname); err != nil {
return err
}
_ = c.addQdisc(ifname)
_ = c.mapLinkType(ifname)
/// Insert an elem into IfindexParamsMap.
ifParams, err := getIfParamsFromLink(link)
if err != nil {
@ -564,6 +566,9 @@ func (c *controlPlaneCore) _bindWan(ifname string) error {
if link.Attrs().Index == consts.LoopbackIfIndex {
return fmt.Errorf("cannot bind to loopback interface")
}
_ = c.addQdisc(ifname)
_ = c.mapLinkType(ifname)
/// Insert an elem into IfindexParamsMap.
ifParams, err := getIfParamsFromLink(link)
if err != nil {