Skip to content

Commit

Permalink
feat: 增加Vmess tcp http下发支持
Browse files Browse the repository at this point in the history
  • Loading branch information
xboard committed Dec 18, 2023
1 parent 0ef19e9 commit 9dcb9ce
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 12 deletions.
10 changes: 9 additions & 1 deletion app/Protocols/Clash.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,15 @@ public static function buildVmess($uuid, $server)
if ($server['network'] === 'tcp') {
$tcpSettings = $server['networkSettings'];
if (isset($tcpSettings['header']['type'])) $array['network'] = $tcpSettings['header']['type'];
if (isset($tcpSettings['header']['request']['path'][0])) $array['http-opts']['path'] = $tcpSettings['header']['request']['path'][0];

if (isset($tcpSettings['header']['request']['headers'])){
$headers = $$tcpSettings['header']['request']['headers'];
$array['http-opts']['headers'] = $headers;
}
if (isset($tcpSettings['header']['request']['path'][0])){
$paths = $tcpSettings['header']['request']['path'];
$array['http-opts']['path'] = $paths;
}
}
if ($server['network'] === 'ws') {
$array['network'] = 'ws';
Expand Down
10 changes: 9 additions & 1 deletion app/Protocols/ClashMeta.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,15 @@ public static function buildVmess($uuid, $server)
if ($server['network'] === 'tcp') {
$tcpSettings = $server['networkSettings'];
if (isset($tcpSettings['header']['type'])) $array['network'] = $tcpSettings['header']['type'];
if (isset($tcpSettings['header']['request']['path'][0])) $array['http-opts']['path'] = $tcpSettings['header']['request']['path'][0];

if (isset($tcpSettings['header']['request']['headers'])){
$headers = $$tcpSettings['header']['request']['headers'];
$array['http-opts']['headers'] = $headers;
}
if (isset($tcpSettings['header']['request']['path'][0])){
$paths = $tcpSettings['header']['request']['path'];
$array['http-opts']['path'] = $paths;
}
}
if ($server['network'] === 'ws') {
$array['network'] = 'ws';
Expand Down
9 changes: 8 additions & 1 deletion app/Protocols/General.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,14 @@ public static function buildVmess($uuid, $server)
if ((string)$server['network'] === 'tcp') {
$tcpSettings = $server['networkSettings'];
if (isset($tcpSettings['header']['type'])) $config['type'] = $tcpSettings['header']['type'];
if (isset($tcpSettings['header']['request']['path'][0])) $config['path'] = $tcpSettings['header']['request']['path'][0];
if (isset($tcpSettings['header']['request']['path'][0])){
$paths = $tcpSettings['header']['request']['path'];
$config['path'] = $paths[array_rand($paths)];
}
if (isset($tcpSettings['header']['request']['headers']['Host'][0])){
$hosts = $tcpSettings['header']['request']['headers']['Host'];
$config['host'] = $hosts[array_rand($hosts)];
}
}
if ((string)$server['network'] === 'ws') {
$wsSettings = $server['networkSettings'];
Expand Down
11 changes: 8 additions & 3 deletions app/Protocols/Loon.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,14 @@ public static function buildVmess($uuid, $server)
if (isset($tcpSettings['header']['type']) && !empty($tcpSettings['header']['type']))
$config = str_replace('transport=tcp', "transport={$tcpSettings['header']['type']}", $config);
if (isset($tcpSettings['header']['request']['path'][0]) && !empty($tcpSettings['header']['request']['path'][0]))
array_push($config, "path={$tcpSettings['header']['request']['path'][0]}");
if (isset($tcpSettings['header']['Host']) && !empty($tcpSettings['header']['Host']))
array_push($config, "host={$tcpSettings['header']['Host']}");
$paths = $tcpSettings['header']['request']['path'];
$path = array_rand(array_rand($paths));
array_push($config, "path={$path}");
if (isset($tcpSettings['header']['request']['headers']['Host'][0])){
$hosts = $tcpSettings['header']['request']['headers']['Host'];
$host = $hosts[array_rand($hosts)];
array_push($config, "host={$host}");
}
}
}
if ($server['tls']) {
Expand Down
9 changes: 8 additions & 1 deletion app/Protocols/Passwall.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,14 @@ public static function buildVmess($uuid, $server)
if ((string)$server['network'] === 'tcp') {
$tcpSettings = $server['networkSettings'];
if (isset($tcpSettings['header']['type'])) $config['type'] = $tcpSettings['header']['type'];
if (isset($tcpSettings['header']['request']['path'][0])) $config['path'] = $tcpSettings['header']['request']['path'][0];
if (isset($tcpSettings['header']['request']['path'][0])){
$paths = $tcpSettings['header']['request']['path'];
$config['path'] = $paths[array_rand($paths)];
}
if (isset($tcpSettings['header']['request']['headers']['Host'][0])){
$hosts = $tcpSettings['header']['request']['headers']['Host'];
$config['host'] = $hosts[array_rand($hosts)];
}
}
if ((string)$server['network'] === 'ws') {
$wsSettings = $server['networkSettings'];
Expand Down
4 changes: 4 additions & 0 deletions app/Protocols/Shadowrocket.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@ public static function buildVless($uuid, $server)
$config['obfs'] = $tcpSettings['header']['type'];
if (isset($tcpSettings['header']['request']['path'][0]) && !empty($tcpSettings['header']['request']['path'][0]))
$config['path'] = $tcpSettings['header']['request']['path'][0];
if (isset($tcpSettings['header']['request']['headers']['Host'][0])){
$hosts = $tcpSettings['header']['request']['headers']['Host'];
$config['obfsParam'] = $hosts[array_rand($hosts)];
}
}
}
if ($server['network'] === 'ws') {
Expand Down
9 changes: 8 additions & 1 deletion app/Protocols/SingBox.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,14 @@ protected function buildVmess($uuid, $server)
if ($server['network'] === 'tcp') {
$tcpSettings = $server['networkSettings'];
if (isset($tcpSettings['header']['type']) && $tcpSettings['header']['type'] == 'http') $array['transport']['type'] = $tcpSettings['header']['type'];
if (isset($tcpSettings['header']['request']['path'])) $array['transport']['path'] = $tcpSettings['header']['request']['path'];
if (isset($tcpSettings['header']['request']['path'][0])){
$paths = $tcpSettings['header']['request']['path'];
$array['transport']['path'] = $paths[array_rand($paths)];
}
if (isset($tcpSettings['header']['request']['headers']['Host'][0])){
$hosts = $tcpSettings['header']['request']['headers']['Host'];
$array['transport']['host'] = $hosts;
}
}
if ($server['network'] === 'ws') {
$array['transport']['type'] ='ws';
Expand Down
12 changes: 11 additions & 1 deletion app/Protocols/Stash.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,17 @@ public static function buildVless($uuid, $server)
}

if ($server['network'] === 'tcp') {
$tcpSettings = $server['network_settings'];
$tcpSettings = $server['networkSettings'];
if (isset($tcpSettings['header']['type']) && $tcpSettings['header']['type'] == 'http') {
$array['network'] = $tcpSettings['header']['type'];
if (isset($tcpSettings['header']['request']['headers']['Host'])){
$array['http-opts']['headers']['Host'] = $tcpSettings['header']['request']['headers']['Host'];
}
if (isset($tcpSettings['header']['request']['path'][0])){
$paths = $tcpSettings['header']['request']['path'];
$array['http-opts']['path'] = $paths[array_rand($paths)];
};
}
}

if ($server['network'] === 'ws') {
Expand Down
11 changes: 9 additions & 2 deletions app/Protocols/V2rayN.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,14 @@ public static function buildVmess($uuid, $server)
if ((string)$server['network'] === 'tcp') {
$tcpSettings = $server['networkSettings'];
if (isset($tcpSettings['header']['type'])) $config['type'] = $tcpSettings['header']['type'];
if (isset($tcpSettings['header']['request']['path'][0])) $config['path'] = $tcpSettings['header']['request']['path'][0];
if (isset($tcpSettings['header']['request']['path'][0])){
$paths = $tcpSettings['header']['request']['path'];
$config['path'] = $paths[array_rand($paths)];
}
if (isset($tcpSettings['header']['request']['headers']['Host'][0])){
$hosts = $tcpSettings['header']['request']['headers']['Host'];
$config['host'] = $hosts[array_rand($hosts)];
}
}
if ((string)$server['network'] === 'ws') {
$wsSettings = $server['networkSettings'];
Expand Down Expand Up @@ -137,7 +144,7 @@ public static function buildVless($uuid, $server){
$config['servername'] = $tls_settings['server_name'];
$config['spx'] = "/";
$fingerprints = ['chrome', 'firefox', 'safari', 'ios', 'edge', 'qq']; //随机客户端指纹
$config['fp'] = $fingerprints[rand(0,count($fingerprints) - 1)];
$config['fp'] = $fingerprints[array_rand($fingerprints)];
};
break;
}
Expand Down
9 changes: 8 additions & 1 deletion app/Protocols/V2rayNG.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,14 @@ public static function buildVmess($uuid, $server)
if ((string)$server['network'] === 'tcp') {
$tcpSettings = $server['networkSettings'];
if (isset($tcpSettings['header']['type'])) $config['type'] = $tcpSettings['header']['type'];
if (isset($tcpSettings['header']['request']['path'][0])) $config['path'] = $tcpSettings['header']['request']['path'][0];
if (isset($tcpSettings['header']['request']['path'][0])){
$paths = $tcpSettings['header']['request']['path'];
$config['path'] = $paths[array_rand($paths)];
}
if (isset($tcpSettings['header']['request']['headers']['Host'][0])){
$hosts = $tcpSettings['header']['request']['headers']['Host'];
$config['host'] = $hosts[array_rand($hosts)];
}
}
if ((string)$server['network'] === 'ws') {
$wsSettings = $server['networkSettings'];
Expand Down

0 comments on commit 9dcb9ce

Please sign in to comment.