Skip to content

Commit

Permalink
1. 增加缺失 环境变量 keep_connect
Browse files Browse the repository at this point in the history
2. 删去多余的 环境变量 user_agreement_scheme
3. 兼容单多承载没有按照 geek的端口偏移填写规范来的 bug
4. 增加对node_id的key是否存在的bug判断的补丁(有些丑)
  • Loading branch information
v2rayv3 committed Mar 10, 2020
1 parent fb18b2c commit 9a8c562
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 17 deletions.
2 changes: 1 addition & 1 deletion config/.config.example.php
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@

$_ENV['checkNodeIp'] = true; //是否webapi验证节点ip
$_ENV['muKeyList'] = []; //多 key 列表

$_ENV['keep_connect'] = false; // 流量耗尽用户限速至 1Mbps
$_ENV['money_from_admin'] = false; //是否开启管理员修改用户余额时创建充值记录

#aws
Expand Down
7 changes: 6 additions & 1 deletion src/Controllers/Mod_Mu/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ public function index($request, $response, $args)
{
$params = $request->getQueryParams();

$node_id = $params['node_id'];
if (isset($params['node_id'])) {
$node_id = $params['node_id'];
}else {
$node_id = '0';
}

$node = new Node();
if ($node_id == '0') {
$node = Node::where('node_ip', $_SERVER['REMOTE_ADDR'])->first();
Expand Down
1 change: 0 additions & 1 deletion src/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,6 @@ public function edit($request, $response, $args)

return $this->view()
->assign('user', $this->user)
->assign('schemes', $_ENV['user_agreement_scheme'])
->assign('themes', $themes)
->assign('isBlock', $isBlock)
->assign('Block', $Block)
Expand Down
32 changes: 18 additions & 14 deletions src/Utils/Tools.php
Original file line number Diff line number Diff line change
Expand Up @@ -616,26 +616,30 @@ public static function OutPort($server, $node_name, $mu_port)
{
$node_server = explode(';', $server);
$node_port = $mu_port;
if (strpos($node_server[1], 'port') !== false) {
$item = URL::parse_args($node_server[1]);
if (strpos($item['port'], '#') !== false) { // 端口偏移,指定端口,格式:8.8.8.8;port=80#1080
if (strpos($item['port'], '+') !== false) { // 多个单端口节点,格式:8.8.8.8;port=80#1080+443#8443
$args_explode = explode('+', $item['port']);
foreach ($args_explode as $arg) {
if ((int) substr($arg, 0, strpos($arg, '#')) == $mu_port) {
$node_port = (int) substr($arg, strpos($arg, '#') + 1);

if (isset($node_server[1])) {
if (strpos($node_server[1], 'port') !== false) {
$item = URL::parse_args($node_server[1]);
if (strpos($item['port'], '#') !== false) { // 端口偏移,指定端口,格式:8.8.8.8;port=80#1080
if (strpos($item['port'], '+') !== false) { // 多个单端口节点,格式:8.8.8.8;port=80#1080+443#8443
$args_explode = explode('+', $item['port']);
foreach ($args_explode as $arg) {
if ((int) substr($arg, 0, strpos($arg, '#')) == $mu_port) {
$node_port = (int) substr($arg, strpos($arg, '#') + 1);
}
}
} else {
if ((int) substr($item['port'], 0, strpos($item['port'], '#')) == $mu_port) {
$node_port = (int) substr($item['port'], strpos($item['port'], '#') + 1);
}
}
} else {
if ((int) substr($item['port'], 0, strpos($item['port'], '#')) == $mu_port) {
$node_port = (int) substr($item['port'], strpos($item['port'], '#') + 1);
}
} else { // 端口偏移,偏移端口,格式:8.8.8.8;port=1000 or 8.8.8.8;port=-1000
$node_port = ($mu_port + (int) $item['port']);
}
} else { // 端口偏移,偏移端口,格式:8.8.8.8;port=1000 or 8.8.8.8;port=-1000
$node_port = ($mu_port + (int) $item['port']);
}
}


return [
'name' => ($_ENV['disable_sub_mu_port'] ? $node_name : $node_name . ' - ' . $node_port . ' 单端口'),
'address' => $node_server[0],
Expand Down

0 comments on commit 9a8c562

Please sign in to comment.