Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

节点和商品的IP限制和端口限速功能 #12

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions app/Controllers/Admin/NodeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function index($request, $response, $args)
"server" => "节点地址", "node_ip" => "节点IP",
"info" => "节点信息",
"status" => "状态", "traffic_rate" => "流量比率", "node_group" => "节点群组",
"node_class" => "节点等级", "node_speedlimit" => "节点限速/Mbps",
"node_class" => "节点等级", "node_speedlimit" => "节点限速/Mbps", "node_connector" => "节点IP限制",
"node_bandwidth" => "已走流量/GB", "node_bandwidth_limit" => "流量限制/GB",
"bandwidthlimit_resetday" => "流量重置日", "node_heartbeat" => "上一次活跃时间",
"custom_method" => "自定义加密", "custom_rss" => "自定义协议以及混淆",
Expand Down Expand Up @@ -50,6 +50,7 @@ public function add($request, $response, $args)
$node->type = $request->getParam('type');
$node->node_group = $request->getParam('group');
$node->node_speedlimit = $request->getParam('node_speedlimit');
$node->node_connector = $request->getParam('node_connector');
$node->status = $request->getParam('status');
$node->sort = $request->getParam('sort');
if ($node->sort == 0 || $node->sort == 1 || $node->sort == 10) {
Expand Down Expand Up @@ -106,6 +107,7 @@ public function update($request, $response, $args)
$node->traffic_rate = $request->getParam('rate');
$node->info = $request->getParam('info');
$node->node_speedlimit = $request->getParam('node_speedlimit');
$node->node_connector = $request->getParam('node_connector');
$node->type = $request->getParam('type');
$node->sort = $request->getParam('sort');

Expand Down Expand Up @@ -192,7 +194,7 @@ public function ajax($request, $response, $args)
"server" => "节点地址", "node_ip" => "节点IP",
"info" => "节点信息",
"status" => "状态", "traffic_rate" => "流量比率", "node_group" => "节点群组",
"node_class" => "节点等级", "node_speedlimit" => "节点限速/Mbps",
"node_class" => "节点等级", "node_speedlimit" => "节点限速/Mbps", "node_connector" => "节点IP限制",
"node_bandwidth" => "已走流量/GB", "node_bandwidth_limit" => "流量限制/GB",
"bandwidthlimit_resetday" => "流量重置日", "node_heartbeat" => "上一次活跃时间",
"custom_method" => "自定义加密", "custom_rss" => "自定义协议以及混淆",
Expand Down
16 changes: 16 additions & 0 deletions app/Controllers/Admin/ShopController.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ public function add($request, $response, $args)
$content["reset_exp"]=$request->getParam('reset_exp');
}

if ($request->getParam('speedlimit')!=0) {
$content["speedlimit"]=$request->getParam('speedlimit');
}

if ($request->getParam('connector')!=0) {
$content["connector"]=$request->getParam('connector');
}

$shop->content=json_encode($content);


Expand Down Expand Up @@ -138,6 +146,14 @@ public function update($request, $response, $args)
if ($request->getParam('reset_exp')!=0) {
$content["reset_exp"]=$request->getParam('reset_exp');
}

if ($request->getParam('speedlimit')!=0) {
$content["speedlimit"]=$request->getParam('speedlimit');
}

if ($request->getParam('connector')!=0) {
$content["connector"]=$request->getParam('connector');
}

$shop->content=json_encode($content);

Expand Down
34 changes: 33 additions & 1 deletion app/Models/Shop.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,16 @@ public function content()
case "reset":
$content_text .= " 在 ".$content["reset_exp"]." 天内,每 ".$value." 天重置流量为 ".$content["reset_value"]." G ";
break;
case "speedlimit":
$content_text .= "用户端口限速变为".$content["speedlimit"]." Mbps";
break;
case "connector":
$content_text .= "用户IP限制变为".$content["connector"]." 个";
break;
default:
}

if ($i<count($content)&&$key!="reset_exp") {
if ($i<count($content)&&$key!="connector") {
$content_text .= ",";
}

Expand Down Expand Up @@ -115,6 +121,26 @@ public function class_expire()
}
}

public function speedlimit()
{
$content = json_decode($this->attributes['content']);
if (isset($content->speedlimit)) {
return $content->speedlimit;
} else {
return 0;
}
}

public function connector()
{
$content = json_decode($this->attributes['content']);
if (isset($content->connector)) {
return $content->connector;
} else {
return 0;
}
}

public function buy($user, $is_renew = 0)
{
$content = json_decode($this->attributes['content'], true);
Expand Down Expand Up @@ -157,6 +183,12 @@ public function buy($user, $is_renew = 0)
$user->class_expire=date("Y-m-d H:i:s", strtotime($user->class_expire)+$content["class_expire"]*86400);
$user->class=$value;
break;
case "speedlimit":
$user->node_speedlimit=$value;
break;
case "connector":
$user->node_connector=$value;
break;
default:
}
}
Expand Down
7 changes: 7 additions & 0 deletions resources/views/material/admin/node/create.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@
<label class="floating-label" for="node_speedlimit">节点限速(对于每个用户端口)(Mbps)</label>
<input class="form-control" id="node_speedlimit" type="text" value="0" name="node_speedlimit">
</div>

<div class="form-group form-group-label">
<label class="floating-label" for="node_connector">节点IP限制</label>
<input class="form-control" id="node_connector" type="text" value="0" name="node_connector">
</div>
</div>
</div>
</div>
Expand Down Expand Up @@ -205,6 +210,7 @@
group: {required: true},
status: {required: true},
node_speedlimit: {required: true},
node_connector: {required: true},
sort: {required: true},
node_bandwidth_limit: {required: true},
bandwidthlimit_resetday: {required: true}
Expand Down Expand Up @@ -255,6 +261,7 @@
group: $("#group").val(),
status: $("#status").val(),
node_speedlimit: $("#node_speedlimit").val(),
node_connector: $("#node_connector").val(),
sort: $("#sort").val(),
class: $("#class").val(),
node_bandwidth_limit: $("#node_bandwidth_limit").val(),
Expand Down
6 changes: 6 additions & 0 deletions resources/views/material/admin/node/edit.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@
<label class="floating-label" for="node_speedlimit">节点限速(对于每个用户端口)(Mbps)</label>
<input class="form-control" id="node_speedlimit" name="node_speedlimit" type="text" value="{$node->node_speedlimit}">
</div>
<div class="form-group form-group-label">
<label class="floating-label" for="node_connector">节点IP限制</label>
<input class="form-control" id="node_connector" type="text" value="0" name="{$node->node_connector}">
</div>
</div>
</div>
</div>
Expand Down Expand Up @@ -202,6 +206,7 @@
group: {required: true},
status: {required: true},
node_speedlimit: {required: true},
node_connector: {required: true},
sort: {required: true},
node_bandwidth_limit: {required: true},
bandwidthlimit_resetday: {required: true}
Expand Down Expand Up @@ -257,6 +262,7 @@
status: $("#status").val(),
sort: $("#sort").val(),
node_speedlimit: $("#node_speedlimit").val(),
node_connector: $("#node_connector").val(),
class: $("#class").val(),
node_bandwidth_limit: $("#node_bandwidth_limit").val(),
bandwidthlimit_resetday: $("#bandwidthlimit_resetday").val(){/literal},
Expand Down
18 changes: 18 additions & 0 deletions resources/views/material/admin/shop/create.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,22 @@
</div>


<div class="card">
<div class="card-main">
<div class="card-inner">
<div class="form-group form-group-label">
<label class="floating-label" for="speedlimit">端口限速</label>
<input class="form-control" id="speedlimit" type="number" value="0">
</div>


<div class="form-group form-group-label">
<label class="floating-label" for="connector">IP限制</label>
<input class="form-control" id="connector" type="number" value="0">
</div>
</div>
</div>
</div>


<div class="card">
Expand Down Expand Up @@ -181,6 +197,8 @@
price: $("#price").val(),
auto_renew: $("#auto_renew").val(),
bandwidth: $("#bandwidth").val(),
speedlimit: $("#speedlimit").val(),
connector: $("#connector").val(),
expire: $("#expire").val(),
class: $("#class").val(),
class_expire: $("#class_expire").val(),
Expand Down
22 changes: 22 additions & 0 deletions resources/views/material/admin/shop/edit.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,26 @@
</div>




<div class="card">
<div class="card-main">
<div class="card-inner">
<div class="form-group form-group-label">
<label class="floating-label" for="speedlimit">端口限速</label>
<input class="form-control" id="speedlimit" type="number" value="0">
</div>


<div class="form-group form-group-label">
<label class="floating-label" for="connector">IP限制</label>
<input class="form-control" id="connector" type="number" value="0">
</div>
</div>
</div>
</div>


<div class="card">
<div class="card-main">
<div class="card-inner">
Expand Down Expand Up @@ -181,6 +201,8 @@
price: $("#price").val(),
auto_renew: $("#auto_renew").val(),
bandwidth: $("#bandwidth").val(),
speedlimit: $("#speedlimit").val(),
connector: $("#connector").val(),
expire: $("#expire").val(),
class: $("#class").val(),
class_expire: $("#class_expire").val(),
Expand Down