[反向代理]实验性添加TOA支持

This commit is contained in:
GoEdgeLab
2020-12-03 10:17:28 +08:00
parent 8d7d52223a
commit ff08a1e6f3
15 changed files with 228 additions and 18 deletions

View File

@@ -92,6 +92,9 @@ func (this *Node) Start() {
}
sharedNodeConfig = nodeConfig
// 发送事件
events.Notify(events.EventLoaded)
// 设置rlimit
_ = utils.SetRLimit(1024 * 1024)
@@ -166,10 +169,16 @@ func (this *Node) syncConfig(isFirstTime bool) error {
return errors.New("create rpc client failed: " + err.Error())
}
// TODO 这里考虑只同步版本号有变更的
configResp, err := rpcClient.NodeRPC().FindCurrentNodeConfig(rpcClient.Context(), &pb.FindCurrentNodeConfigRequest{})
configResp, err := rpcClient.NodeRPC().FindCurrentNodeConfig(rpcClient.Context(), &pb.FindCurrentNodeConfigRequest{
Version: lastVersion,
})
if err != nil {
return errors.New("read config from rpc failed: " + err.Error())
}
if !configResp.IsChanged {
return nil
}
configJSON := configResp.NodeJSON
nodeConfig := &nodeconfigs.NodeConfig{}
err = json.Unmarshal(configJSON, nodeConfig)
@@ -213,6 +222,9 @@ func (this *Node) syncConfig(isFirstTime bool) error {
sharedWAFManager.UpdatePolicies(nodeConfig.AllHTTPFirewallPolicies())
sharedNodeConfig = nodeConfig
// 发送事件
events.Notify(events.EventReload)
if !isFirstTime {
return sharedListenerManager.Start(nodeConfig)
}