mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-07 23:30:26 +08:00
实现路径规则部分功能
This commit is contained in:
@@ -35,6 +35,7 @@ type RPCClient struct {
|
||||
httpAccessLogPolicyClients []pb.HTTPAccessLogPolicyServiceClient
|
||||
httpCachePolicyClients []pb.HTTPCachePolicyServiceClient
|
||||
httpFirewallPolicyClients []pb.HTTPFirewallPolicyServiceClient
|
||||
httpLocationClients []pb.HTTPLocationServiceClient
|
||||
}
|
||||
|
||||
func NewRPCClient(apiConfig *configs.APIConfig) (*RPCClient, error) {
|
||||
@@ -59,6 +60,7 @@ func NewRPCClient(apiConfig *configs.APIConfig) (*RPCClient, error) {
|
||||
httpAccessLogPolicyClients := []pb.HTTPAccessLogPolicyServiceClient{}
|
||||
httpCachePolicyClients := []pb.HTTPCachePolicyServiceClient{}
|
||||
httpFirewallPolicyClients := []pb.HTTPFirewallPolicyServiceClient{}
|
||||
httpLocationClients := []pb.HTTPLocationServiceClient{}
|
||||
|
||||
conns := []*grpc.ClientConn{}
|
||||
for _, endpoint := range apiConfig.RPC.Endpoints {
|
||||
@@ -91,6 +93,7 @@ func NewRPCClient(apiConfig *configs.APIConfig) (*RPCClient, error) {
|
||||
httpAccessLogPolicyClients = append(httpAccessLogPolicyClients, pb.NewHTTPAccessLogPolicyServiceClient(conn))
|
||||
httpCachePolicyClients = append(httpCachePolicyClients, pb.NewHTTPCachePolicyServiceClient(conn))
|
||||
httpFirewallPolicyClients = append(httpFirewallPolicyClients, pb.NewHTTPFirewallPolicyServiceClient(conn))
|
||||
httpLocationClients = append(httpLocationClients, pb.NewHTTPLocationServiceClient(conn))
|
||||
}
|
||||
|
||||
return &RPCClient{
|
||||
@@ -112,6 +115,7 @@ func NewRPCClient(apiConfig *configs.APIConfig) (*RPCClient, error) {
|
||||
httpAccessLogPolicyClients: httpAccessLogPolicyClients,
|
||||
httpCachePolicyClients: httpCachePolicyClients,
|
||||
httpFirewallPolicyClients: httpFirewallPolicyClients,
|
||||
httpLocationClients: httpLocationClients,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -234,6 +238,13 @@ func (this *RPCClient) HTTPFirewallPolicyRPC() pb.HTTPFirewallPolicyServiceClien
|
||||
return nil
|
||||
}
|
||||
|
||||
func (this *RPCClient) HTTPLocationRPC() pb.HTTPLocationServiceClient {
|
||||
if len(this.httpLocationClients) > 0 {
|
||||
return this.httpLocationClients[rands.Int(0, len(this.httpLocationClients)-1)]
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (this *RPCClient) Context(adminId int64) context.Context {
|
||||
ctx := context.Background()
|
||||
m := maps.Map{
|
||||
|
||||
Reference in New Issue
Block a user