mirror of
				https://github.com/TeaOSLab/EdgeAdmin.git
				synced 2025-11-04 13:10:26 +08:00 
			
		
		
		
	修复创建网站时不启用访问日志导致Websocket、统计等选项失效的问题
This commit is contained in:
		@@ -11,7 +11,6 @@ import (
 | 
				
			|||||||
	"github.com/TeaOSLab/EdgeAdmin/internal/nodes"
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/nodes"
 | 
				
			||||||
	"github.com/TeaOSLab/EdgeAdmin/internal/utils"
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/utils"
 | 
				
			||||||
	_ "github.com/TeaOSLab/EdgeAdmin/internal/web"
 | 
						_ "github.com/TeaOSLab/EdgeAdmin/internal/web"
 | 
				
			||||||
	"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/cluster/node/nodeutils"
 | 
					 | 
				
			||||||
	_ "github.com/TeaOSLab/EdgeCommon/pkg/langs/messages"
 | 
						_ "github.com/TeaOSLab/EdgeCommon/pkg/langs/messages"
 | 
				
			||||||
	"github.com/iwind/TeaGo/Tea"
 | 
						"github.com/iwind/TeaGo/Tea"
 | 
				
			||||||
	_ "github.com/iwind/TeaGo/bootstrap"
 | 
						_ "github.com/iwind/TeaGo/bootstrap"
 | 
				
			||||||
@@ -180,14 +179,6 @@ func main() {
 | 
				
			|||||||
		log.Println("restarting ...")
 | 
							log.Println("restarting ...")
 | 
				
			||||||
		app.RunRestart()
 | 
							app.RunRestart()
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	app.On("install-local-node", func() {
 | 
					 | 
				
			||||||
		err := nodeutils.InstallLocalNode()
 | 
					 | 
				
			||||||
		if err != nil {
 | 
					 | 
				
			||||||
			fmt.Println("[ERROR]" + err.Error())
 | 
					 | 
				
			||||||
			return
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		fmt.Println("success")
 | 
					 | 
				
			||||||
	})
 | 
					 | 
				
			||||||
	app.Run(func() {
 | 
						app.Run(func() {
 | 
				
			||||||
		var adminNode = nodes.NewAdminNode()
 | 
							var adminNode = nodes.NewAdminNode()
 | 
				
			||||||
		adminNode.Run()
 | 
							adminNode.Run()
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -11,7 +11,6 @@ import (
 | 
				
			|||||||
	"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs"
 | 
						"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs"
 | 
				
			||||||
	"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/sslconfigs"
 | 
						"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/sslconfigs"
 | 
				
			||||||
	"github.com/iwind/TeaGo/actions"
 | 
						"github.com/iwind/TeaGo/actions"
 | 
				
			||||||
	"github.com/iwind/TeaGo/logs"
 | 
					 | 
				
			||||||
	"github.com/iwind/TeaGo/maps"
 | 
						"github.com/iwind/TeaGo/maps"
 | 
				
			||||||
	"github.com/iwind/TeaGo/types"
 | 
						"github.com/iwind/TeaGo/types"
 | 
				
			||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
@@ -454,10 +453,11 @@ 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, findErr := dao.SharedHTTPWebDAO.FindWebConfigWithServerId(this.AdminContext(), serverId)
 | 
				
			||||||
		if err != nil {
 | 
							if findErr != nil {
 | 
				
			||||||
			logs.Error(err)
 | 
								this.ErrorPage(findErr)
 | 
				
			||||||
		} else {
 | 
								return
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
		// 访问日志
 | 
							// 访问日志
 | 
				
			||||||
		if params.AccessLogIsOn {
 | 
							if params.AccessLogIsOn {
 | 
				
			||||||
			_, err = this.RPC().HTTPWebRPC().UpdateHTTPWebAccessLog(this.AdminContext(), &pb.UpdateHTTPWebAccessLogRequest{
 | 
								_, err = this.RPC().HTTPWebRPC().UpdateHTTPWebAccessLog(this.AdminContext(), &pb.UpdateHTTPWebAccessLogRequest{
 | 
				
			||||||
@@ -479,7 +479,8 @@ func (this *CreateAction) RunPost(params struct {
 | 
				
			|||||||
		}`),
 | 
							}`),
 | 
				
			||||||
			})
 | 
								})
 | 
				
			||||||
			if err != nil {
 | 
								if err != nil {
 | 
				
			||||||
					logs.Error(err)
 | 
									this.ErrorPage(err)
 | 
				
			||||||
 | 
									return
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -496,20 +497,22 @@ func (this *CreateAction) RunPost(params struct {
 | 
				
			|||||||
				RequestOrigin:     "",
 | 
									RequestOrigin:     "",
 | 
				
			||||||
			})
 | 
								})
 | 
				
			||||||
			if err != nil {
 | 
								if err != nil {
 | 
				
			||||||
					logs.Error(err)
 | 
									this.ErrorPage(err)
 | 
				
			||||||
				} else {
 | 
									return
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			websocketId := createWebSocketResp.WebsocketId
 | 
								websocketId := createWebSocketResp.WebsocketId
 | 
				
			||||||
			_, err = this.RPC().HTTPWebRPC().UpdateHTTPWebWebsocket(this.AdminContext(), &pb.UpdateHTTPWebWebsocketRequest{
 | 
								_, err = this.RPC().HTTPWebRPC().UpdateHTTPWebWebsocket(this.AdminContext(), &pb.UpdateHTTPWebWebsocketRequest{
 | 
				
			||||||
				HttpWebId: webConfig.Id,
 | 
									HttpWebId: 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)
 | 
									this.ErrorPage(err)
 | 
				
			||||||
					}
 | 
									return
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -561,6 +564,7 @@ func (this *CreateAction) RunPost(params struct {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// remoteAddr
 | 
							// remoteAddr
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
			var remoteAddrConfig = &serverconfigs.HTTPRemoteAddrConfig{
 | 
								var remoteAddrConfig = &serverconfigs.HTTPRemoteAddrConfig{
 | 
				
			||||||
				IsOn:  true,
 | 
									IsOn:  true,
 | 
				
			||||||
				Value: "${rawRemoteAddr}",
 | 
									Value: "${rawRemoteAddr}",
 | 
				
			||||||
@@ -583,6 +587,7 @@ func (this *CreateAction) RunPost(params struct {
 | 
				
			|||||||
				this.ErrorPage(err)
 | 
									this.ErrorPage(err)
 | 
				
			||||||
				return
 | 
									return
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// 统计
 | 
							// 统计
 | 
				
			||||||
		if params.StatIsOn {
 | 
							if params.StatIsOn {
 | 
				
			||||||
@@ -605,7 +610,6 @@ func (this *CreateAction) RunPost(params struct {
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// 创建日志
 | 
						// 创建日志
 | 
				
			||||||
	defer this.CreateLogInfo(codes.Server_LogCreateServer, createResp.ServerId)
 | 
						defer this.CreateLogInfo(codes.Server_LogCreateServer, createResp.ServerId)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user