mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-04-29 16:58:34 +00:00
Refactor log (#3446)
* Refactor log * Add new log methods * Fix logger test * Change all logging code * Clean up pathObj * Rebase to latest main * Remove invoking method name after the dot
This commit is contained in:
parent
8320732743
commit
079d0bd8a9
291 changed files with 1837 additions and 2368 deletions
|
@ -1,10 +1,12 @@
|
|||
package conf
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"encoding/hex"
|
||||
"strings"
|
||||
|
||||
"github.com/xtls/xray-core/common/errors"
|
||||
"github.com/xtls/xray-core/proxy/wireguard"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
@ -97,7 +99,7 @@ func (c *WireGuardConfig) Build() (proto.Message, error) {
|
|||
config.NumWorkers = c.NumWorkers
|
||||
|
||||
if len(c.Reserved) != 0 && len(c.Reserved) != 3 {
|
||||
return nil, newError(`"reserved" should be empty or 3 bytes`)
|
||||
return nil, errors.New(`"reserved" should be empty or 3 bytes`)
|
||||
}
|
||||
config.Reserved = c.Reserved
|
||||
|
||||
|
@ -113,19 +115,19 @@ func (c *WireGuardConfig) Build() (proto.Message, error) {
|
|||
case "forceipv6v4":
|
||||
config.DomainStrategy = wireguard.DeviceConfig_FORCE_IP64
|
||||
default:
|
||||
return nil, newError("unsupported domain strategy: ", c.DomainStrategy)
|
||||
return nil, errors.New("unsupported domain strategy: ", c.DomainStrategy)
|
||||
}
|
||||
|
||||
config.IsClient = c.IsClient
|
||||
if c.KernelMode != nil {
|
||||
config.KernelMode = *c.KernelMode
|
||||
if config.KernelMode && !wireguard.KernelTunSupported() {
|
||||
newError("kernel mode is not supported on your OS or permission is insufficient").AtWarning().WriteToLog()
|
||||
errors.LogWarning(context.Background(), "kernel mode is not supported on your OS or permission is insufficient")
|
||||
}
|
||||
} else {
|
||||
config.KernelMode = wireguard.KernelTunSupported()
|
||||
if config.KernelMode {
|
||||
newError("kernel mode is enabled as it's supported and permission is sufficient").AtDebug().WriteToLog()
|
||||
errors.LogDebug(context.Background(), "kernel mode is enabled as it's supported and permission is sufficient")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -153,5 +155,5 @@ func ParseWireGuardKey(str string) (string, error) {
|
|||
return hex.EncodeToString(dat), nil
|
||||
}
|
||||
|
||||
return "", newError("failed to deserialize key").Base(err)
|
||||
return "", errors.New("failed to deserialize key").Base(err)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue