add server rules

This commit is contained in:
Tokumeikoi 2020-02-10 18:48:06 +08:00
parent 3a7a0c6e62
commit 5bd524fbf1
4 changed files with 13 additions and 1 deletions

View File

@ -40,6 +40,11 @@ class ServerController extends Controller
if (isset($params['tags'])) {
$params['tags'] = json_encode($params['tags']);
}
if (isset($params['rules'])) {
if (!is_object(json_decode($params['rules']))) {
abort(500, '审计规则配置格式不正确');
}
}
if (isset($params['settings'])) {
if (!is_object(json_decode($params['settings']))) {

View File

@ -12,7 +12,7 @@ use Illuminate\Support\Facades\Cache;
class DeepbworkController extends Controller
{
CONST SERVER_CONFIG = '{"api":{"services":["HandlerService","StatsService"],"tag":"api"},"stats":{},"inbound":{"port":443,"protocol":"vmess","settings":{"clients":[]},"streamSettings":{"network":"tcp"},"tag":"proxy"},"inboundDetour":[{"listen":"0.0.0.0","port":23333,"protocol":"dokodemo-door","settings":{"address":"0.0.0.0"},"tag":"api"}],"log":{"loglevel":"debug","access":"access.log","error":"error.log"},"outbound":{"protocol":"freedom","settings":{}},"routing":{"settings":{"rules":[{"inboundTag":["api"],"outboundTag":"api","type":"field"}]},"strategy":"rules"},"policy":{"levels":{"0":{"handshake":4,"connIdle":300,"uplinkOnly":5,"downlinkOnly":30,"statsUserUplink":true,"statsUserDownlink":true}}}}';
CONST SERVER_CONFIG = '{"api":{"services":["HandlerService","StatsService"],"tag":"api"},"stats":{},"inbound":{"port":443,"protocol":"vmess","settings":{"clients":[]},"streamSettings":{"network":"tcp"},"tag":"proxy"},"inboundDetour":[{"listen":"0.0.0.0","port":23333,"protocol":"dokodemo-door","settings":{"address":"0.0.0.0"},"tag":"api"}],"log":{"loglevel":"debug","access":"access.log","error":"error.log"},"outbound":{"protocol":"freedom","settings":{}},"outboundDetour":[{"protocol":"blackhole","settings":{},"tag":"block"}],"routing":{"settings":{"rules":[{"inboundTag":["api"],"outboundTag":"api","type":"field"}]},"strategy":"rules"},"policy":{"levels":{"0":{"handshake":4,"connIdle":300,"uplinkOnly":5,"downlinkOnly":30,"statsUserUplink":true,"statsUserDownlink":true}}}}';
public function __construct(Request $request)
{

View File

@ -7,6 +7,7 @@ use Illuminate\Foundation\Http\FormRequest;
class ServerSave extends FormRequest
{
CONST RULES = [
'rules' => '',
'show' => '',
'name' => 'required',
'group_id' => 'required|array',

View File

@ -137,3 +137,9 @@ ADD `pv` int(11) NOT NULL DEFAULT '0' AFTER `status`;
ALTER TABLE `v2_user`
ADD `password_algo` char(10) COLLATE 'utf8_general_ci' NULL AFTER `password`;
ALTER TABLE `v2_server`
CHANGE `tls` `tls` tinyint(4) NOT NULL DEFAULT '0' AFTER `server_port`;
ALTER TABLE `v2_server`
ADD `rules` text COLLATE 'utf8_general_ci' NULL AFTER `settings`;