mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-04-30 09:18:34 +00:00
Improve configuration detector (cone or symmetric)
This commit is contained in:
parent
43eb5d1b25
commit
ee15cc253f
9 changed files with 47 additions and 30 deletions
30
core/xray.go
30
core/xray.go
|
@ -3,8 +3,13 @@ package core
|
|||
import (
|
||||
"context"
|
||||
"reflect"
|
||||
"runtime/debug"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/golang/protobuf/proto"
|
||||
|
||||
"github.com/xtls/xray-core/app/proxyman"
|
||||
"github.com/xtls/xray-core/common"
|
||||
"github.com/xtls/xray-core/common/serial"
|
||||
"github.com/xtls/xray-core/features"
|
||||
|
@ -179,6 +184,31 @@ func NewWithContext(ctx context.Context, config *Config) (*Instance, error) {
|
|||
}
|
||||
|
||||
func initInstanceWithConfig(config *Config, server *Instance) (bool, error) {
|
||||
cone := true
|
||||
v, t := false, false
|
||||
for _, outbound := range config.Outbound {
|
||||
s := strings.ToLower(outbound.ProxySettings.Type)
|
||||
l := len(s)
|
||||
if l >= 16 && s[11:16] == "vless" || l >= 16 && s[11:16] == "vmess" {
|
||||
v = true
|
||||
continue
|
||||
}
|
||||
if l >= 17 && s[11:17] == "trojan" || l >= 22 && s[11:22] == "shadowsocks" {
|
||||
t = true
|
||||
var m proxyman.SenderConfig
|
||||
proto.Unmarshal(outbound.SenderSettings.Value, &m)
|
||||
if m.MultiplexSettings != nil && m.MultiplexSettings.Enabled {
|
||||
cone = false
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
if v && !t {
|
||||
cone = false
|
||||
}
|
||||
server.ctx = context.WithValue(server.ctx, "cone", cone)
|
||||
defer debug.FreeOSMemory()
|
||||
|
||||
if config.Transport != nil {
|
||||
features.PrintDeprecatedFeatureWarning("global transport settings")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue