mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-07-02 09:48:43 +00:00
refactor: switch browser dialer to browser:// dialerProxy collection
Agent-Logs-Url: https://github.com/XTLS/Xray-core/sessions/84d72770-6ad0-447a-8d86-94d692972a05 Co-authored-by: RPRX <63339210+RPRX@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
7416fd225e
commit
be9a229d68
@@ -1972,12 +1972,12 @@ func (c *StreamConfig) Build() (*internet.StreamConfig, error) {
|
||||
config.ProtocolName = protocol
|
||||
}
|
||||
if c.SocketSettings != nil && c.SocketSettings.DialerProxy != "" {
|
||||
if browser_dialer.HasConfiguredURL(c.SocketSettings.DialerProxy) {
|
||||
if browser_dialer.IsBrowserDialerProxy(c.SocketSettings.DialerProxy) {
|
||||
if config.ProtocolName != "websocket" && config.ProtocolName != "splithttp" {
|
||||
return nil, errors.New("dialerProxy url ", c.SocketSettings.DialerProxy, " is in browserDialers and only supports websocket or splithttp")
|
||||
return nil, errors.New("dialerProxy ", c.SocketSettings.DialerProxy, " only supports websocket or splithttp")
|
||||
}
|
||||
if strings.EqualFold(c.Security, "reality") {
|
||||
return nil, errors.New("dialerProxy url ", c.SocketSettings.DialerProxy, " is in browserDialers and does not support REALITY")
|
||||
return nil, errors.New("dialerProxy ", c.SocketSettings.DialerProxy, " does not support REALITY")
|
||||
}
|
||||
if config.ProtocolName == "splithttp" {
|
||||
splitHTTPSettings := c.SplitHTTPSettings
|
||||
@@ -1988,13 +1988,14 @@ func (c *StreamConfig) Build() (*internet.StreamConfig, error) {
|
||||
splitHTTPSettingsCopy := *splitHTTPSettings
|
||||
hs, err := splitHTTPSettingsCopy.Build()
|
||||
if err != nil {
|
||||
return nil, errors.New("failed to build XHTTP config for browserDialers validation.").Base(err)
|
||||
return nil, errors.New("failed to build XHTTP config for browser dialer validation").Base(err)
|
||||
}
|
||||
if splitHTTPConfig, ok := hs.(*splithttp.Config); ok && splitHTTPConfig.Mode != "auto" && splitHTTPConfig.Mode != "packet-up" {
|
||||
return nil, errors.New("dialerProxy url ", c.SocketSettings.DialerProxy, " is in browserDialers and only supports XHTTP modes \"auto\" or \"packet-up\", got: \"", splitHTTPConfig.Mode, "\"")
|
||||
return nil, errors.New("dialerProxy ", c.SocketSettings.DialerProxy, " only supports XHTTP modes \"auto\" or \"packet-up\", got: \"", splitHTTPConfig.Mode, "\"")
|
||||
}
|
||||
}
|
||||
}
|
||||
browser_dialer.RegisterDialerProxyURL(c.SocketSettings.DialerProxy)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
-10
@@ -363,7 +363,6 @@ type Config struct {
|
||||
BurstObservatory *BurstObservatoryConfig `json:"burstObservatory"`
|
||||
Version *VersionConfig `json:"version"`
|
||||
Geodata *GeodataConfig `json:"geodata"`
|
||||
BrowserDialers []string `json:"browserDialers"`
|
||||
}
|
||||
|
||||
func (c *Config) findInboundTag(tag string) int {
|
||||
@@ -439,10 +438,6 @@ func (c *Config) Override(o *Config, fn string) {
|
||||
if o.Geodata != nil {
|
||||
c.Geodata = o.Geodata
|
||||
}
|
||||
if o.BrowserDialers != nil {
|
||||
c.BrowserDialers = o.BrowserDialers
|
||||
}
|
||||
|
||||
// update the Inbound in slice if the only one in override config has same tag
|
||||
if len(o.InboundConfigs) > 0 {
|
||||
for i := range o.InboundConfigs {
|
||||
@@ -609,14 +604,10 @@ func (c *Config) Build() (*core.Config, error) {
|
||||
if len(c.Transport) > 0 {
|
||||
return nil, errors.PrintRemovedFeatureError("Global transport config", "streamSettings in inbounds and outbounds")
|
||||
}
|
||||
if err := browser_dialer.CheckLegacyEnv(); err != nil {
|
||||
if err := browser_dialer.BeginCollectingDialerProxyURLs(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := browser_dialer.ConfigureDialers(c.BrowserDialers); err != nil {
|
||||
return nil, errors.New("failed to configure browserDialers").Base(err)
|
||||
}
|
||||
|
||||
for _, rawInboundConfig := range inbounds {
|
||||
ic, err := rawInboundConfig.Build()
|
||||
if err != nil {
|
||||
@@ -638,6 +629,9 @@ func (c *Config) Build() (*core.Config, error) {
|
||||
}
|
||||
config.Outbound = append(config.Outbound, oc)
|
||||
}
|
||||
if err := browser_dialer.ConfigureCollectedDialerProxyURLs(); err != nil {
|
||||
return nil, errors.New("failed to configure browser dialer").Base(err)
|
||||
}
|
||||
|
||||
return config, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user