mirror of
				https://github.com/TeaOSLab/EdgeAdmin.git
				synced 2025-11-04 05:00:25 +08:00 
			
		
		
		
	实现防火墙配置
This commit is contained in:
		@@ -34,6 +34,7 @@ type RPCClient struct {
 | 
			
		||||
	httpPageClients            []pb.HTTPPageServiceClient
 | 
			
		||||
	httpAccessLogPolicyClients []pb.HTTPAccessLogPolicyServiceClient
 | 
			
		||||
	httpCachePolicyClients     []pb.HTTPCachePolicyServiceClient
 | 
			
		||||
	httpFirewallPolicyClients  []pb.HTTPFirewallPolicyServiceClient
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewRPCClient(apiConfig *configs.APIConfig) (*RPCClient, error) {
 | 
			
		||||
@@ -57,6 +58,7 @@ func NewRPCClient(apiConfig *configs.APIConfig) (*RPCClient, error) {
 | 
			
		||||
	httpPageClients := []pb.HTTPPageServiceClient{}
 | 
			
		||||
	httpAccessLogPolicyClients := []pb.HTTPAccessLogPolicyServiceClient{}
 | 
			
		||||
	httpCachePolicyClients := []pb.HTTPCachePolicyServiceClient{}
 | 
			
		||||
	httpFirewallPolicyClients := []pb.HTTPFirewallPolicyServiceClient{}
 | 
			
		||||
 | 
			
		||||
	conns := []*grpc.ClientConn{}
 | 
			
		||||
	for _, endpoint := range apiConfig.RPC.Endpoints {
 | 
			
		||||
@@ -88,6 +90,7 @@ func NewRPCClient(apiConfig *configs.APIConfig) (*RPCClient, error) {
 | 
			
		||||
		httpPageClients = append(httpPageClients, pb.NewHTTPPageServiceClient(conn))
 | 
			
		||||
		httpAccessLogPolicyClients = append(httpAccessLogPolicyClients, pb.NewHTTPAccessLogPolicyServiceClient(conn))
 | 
			
		||||
		httpCachePolicyClients = append(httpCachePolicyClients, pb.NewHTTPCachePolicyServiceClient(conn))
 | 
			
		||||
		httpFirewallPolicyClients = append(httpFirewallPolicyClients, pb.NewHTTPFirewallPolicyServiceClient(conn))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return &RPCClient{
 | 
			
		||||
@@ -108,6 +111,7 @@ func NewRPCClient(apiConfig *configs.APIConfig) (*RPCClient, error) {
 | 
			
		||||
		httpPageClients:            httpPageClients,
 | 
			
		||||
		httpAccessLogPolicyClients: httpAccessLogPolicyClients,
 | 
			
		||||
		httpCachePolicyClients:     httpCachePolicyClients,
 | 
			
		||||
		httpFirewallPolicyClients:  httpFirewallPolicyClients,
 | 
			
		||||
	}, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -223,6 +227,13 @@ func (this *RPCClient) HTTPCachePolicyRPC() pb.HTTPCachePolicyServiceClient {
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (this *RPCClient) HTTPFirewallPolicyRPC() pb.HTTPFirewallPolicyServiceClient {
 | 
			
		||||
	if len(this.httpFirewallPolicyClients) > 0 {
 | 
			
		||||
		return this.httpFirewallPolicyClients[rands.Int(0, len(this.httpFirewallPolicyClients)-1)]
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (this *RPCClient) Context(adminId int64) context.Context {
 | 
			
		||||
	ctx := context.Background()
 | 
			
		||||
	m := maps.Map{
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user