mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-04-30 01:08:33 +00:00
Refactor: VLESS & VMess & Mux UDP FullCone NAT
https://t.me/projectXray/242770
This commit is contained in:
parent
523c416bb5
commit
1174ff3090
10 changed files with 186 additions and 39 deletions
32
core/xray.go
32
core/xray.go
|
@ -3,13 +3,8 @@ 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"
|
||||
|
@ -184,32 +179,7 @@ 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
|
||||
if outbound.SenderSettings != nil {
|
||||
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()
|
||||
server.ctx = context.WithValue(server.ctx, "cone", true)
|
||||
|
||||
if config.Transport != nil {
|
||||
features.PrintDeprecatedFeatureWarning("global transport settings")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue