mirror of
https://github.com/v2board/v2board.git
synced 2024-11-10 17:49: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)
|
||||
{
|
||||
$params = $request->only([
|
||||
'show',
|
||||
'group_id',
|
||||
'parent_id',
|
||||
'name',
|
||||
'host',
|
||||
'port',
|
||||
'server_port',
|
||||
'tls',
|
||||
'tags',
|
||||
'rate',
|
||||
'network',
|
||||
'settings'
|
||||
]);
|
||||
$params = $request->only(array_keys(ServerSave::RULES));
|
||||
$params['group_id'] = json_encode($params['group_id']);
|
||||
if (isset($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 (!is_object(json_decode($params['settings']))) {
|
||||
abort(500, '传输协议配置格式不正确');
|
||||
|
@ -6,6 +6,21 @@ use Illuminate\Foundation\Http\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.
|
||||
*
|
||||
@ -13,18 +28,7 @@ class ServerSave extends FormRequest
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'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'
|
||||
];
|
||||
return self::RULES;
|
||||
}
|
||||
|
||||
public function messages()
|
||||
|
Loading…
Reference in New Issue
Block a user