mirror of
https://github.com/XTLS/Xray-core.git
synced 2024-11-29 12:01:27 +00:00
Update common/xudp/xudp.go and common/mux/server.go
This commit is contained in:
parent
15cf31f30a
commit
76b27a37cb
|
@ -177,6 +177,9 @@ func (w *ServerWorker) handleStatusNew(ctx context.Context, meta *FrameMetadata,
|
||||||
// Actually, it won't return an error in Xray-core's implementations.
|
// Actually, it won't return an error in Xray-core's implementations.
|
||||||
link, err := w.dispatcher.Dispatch(ctx, meta.Target)
|
link, err := w.dispatcher.Dispatch(ctx, meta.Target)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
XUDPManager.Lock()
|
||||||
|
delete(XUDPManager.Map, x.GlobalID)
|
||||||
|
XUDPManager.Unlock()
|
||||||
err = newError("failed to dispatch request to ", meta.Target).Base(err)
|
err = newError("failed to dispatch request to ", meta.Target).Base(err)
|
||||||
if xudp.Show {
|
if xudp.Show {
|
||||||
fmt.Printf("XUDP new: %v err: %v\n", meta.GlobalID, err)
|
fmt.Printf("XUDP new: %v err: %v\n", meta.GlobalID, err)
|
||||||
|
|
|
@ -25,7 +25,7 @@ var AddrParser = protocol.NewAddressParser(
|
||||||
|
|
||||||
var (
|
var (
|
||||||
Show bool
|
Show bool
|
||||||
BaseKey [32]byte
|
BaseKey []byte
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -37,24 +37,24 @@ func init() {
|
||||||
if strings.ToLower(os.Getenv(EnvShow)) == "true" {
|
if strings.ToLower(os.Getenv(EnvShow)) == "true" {
|
||||||
Show = true
|
Show = true
|
||||||
}
|
}
|
||||||
if raw := os.Getenv(EnvBaseKey); raw != "" {
|
if raw, found := os.LookupEnv(EnvBaseKey); found {
|
||||||
if key, _ := base64.RawURLEncoding.DecodeString(raw); len(key) == len(BaseKey) {
|
if BaseKey, _ = base64.RawURLEncoding.DecodeString(raw); len(BaseKey) == 32 {
|
||||||
copy(BaseKey[:], key)
|
|
||||||
return
|
return
|
||||||
} else {
|
|
||||||
panic(EnvBaseKey + ": invalid value: " + raw)
|
|
||||||
}
|
}
|
||||||
|
panic(EnvBaseKey + ": invalid value: " + raw)
|
||||||
}
|
}
|
||||||
rand.Read(BaseKey[:])
|
rand.Read(BaseKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetGlobalID(ctx context.Context) (globalID [8]byte) {
|
func GetGlobalID(ctx context.Context) (globalID [8]byte) {
|
||||||
if inbound := session.InboundFromContext(ctx); inbound != nil && inbound.Source.Network == net.Network_UDP &&
|
if inbound := session.InboundFromContext(ctx); inbound != nil && inbound.Source.Network == net.Network_UDP &&
|
||||||
(inbound.Name == "dokodemo-door" || inbound.Name == "socks" || inbound.Name == "shadowsocks") {
|
(inbound.Name == "dokodemo-door" || inbound.Name == "socks" || inbound.Name == "shadowsocks") {
|
||||||
h := blake3.New(8, BaseKey[:])
|
h := blake3.New(8, BaseKey)
|
||||||
h.Write([]byte(inbound.Source.String()))
|
h.Write([]byte(inbound.Source.String()))
|
||||||
copy(globalID[:], h.Sum(nil))
|
copy(globalID[:], h.Sum(nil))
|
||||||
fmt.Printf("XUDP inbound.Source.String(): %v\tglobalID: %v\n", inbound.Source.String(), globalID)
|
if Show {
|
||||||
|
fmt.Printf("XUDP inbound.Source.String(): %v\tglobalID: %v\n", inbound.Source.String(), globalID)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue