mirror of
				https://github.com/MHSanaei/3x-ui.git
				synced 2025-11-04 06:12:52 +00:00 
			
		
		
		
	SplitHTTP - Mode
This commit is contained in:
		
							parent
							
								
									2982d809ab
								
							
						
					
					
						commit
						ccda652e69
					
				
					 6 changed files with 57 additions and 5 deletions
				
			
		| 
						 | 
				
			
			@ -238,6 +238,7 @@ func (s *SubService) genVmessLink(inbound *model.Inbound, email string) string {
 | 
			
		|||
			headers, _ := splithttp["headers"].(map[string]interface{})
 | 
			
		||||
			obj["host"] = searchHost(headers)
 | 
			
		||||
		}
 | 
			
		||||
		obj["mode"] = splithttp["mode"].(string)
 | 
			
		||||
	}
 | 
			
		||||
	security, _ := stream["security"].(string)
 | 
			
		||||
	obj["tls"] = security
 | 
			
		||||
| 
						 | 
				
			
			@ -389,6 +390,7 @@ func (s *SubService) genVlessLink(inbound *model.Inbound, email string) string {
 | 
			
		|||
			headers, _ := splithttp["headers"].(map[string]interface{})
 | 
			
		||||
			params["host"] = searchHost(headers)
 | 
			
		||||
		}
 | 
			
		||||
		params["mode"] = splithttp["mode"].(string)
 | 
			
		||||
	}
 | 
			
		||||
	security, _ := stream["security"].(string)
 | 
			
		||||
	if security == "tls" {
 | 
			
		||||
| 
						 | 
				
			
			@ -586,6 +588,7 @@ func (s *SubService) genTrojanLink(inbound *model.Inbound, email string) string
 | 
			
		|||
			headers, _ := splithttp["headers"].(map[string]interface{})
 | 
			
		||||
			params["host"] = searchHost(headers)
 | 
			
		||||
		}
 | 
			
		||||
		params["mode"] = splithttp["mode"].(string)
 | 
			
		||||
	}
 | 
			
		||||
	security, _ := stream["security"].(string)
 | 
			
		||||
	if security == "tls" {
 | 
			
		||||
| 
						 | 
				
			
			@ -783,6 +786,7 @@ func (s *SubService) genShadowsocksLink(inbound *model.Inbound, email string) st
 | 
			
		|||
			headers, _ := splithttp["headers"].(map[string]interface{})
 | 
			
		||||
			params["host"] = searchHost(headers)
 | 
			
		||||
		}
 | 
			
		||||
		params["mode"] = splithttp["mode"].(string)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	security, _ := stream["security"].(string)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -113,6 +113,12 @@ const USERS_SECURITY = {
 | 
			
		|||
    ZERO: "zero",
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const MODE_OPTION = {
 | 
			
		||||
    AUTO: "auto",
 | 
			
		||||
    PACKET_UP: "packet-up",
 | 
			
		||||
    STREAM_UP: "stream-up",
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
Object.freeze(Protocols);
 | 
			
		||||
Object.freeze(SSMethods);
 | 
			
		||||
Object.freeze(TLS_FLOW_CONTROL);
 | 
			
		||||
| 
						 | 
				
			
			@ -125,6 +131,7 @@ Object.freeze(USAGE_OPTION);
 | 
			
		|||
Object.freeze(DOMAIN_STRATEGY_OPTION);
 | 
			
		||||
Object.freeze(TCP_CONGESTION_OPTION);
 | 
			
		||||
Object.freeze(USERS_SECURITY);
 | 
			
		||||
Object.freeze(MODE_OPTION);
 | 
			
		||||
 | 
			
		||||
class XrayCommonClass {
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -528,7 +535,8 @@ class SplitHTTPStreamSettings extends XrayCommonClass {
 | 
			
		|||
            maxConnections: 0,
 | 
			
		||||
            cMaxReuseTimes: "64-128",
 | 
			
		||||
            cMaxLifetimeMs: 0
 | 
			
		||||
        }
 | 
			
		||||
        },
 | 
			
		||||
        mode = MODE_OPTION.AUTO,
 | 
			
		||||
    ) {
 | 
			
		||||
        super();
 | 
			
		||||
        this.path = path;
 | 
			
		||||
| 
						 | 
				
			
			@ -540,6 +548,7 @@ class SplitHTTPStreamSettings extends XrayCommonClass {
 | 
			
		|||
        this.noSSEHeader = noSSEHeader;
 | 
			
		||||
        this.xPaddingBytes = xPaddingBytes;
 | 
			
		||||
        this.xmux = xmux;
 | 
			
		||||
        this.mode = mode;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    addHeader(name, value) {
 | 
			
		||||
| 
						 | 
				
			
			@ -561,6 +570,7 @@ class SplitHTTPStreamSettings extends XrayCommonClass {
 | 
			
		|||
            json.noSSEHeader,
 | 
			
		||||
            json.xPaddingBytes,
 | 
			
		||||
            json.xmux,
 | 
			
		||||
            json.mode,
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -579,7 +589,8 @@ class SplitHTTPStreamSettings extends XrayCommonClass {
 | 
			
		|||
                maxConnections: this.xmux.maxConnections,
 | 
			
		||||
                cMaxReuseTimes: this.xmux.cMaxReuseTimes,
 | 
			
		||||
                cMaxLifetimeMs: this.xmux.cMaxLifetimeMs
 | 
			
		||||
            }
 | 
			
		||||
            },
 | 
			
		||||
            mode: this.mode,
 | 
			
		||||
        };
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1329,6 +1340,7 @@ class Inbound extends XrayCommonClass {
 | 
			
		|||
            const splithttp = this.stream.splithttp;
 | 
			
		||||
            obj.path = splithttp.path;
 | 
			
		||||
            obj.host = splithttp.host?.length > 0 ? splithttp.host : this.getHeader(splithttp, 'host');
 | 
			
		||||
            obj.mode = splithttp.mode;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (security === 'tls') {
 | 
			
		||||
| 
						 | 
				
			
			@ -1401,6 +1413,7 @@ class Inbound extends XrayCommonClass {
 | 
			
		|||
                const splithttp = this.stream.splithttp;
 | 
			
		||||
                params.set("path", splithttp.path);
 | 
			
		||||
                params.set("host", splithttp.host?.length > 0 ? splithttp.host : this.getHeader(splithttp, 'host'));
 | 
			
		||||
                params.set("mode", splithttp.mode);
 | 
			
		||||
                break;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1504,6 +1517,7 @@ class Inbound extends XrayCommonClass {
 | 
			
		|||
                const splithttp = this.stream.splithttp;
 | 
			
		||||
                params.set("path", splithttp.path);
 | 
			
		||||
                params.set("host", splithttp.host?.length > 0 ? splithttp.host : this.getHeader(splithttp, 'host'));
 | 
			
		||||
                params.set("mode", splithttp.mode);
 | 
			
		||||
                break;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1586,6 +1600,7 @@ class Inbound extends XrayCommonClass {
 | 
			
		|||
                const splithttp = this.stream.splithttp;
 | 
			
		||||
                params.set("path", splithttp.path);
 | 
			
		||||
                params.set("host", splithttp.host?.length > 0 ? splithttp.host : this.getHeader(splithttp, 'host'));
 | 
			
		||||
                params.set("mode", splithttp.mode);
 | 
			
		||||
                break;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -77,6 +77,12 @@ const USERS_SECURITY = {
 | 
			
		|||
    ZERO: "zero",
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const MODE_OPTION = {
 | 
			
		||||
    AUTO: "auto",
 | 
			
		||||
    PACKET_UP: "packet-up",
 | 
			
		||||
    STREAM_UP: "stream-up",
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
Object.freeze(Protocols);
 | 
			
		||||
Object.freeze(SSMethods);
 | 
			
		||||
Object.freeze(TLS_FLOW_CONTROL);
 | 
			
		||||
| 
						 | 
				
			
			@ -85,6 +91,7 @@ Object.freeze(ALPN_OPTION);
 | 
			
		|||
Object.freeze(OutboundDomainStrategies);
 | 
			
		||||
Object.freeze(WireguardDomainStrategy);
 | 
			
		||||
Object.freeze(USERS_SECURITY);
 | 
			
		||||
Object.freeze(MODE_OPTION);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CommonClass {
 | 
			
		||||
| 
						 | 
				
			
			@ -320,16 +327,22 @@ class HttpUpgradeStreamSettings extends CommonClass {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
class SplitHTTPStreamSettings extends CommonClass {
 | 
			
		||||
    constructor(path = '/', host = '') {
 | 
			
		||||
    constructor(
 | 
			
		||||
        path = '/',
 | 
			
		||||
        host = '',
 | 
			
		||||
        mode = '',
 | 
			
		||||
    ) {
 | 
			
		||||
        super();
 | 
			
		||||
        this.path = path;
 | 
			
		||||
        this.host = host;
 | 
			
		||||
        this.mode = mode;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    static fromJson(json = {}) {
 | 
			
		||||
        return new SplitHTTPStreamSettings(
 | 
			
		||||
            json.path,
 | 
			
		||||
            json.host,
 | 
			
		||||
            json.mode,
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -337,6 +350,7 @@ class SplitHTTPStreamSettings extends CommonClass {
 | 
			
		|||
        return {
 | 
			
		||||
            path: this.path,
 | 
			
		||||
            host: this.host,
 | 
			
		||||
            mode: this.mode,
 | 
			
		||||
        };
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -710,7 +724,7 @@ class Outbound extends CommonClass {
 | 
			
		|||
        } else if (network === 'httpupgrade') {
 | 
			
		||||
            stream.httpupgrade = new HttpUpgradeStreamSettings(json.path, json.host);
 | 
			
		||||
        } else if (network === 'splithttp') {
 | 
			
		||||
            stream.splithttp = new SplitHTTPStreamSettings(json.path, json.host);
 | 
			
		||||
            stream.splithttp = new SplitHTTPStreamSettings(json.path, json.host, json.mode);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (json.tls && json.tls == 'tls') {
 | 
			
		||||
| 
						 | 
				
			
			@ -754,7 +768,7 @@ class Outbound extends CommonClass {
 | 
			
		|||
        } else if (type === 'httpupgrade') {
 | 
			
		||||
            stream.httpupgrade = new HttpUpgradeStreamSettings(path, host);
 | 
			
		||||
        } else if (type === 'splithttp') {
 | 
			
		||||
            stream.splithttp = new SplitHTTPStreamSettings(path, host);
 | 
			
		||||
            stream.splithttp = new SplitHTTPStreamSettings(path, host, mode);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (security == 'tls') {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -380,6 +380,11 @@
 | 
			
		|||
          <a-form-item label='{{ i18n "path" }}'>
 | 
			
		||||
            <a-input v-model.trim="outbound.stream.splithttp.path"></a-input>
 | 
			
		||||
          </a-form-item>
 | 
			
		||||
          <a-form-item label='Mode'>
 | 
			
		||||
            <a-select v-model="outbound.stream.splithttp.mode" :dropdown-class-name="themeSwitcher.currentTheme">
 | 
			
		||||
              <a-select-option v-for="key in MODE_OPTION" :value="key">[[ key ]]</a-select-option>
 | 
			
		||||
            </a-select>
 | 
			
		||||
          </a-form-item>
 | 
			
		||||
        </template>
 | 
			
		||||
      </template>
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -22,6 +22,12 @@
 | 
			
		|||
            </a-input>
 | 
			
		||||
        </a-input-group>
 | 
			
		||||
    </a-form-item>
 | 
			
		||||
    <a-form-item label='Mode'>
 | 
			
		||||
        <a-select v-model="inbound.stream.splithttp.mode" style="width: 50%"
 | 
			
		||||
            :dropdown-class-name="themeSwitcher.currentTheme">
 | 
			
		||||
            <a-select-option v-for="key in MODE_OPTION" :value="key">[[ key ]]</a-select-option>
 | 
			
		||||
        </a-select>
 | 
			
		||||
    </a-form-item>
 | 
			
		||||
    <a-form-item label="Max Concurrent Upload">
 | 
			
		||||
        <a-input v-model.trim="inbound.stream.splithttp.scMaxConcurrentPosts"></a-input>
 | 
			
		||||
    </a-form-item>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -58,6 +58,14 @@
 | 
			
		|||
              </td>
 | 
			
		||||
            </tr>
 | 
			
		||||
          </template>
 | 
			
		||||
          <template v-if="inbound.isSplithttp">
 | 
			
		||||
            <tr>
 | 
			
		||||
              <td>Mode</td>
 | 
			
		||||
              <td>
 | 
			
		||||
                <a-tag>[[ inbound.stream.splithttp.mode ]]</a-tag>
 | 
			
		||||
              </td>
 | 
			
		||||
            </tr>
 | 
			
		||||
          </template>
 | 
			
		||||
          <template v-if="inbound.isKcp">
 | 
			
		||||
            <tr>
 | 
			
		||||
              <td>kcp {{ i18n "encryption" }}</td>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue