This commit is contained in:
v2board 2023-05-20 20:51:41 +08:00
commit 45fd04137b
11 changed files with 193 additions and 1 deletions

View File

@ -128,6 +128,11 @@ class Clash
$array['servername'] = $tlsSettings['serverName']; $array['servername'] = $tlsSettings['serverName'];
} }
} }
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 ($server['network'] === 'ws') { if ($server['network'] === 'ws') {
$array['network'] = 'ws'; $array['network'] = 'ws';
if ($server['networkSettings']) { if ($server['networkSettings']) {

View File

@ -128,6 +128,11 @@ class ClashMeta
$array['servername'] = $tlsSettings['serverName']; $array['servername'] = $tlsSettings['serverName'];
} }
} }
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 ($server['network'] === 'ws') { if ($server['network'] === 'ws') {
$array['network'] = 'ws'; $array['network'] = 'ws';
if ($server['networkSettings']) { if ($server['networkSettings']) {

View File

@ -80,6 +80,11 @@ class General
$config['sni'] = $tlsSettings['serverName']; $config['sni'] = $tlsSettings['serverName'];
} }
} }
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 ((string)$server['network'] === 'ws') { if ((string)$server['network'] === 'ws') {
$wsSettings = $server['networkSettings']; $wsSettings = $server['networkSettings'];
if (isset($wsSettings['path'])) $config['path'] = $wsSettings['path']; if (isset($wsSettings['path'])) $config['path'] = $wsSettings['path'];

View File

@ -0,0 +1,128 @@
<?php
namespace App\Http\Controllers\Client\Protocols;
use App\Utils\Helper;
class Loon
{
public $flag = 'loon';
private $servers;
private $user;
public function __construct($user, $servers)
{
$this->user = $user;
$this->servers = $servers;
}
public function handle()
{
$servers = $this->servers;
$user = $this->user;
$uri = '';
header("Subscription-Userinfo: upload={$user['u']}; download={$user['d']}; total={$user['transfer_enable']}; expire={$user['expired_at']}");
foreach ($servers as $item) {
if ($item['type'] === 'shadowsocks'
&& in_array($item['cipher'], [
'aes-128-gcm',
'aes-192-gcm',
'aes-256-gcm',
'chacha20-ietf-poly1305'
])
) {
$uri .= self::buildShadowsocks($user['uuid'], $item);
}
if ($item['type'] === 'vmess') {
$uri .= self::buildVmess($user['uuid'], $item);
}
if ($item['type'] === 'trojan') {
$uri .= self::buildTrojan($user['uuid'], $item);
}
}
return $uri;
}
public static function buildShadowsocks($password, $server)
{
$config = [
"{$server['name']}=Shadowsocks",
"{$server['host']}",
"{$server['port']}",
"{$server['cipher']}",
"{$password}",
'fast-open=false',
'udp=true'
];
$config = array_filter($config);
$uri = implode(',', $config);
$uri .= "\r\n";
return $uri;
}
public static function buildVmess($uuid, $server)
{
$config = [
"{$server['name']}=vmess",
"{$server['host']}",
"{$server['port']}",
'aes-128-gcm',
"{$uuid}",
'fast-open=false',
'udp=true',
"alterId=0"
];
if ($server['network'] === 'tcp') {
array_push($config, 'transport=tcp');
}
if ($server['tls']) {
if ($server['network'] === 'tcp')
array_push($config, 'over-tls=true');
if ($server['tlsSettings']) {
$tlsSettings = $server['tlsSettings'];
if (isset($tlsSettings['allowInsecure']) && !empty($tlsSettings['allowInsecure']))
array_push($config, 'skip-cert-verify=' . ($tlsSettings['allowInsecure'] ? 'true' : 'false'));
if (isset($tlsSettings['serverName']) && !empty($tlsSettings['serverName']))
array_push($config, "tls-name={$tlsSettings['serverName']}");
}
}
if ($server['network'] === 'ws') {
array_push($config, 'transport=ws');
if ($server['networkSettings']) {
$wsSettings = $server['networkSettings'];
if (isset($wsSettings['path']) && !empty($wsSettings['path']))
array_push($config, "path={$wsSettings['path']}");
if (isset($wsSettings['headers']['Host']) && !empty($wsSettings['headers']['Host']))
array_push($config, "host={$wsSettings['headers']['Host']}");
}
}
$uri = implode(',', $config);
$uri .= "\r\n";
return $uri;
}
public static function buildTrojan($password, $server)
{
$config = [
"{$server['name']}=trojan",
"{$server['host']}",
"{$server['port']}",
"{$password}",
$server['server_name'] ? "tls-name={$server['server_name']}" : "",
'fast-open=false',
'udp=true'
];
if (!empty($server['allow_insecure'])) {
array_push($config, $server['allow_insecure'] ? 'skip-cert-verify=true' : 'skip-cert-verify=false');
}
$config = array_filter($config);
$uri = implode(',', $config);
$uri .= "\r\n";
return $uri;
}
}

View File

@ -68,6 +68,11 @@ class Passwall
$config['sni'] = $tlsSettings['serverName']; $config['sni'] = $tlsSettings['serverName'];
} }
} }
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 ((string)$server['network'] === 'ws') { if ((string)$server['network'] === 'ws') {
$wsSettings = $server['networkSettings']; $wsSettings = $server['networkSettings'];
if (isset($wsSettings['path'])) $config['path'] = $wsSettings['path']; if (isset($wsSettings['path'])) $config['path'] = $wsSettings['path'];

View File

@ -72,6 +72,11 @@ class SagerNet
$config['sni'] = urlencode($tlsSettings['serverName']); $config['sni'] = urlencode($tlsSettings['serverName']);
} }
} }
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 ((string)$server['network'] === 'ws') { if ((string)$server['network'] === 'ws') {
$wsSettings = $server['networkSettings']; $wsSettings = $server['networkSettings'];
if (isset($wsSettings['path'])) $config['path'] = $wsSettings['path']; if (isset($wsSettings['path'])) $config['path'] = $wsSettings['path'];

View File

@ -82,6 +82,15 @@ class Shadowrocket
$config['peer'] = $tlsSettings['serverName']; $config['peer'] = $tlsSettings['serverName'];
} }
} }
if ($server['network'] === 'tcp') {
if ($server['networkSettings']) {
$tcpSettings = $server['networkSettings'];
if (isset($tcpSettings['header']['type']) && !empty($tcpSettings['header']['type']))
$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 ($server['network'] === 'ws') { if ($server['network'] === 'ws') {
$config['obfs'] = "websocket"; $config['obfs'] = "websocket";
if ($server['networkSettings']) { if ($server['networkSettings']) {

View File

@ -125,6 +125,11 @@ class Stash
$array['servername'] = $tlsSettings['serverName']; $array['servername'] = $tlsSettings['serverName'];
} }
} }
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 ($server['network'] === 'ws') { if ($server['network'] === 'ws') {
$array['network'] = 'ws'; $array['network'] = 'ws';
if ($server['networkSettings']) { if ($server['networkSettings']) {

View File

@ -80,6 +80,11 @@ class V2rayN
$config['sni'] = $tlsSettings['serverName']; $config['sni'] = $tlsSettings['serverName'];
} }
} }
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 ((string)$server['network'] === 'ws') { if ((string)$server['network'] === 'ws') {
$wsSettings = $server['networkSettings']; $wsSettings = $server['networkSettings'];
if (isset($wsSettings['path'])) $config['path'] = $wsSettings['path']; if (isset($wsSettings['path'])) $config['path'] = $wsSettings['path'];

View File

@ -68,6 +68,11 @@ class V2rayNG
$config['sni'] = $tlsSettings['serverName']; $config['sni'] = $tlsSettings['serverName'];
} }
} }
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 ((string)$server['network'] === 'ws') { if ((string)$server['network'] === 'ws') {
$wsSettings = $server['networkSettings']; $wsSettings = $server['networkSettings'];
if (isset($wsSettings['path'])) $config['path'] = $wsSettings['path']; if (isset($wsSettings['path'])) $config['path'] = $wsSettings['path'];

View File

@ -33,6 +33,11 @@ class StripeCheckout {
'label' => 'WebHook 密钥签名', 'label' => 'WebHook 密钥签名',
'description' => '', 'description' => '',
'type' => 'input', 'type' => 'input',
],
'stripe_custom_field_name' => [
'label' => '自定义字段名称',
'description' => '例如可设置为“联系方式”,以便及时与客户取得联系',
'type' => 'input',
] ]
]; ];
} }
@ -44,6 +49,7 @@ class StripeCheckout {
if (!$exchange) { if (!$exchange) {
abort(500, __('Currency conversion has timed out, please try again later')); abort(500, __('Currency conversion has timed out, please try again later'));
} }
$customFieldName = isset($this->config['stripe_custom_field_name']) ? $this->config['stripe_custom_field_name'] : 'Contact Infomation';
$params = [ $params = [
'success_url' => $order['return_url'], 'success_url' => $order['return_url'],
@ -61,7 +67,16 @@ class StripeCheckout {
'quantity' => 1 'quantity' => 1
] ]
], ],
'mode' => 'payment' 'mode' => 'payment',
'invoice_creation' => ['enabled' => true],
'phone_number_collection' => ['enabled' => true],
'custom_fields' => [
[
'key' => 'contactinfo',
'label' => ['type' => 'custom', 'custom' => $customFieldName],
'type' => 'text',
],
],
// 'customer_email' => $user['email'] not support // 'customer_email' => $user['email'] not support
]; ];