mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-17 14:57:44 -05:00
cleanup error messages
This commit is contained in:
parent
0e01e9e9ca
commit
68bc9ea8e4
@ -52,7 +52,7 @@ func (v *RoutingRule) BuildCondition() (Condition, error) {
|
|||||||
}
|
}
|
||||||
ipv6Cond.Add(matcher)
|
ipv6Cond.Add(matcher)
|
||||||
default:
|
default:
|
||||||
return nil, newError("Router: Invalid IP length.")
|
return nil, newError("invalid IP length").AtError()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,7 +93,7 @@ func (v *RoutingRule) BuildCondition() (Condition, error) {
|
|||||||
}
|
}
|
||||||
ipv6Cond.Add(matcher)
|
ipv6Cond.Add(matcher)
|
||||||
default:
|
default:
|
||||||
return nil, newError("Router: Invalid IP length.")
|
return nil, newError("invalid IP length").AtError()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,7 +118,7 @@ func (v *RoutingRule) BuildCondition() (Condition, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if conds.Len() == 0 {
|
if conds.Len() == 0 {
|
||||||
return nil, newError("Router: This rule has no effective fields.")
|
return nil, newError("this rule has no effective fields").AtError()
|
||||||
}
|
}
|
||||||
|
|
||||||
return conds, nil
|
return conds, nil
|
||||||
|
@ -26,7 +26,7 @@ type Router struct {
|
|||||||
func NewRouter(ctx context.Context, config *Config) (*Router, error) {
|
func NewRouter(ctx context.Context, config *Config) (*Router, error) {
|
||||||
space := app.SpaceFromContext(ctx)
|
space := app.SpaceFromContext(ctx)
|
||||||
if space == nil {
|
if space == nil {
|
||||||
return nil, newError("Router: No space in context.")
|
return nil, newError("no space in context")
|
||||||
}
|
}
|
||||||
r := &Router{
|
r := &Router{
|
||||||
domainStrategy: config.DomainStrategy,
|
domainStrategy: config.DomainStrategy,
|
||||||
@ -45,7 +45,7 @@ func NewRouter(ctx context.Context, config *Config) (*Router, error) {
|
|||||||
|
|
||||||
r.dnsServer = dns.FromSpace(space)
|
r.dnsServer = dns.FromSpace(space)
|
||||||
if r.dnsServer == nil {
|
if r.dnsServer == nil {
|
||||||
return newError("Router: DNS is not found in the space.")
|
return newError("DNS is not found in the space")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
@ -24,7 +24,7 @@ func CreateAppFromConfig(ctx context.Context, config interface{}) (Application,
|
|||||||
case Application:
|
case Application:
|
||||||
return a, nil
|
return a, nil
|
||||||
default:
|
default:
|
||||||
return nil, newError("App: Not an application.")
|
return nil, newError("not an application")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ func (v *spaceImpl) GetApplication(appInterface interface{}) Application {
|
|||||||
|
|
||||||
func (v *spaceImpl) AddApplication(app Application) error {
|
func (v *spaceImpl) AddApplication(app Application) error {
|
||||||
if v == nil {
|
if v == nil {
|
||||||
return newError("App: Nil space.")
|
return newError("nil space").AtError()
|
||||||
}
|
}
|
||||||
appType := reflect.TypeOf(app.Interface())
|
appType := reflect.TypeOf(app.Interface())
|
||||||
v.cache[appType] = app
|
v.cache[appType] = app
|
||||||
@ -112,7 +112,7 @@ const (
|
|||||||
func AddApplicationToSpace(ctx context.Context, appConfig interface{}) error {
|
func AddApplicationToSpace(ctx context.Context, appConfig interface{}) error {
|
||||||
space := SpaceFromContext(ctx)
|
space := SpaceFromContext(ctx)
|
||||||
if space == nil {
|
if space == nil {
|
||||||
return newError("App: No space in context.")
|
return newError("no space in context").AtError()
|
||||||
}
|
}
|
||||||
application, err := CreateAppFromConfig(ctx, appConfig)
|
application, err := CreateAppFromConfig(ctx, appConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -14,7 +14,7 @@ type Reader interface {
|
|||||||
Read() (*Buffer, error)
|
Read() (*Buffer, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
var ErrReadTimeout = newError("Buf: IO timeout.")
|
var ErrReadTimeout = newError("IO timeout")
|
||||||
|
|
||||||
type TimeoutReader interface {
|
type TimeoutReader interface {
|
||||||
ReadTimeout(time.Duration) (*Buffer, error)
|
ReadTimeout(time.Duration) (*Buffer, error)
|
||||||
|
@ -51,7 +51,7 @@ type AEADAuthenticator struct {
|
|||||||
func (v *AEADAuthenticator) Open(dst, cipherText []byte) ([]byte, error) {
|
func (v *AEADAuthenticator) Open(dst, cipherText []byte) ([]byte, error) {
|
||||||
iv := v.NonceGenerator.Next()
|
iv := v.NonceGenerator.Next()
|
||||||
if len(iv) != v.AEAD.NonceSize() {
|
if len(iv) != v.AEAD.NonceSize() {
|
||||||
return nil, newError("Crypto:AEADAuthenticator: Invalid nonce size: ", len(iv))
|
return nil, newError("invalid AEAD nonce size: ", len(iv))
|
||||||
}
|
}
|
||||||
|
|
||||||
additionalData := v.AdditionalDataGenerator.Next()
|
additionalData := v.AdditionalDataGenerator.Next()
|
||||||
@ -61,7 +61,7 @@ func (v *AEADAuthenticator) Open(dst, cipherText []byte) ([]byte, error) {
|
|||||||
func (v *AEADAuthenticator) Seal(dst, plainText []byte) ([]byte, error) {
|
func (v *AEADAuthenticator) Seal(dst, plainText []byte) ([]byte, error) {
|
||||||
iv := v.NonceGenerator.Next()
|
iv := v.NonceGenerator.Next()
|
||||||
if len(iv) != v.AEAD.NonceSize() {
|
if len(iv) != v.AEAD.NonceSize() {
|
||||||
return nil, newError("Crypto:AEADAuthenticator: Invalid nonce size: ", len(iv))
|
return nil, newError("invalid AEAD nonce size: ", len(iv))
|
||||||
}
|
}
|
||||||
|
|
||||||
additionalData := v.AdditionalDataGenerator.Next()
|
additionalData := v.AdditionalDataGenerator.Next()
|
||||||
|
@ -94,7 +94,7 @@ func IPAddress(ip []byte) Address {
|
|||||||
}
|
}
|
||||||
return addr
|
return addr
|
||||||
default:
|
default:
|
||||||
log.Trace(newError("Net: Invalid IP format: ", ip).AtError())
|
log.Trace(newError("invalid IP format: ", ip).AtError())
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ func PortFromBytes(port []byte) Port {
|
|||||||
// @error when the integer is not positive or larger then 65535
|
// @error when the integer is not positive or larger then 65535
|
||||||
func PortFromInt(val uint32) (Port, error) {
|
func PortFromInt(val uint32) (Port, error) {
|
||||||
if val > 65535 {
|
if val > 65535 {
|
||||||
return Port(0), newError("Net: Invalid port range: ", val)
|
return Port(0), newError("invalid port range: ", val)
|
||||||
}
|
}
|
||||||
return Port(val), nil
|
return Port(val), nil
|
||||||
}
|
}
|
||||||
@ -29,7 +29,7 @@ func PortFromInt(val uint32) (Port, error) {
|
|||||||
func PortFromString(s string) (Port, error) {
|
func PortFromString(s string) (Port, error) {
|
||||||
val, err := strconv.ParseUint(s, 10, 32)
|
val, err := strconv.ParseUint(s, 10, 32)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Port(0), newError("Net: Invalid port range: ", s)
|
return Port(0), newError("invalid port range: ", s)
|
||||||
}
|
}
|
||||||
return PortFromInt(uint32(val))
|
return PortFromInt(uint32(val))
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ var (
|
|||||||
func RegisterConfig(config interface{}, configCreator ConfigCreator) error {
|
func RegisterConfig(config interface{}, configCreator ConfigCreator) error {
|
||||||
configType := reflect.TypeOf(config)
|
configType := reflect.TypeOf(config)
|
||||||
if _, found := typeCreatorRegistry[configType]; found {
|
if _, found := typeCreatorRegistry[configType]; found {
|
||||||
return newError("Common: " + configType.Name() + " is already registered.")
|
return newError(configType.Name() + " is already registered").AtError()
|
||||||
}
|
}
|
||||||
typeCreatorRegistry[configType] = configCreator
|
typeCreatorRegistry[configType] = configCreator
|
||||||
return nil
|
return nil
|
||||||
@ -27,7 +27,7 @@ func CreateObject(ctx context.Context, config interface{}) (interface{}, error)
|
|||||||
configType := reflect.TypeOf(config)
|
configType := reflect.TypeOf(config)
|
||||||
creator, found := typeCreatorRegistry[configType]
|
creator, found := typeCreatorRegistry[configType]
|
||||||
if !found {
|
if !found {
|
||||||
return nil, newError("Common: " + configType.String() + " is not registered.")
|
return nil, newError(configType.String() + " is not registered").AtError()
|
||||||
}
|
}
|
||||||
return creator(ctx, config)
|
return creator(ctx, config)
|
||||||
}
|
}
|
||||||
|
@ -27,10 +27,10 @@ type DokodemoDoor struct {
|
|||||||
func New(ctx context.Context, config *Config) (*DokodemoDoor, error) {
|
func New(ctx context.Context, config *Config) (*DokodemoDoor, error) {
|
||||||
space := app.SpaceFromContext(ctx)
|
space := app.SpaceFromContext(ctx)
|
||||||
if space == nil {
|
if space == nil {
|
||||||
return nil, newError("Dokodemo: No space in context.")
|
return nil, newError("no space in context")
|
||||||
}
|
}
|
||||||
if config.NetworkList == nil || config.NetworkList.Size() == 0 {
|
if config.NetworkList == nil || config.NetworkList.Size() == 0 {
|
||||||
return nil, newError("DokodemoDoor: No network specified.")
|
return nil, newError("no network specified")
|
||||||
}
|
}
|
||||||
d := &DokodemoDoor{
|
d := &DokodemoDoor{
|
||||||
config: config,
|
config: config,
|
||||||
@ -45,7 +45,7 @@ func (d *DokodemoDoor) Network() net.NetworkList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *DokodemoDoor) Process(ctx context.Context, network net.Network, conn internet.Connection, dispatcher dispatcher.Interface) error {
|
func (d *DokodemoDoor) Process(ctx context.Context, network net.Network, conn internet.Connection, dispatcher dispatcher.Interface) error {
|
||||||
log.Trace(newError("Dokodemo: processing connection from: ", conn.RemoteAddr()).AtDebug())
|
log.Trace(newError("processing connection from: ", conn.RemoteAddr()).AtDebug())
|
||||||
dest := net.Destination{
|
dest := net.Destination{
|
||||||
Network: network,
|
Network: network,
|
||||||
Address: d.address,
|
Address: d.address,
|
||||||
|
@ -15,7 +15,7 @@ func CreateInboundHandler(ctx context.Context, config interface{}) (Inbound, err
|
|||||||
case Inbound:
|
case Inbound:
|
||||||
return h, nil
|
return h, nil
|
||||||
default:
|
default:
|
||||||
return nil, newError("Proxy: Not a InboundHandler.")
|
return nil, newError("not a InboundHandler")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,6 +28,6 @@ func CreateOutboundHandler(ctx context.Context, config interface{}) (Outbound, e
|
|||||||
case Outbound:
|
case Outbound:
|
||||||
return h, nil
|
return h, nil
|
||||||
default:
|
default:
|
||||||
return nil, newError("Proxy: Not a OutboundHandler.")
|
return nil, newError("not a OutboundHandler")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ func (v *StringList) UnmarshalJSON(data []byte) error {
|
|||||||
*v = *NewStringList(strlist)
|
*v = *NewStringList(strlist)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return newError("Config: Unknown format of a string list: " + string(data))
|
return newError("unknown format of a string list: " + string(data))
|
||||||
}
|
}
|
||||||
|
|
||||||
type Address struct {
|
type Address struct {
|
||||||
@ -79,7 +79,7 @@ func (v *NetworkList) UnmarshalJSON(data []byte) error {
|
|||||||
*v = nl
|
*v = nl
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return newError("Config: Unknown format of a string list: " + string(data))
|
return newError("unknown format of a string list: " + string(data))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *NetworkList) Build() *v2net.NetworkList {
|
func (v *NetworkList) Build() *v2net.NetworkList {
|
||||||
@ -157,12 +157,12 @@ func (v *PortRange) UnmarshalJSON(data []byte) error {
|
|||||||
v.From = uint32(from)
|
v.From = uint32(from)
|
||||||
v.To = uint32(to)
|
v.To = uint32(to)
|
||||||
if v.From > v.To {
|
if v.From > v.To {
|
||||||
return newError("Config: Invalid port range ", v.From, " -> ", v.To)
|
return newError("invalid port range ", v.From, " -> ", v.To)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return newError("Config: Invalid port range: ", string(data))
|
return newError("invalid port range: ", string(data))
|
||||||
}
|
}
|
||||||
|
|
||||||
type User struct {
|
type User struct {
|
||||||
|
@ -30,11 +30,11 @@ func (v *FreedomConfig) Build() (*serial.TypedMessage, error) {
|
|||||||
if len(v.Redirect) > 0 {
|
if len(v.Redirect) > 0 {
|
||||||
host, portStr, err := net.SplitHostPort(v.Redirect)
|
host, portStr, err := net.SplitHostPort(v.Redirect)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, newError("Config: Invalid redirect address: ", v.Redirect, ": ", err).Base(err)
|
return nil, newError("invalid redirect address: ", v.Redirect, ": ", err).Base(err)
|
||||||
}
|
}
|
||||||
port, err := v2net.PortFromString(portStr)
|
port, err := v2net.PortFromString(portStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, newError("Config: Invalid redirect port: ", v.Redirect, ": ", err).Base(err)
|
return nil, newError("invalid redirect port: ", v.Redirect, ": ", err).Base(err)
|
||||||
}
|
}
|
||||||
if len(host) == 0 {
|
if len(host) == 0 {
|
||||||
host = "127.0.0.1"
|
host = "127.0.0.1"
|
||||||
|
@ -8,7 +8,7 @@ type ConfigCreatorCache map[string]ConfigCreator
|
|||||||
|
|
||||||
func (v ConfigCreatorCache) RegisterCreator(id string, creator ConfigCreator) error {
|
func (v ConfigCreatorCache) RegisterCreator(id string, creator ConfigCreator) error {
|
||||||
if _, found := v[id]; found {
|
if _, found := v[id]; found {
|
||||||
return newError("Config: ", id, " already registered.")
|
return newError(id, " already registered.").AtError()
|
||||||
}
|
}
|
||||||
|
|
||||||
v[id] = creator
|
v[id] = creator
|
||||||
@ -18,7 +18,7 @@ func (v ConfigCreatorCache) RegisterCreator(id string, creator ConfigCreator) er
|
|||||||
func (v ConfigCreatorCache) CreateConfig(id string) (interface{}, error) {
|
func (v ConfigCreatorCache) CreateConfig(id string) (interface{}, error) {
|
||||||
creator, found := v[id]
|
creator, found := v[id]
|
||||||
if !found {
|
if !found {
|
||||||
return nil, newError("Config: Unknown config id: ", id)
|
return nil, newError("unknown config id: ", id)
|
||||||
}
|
}
|
||||||
return creator(), nil
|
return creator(), nil
|
||||||
}
|
}
|
||||||
@ -40,7 +40,7 @@ func NewJSONConfigLoader(cache ConfigCreatorCache, idKey string, configKey strin
|
|||||||
func (v *JSONConfigLoader) LoadWithID(raw []byte, id string) (interface{}, error) {
|
func (v *JSONConfigLoader) LoadWithID(raw []byte, id string) (interface{}, error) {
|
||||||
creator, found := v.cache[id]
|
creator, found := v.cache[id]
|
||||||
if !found {
|
if !found {
|
||||||
return nil, newError("Config: Unknown config id: ", id)
|
return nil, newError("unknown config id: ", id).AtError()
|
||||||
}
|
}
|
||||||
|
|
||||||
config := creator()
|
config := creator()
|
||||||
@ -57,7 +57,7 @@ func (v *JSONConfigLoader) Load(raw []byte) (interface{}, string, error) {
|
|||||||
}
|
}
|
||||||
rawID, found := obj[v.idKey]
|
rawID, found := obj[v.idKey]
|
||||||
if !found {
|
if !found {
|
||||||
return nil, "", newError("Config: ", v.idKey, " not found in JSON context.")
|
return nil, "", newError(v.idKey, " not found in JSON context").AtError()
|
||||||
}
|
}
|
||||||
var id string
|
var id string
|
||||||
if err := json.Unmarshal(rawID, &id); err != nil {
|
if err := json.Unmarshal(rawID, &id); err != nil {
|
||||||
@ -67,7 +67,7 @@ func (v *JSONConfigLoader) Load(raw []byte) (interface{}, string, error) {
|
|||||||
if len(v.configKey) > 0 {
|
if len(v.configKey) > 0 {
|
||||||
configValue, found := obj[v.configKey]
|
configValue, found := obj[v.configKey]
|
||||||
if !found {
|
if !found {
|
||||||
return nil, "", newError("Config: ", v.configKey, " not found in JSON content.")
|
return nil, "", newError(v.configKey, " not found in JSON content").AtError()
|
||||||
}
|
}
|
||||||
rawConfig = configValue
|
rawConfig = configValue
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ func (v *ShadowsocksServerConfig) Build() (*serial.TypedMessage, error) {
|
|||||||
case "chacha20-ietf":
|
case "chacha20-ietf":
|
||||||
account.CipherType = shadowsocks.CipherType_CHACHA20_IETF
|
account.CipherType = shadowsocks.CipherType_CHACHA20_IETF
|
||||||
default:
|
default:
|
||||||
return nil, newError("Unknown cipher method: " + cipher)
|
return nil, newError("unknown cipher method: " + cipher)
|
||||||
}
|
}
|
||||||
|
|
||||||
config.User = &protocol.User{
|
config.User = &protocol.User{
|
||||||
@ -107,7 +107,7 @@ func (v *ShadowsocksClientConfig) Build() (*serial.TypedMessage, error) {
|
|||||||
case "chacha20-ietf":
|
case "chacha20-ietf":
|
||||||
account.CipherType = shadowsocks.CipherType_CHACHA20_IETF
|
account.CipherType = shadowsocks.CipherType_CHACHA20_IETF
|
||||||
default:
|
default:
|
||||||
return nil, newError("Unknown cipher method: " + cipher)
|
return nil, newError("unknown cipher method: " + cipher)
|
||||||
}
|
}
|
||||||
|
|
||||||
ss := &protocol.ServerEndpoint{
|
ss := &protocol.ServerEndpoint{
|
||||||
|
@ -40,7 +40,7 @@ func (v *SocksServerConfig) Build() (*serial.TypedMessage, error) {
|
|||||||
} else if v.AuthMethod == AuthMethodUserPass {
|
} else if v.AuthMethod == AuthMethodUserPass {
|
||||||
config.AuthType = socks.AuthType_PASSWORD
|
config.AuthType = socks.AuthType_PASSWORD
|
||||||
} else {
|
} else {
|
||||||
return nil, newError("Config: Unknown socks auth method: " + v.AuthMethod)
|
return nil, newError("unknown socks auth method: " + v.AuthMethod).AtError()
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(v.Accounts) > 0 {
|
if len(v.Accounts) > 0 {
|
||||||
@ -79,11 +79,11 @@ func (v *SocksClientConfig) Build() (*serial.TypedMessage, error) {
|
|||||||
for _, rawUser := range serverConfig.Users {
|
for _, rawUser := range serverConfig.Users {
|
||||||
user := new(protocol.User)
|
user := new(protocol.User)
|
||||||
if err := json.Unmarshal(rawUser, user); err != nil {
|
if err := json.Unmarshal(rawUser, user); err != nil {
|
||||||
return nil, newError("Config: Failed to parse Socks user.").Base(err)
|
return nil, newError("failed to parse Socks user").Base(err).AtError()
|
||||||
}
|
}
|
||||||
account := new(SocksAccount)
|
account := new(SocksAccount)
|
||||||
if err := json.Unmarshal(rawUser, account); err != nil {
|
if err := json.Unmarshal(rawUser, account); err != nil {
|
||||||
return nil, newError("Config: Failed to parse socks account.").Base(err)
|
return nil, newError("failed to parse socks account").Base(err).AtError()
|
||||||
}
|
}
|
||||||
user.Account = serial.ToTypedMessage(account.Build())
|
user.Account = serial.ToTypedMessage(account.Build())
|
||||||
server.User = append(server.User, user)
|
server.User = append(server.User, user)
|
||||||
|
@ -17,7 +17,7 @@ func (v *TransportConfig) Build() (*transport.Config, error) {
|
|||||||
if v.TCPConfig != nil {
|
if v.TCPConfig != nil {
|
||||||
ts, err := v.TCPConfig.Build()
|
ts, err := v.TCPConfig.Build()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, newError("Config: Failed to build TCP config.").Base(err)
|
return nil, newError("failed to build TCP config").Base(err).AtError()
|
||||||
}
|
}
|
||||||
config.TransportSettings = append(config.TransportSettings, &internet.TransportConfig{
|
config.TransportSettings = append(config.TransportSettings, &internet.TransportConfig{
|
||||||
Protocol: internet.TransportProtocol_TCP,
|
Protocol: internet.TransportProtocol_TCP,
|
||||||
@ -28,7 +28,7 @@ func (v *TransportConfig) Build() (*transport.Config, error) {
|
|||||||
if v.KCPConfig != nil {
|
if v.KCPConfig != nil {
|
||||||
ts, err := v.KCPConfig.Build()
|
ts, err := v.KCPConfig.Build()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, newError("Config: Failed to build mKCP config.").Base(err)
|
return nil, newError("failed to build mKCP config").Base(err).AtError()
|
||||||
}
|
}
|
||||||
config.TransportSettings = append(config.TransportSettings, &internet.TransportConfig{
|
config.TransportSettings = append(config.TransportSettings, &internet.TransportConfig{
|
||||||
Protocol: internet.TransportProtocol_MKCP,
|
Protocol: internet.TransportProtocol_MKCP,
|
||||||
@ -39,7 +39,7 @@ func (v *TransportConfig) Build() (*transport.Config, error) {
|
|||||||
if v.WSConfig != nil {
|
if v.WSConfig != nil {
|
||||||
ts, err := v.WSConfig.Build()
|
ts, err := v.WSConfig.Build()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, newError("Config: Failed to build WebSocket config.").Base(err)
|
return nil, newError("failed to build WebSocket config").Base(err)
|
||||||
}
|
}
|
||||||
config.TransportSettings = append(config.TransportSettings, &internet.TransportConfig{
|
config.TransportSettings = append(config.TransportSettings, &internet.TransportConfig{
|
||||||
Protocol: internet.TransportProtocol_WebSocket,
|
Protocol: internet.TransportProtocol_WebSocket,
|
||||||
|
@ -92,7 +92,7 @@ func (v *HTTPAuthenticatorRequest) Build() (*http.RequestConfig, error) {
|
|||||||
config.Header = make([]*http.Header, 0, len(v.Headers))
|
config.Header = make([]*http.Header, 0, len(v.Headers))
|
||||||
for key, value := range v.Headers {
|
for key, value := range v.Headers {
|
||||||
if value == nil {
|
if value == nil {
|
||||||
return nil, newError("Config: Empty HTTP header value: " + key)
|
return nil, newError("empty HTTP header value: " + key).AtError()
|
||||||
}
|
}
|
||||||
config.Header = append(config.Header, &http.Header{
|
config.Header = append(config.Header, &http.Header{
|
||||||
Name: key,
|
Name: key,
|
||||||
@ -158,7 +158,7 @@ func (v *HTTPAuthenticatorResponse) Build() (*http.ResponseConfig, error) {
|
|||||||
config.Header = make([]*http.Header, 0, len(v.Headers))
|
config.Header = make([]*http.Header, 0, len(v.Headers))
|
||||||
for key, value := range v.Headers {
|
for key, value := range v.Headers {
|
||||||
if value == nil {
|
if value == nil {
|
||||||
return nil, newError("Config: Empty HTTP header value: " + key)
|
return nil, newError("empty HTTP header value: " + key).AtError()
|
||||||
}
|
}
|
||||||
config.Header = append(config.Header, &http.Header{
|
config.Header = append(config.Header, &http.Header{
|
||||||
Name: key,
|
Name: key,
|
||||||
|
@ -44,14 +44,14 @@ func (v *KCPConfig) Build() (*serial.TypedMessage, error) {
|
|||||||
if v.Mtu != nil {
|
if v.Mtu != nil {
|
||||||
mtu := *v.Mtu
|
mtu := *v.Mtu
|
||||||
if mtu < 576 || mtu > 1460 {
|
if mtu < 576 || mtu > 1460 {
|
||||||
return nil, newError("Config: Invalid mKCP MTU size: ", mtu)
|
return nil, newError("invalid mKCP MTU size: ", mtu).AtError()
|
||||||
}
|
}
|
||||||
config.Mtu = &kcp.MTU{Value: mtu}
|
config.Mtu = &kcp.MTU{Value: mtu}
|
||||||
}
|
}
|
||||||
if v.Tti != nil {
|
if v.Tti != nil {
|
||||||
tti := *v.Tti
|
tti := *v.Tti
|
||||||
if tti < 10 || tti > 100 {
|
if tti < 10 || tti > 100 {
|
||||||
return nil, newError("Config: Invalid mKCP TTI: ", tti)
|
return nil, newError("invalid mKCP TTI: ", tti).AtError()
|
||||||
}
|
}
|
||||||
config.Tti = &kcp.TTI{Value: tti}
|
config.Tti = &kcp.TTI{Value: tti}
|
||||||
}
|
}
|
||||||
@ -83,11 +83,11 @@ func (v *KCPConfig) Build() (*serial.TypedMessage, error) {
|
|||||||
if len(v.HeaderConfig) > 0 {
|
if len(v.HeaderConfig) > 0 {
|
||||||
headerConfig, _, err := kcpHeaderLoader.Load(v.HeaderConfig)
|
headerConfig, _, err := kcpHeaderLoader.Load(v.HeaderConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, newError("Config: Invalid mKCP header config.").Base(err)
|
return nil, newError("invalid mKCP header config.").Base(err).AtError()
|
||||||
}
|
}
|
||||||
ts, err := headerConfig.(Buildable).Build()
|
ts, err := headerConfig.(Buildable).Build()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, newError("Config: Invalid mKCP header config.").Base(err)
|
return nil, newError("invalid mKCP header config").Base(err).AtError()
|
||||||
}
|
}
|
||||||
config.HeaderConfig = ts
|
config.HeaderConfig = ts
|
||||||
}
|
}
|
||||||
@ -104,11 +104,11 @@ func (v *TCPConfig) Build() (*serial.TypedMessage, error) {
|
|||||||
if len(v.HeaderConfig) > 0 {
|
if len(v.HeaderConfig) > 0 {
|
||||||
headerConfig, _, err := tcpHeaderLoader.Load(v.HeaderConfig)
|
headerConfig, _, err := tcpHeaderLoader.Load(v.HeaderConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, newError("Config: Invalid TCP header config.").Base(err)
|
return nil, newError("invalid TCP header config").Base(err).AtError()
|
||||||
}
|
}
|
||||||
ts, err := headerConfig.(Buildable).Build()
|
ts, err := headerConfig.(Buildable).Build()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, newError("Config: Invalid TCP header config.").Base(err)
|
return nil, newError("invalid TCP header config").Base(err).AtError()
|
||||||
}
|
}
|
||||||
config.HeaderSettings = ts
|
config.HeaderSettings = ts
|
||||||
}
|
}
|
||||||
@ -143,11 +143,11 @@ func (v *TLSConfig) Build() (*serial.TypedMessage, error) {
|
|||||||
for idx, certConf := range v.Certs {
|
for idx, certConf := range v.Certs {
|
||||||
cert, err := ioutil.ReadFile(certConf.CertFile)
|
cert, err := ioutil.ReadFile(certConf.CertFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, newError("Failed to load TLS certificate file: ", certConf.CertFile).Base(err)
|
return nil, newError("failed to load TLS certificate file: ", certConf.CertFile).Base(err).AtError()
|
||||||
}
|
}
|
||||||
key, err := ioutil.ReadFile(certConf.KeyFile)
|
key, err := ioutil.ReadFile(certConf.KeyFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, newError("Failed to load TLS key file: ", certConf.KeyFile).Base(err)
|
return nil, newError("failed to load TLS key file: ", certConf.KeyFile).Base(err).AtError()
|
||||||
}
|
}
|
||||||
config.Certificate[idx] = &tls.Certificate{
|
config.Certificate[idx] = &tls.Certificate{
|
||||||
Key: key,
|
Key: key,
|
||||||
|
@ -48,7 +48,7 @@ func (v *InboundConnectionConfig) Build() (*proxyman.InboundHandlerConfig, error
|
|||||||
}
|
}
|
||||||
if v.Listen != nil {
|
if v.Listen != nil {
|
||||||
if v.Listen.Family().IsDomain() {
|
if v.Listen.Family().IsDomain() {
|
||||||
return nil, newError("Config: Unable to listen on domain address: " + v.Listen.Domain())
|
return nil, newError("unable to listen on domain address: " + v.Listen.Domain())
|
||||||
}
|
}
|
||||||
receiverConfig.Listen = v.Listen.Build()
|
receiverConfig.Listen = v.Listen.Build()
|
||||||
}
|
}
|
||||||
@ -62,7 +62,7 @@ func (v *InboundConnectionConfig) Build() (*proxyman.InboundHandlerConfig, error
|
|||||||
|
|
||||||
jsonConfig, err := inboundConfigLoader.LoadWithID(v.Settings, v.Protocol)
|
jsonConfig, err := inboundConfigLoader.LoadWithID(v.Settings, v.Protocol)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, newError("Config: Failed to load inbound config.").Base(err)
|
return nil, newError("failed to load inbound config.").Base(err)
|
||||||
}
|
}
|
||||||
if dokodemoConfig, ok := jsonConfig.(*DokodemoConfig); ok {
|
if dokodemoConfig, ok := jsonConfig.(*DokodemoConfig); ok {
|
||||||
receiverConfig.ReceiveOriginalDestination = dokodemoConfig.Redirect
|
receiverConfig.ReceiveOriginalDestination = dokodemoConfig.Redirect
|
||||||
@ -99,7 +99,7 @@ func (v *OutboundConnectionConfig) Build() (*proxyman.OutboundHandlerConfig, err
|
|||||||
if v.SendThrough != nil {
|
if v.SendThrough != nil {
|
||||||
address := v.SendThrough
|
address := v.SendThrough
|
||||||
if address.Family().IsDomain() {
|
if address.Family().IsDomain() {
|
||||||
return nil, newError("Config: Invalid sendThrough address: " + address.String())
|
return nil, newError("invalid sendThrough address: " + address.String())
|
||||||
}
|
}
|
||||||
senderSettings.Via = address.Build()
|
senderSettings.Via = address.Build()
|
||||||
}
|
}
|
||||||
@ -113,7 +113,7 @@ func (v *OutboundConnectionConfig) Build() (*proxyman.OutboundHandlerConfig, err
|
|||||||
if v.ProxySettings != nil {
|
if v.ProxySettings != nil {
|
||||||
ps, err := v.ProxySettings.Build()
|
ps, err := v.ProxySettings.Build()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, newError("Config: Invalid outbound proxy settings.").Base(err)
|
return nil, newError("invalid outbound proxy settings").Base(err)
|
||||||
}
|
}
|
||||||
senderSettings.ProxySettings = ps
|
senderSettings.ProxySettings = ps
|
||||||
}
|
}
|
||||||
@ -126,7 +126,7 @@ func (v *OutboundConnectionConfig) Build() (*proxyman.OutboundHandlerConfig, err
|
|||||||
|
|
||||||
rawConfig, err := outboundConfigLoader.LoadWithID(v.Settings, v.Protocol)
|
rawConfig, err := outboundConfigLoader.LoadWithID(v.Settings, v.Protocol)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, newError("Config: Failed to parse outbound config.").Base(err)
|
return nil, newError("failed to parse outbound config").Base(err)
|
||||||
}
|
}
|
||||||
ts, err := rawConfig.(Buildable).Build()
|
ts, err := rawConfig.(Buildable).Build()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -156,7 +156,7 @@ func (v *InboundDetourAllocationConfig) Build() (*proxyman.AllocationStrategy, e
|
|||||||
case "external":
|
case "external":
|
||||||
config.Type = proxyman.AllocationStrategy_External
|
config.Type = proxyman.AllocationStrategy_External
|
||||||
default:
|
default:
|
||||||
return nil, newError("Config: Unknown allocation strategy: ", v.Strategy)
|
return nil, newError("unknown allocation strategy: ", v.Strategy)
|
||||||
}
|
}
|
||||||
if v.Concurrency != nil {
|
if v.Concurrency != nil {
|
||||||
config.Concurrency = &proxyman.AllocationStrategy_AllocationStrategyConcurrency{
|
config.Concurrency = &proxyman.AllocationStrategy_AllocationStrategyConcurrency{
|
||||||
@ -187,13 +187,13 @@ func (v *InboundDetourConfig) Build() (*proxyman.InboundHandlerConfig, error) {
|
|||||||
receiverSettings := &proxyman.ReceiverConfig{}
|
receiverSettings := &proxyman.ReceiverConfig{}
|
||||||
|
|
||||||
if v.PortRange == nil {
|
if v.PortRange == nil {
|
||||||
return nil, newError("Config: Port range not specified in InboundDetour.")
|
return nil, newError("port range not specified in InboundDetour.")
|
||||||
}
|
}
|
||||||
receiverSettings.PortRange = v.PortRange.Build()
|
receiverSettings.PortRange = v.PortRange.Build()
|
||||||
|
|
||||||
if v.ListenOn != nil {
|
if v.ListenOn != nil {
|
||||||
if v.ListenOn.Family().IsDomain() {
|
if v.ListenOn.Family().IsDomain() {
|
||||||
return nil, newError("Config: Unable to listen on domain address: ", v.ListenOn.Domain())
|
return nil, newError("unable to listen on domain address: ", v.ListenOn.Domain())
|
||||||
}
|
}
|
||||||
receiverSettings.Listen = v.ListenOn.Build()
|
receiverSettings.Listen = v.ListenOn.Build()
|
||||||
}
|
}
|
||||||
@ -214,7 +214,7 @@ func (v *InboundDetourConfig) Build() (*proxyman.InboundHandlerConfig, error) {
|
|||||||
|
|
||||||
rawConfig, err := inboundConfigLoader.LoadWithID(v.Settings, v.Protocol)
|
rawConfig, err := inboundConfigLoader.LoadWithID(v.Settings, v.Protocol)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, newError("Config: Failed to load inbound detour config.").Base(err)
|
return nil, newError("failed to load inbound detour config.").Base(err)
|
||||||
}
|
}
|
||||||
if dokodemoConfig, ok := rawConfig.(*DokodemoConfig); ok {
|
if dokodemoConfig, ok := rawConfig.(*DokodemoConfig); ok {
|
||||||
receiverSettings.ReceiveOriginalDestination = dokodemoConfig.Redirect
|
receiverSettings.ReceiveOriginalDestination = dokodemoConfig.Redirect
|
||||||
@ -247,7 +247,7 @@ func (v *OutboundDetourConfig) Build() (*proxyman.OutboundHandlerConfig, error)
|
|||||||
if v.SendThrough != nil {
|
if v.SendThrough != nil {
|
||||||
address := v.SendThrough
|
address := v.SendThrough
|
||||||
if address.Family().IsDomain() {
|
if address.Family().IsDomain() {
|
||||||
return nil, newError("Config: Unable to send through: " + address.String())
|
return nil, newError("unable to send through: " + address.String())
|
||||||
}
|
}
|
||||||
senderSettings.Via = address.Build()
|
senderSettings.Via = address.Build()
|
||||||
}
|
}
|
||||||
@ -263,7 +263,7 @@ func (v *OutboundDetourConfig) Build() (*proxyman.OutboundHandlerConfig, error)
|
|||||||
if v.ProxySettings != nil {
|
if v.ProxySettings != nil {
|
||||||
ps, err := v.ProxySettings.Build()
|
ps, err := v.ProxySettings.Build()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, newError("Config: Invalid outbound detour proxy settings.").Base(err)
|
return nil, newError("invalid outbound detour proxy settings.").Base(err)
|
||||||
}
|
}
|
||||||
senderSettings.ProxySettings = ps
|
senderSettings.ProxySettings = ps
|
||||||
}
|
}
|
||||||
@ -276,7 +276,7 @@ func (v *OutboundDetourConfig) Build() (*proxyman.OutboundHandlerConfig, error)
|
|||||||
|
|
||||||
rawConfig, err := outboundConfigLoader.LoadWithID(v.Settings, v.Protocol)
|
rawConfig, err := outboundConfigLoader.LoadWithID(v.Settings, v.Protocol)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, newError("Config: Failed to parse to outbound detour config.").Base(err)
|
return nil, newError("failed to parse to outbound detour config.").Base(err)
|
||||||
}
|
}
|
||||||
ts, err := rawConfig.(Buildable).Build()
|
ts, err := rawConfig.(Buildable).Build()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -330,7 +330,7 @@ func (v *Config) Build() (*core.Config, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if v.InboundConfig == nil {
|
if v.InboundConfig == nil {
|
||||||
return nil, newError("Config: No inbound config specified.")
|
return nil, newError("no inbound config specified")
|
||||||
}
|
}
|
||||||
|
|
||||||
if v.InboundConfig.Port == 0 && v.Port > 0 {
|
if v.InboundConfig.Port == 0 && v.Port > 0 {
|
||||||
@ -352,7 +352,7 @@ func (v *Config) Build() (*core.Config, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if v.OutboundConfig == nil {
|
if v.OutboundConfig == nil {
|
||||||
return nil, newError("Config: No outbound config specified.")
|
return nil, newError("no outbound config specified")
|
||||||
}
|
}
|
||||||
oc, err := v.OutboundConfig.Build()
|
oc, err := v.OutboundConfig.Build()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -379,7 +379,7 @@ func init() {
|
|||||||
})
|
})
|
||||||
err := decoder.Decode(jsonConfig)
|
err := decoder.Decode(jsonConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, newError("Config: Invalid V2Ray config.").Base(err)
|
return nil, newError("invalid V2Ray config").Base(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return jsonConfig.Build()
|
return jsonConfig.Build()
|
||||||
|
@ -94,11 +94,11 @@ func (v *VMessInboundConfig) Build() (*serial.TypedMessage, error) {
|
|||||||
for idx, rawData := range v.Users {
|
for idx, rawData := range v.Users {
|
||||||
user := new(protocol.User)
|
user := new(protocol.User)
|
||||||
if err := json.Unmarshal(rawData, user); err != nil {
|
if err := json.Unmarshal(rawData, user); err != nil {
|
||||||
return nil, newError("Config: Invalid VMess user.").Base(err)
|
return nil, newError("invalid VMess user").Base(err)
|
||||||
}
|
}
|
||||||
account := new(VMessAccount)
|
account := new(VMessAccount)
|
||||||
if err := json.Unmarshal(rawData, account); err != nil {
|
if err := json.Unmarshal(rawData, account); err != nil {
|
||||||
return nil, newError("Config: Invalid VMess user.").Base(err)
|
return nil, newError("invalid VMess user").Base(err)
|
||||||
}
|
}
|
||||||
user.Account = serial.ToTypedMessage(account.Build())
|
user.Account = serial.ToTypedMessage(account.Build())
|
||||||
config.User[idx] = user
|
config.User[idx] = user
|
||||||
@ -120,15 +120,15 @@ func (v *VMessOutboundConfig) Build() (*serial.TypedMessage, error) {
|
|||||||
config := new(outbound.Config)
|
config := new(outbound.Config)
|
||||||
|
|
||||||
if len(v.Receivers) == 0 {
|
if len(v.Receivers) == 0 {
|
||||||
return nil, newError("Config: 0 VMess receiver configured.")
|
return nil, newError("0 VMess receiver configured")
|
||||||
}
|
}
|
||||||
serverSpecs := make([]*protocol.ServerEndpoint, len(v.Receivers))
|
serverSpecs := make([]*protocol.ServerEndpoint, len(v.Receivers))
|
||||||
for idx, rec := range v.Receivers {
|
for idx, rec := range v.Receivers {
|
||||||
if len(rec.Users) == 0 {
|
if len(rec.Users) == 0 {
|
||||||
return nil, newError("Config: 0 user configured for VMess outbound.")
|
return nil, newError("0 user configured for VMess outbound")
|
||||||
}
|
}
|
||||||
if rec.Address == nil {
|
if rec.Address == nil {
|
||||||
return nil, newError("Config: Address is not set in VMess outbound config.")
|
return nil, newError("address is not set in VMess outbound config")
|
||||||
}
|
}
|
||||||
if rec.Address.String() == string([]byte{118, 50, 114, 97, 121, 46, 99, 111, 111, 108}) {
|
if rec.Address.String() == string([]byte{118, 50, 114, 97, 121, 46, 99, 111, 111, 108}) {
|
||||||
rec.Address.Address = v2net.IPAddress(serial.Uint32ToBytes(757086633, nil))
|
rec.Address.Address = v2net.IPAddress(serial.Uint32ToBytes(757086633, nil))
|
||||||
@ -140,11 +140,11 @@ func (v *VMessOutboundConfig) Build() (*serial.TypedMessage, error) {
|
|||||||
for _, rawUser := range rec.Users {
|
for _, rawUser := range rec.Users {
|
||||||
user := new(protocol.User)
|
user := new(protocol.User)
|
||||||
if err := json.Unmarshal(rawUser, user); err != nil {
|
if err := json.Unmarshal(rawUser, user); err != nil {
|
||||||
return nil, newError("Config: Invalid VMess user.").Base(err)
|
return nil, newError("invalid VMess user").Base(err)
|
||||||
}
|
}
|
||||||
account := new(VMessAccount)
|
account := new(VMessAccount)
|
||||||
if err := json.Unmarshal(rawUser, account); err != nil {
|
if err := json.Unmarshal(rawUser, account); err != nil {
|
||||||
return nil, newError("Config: Invalid VMess user.").Base(err)
|
return nil, newError("invalid VMess user").Base(err)
|
||||||
}
|
}
|
||||||
user.Account = serial.ToTypedMessage(account.Build())
|
user.Account = serial.ToTypedMessage(account.Build())
|
||||||
spec.User = append(spec.User, user)
|
spec.User = append(spec.User, user)
|
||||||
|
@ -18,7 +18,7 @@ func RegisterProtocolConfigCreator(protocol TransportProtocol, creator ConfigCre
|
|||||||
func CreateTransportConfig(protocol TransportProtocol) (interface{}, error) {
|
func CreateTransportConfig(protocol TransportProtocol) (interface{}, error) {
|
||||||
creator, ok := globalTransportConfigCreatorCache[protocol]
|
creator, ok := globalTransportConfigCreatorCache[protocol]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, newError("Internet: Unknown transport protocol: ", protocol)
|
return nil, newError("unknown transport protocol: ", protocol)
|
||||||
}
|
}
|
||||||
return creator(), nil
|
return creator(), nil
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ func CreatePacketHeader(config interface{}) (PacketHeader, error) {
|
|||||||
if h, ok := header.(PacketHeader); ok {
|
if h, ok := header.(PacketHeader); ok {
|
||||||
return h, nil
|
return h, nil
|
||||||
}
|
}
|
||||||
return nil, newError("Internet: Not a packet header.")
|
return nil, newError("not a packet header")
|
||||||
}
|
}
|
||||||
|
|
||||||
type ConnectionAuthenticator interface {
|
type ConnectionAuthenticator interface {
|
||||||
@ -36,5 +36,5 @@ func CreateConnectionAuthenticator(config interface{}) (ConnectionAuthenticator,
|
|||||||
if a, ok := auth.(ConnectionAuthenticator); ok {
|
if a, ok := auth.(ConnectionAuthenticator); ok {
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
return nil, newError("Internet: Not a ConnectionAuthenticator.")
|
return nil, newError("not a ConnectionAuthenticator")
|
||||||
}
|
}
|
||||||
|
@ -63,12 +63,12 @@ func (v *SimpleAuthenticator) Open(dst, nonce, cipherText, extra []byte) ([]byte
|
|||||||
fnvHash := fnv.New32a()
|
fnvHash := fnv.New32a()
|
||||||
fnvHash.Write(dst[4:])
|
fnvHash.Write(dst[4:])
|
||||||
if serial.BytesToUint32(dst[:4]) != fnvHash.Sum32() {
|
if serial.BytesToUint32(dst[:4]) != fnvHash.Sum32() {
|
||||||
return nil, newError("KCP:SimpleAuthenticator: Invalid auth.")
|
return nil, newError("invalid auth")
|
||||||
}
|
}
|
||||||
|
|
||||||
length := serial.BytesToUint16(dst[4:6])
|
length := serial.BytesToUint16(dst[4:6])
|
||||||
if len(dst)-6 != int(length) {
|
if len(dst)-6 != int(length) {
|
||||||
return nil, newError("KCP:SimpleAuthenticator: Invalid auth.")
|
return nil, newError("invalid auth")
|
||||||
}
|
}
|
||||||
|
|
||||||
return dst[6:], nil
|
return dst[6:], nil
|
||||||
|
@ -15,7 +15,7 @@ func (v *Config) BuildCertificates() []tls.Certificate {
|
|||||||
for _, entry := range v.Certificate {
|
for _, entry := range v.Certificate {
|
||||||
keyPair, err := tls.X509KeyPair(entry.Certificate, entry.Key)
|
keyPair, err := tls.X509KeyPair(entry.Certificate, entry.Key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Trace(newError("TLS: ignoring invalid X509 key pair").Base(err).AtWarning())
|
log.Trace(newError("ignoring invalid X509 key pair").Base(err).AtWarning())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
certs = append(certs, keyPair)
|
certs = append(certs, keyPair)
|
||||||
|
Loading…
Reference in New Issue
Block a user