Skip to content

Commit 8ffb329

Browse files
MHSanaeixeefei
authored andcommitted
XHTTP transport: New options for bypassing CDN's detection
XTLS/Xray-core#5414
1 parent 7137b6e commit 8ffb329

File tree

2 files changed

+165
-12
lines changed

2 files changed

+165
-12
lines changed

web/assets/js/model/inbound.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,19 @@ class xHTTPStreamSettings extends XrayCommonClass {
500500
noSSEHeader = false,
501501
xPaddingBytes = "100-1000",
502502
mode = MODE_OPTION.AUTO,
503+
xPaddingObfsMode = false,
504+
xPaddingKey = '',
505+
xPaddingHeader = '',
506+
xPaddingPlacement = '',
507+
xPaddingMethod = '',
508+
uplinkHTTPMethod = '',
509+
sessionPlacement = '',
510+
sessionKey = '',
511+
seqPlacement = '',
512+
seqKey = '',
513+
uplinkDataPlacement = '',
514+
uplinkDataKey = '',
515+
uplinkChunkSize = 0,
503516
) {
504517
super();
505518
this.path = path;
@@ -511,6 +524,19 @@ class xHTTPStreamSettings extends XrayCommonClass {
511524
this.noSSEHeader = noSSEHeader;
512525
this.xPaddingBytes = xPaddingBytes;
513526
this.mode = mode;
527+
this.xPaddingObfsMode = xPaddingObfsMode;
528+
this.xPaddingKey = xPaddingKey;
529+
this.xPaddingHeader = xPaddingHeader;
530+
this.xPaddingPlacement = xPaddingPlacement;
531+
this.xPaddingMethod = xPaddingMethod;
532+
this.uplinkHTTPMethod = uplinkHTTPMethod;
533+
this.sessionPlacement = sessionPlacement;
534+
this.sessionKey = sessionKey;
535+
this.seqPlacement = seqPlacement;
536+
this.seqKey = seqKey;
537+
this.uplinkDataPlacement = uplinkDataPlacement;
538+
this.uplinkDataKey = uplinkDataKey;
539+
this.uplinkChunkSize = uplinkChunkSize;
514540
}
515541

516542
addHeader(name, value) {
@@ -532,6 +558,19 @@ class xHTTPStreamSettings extends XrayCommonClass {
532558
json.noSSEHeader,
533559
json.xPaddingBytes,
534560
json.mode,
561+
json.xPaddingObfsMode,
562+
json.xPaddingKey,
563+
json.xPaddingHeader,
564+
json.xPaddingPlacement,
565+
json.xPaddingMethod,
566+
json.uplinkHTTPMethod,
567+
json.sessionPlacement,
568+
json.sessionKey,
569+
json.seqPlacement,
570+
json.seqKey,
571+
json.uplinkDataPlacement,
572+
json.uplinkDataKey,
573+
json.uplinkChunkSize,
535574
);
536575
}
537576

@@ -546,6 +585,19 @@ class xHTTPStreamSettings extends XrayCommonClass {
546585
noSSEHeader: this.noSSEHeader,
547586
xPaddingBytes: this.xPaddingBytes,
548587
mode: this.mode,
588+
xPaddingObfsMode: this.xPaddingObfsMode,
589+
xPaddingKey: this.xPaddingKey,
590+
xPaddingHeader: this.xPaddingHeader,
591+
xPaddingPlacement: this.xPaddingPlacement,
592+
xPaddingMethod: this.xPaddingMethod,
593+
uplinkHTTPMethod: this.uplinkHTTPMethod,
594+
sessionPlacement: this.sessionPlacement,
595+
sessionKey: this.sessionKey,
596+
seqPlacement: this.seqPlacement,
597+
seqKey: this.seqKey,
598+
uplinkDataPlacement: this.uplinkDataPlacement,
599+
uplinkDataKey: this.uplinkDataKey,
600+
uplinkChunkSize: this.uplinkChunkSize,
549601
};
550602
}
551603
}

web/html/form/stream/stream_xhttp.html

Lines changed: 113 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,145 @@
11
{{define "form/streamXHTTP"}}
2-
<a-form :colon="false" :label-col="{ md: {span:8} }" :wrapper-col="{ md: {span:14} }">
2+
<a-form :colon="false" :label-col="{ md: {span:8} }"
3+
:wrapper-col="{ md: {span:14} }">
34
<a-form-item label='{{ i18n "host" }}'>
45
<a-input v-model.trim="inbound.stream.xhttp.host"></a-input>
56
</a-form-item>
67
<a-form-item label='{{ i18n "path" }}'>
78
<a-input v-model.trim="inbound.stream.xhttp.path"></a-input>
89
</a-form-item>
910
<a-form-item label='{{ i18n "pages.inbounds.stream.tcp.requestHeader" }}'>
10-
<a-button icon="plus" size="small" @click="inbound.stream.xhttp.addHeader('', '')"></a-button>
11+
<a-button icon="plus" size="small"
12+
@click="inbound.stream.xhttp.addHeader('', '')"></a-button>
1113
</a-form-item>
1214
<a-form-item :wrapper-col="{span:24}">
13-
<a-input-group compact v-for="(header, index) in inbound.stream.xhttp.headers">
15+
<a-input-group compact
16+
v-for="(header, index) in inbound.stream.xhttp.headers">
1417
<a-input :style="{ width: '50%' }" v-model.trim="header.name"
1518
placeholder='{{ i18n "pages.inbounds.stream.general.name"}}'>
16-
<template slot="addonBefore" :style="{ margin: '0' }">[[ index+1 ]]</template>
19+
<template slot="addonBefore" :style="{ margin: '0' }">[[ index+1
20+
]]</template>
1721
</a-input>
1822
<a-input :style="{ width: '50%' }" v-model.trim="header.value"
1923
placeholder='{{ i18n "pages.inbounds.stream.general.value" }}'>
20-
<a-button icon="minus" slot="addonAfter" size="small" @click="inbound.stream.xhttp.removeHeader(index)"></a-button>
24+
<a-button icon="minus" slot="addonAfter" size="small"
25+
@click="inbound.stream.xhttp.removeHeader(index)"></a-button>
2126
</a-input>
2227
</a-input-group>
2328
</a-form-item>
2429
<a-form-item label='Mode'>
2530
<a-select v-model="inbound.stream.xhttp.mode" :style="{ width: '50%' }"
2631
:dropdown-class-name="themeSwitcher.currentTheme">
27-
<a-select-option v-for="key in MODE_OPTION" :value="key">[[ key ]]</a-select-option>
32+
<a-select-option v-for="key in MODE_OPTION" :value="key">[[ key
33+
]]</a-select-option>
2834
</a-select>
2935
</a-form-item>
30-
<a-form-item label="Max Buffered Upload" v-if="inbound.stream.xhttp.mode === 'packet-up'">
31-
<a-input-number v-model.number="inbound.stream.xhttp.scMaxBufferedPosts"></a-input-number>
36+
<a-form-item label="Max Buffered Upload"
37+
v-if="inbound.stream.xhttp.mode === 'packet-up'">
38+
<a-input-number
39+
v-model.number="inbound.stream.xhttp.scMaxBufferedPosts"></a-input-number>
3240
</a-form-item>
33-
<a-form-item label="Max Upload Size (Byte)" v-if="inbound.stream.xhttp.mode === 'packet-up'">
34-
<a-input v-model.trim="inbound.stream.xhttp.scMaxEachPostBytes"></a-input>
41+
<a-form-item label="Max Upload Size (Byte)"
42+
v-if="inbound.stream.xhttp.mode === 'packet-up'">
43+
<a-input
44+
v-model.trim="inbound.stream.xhttp.scMaxEachPostBytes"></a-input>
3545
</a-form-item>
36-
<a-form-item label="Stream-Up Server" v-if="inbound.stream.xhttp.mode === 'stream-up'">
37-
<a-input v-model.trim="inbound.stream.xhttp.scStreamUpServerSecs"></a-input>
46+
<a-form-item label="Stream-Up Server"
47+
v-if="inbound.stream.xhttp.mode === 'stream-up'">
48+
<a-input
49+
v-model.trim="inbound.stream.xhttp.scStreamUpServerSecs"></a-input>
3850
</a-form-item>
3951
<a-form-item label="Padding Bytes">
4052
<a-input v-model.trim="inbound.stream.xhttp.xPaddingBytes"></a-input>
4153
</a-form-item>
54+
<a-form-item label="Padding Obfs Mode">
55+
<a-switch v-model="inbound.stream.xhttp.xPaddingObfsMode"></a-switch>
56+
</a-form-item>
57+
<template v-if="inbound.stream.xhttp.xPaddingObfsMode">
58+
<a-form-item label="Padding Key">
59+
<a-input v-model.trim="inbound.stream.xhttp.xPaddingKey"
60+
placeholder="x_padding"></a-input>
61+
</a-form-item>
62+
<a-form-item label="Padding Header">
63+
<a-input v-model.trim="inbound.stream.xhttp.xPaddingHeader"
64+
placeholder="X-Padding"></a-input>
65+
</a-form-item>
66+
<a-form-item label="Padding Placement">
67+
<a-select v-model="inbound.stream.xhttp.xPaddingPlacement"
68+
:dropdown-class-name="themeSwitcher.currentTheme">
69+
<a-select-option value>Default (queryInHeader)</a-select-option>
70+
<a-select-option
71+
value="queryInHeader">queryInHeader</a-select-option>
72+
<a-select-option value="header">header</a-select-option>
73+
</a-select>
74+
</a-form-item>
75+
<a-form-item label="Padding Method">
76+
<a-select v-model="inbound.stream.xhttp.xPaddingMethod"
77+
:dropdown-class-name="themeSwitcher.currentTheme">
78+
<a-select-option value>Default (repeat-x)</a-select-option>
79+
<a-select-option value="repeat-x">repeat-x</a-select-option>
80+
<a-select-option value="tokenish">tokenish</a-select-option>
81+
</a-select>
82+
</a-form-item>
83+
</template>
84+
<a-form-item label="Uplink HTTP Method">
85+
<a-select v-model="inbound.stream.xhttp.uplinkHTTPMethod"
86+
:dropdown-class-name="themeSwitcher.currentTheme">
87+
<a-select-option value>Default (POST)</a-select-option>
88+
<a-select-option value="POST">POST</a-select-option>
89+
<a-select-option value="PUT">PUT</a-select-option>
90+
<a-select-option value="GET">GET (packet-up only)</a-select-option>
91+
</a-select>
92+
</a-form-item>
93+
<a-form-item label="Session Placement">
94+
<a-select v-model="inbound.stream.xhttp.sessionPlacement"
95+
:dropdown-class-name="themeSwitcher.currentTheme">
96+
<a-select-option value>Default (path)</a-select-option>
97+
<a-select-option value="path">path</a-select-option>
98+
<a-select-option value="header">header</a-select-option>
99+
<a-select-option value="cookie">cookie</a-select-option>
100+
<a-select-option value="query">query</a-select-option>
101+
</a-select>
102+
</a-form-item>
103+
<a-form-item label="Session Key"
104+
v-if="inbound.stream.xhttp.sessionPlacement && inbound.stream.xhttp.sessionPlacement !== 'path'">
105+
<a-input v-model.trim="inbound.stream.xhttp.sessionKey"
106+
placeholder="x_session"></a-input>
107+
</a-form-item>
108+
<a-form-item label="Sequence Placement">
109+
<a-select v-model="inbound.stream.xhttp.seqPlacement"
110+
:dropdown-class-name="themeSwitcher.currentTheme">
111+
<a-select-option value>Default (path)</a-select-option>
112+
<a-select-option value="path">path</a-select-option>
113+
<a-select-option value="header">header</a-select-option>
114+
<a-select-option value="cookie">cookie</a-select-option>
115+
<a-select-option value="query">query</a-select-option>
116+
</a-select>
117+
</a-form-item>
118+
<a-form-item label="Sequence Key"
119+
v-if="inbound.stream.xhttp.seqPlacement && inbound.stream.xhttp.seqPlacement !== 'path'">
120+
<a-input v-model.trim="inbound.stream.xhttp.seqKey"
121+
placeholder="x_seq"></a-input>
122+
</a-form-item>
123+
<a-form-item label="Uplink Data Placement"
124+
v-if="inbound.stream.xhttp.mode === 'packet-up'">
125+
<a-select v-model="inbound.stream.xhttp.uplinkDataPlacement"
126+
:dropdown-class-name="themeSwitcher.currentTheme">
127+
<a-select-option value>Default (body)</a-select-option>
128+
<a-select-option value="body">body</a-select-option>
129+
<a-select-option value="header">header</a-select-option>
130+
<a-select-option value="query">query</a-select-option>
131+
</a-select>
132+
</a-form-item>
133+
<a-form-item label="Uplink Data Key"
134+
v-if="inbound.stream.xhttp.mode === 'packet-up' && inbound.stream.xhttp.uplinkDataPlacement && inbound.stream.xhttp.uplinkDataPlacement !== 'body'">
135+
<a-input v-model.trim="inbound.stream.xhttp.uplinkDataKey"
136+
placeholder="x_data"></a-input>
137+
</a-form-item>
138+
<a-form-item label="Uplink Chunk Size"
139+
v-if="inbound.stream.xhttp.mode === 'packet-up' && inbound.stream.xhttp.uplinkDataPlacement && inbound.stream.xhttp.uplinkDataPlacement !== 'body'">
140+
<a-input-number v-model.number="inbound.stream.xhttp.uplinkChunkSize"
141+
:min="0" placeholder="0 (unlimited)"></a-input-number>
142+
</a-form-item>
42143
<a-form-item label="No SSE Header">
43144
<a-switch v-model="inbound.stream.xhttp.noSSEHeader"></a-switch>
44145
</a-form-item>

0 commit comments

Comments
 (0)