V2RayN 客户端支持附带节点信息下载

Admin-mod-add-vmess-sub
GeekQu 7 years ago
parent 7c817b6174
commit d47bd98773
No known key found for this signature in database
GPG Key ID: F0EEABFCD04A5891

@ -32,6 +32,7 @@ use App\Utils\Telegram;
use ArrayObject;
use App\Models\Disconnect;
use App\Models\GConfig;
use App\Models\Token;
use App\Models\UnblockIp;
use Exception;
use RuntimeException;
@ -154,6 +155,8 @@ class Job
// 清理订阅记录
UserSubscribeLog::where('request_time', '<', date('Y-m-d H:i:s', time() - 86400 * (int) Config::get('subscribeLog_keep_days')))->delete();
Token::where('expire_time', '<', time())->delete();
NodeInfoLog::where('log_time', '<', time() - 86400 * 3)->delete();
NodeOnlineLog::where('log_time', '<', time() - 86400 * 3)->delete();
TrafficLog::where('log_time', '<', time() - 86400 * 3)->delete();

@ -1331,6 +1331,112 @@ class LinkController extends BaseController
return json_encode($config, JSON_PRETTY_PRINT);
}
public static function getV2RayPcNConf($user)
{
$subUrl = self::getSubinfo($user, 0)['v2ray'];
$subId = Uuid::uuid3(Uuid::NAMESPACE_DNS, $subUrl)->toString();
$config = [
'inbound' => [
[
'localPort' => 10808,
'protocol' => 'socks',
'udpEnabled' => true,
'sniffingEnabled' => true,
],
],
'logEnabled' => false,
'loglevel' => 'warning',
'index' => 0,
'vmess' => [],
'muxEnabled' => false,
'domainStrategy' => 'IPIfNonMatch',
'routingMode' => '3',
'useragent' => [],
'userdirect' => [],
'userblock' => [],
'kcpItem' => [
'mtu' => 1350,
'tti' => 50,
'uplinkCapacity' => 12,
'downlinkCapacity' => 100,
'congestion' => false,
'readBufferSize' => 2,
'writeBufferSize' => 2,
],
'listenerType' => 0,
'urlGFWList' => 'https://raw.githubusercontent.com/gfwlist/gfwlist/master/gfwlist.txt',
'allowLANConn' => false,
'enableStatistics' => true,
'statisticsFreshRate' => 2000,
'remoteDNS' => '114.114.114.114,1.2.4.8,223.5.5.5,8,8,8,8',
'subItem' => [
[
'id' => $subId,
'remarks' => $_ENV['appName'],
'url' => $subUrl,
'enabled' => true,
],
],
'uiItem' => [
'mainQRCodeWidth' => 600,
],
'userPacRule' => []
];
$Rule = [
'type' => 'vmess',
'is_mu' => ($_ENV['mergeSub'] === true ? 1 : 0),
'emoji' => $_ENV['add_emoji_to_node_name'],
'extend' => $_ENV['enable_sub_extend'],
];
$proxys = [];
$items = URL::getNew_AllItems($user, $Rule);
foreach ($items as $item) {
if (!in_array($item['net'], ['tcp', 'ws', 'kcp', 'h2'])) {
continue;
}
$proxy = [
'configVersion' => 2,
'address' => $item['add'],
'port' => $item['port'],
'id' => $item['id'],
'alterId' => $item['aid'],
'security' => 'auto',
'network' => $item['net'],
'remarks' => $item['remark'],
'headerType' => 'none',
'requestHost' => '',
'path' => '',
'streamSecurity' => '',
'allowInsecure' => '',
'configType' => 1,
'testResult' => '',
'subid' => $subId,
];
switch ($item['net']) {
case 'h2':
$proxy['requestHost'] = ($item['host'] != '' ? $item['host'] : $item['add']);
$proxy['path'] = $item['path'];
break;
case 'ws':
$proxy['requestHost'] = ($item['host'] != '' ? $item['host'] : $item['add']);
$proxy['path'] = $item['path'];
break;
case 'kcp':
$proxy['headerType'] = $item['type'];
break;
}
if ($item['tls'] == 'tls') {
$proxy['streamSecurity'] = $item['tls'];
if ($item['verify_cert'] == false){
$proxy['allowInsecure'] = 'true';
}
}
$proxys[] = $proxy;
}
$config['vmess'] = $proxys;
return json_encode($config, JSON_PRETTY_PRINT);
}
/**
* 通用订阅,ssr & v2rayn
*

@ -37,6 +37,7 @@ use App\Models\BlockIp;
use App\Models\UnblockIp;
use App\Models\Payback;
use App\Models\Relay;
use App\Models\Token;
use App\Models\UserSubscribeLog;
use App\Utils\QQWry;
use App\Utils\GA;
@ -73,9 +74,28 @@ class UserController extends BaseController
$Ann = Ann::orderBy('date', 'desc')->first();
if ($_ENV['subscribe_client_url'] != '') {
$getClient = new Token();
for ($i = 0; $i < 10; $i++) {
$token = $this->user->id . Tools::genRandomChar(16);
$Elink = Token::where('token', '=', $token)->first();
if ($Elink == null) {
$getClient->token = $token;
break;
}
}
$getClient->user_id = $this->user->id;
$getClient->create_time = time();
$getClient->expire_time = time() + 10 * 60;
$getClient->save();
} else {
$token = '';
}
return $this->view()
->assign('subInfo', LinkController::getSubinfo($this->user, 0))
->assign('ssr_sub_token', $ssr_sub_token)
->assign('getClient', $token)
->assign('display_ios_class', Config::get('display_ios_class'))
->assign('display_ios_topup', Config::get('display_ios_topup'))
->assign('ios_account', Config::get('ios_account'))
@ -1886,6 +1906,12 @@ class UserController extends BaseController
$content = LinkController::getSSRPcConf($this->user);
$client_path .= $type . '/';
break;
case 'v2rayn-win':
$temp_file_path .= $type . '_' . $user_token . '.zip';
$user_config_file_name = 'guiNConfig.json';
$content = LinkController::getV2RayPcNConf($this->user);
$client_path .= $type . '/';
break;
default:
return 'gg';
}
@ -1909,6 +1935,21 @@ class UserController extends BaseController
return $newResponse;
}
public function getClientfromToken($request, $response, $args)
{
$token = $args['token'];
$Etoken = Token::where('token', '=', $token)->where('create_time', '>', time() - 60 * 10)->first();
if ($Etoken == null) {
return '下载链接已失效,请刷新页面后重新点击.';
}
$user = User::find($Etoken->user_id);
if ($user == null) {
return null;
}
$this->user = $user;
return self::getPcClient($request, $response, $args);
}
/**
* 清理订阅缓存
*

@ -67,6 +67,7 @@ class Config
'subscribe_client' => self::get('subscribe_client'),
'enable_sub_cache' => self::get('enable_sub_cache'),
'use_new_telegram_bot' => self::get('use_new_telegram_bot'),
'subscribe_client_url' => self::get('subscribe_client_url'),
];
}

@ -378,6 +378,7 @@ $_ENV['db_collation'] = 'utf8_general_ci';
$_ENV['db_prefix'] = '';
$_ENV['muKeyList'] = []; //多 key 列表
$_ENV['subscribe_client'] = false; //下载协议客户端时附带节点和订阅信息
$_ENV['subscribe_client_url'] = ''; //使用独立的服务器提供附带节点和订阅信息的协议客户端下载,为空表示不使用
$_ENV['mu_port_migration'] = false; //为后端直接下发偏移后的端口
$_ENV['relay_port_migration'] = false; //为中转规则下发偏移后的端口,此项未经测试

@ -369,6 +369,9 @@ $app->group('/res', function () {
$this->get('/captcha/{id}', App\Controllers\ResController::class . ':captcha');
});
$app->group('/getClient', function () {
$this->get('/{token}', App\Controllers\UserController::class . ':getClientfromToken');
});
$app->group('/link', function () {
$this->get('/{token}', App\Controllers\LinkController::class . ':GetContent');

@ -0,0 +1,3 @@
尊敬的用户您好:
如您在使用上遇到问题,请注意在我们的网站上查询相关的教程或联系我们。

@ -411,23 +411,27 @@ table tr td:first-child {
</div>
<div class="tab-pane fade" id="sub_center_windows">
<p><span class="icon icon-lg text-white">filter_1</span> <a class="btn-dl" href="{if $config["subscribe_client"]===true}/user/getPcClient?type=ss-win{else}https://github.com/shadowsocks/shadowsocks-windows/releases{/if}"><i class="material-icons">save_alt</i> 下载</a> SS - [ SS ]:</p>
<p><span class="icon icon-lg text-white">filter_1</span> <a class="btn-dl" href="{if $config["subscribe_client"]===true}{if $config["subscribe_client_url"]==''}/user/getPcClient{else}{$config["subscribe_client_url"]}/getClient/{$getClient}{/if}?type=ss-win{else}https://github.com/shadowsocks/shadowsocks-windows/releases{/if}"><i class="material-icons">save_alt</i> 下载</a> SS - [ SS ]:</p>
<p>教程文档:<a class="btn-dl" href="/doc/#/Windows/Shadowsocks"><i class="material-icons icon-sm">how_to_vote</i>点击查看</a></p>
<p>使用方式:<a id="win_ss" class="copy-config btn-dl" onclick=Copyconfig("/user/getUserAllURL?type=ss","#win_ss","")><i class="material-icons icon-sm">how_to_vote</i>全部 URL</a></p>
<hr/>
<p><span class="icon icon-lg text-white">filter_2</span> <a class="btn-dl" href="{if $config["subscribe_client"]===true}/user/getPcClient?type=ssd-win{else}https://github.com/CGDF-Github/SSD-Windows/releases{/if}"><i class="material-icons">save_alt</i> 下载</a> SSD - [ SS ]:</p>
<p><span class="icon icon-lg text-white">filter_2</span> <a class="btn-dl" href="{if $config["subscribe_client"]===true}{if $config["subscribe_client_url"]==''}/user/getPcClient{else}{$config["subscribe_client_url"]}/getClient/{$getClient}{/if}?type=ssd-win{else}https://github.com/CGDF-Github/SSD-Windows/releases{/if}"><i class="material-icons">save_alt</i> 下载</a> SSD - [ SS ]:</p>
<p>教程文档:<a class="btn-dl" href="/doc/#/Windows/ShadowsocksD"><i class="material-icons icon-sm">how_to_vote</i>点击查看</a></p>
<p>使用方式:<a class="copy-text btn-dl" data-clipboard-text="{$subInfo["ssd"]}"><i class="material-icons icon-sm">how_to_vote</i>拷贝链接</a>.<a id="win_ssd" class="copy-config btn-dl" onclick=Copyconfig("/user/getUserAllURL?type=ssd","#win_ssd","")><i class="material-icons icon-sm">how_to_vote</i>全部 URL</a></p>
<hr/>
<p><span class="icon icon-lg text-white">filter_3</span> <a class="btn-dl" href="{if $config["subscribe_client"]===true}/user/getPcClient?type=ssr-win{else}https://github.com/shadowsocksrr/shadowsocksr-csharp/releases{/if}"><i class="material-icons">save_alt</i> 下载</a> SSR(R) - [ SS/SSR ]:</p>
<p><span class="icon icon-lg text-white">filter_3</span> <a class="btn-dl" href="{if $config["subscribe_client"]===true}{if $config["subscribe_client_url"]==''}/user/getPcClient{else}{$config["subscribe_client_url"]}/getClient/{$getClient}{/if}?type=ssr-win{else}https://github.com/shadowsocksrr/shadowsocksr-csharp/releases{/if}"><i class="material-icons">save_alt</i> 下载</a> SSR(R) - [ SS/SSR ]:</p>
<p>教程文档:<a class="btn-dl" href="/doc/#/Windows/ShadowsocksR"><i class="material-icons icon-sm">how_to_vote</i>点击查看</a></p>
<p>使用方式:<a class="copy-text btn-dl" data-clipboard-text="{$subInfo["ssr"]}"><i class="material-icons icon-sm">how_to_vote</i>订阅链接</a>.<a id="win_ssr" class="copy-config btn-dl" onclick=Copyconfig("/user/getUserAllURL?type=ssr","#win_ssr","")><i class="material-icons icon-sm">how_to_vote</i>全部 URL</a></p>
<hr/>
<p><span class="icon icon-lg text-white">filter_4</span> <a class="btn-dl" href="https://github.com/Fndroid/clash_for_windows_pkg/releases"><i class="material-icons">save_alt</i> 下载</a> Clash for Windows - [ SS/VMess ]:</p>
<p><span class="icon icon-lg text-white">filter_4</span> <a class="btn-dl" href="{if $config["subscribe_client"]===true}{if $config["subscribe_client_url"]==''}/user/getPcClient{else}{$config["subscribe_client_url"]}/getClient/{$getClient}{/if}?type=v2rayn-win{else}https://github.com/2dust/v2rayN/releases{/if}"><i class="material-icons">save_alt</i> 下载</a> V2RayN - [ SS/VMess ]:</p>
<p>教程文档:<a class="btn-dl" href="/doc/#/Windows/V2RayN"><i class="material-icons icon-sm">how_to_vote</i>点击查看</a></p>
<p>使用方式:<a class="copy-text btn-dl" data-clipboard-text="{$subInfo["v2ray"]}"><i class="material-icons icon-sm">how_to_vote</i>订阅链接</a>.<a id="win_v2rayn" class="copy-config btn-dl" onclick=Copyconfig("/user/getUserAllURL?type=v2ray","#win_v2rayn","")><i class="material-icons icon-sm">how_to_vote</i>全部 URL</a></p>
<hr/>
<p><span class="icon icon-lg text-white">filter_5</span> <a class="btn-dl" href="https://github.com/Fndroid/clash_for_windows_pkg/releases"><i class="material-icons">save_alt</i> 下载</a> Clash for Windows - [ SS/VMess ]:</p>
<p>教程文档:<a class="btn-dl" href="/doc/#/Windows/Clash-for-Windows"><i class="material-icons icon-sm">how_to_vote</i>点击查看</a></p>
<p>使用方式:<a class="btn-dl" href="{$subInfo["clash"]}"><i class="material-icons icon-sm">how_to_vote</i>配置下载</a>.<a class="btn-dl" href="clash://install-config?url={urlencode($subInfo["clash"])}"><i class="material-icons icon-sm">how_to_vote</i>Clash for Windows 一键导入</a></p>
<hr/>
<p><span class="icon icon-lg text-white">filter_5</span> <a class="btn-dl" href="#"><i class="material-icons">save_alt</i> 下载</a> ClashR for Windows - [ SS/SSR/VMess ]:</p>
<p><span class="icon icon-lg text-white">filter_6</span> <a class="btn-dl" href="#"><i class="material-icons">save_alt</i> 下载</a> ClashR for Windows - [ SS/SSR/VMess ]:</p>
<p>教程文档:自行摸索</p>
<p>使用方式:<a class="btn-dl" href="{$subInfo["clashr"]}"><i class="material-icons icon-sm">how_to_vote</i>配置下载</a>.<a class="btn-dl" href="clash://install-config?url={urlencode($subInfo["clashr"])}"><i class="material-icons icon-sm">how_to_vote</i>ClashR for Windows 一键导入</a></p>
</div>

Loading…
Cancel
Save