mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-04-29 16:58:34 +00:00
WireGuard config: Replace kernelMode
with noKernelTun
https://github.com/XTLS/Xray-core/pull/3871#issuecomment-2420770309
This commit is contained in:
parent
b0272c172a
commit
9bdf72d658
6 changed files with 58 additions and 65 deletions
|
@ -1,10 +1,8 @@
|
|||
package conf
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/xtls/xray-core/common/errors"
|
||||
|
@ -53,8 +51,7 @@ func (c *WireGuardPeerConfig) Build() (proto.Message, error) {
|
|||
type WireGuardConfig struct {
|
||||
IsClient bool `json:""`
|
||||
|
||||
KernelTun *bool `json:"kernelTun"`
|
||||
KernelMode *bool `json:"kernelMode"`
|
||||
NoKernelTun bool `json:"noKernelTun"`
|
||||
SecretKey string `json:"secretKey"`
|
||||
Address []string `json:"address"`
|
||||
Peers []*WireGuardPeerConfig `json:"peers"`
|
||||
|
@ -121,26 +118,7 @@ func (c *WireGuardConfig) Build() (proto.Message, error) {
|
|||
}
|
||||
|
||||
config.IsClient = c.IsClient
|
||||
kernelTunSupported, err := wireguard.KernelTunSupported()
|
||||
if err != nil {
|
||||
errors.LogWarning(context.Background(), fmt.Sprintf("Failed to check kernel TUN support: %v. This may indicate that your OS doesn't support kernel TUN or you lack the necessary permissions. Please ensure you have the required privileges.", err))
|
||||
config.KernelMode = false
|
||||
return config, nil
|
||||
}
|
||||
if c.KernelMode == nil {
|
||||
c.KernelMode = c.KernelTun
|
||||
}
|
||||
if c.KernelMode != nil {
|
||||
config.KernelMode = *c.KernelMode
|
||||
if config.KernelMode && !kernelTunSupported {
|
||||
errors.LogWarning(context.Background(), "kernel TUN is not supported on your OS or permission is insufficient")
|
||||
}
|
||||
} else {
|
||||
config.KernelMode = kernelTunSupported
|
||||
if config.KernelMode {
|
||||
errors.LogDebug(context.Background(), "kernel TUN is enabled as it's supported and permission is sufficient")
|
||||
}
|
||||
}
|
||||
config.NoKernelTun = c.NoKernelTun
|
||||
|
||||
return config, nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue