mirror of
https://github.com/v2board/v2board.git
synced 2024-11-10 09:39:10 +08:00
Compare commits
3 Commits
94af94df13
...
5fd12f8e5d
Author | SHA1 | Date | |
---|---|---|---|
|
5fd12f8e5d | ||
|
31c5cf1c2b | ||
|
f1d55ae202 |
@ -6,6 +6,7 @@ use App\Http\Controllers\Controller;
|
||||
use App\Models\ServerVless;
|
||||
use Illuminate\Http\Request;
|
||||
use ParagonIE_Sodium_Compat as SodiumCompat;
|
||||
use App\Utils\Helper;
|
||||
|
||||
class VlessController extends Controller
|
||||
{
|
||||
@ -19,7 +20,7 @@ class VlessController extends Controller
|
||||
'host' => 'required',
|
||||
'port' => 'required',
|
||||
'server_port' => 'required',
|
||||
'tls' => 'required|in:0,1',
|
||||
'tls' => 'required|in:0,1,2',
|
||||
'tls_settings' => 'nullable|array',
|
||||
'flow' => 'nullable|in:xtls-rprx-vision',
|
||||
'network' => 'required',
|
||||
@ -30,13 +31,14 @@ class VlessController extends Controller
|
||||
'sort' => 'nullable'
|
||||
]);
|
||||
|
||||
if (isset($params['tls_settings']) && (int)$params['tls_settings']['reality']) {
|
||||
if (isset($params['tls']) && (int)$params['tls'] === 2) {
|
||||
$keyPair = SodiumCompat::crypto_box_keypair();
|
||||
$params['tls_settings'] = $params['tls_settings'] ?? [];
|
||||
if (!isset($params['tls_settings']['public_key'])) {
|
||||
$params['tls_settings']['public_key'] = base64_encode(SodiumCompat::crypto_box_publickey($keyPair));
|
||||
$params['tls_settings']['public_key'] = Helper::base64EncodeUrlSafe(SodiumCompat::crypto_box_publickey($keyPair));
|
||||
}
|
||||
if (!isset($params['tls_settings']['private_key'])) {
|
||||
$params['tls_settings']['private_key'] = base64_encode(SodiumCompat::crypto_box_secretkey($keyPair));
|
||||
$params['tls_settings']['private_key'] = Helper::base64EncodeUrlSafe(SodiumCompat::crypto_box_secretkey($keyPair));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -111,6 +111,16 @@ class UniProxyController extends Controller
|
||||
'obfs' => Helper::getServerKey($this->nodeInfo->created_at, 16)
|
||||
];
|
||||
break;
|
||||
case "vless":
|
||||
$response = [
|
||||
'server_port' => $this->nodeInfo->server_port,
|
||||
'network' => $this->nodeInfo->network,
|
||||
'network_settings' => $this->nodeInfo->network_settings,
|
||||
'tls' => $this->nodeInfo->tls,
|
||||
'flow' => $this->nodeInfo->flow,
|
||||
'tls_settings' => $this->nodeInfo->tls_settings
|
||||
];
|
||||
break;
|
||||
}
|
||||
$response['base_config'] = [
|
||||
'push_interval' => (int)config('v2board.server_push_interval', 60),
|
||||
|
@ -33,6 +33,9 @@ class General
|
||||
if ($item['type'] === 'trojan') {
|
||||
$uri .= self::buildTrojan($user['uuid'], $item);
|
||||
}
|
||||
if ($item['type'] === 'hysteria') {
|
||||
$uri .= self::buildHysteria($user['uuid'], $item);
|
||||
}
|
||||
}
|
||||
return base64_encode($uri);
|
||||
}
|
||||
@ -110,4 +113,22 @@ class General
|
||||
return $uri;
|
||||
}
|
||||
|
||||
public static function buildHysteria($password, $server)
|
||||
{
|
||||
$name = rawurlencode($server['name']);
|
||||
$query = http_build_query([
|
||||
'protocol' => 'udp',
|
||||
'auth' => $password,
|
||||
'insecure' => $server['insecure'],
|
||||
'peer' => $server['server_name'],
|
||||
'upmbps' => $server['up_mbps'],
|
||||
'downmbps' => $server['up_mbps'],
|
||||
'alpn' => 'h3',
|
||||
'obfsParam' => $server['server_key']
|
||||
]);
|
||||
$uri = "hysteria://{$server['host']}:{$server['port']}?{$query}#{$name}";
|
||||
$uri .= "\r\n";
|
||||
return $uri;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -120,4 +120,10 @@ class Helper
|
||||
$portRange = explode('-', $range);
|
||||
return rand($portRange[0], $portRange[1]);
|
||||
}
|
||||
|
||||
public static function base64EncodeUrlSafe($data)
|
||||
{
|
||||
$encoded = base64_encode($data);
|
||||
return str_replace(['+', '/', '='], ['-', '_', ''], $encoded);
|
||||
}
|
||||
}
|
||||
|
2
public/assets/admin/umi.js
vendored
2
public/assets/admin/umi.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user