mirror of
https://github.com/v2board/v2board.git
synced 2024-11-13 11:09:11 +08:00
opt tls
This commit is contained in:
parent
cb8cdb2e0e
commit
7f9ad68e1b
@ -35,25 +35,18 @@ class ServerController extends Controller
|
|||||||
|
|
||||||
public function save(ServerSave $request)
|
public function save(ServerSave $request)
|
||||||
{
|
{
|
||||||
$params = $request->only([
|
$params = $request->only(array_keys(ServerSave::RULES));
|
||||||
'show',
|
|
||||||
'group_id',
|
|
||||||
'parent_id',
|
|
||||||
'name',
|
|
||||||
'host',
|
|
||||||
'port',
|
|
||||||
'server_port',
|
|
||||||
'tls',
|
|
||||||
'tags',
|
|
||||||
'rate',
|
|
||||||
'network',
|
|
||||||
'settings'
|
|
||||||
]);
|
|
||||||
$params['group_id'] = json_encode($params['group_id']);
|
$params['group_id'] = json_encode($params['group_id']);
|
||||||
if (isset($params['tags'])) {
|
if (isset($params['tags'])) {
|
||||||
$params['tags'] = json_encode($params['tags']);
|
$params['tags'] = json_encode($params['tags']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($params['tls'])) {
|
||||||
|
if (!isset($params['tls_pem']) || !isset($params['tls_key'])) {
|
||||||
|
abort(500, '开启TLS必须填写TLS证书');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($params['settings'])) {
|
if (isset($params['settings'])) {
|
||||||
if (!is_object(json_decode($params['settings']))) {
|
if (!is_object(json_decode($params['settings']))) {
|
||||||
abort(500, '传输协议配置格式不正确');
|
abort(500, '传输协议配置格式不正确');
|
||||||
|
@ -6,6 +6,21 @@ use Illuminate\Foundation\Http\FormRequest;
|
|||||||
|
|
||||||
class ServerSave extends FormRequest
|
class ServerSave extends FormRequest
|
||||||
{
|
{
|
||||||
|
CONST RULES = [
|
||||||
|
'show' => '',
|
||||||
|
'name' => 'required',
|
||||||
|
'group_id' => 'required|array',
|
||||||
|
'parent_id' => 'nullable|integer',
|
||||||
|
'host' => 'required',
|
||||||
|
'port' => 'required',
|
||||||
|
'server_port' => 'required',
|
||||||
|
'tls' => 'required',
|
||||||
|
'tls_pem' => '',
|
||||||
|
'tls_key' => '',
|
||||||
|
'tags' => 'array',
|
||||||
|
'rate' => 'required|numeric',
|
||||||
|
'network' => 'required|in:tcp,kcp,ws,http,domainsocket,quic'
|
||||||
|
];
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
*
|
*
|
||||||
@ -13,18 +28,7 @@ class ServerSave extends FormRequest
|
|||||||
*/
|
*/
|
||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
return [
|
return self::RULES;
|
||||||
'name' => 'required',
|
|
||||||
'group_id' => 'required|array',
|
|
||||||
'parent_id' => 'nullable|integer',
|
|
||||||
'host' => 'required',
|
|
||||||
'port' => 'required',
|
|
||||||
'server_port' => 'required',
|
|
||||||
'tls' => 'required',
|
|
||||||
'tags' => 'array',
|
|
||||||
'rate' => 'required|numeric',
|
|
||||||
'network' => 'required|in:tcp,kcp,ws,http,domainsocket,quic'
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function messages()
|
public function messages()
|
||||||
|
Loading…
Reference in New Issue
Block a user