mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-03 12:20:28 +08:00
创建网站服务后自动开启访问日志
This commit is contained in:
@@ -71,6 +71,9 @@ func (this *CreateAction) RunPost(params struct {
|
|||||||
CertIdsJSON []byte
|
CertIdsJSON []byte
|
||||||
Origins string
|
Origins string
|
||||||
|
|
||||||
|
AccessLogIsOn bool
|
||||||
|
WebsocketIsOn bool
|
||||||
|
|
||||||
WebRoot string
|
WebRoot string
|
||||||
|
|
||||||
Must *actions.Must
|
Must *actions.Must
|
||||||
@@ -423,32 +426,61 @@ func (this *CreateAction) RunPost(params struct {
|
|||||||
// 开启访问日志和Websocket
|
// 开启访问日志和Websocket
|
||||||
if params.ServerType == serverconfigs.ServerTypeHTTPProxy {
|
if params.ServerType == serverconfigs.ServerTypeHTTPProxy {
|
||||||
webConfig, err := dao.SharedHTTPWebDAO.FindWebConfigWithServerId(this.AdminContext(), serverId)
|
webConfig, err := dao.SharedHTTPWebDAO.FindWebConfigWithServerId(this.AdminContext(), serverId)
|
||||||
if err == nil {
|
if err != nil {
|
||||||
|
logs.Error(err)
|
||||||
|
} else {
|
||||||
|
// 访问日志
|
||||||
|
if params.AccessLogIsOn {
|
||||||
|
_, err = this.RPC().HTTPWebRPC().UpdateHTTPWebAccessLog(this.AdminContext(), &pb.UpdateHTTPWebAccessLogRequest{
|
||||||
|
WebId: webConfig.Id,
|
||||||
|
AccessLogJSON: []byte(`{
|
||||||
|
"isPrior": false,
|
||||||
|
"isOn": true,
|
||||||
|
"fields": [],
|
||||||
|
"status1": true,
|
||||||
|
"status2": true,
|
||||||
|
"status3": true,
|
||||||
|
"status4": true,
|
||||||
|
"status5": true,
|
||||||
|
|
||||||
|
"storageOnly": false,
|
||||||
|
"storagePolicies": [],
|
||||||
|
|
||||||
|
"firewallOnly": false
|
||||||
|
}`),
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
logs.Error(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// websocket
|
// websocket
|
||||||
createWebSocketResp, err := this.RPC().HTTPWebsocketRPC().CreateHTTPWebsocket(this.AdminContext(), &pb.CreateHTTPWebsocketRequest{
|
if params.WebsocketIsOn {
|
||||||
HandshakeTimeoutJSON: []byte(`{
|
createWebSocketResp, err := this.RPC().HTTPWebsocketRPC().CreateHTTPWebsocket(this.AdminContext(), &pb.CreateHTTPWebsocketRequest{
|
||||||
|
HandshakeTimeoutJSON: []byte(`{
|
||||||
"count": 30,
|
"count": 30,
|
||||||
"unit": "second"
|
"unit": "second"
|
||||||
}`),
|
}`),
|
||||||
AllowAllOrigins: true,
|
AllowAllOrigins: true,
|
||||||
AllowedOrigins: nil,
|
AllowedOrigins: nil,
|
||||||
RequestSameOrigin: true,
|
RequestSameOrigin: true,
|
||||||
RequestOrigin: "",
|
RequestOrigin: "",
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logs.Error(err)
|
logs.Error(err)
|
||||||
} else {
|
} else {
|
||||||
websocketId := createWebSocketResp.WebsocketId
|
websocketId := createWebSocketResp.WebsocketId
|
||||||
_, err = this.RPC().HTTPWebRPC().UpdateHTTPWebWebsocket(this.AdminContext(), &pb.UpdateHTTPWebWebsocketRequest{
|
_, err = this.RPC().HTTPWebRPC().UpdateHTTPWebWebsocket(this.AdminContext(), &pb.UpdateHTTPWebWebsocketRequest{
|
||||||
WebId: webConfig.Id,
|
WebId: webConfig.Id,
|
||||||
WebsocketJSON: []byte(` {
|
WebsocketJSON: []byte(` {
|
||||||
"isPrior": false,
|
"isPrior": false,
|
||||||
"isOn": true,
|
"isOn": true,
|
||||||
"websocketId": ` + types.String(websocketId) + `
|
"websocketId": ` + types.String(websocketId) + `
|
||||||
}`),
|
}`),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logs.Error(err)
|
logs.Error(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,6 +86,15 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>默认开启配置</td>
|
||||||
|
<td>
|
||||||
|
<checkbox checked="checked" name="accessLogIsOn">访问日志</checkbox>
|
||||||
|
|
||||||
|
<checkbox checked="checked" name="websocketIsOn">Websocket</checkbox>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2"><more-options-indicator></more-options-indicator></td>
|
<td colspan="2"><more-options-indicator></more-options-indicator></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
Reference in New Issue
Block a user