mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-07-11 22:28:46 +00:00
refactor: use browserDialers URL array and dialerProxy URL matching
Agent-Logs-Url: https://github.com/XTLS/Xray-core/sessions/6ed9ad08-e0b0-43d4-878b-7fe355be5325 Co-authored-by: RPRX <63339210+RPRX@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
266ae17654
commit
7a9c592221
@@ -1972,12 +1972,12 @@ func (c *StreamConfig) Build() (*internet.StreamConfig, error) {
|
||||
config.ProtocolName = protocol
|
||||
}
|
||||
if c.SocketSettings != nil && c.SocketSettings.DialerProxy != "" {
|
||||
if _, ok := browser_dialer.GetAddressByTag(c.SocketSettings.DialerProxy); ok {
|
||||
if browser_dialer.HasConfiguredURL(c.SocketSettings.DialerProxy) {
|
||||
if config.ProtocolName != "websocket" && config.ProtocolName != "splithttp" {
|
||||
return nil, errors.New("dialerProxy tag ", c.SocketSettings.DialerProxy, " maps to browserDialers and only supports websocket or splithttp")
|
||||
return nil, errors.New("dialerProxy url ", c.SocketSettings.DialerProxy, " is in browserDialers and only supports websocket or splithttp")
|
||||
}
|
||||
if strings.EqualFold(c.Security, "reality") {
|
||||
return nil, errors.New("dialerProxy tag ", c.SocketSettings.DialerProxy, " maps to browserDialers and does not support REALITY")
|
||||
return nil, errors.New("dialerProxy url ", c.SocketSettings.DialerProxy, " is in browserDialers and does not support REALITY")
|
||||
}
|
||||
if config.ProtocolName == "splithttp" {
|
||||
splitHTTPSettings := c.SplitHTTPSettings
|
||||
@@ -1991,7 +1991,7 @@ func (c *StreamConfig) Build() (*internet.StreamConfig, error) {
|
||||
return nil, errors.New("failed to build XHTTP config for browserDialers validation.").Base(err)
|
||||
}
|
||||
if splitHTTPConfig, ok := hs.(*splithttp.Config); ok && splitHTTPConfig.Mode != "auto" && splitHTTPConfig.Mode != "packet-up" {
|
||||
return nil, errors.New("dialerProxy tag ", c.SocketSettings.DialerProxy, " maps to browserDialers and only supports XHTTP modes \"auto\" or \"packet-up\", got: \"", splitHTTPConfig.Mode, "\"")
|
||||
return nil, errors.New("dialerProxy url ", c.SocketSettings.DialerProxy, " is in browserDialers and only supports XHTTP modes \"auto\" or \"packet-up\", got: \"", splitHTTPConfig.Mode, "\"")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-17
@@ -363,12 +363,7 @@ type Config struct {
|
||||
BurstObservatory *BurstObservatoryConfig `json:"burstObservatory"`
|
||||
Version *VersionConfig `json:"version"`
|
||||
Geodata *GeodataConfig `json:"geodata"`
|
||||
BrowserDialers []BrowserDialerConfig `json:"browserDialers"`
|
||||
}
|
||||
|
||||
type BrowserDialerConfig struct {
|
||||
Tag string `json:"tag"`
|
||||
URL string `json:"url"`
|
||||
BrowserDialers []string `json:"browserDialers"`
|
||||
}
|
||||
|
||||
func (c *Config) findInboundTag(tag string) int {
|
||||
@@ -618,17 +613,7 @@ func (c *Config) Build() (*core.Config, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
browserDialerTags := make(map[string]string, len(c.BrowserDialers))
|
||||
for _, browserDialer := range c.BrowserDialers {
|
||||
if browserDialer.Tag == "" {
|
||||
return nil, errors.New("browserDialers tag cannot be empty")
|
||||
}
|
||||
if _, found := browserDialerTags[browserDialer.Tag]; found {
|
||||
return nil, errors.New("duplicate browserDialers tag: ", browserDialer.Tag)
|
||||
}
|
||||
browserDialerTags[browserDialer.Tag] = browserDialer.URL
|
||||
}
|
||||
if err := browser_dialer.ConfigureDialerTags(browserDialerTags); err != nil {
|
||||
if err := browser_dialer.ConfigureDialers(c.BrowserDialers); err != nil {
|
||||
return nil, errors.New("failed to configure browserDialers").Base(err)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user