Skip to content

Commit 380dd7f

Browse files
author
drovosek229
committed
XHTTP config: Add "extra" for sharing extra fields (XTLS#4000)
1 parent 269fedb commit 380dd7f

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

infra/conf/transport_internet.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ type SplitHTTPConfig struct {
234234
Xmux Xmux `json:"xmux"`
235235
DownloadSettings *StreamConfig `json:"downloadSettings"`
236236
Mode string `json:"mode"`
237+
Extra json.RawMessage `json:"extra"`
237238
}
238239

239240
type Xmux struct {
@@ -259,6 +260,18 @@ func splithttpNewRandRangeConfig(input *Int32Range) *splithttp.RandRangeConfig {
259260

260261
// Build implements Buildable.
261262
func (c *SplitHTTPConfig) Build() (proto.Message, error) {
263+
if c.Extra != nil {
264+
var extra SplitHTTPConfig
265+
if err := json.Unmarshal(c.Extra, &extra); err != nil {
266+
return nil, errors.New(`Failed to unmarshal "extra".`).Base(err)
267+
}
268+
extra.Host = c.Host
269+
extra.Path = c.Path
270+
extra.Mode = c.Mode
271+
extra.Extra = c.Extra
272+
c = &extra
273+
}
274+
262275
// If http host is not set in the Host field, but in headers field, we add it to Host Field here.
263276
// If we don't do that, http host will be overwritten as address.
264277
// Host priority: Host field > headers field > address.
@@ -312,6 +325,9 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) {
312325
}
313326
var err error
314327
if c.DownloadSettings != nil {
328+
if c.Extra != nil {
329+
c.DownloadSettings.SocketSettings = nil
330+
}
315331
if config.DownloadSettings, err = c.DownloadSettings.Build(); err != nil {
316332
return nil, errors.New(`Failed to build "downloadSettings".`).Base(err)
317333
}

0 commit comments

Comments
 (0)