mirror of
https://github.com/v2board/v2board.git
synced 2024-11-14 07:29:13 +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,14 +6,8 @@ use Illuminate\Foundation\Http\FormRequest;
|
|||||||
|
|
||||||
class ServerSave extends FormRequest
|
class ServerSave extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
CONST RULES = [
|
||||||
* Get the validation rules that apply to the request.
|
'show' => '',
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function rules()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'name' => 'required',
|
'name' => 'required',
|
||||||
'group_id' => 'required|array',
|
'group_id' => 'required|array',
|
||||||
'parent_id' => 'nullable|integer',
|
'parent_id' => 'nullable|integer',
|
||||||
@ -21,10 +15,20 @@ class ServerSave extends FormRequest
|
|||||||
'port' => 'required',
|
'port' => 'required',
|
||||||
'server_port' => 'required',
|
'server_port' => 'required',
|
||||||
'tls' => 'required',
|
'tls' => 'required',
|
||||||
|
'tls_pem' => '',
|
||||||
|
'tls_key' => '',
|
||||||
'tags' => 'array',
|
'tags' => 'array',
|
||||||
'rate' => 'required|numeric',
|
'rate' => 'required|numeric',
|
||||||
'network' => 'required|in:tcp,kcp,ws,http,domainsocket,quic'
|
'network' => 'required|in:tcp,kcp,ws,http,domainsocket,quic'
|
||||||
];
|
];
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return self::RULES;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function messages()
|
public function messages()
|
||||||
|
Loading…
Reference in New Issue
Block a user