|
|
|
@ -15,28 +15,23 @@
|
|
|
|
|
*/
|
|
|
|
|
package com.alibaba.csp.sentinel.dashboard.client;
|
|
|
|
|
|
|
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
|
|
import java.net.URLEncoder;
|
|
|
|
|
import java.nio.charset.Charset;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Collections;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.Map.Entry;
|
|
|
|
|
import java.util.Optional;
|
|
|
|
|
import java.util.Set;
|
|
|
|
|
import java.util.concurrent.CompletableFuture;
|
|
|
|
|
import java.util.concurrent.ExecutionException;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.csp.sentinel.adapter.gateway.common.rule.GatewayFlowRule;
|
|
|
|
|
import com.alibaba.csp.sentinel.command.CommandConstants;
|
|
|
|
|
import com.alibaba.csp.sentinel.config.SentinelConfig;
|
|
|
|
|
import com.alibaba.csp.sentinel.command.vo.NodeVo;
|
|
|
|
|
import com.alibaba.csp.sentinel.config.SentinelConfig;
|
|
|
|
|
import com.alibaba.csp.sentinel.dashboard.datasource.entity.SentinelVersion;
|
|
|
|
|
import com.alibaba.csp.sentinel.dashboard.datasource.entity.gateway.ApiDefinitionEntity;
|
|
|
|
|
import com.alibaba.csp.sentinel.dashboard.datasource.entity.gateway.GatewayFlowRuleEntity;
|
|
|
|
|
import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.*;
|
|
|
|
|
import com.alibaba.csp.sentinel.dashboard.discovery.AppManagement;
|
|
|
|
|
import com.alibaba.csp.sentinel.dashboard.domain.cluster.ClusterClientInfoVO;
|
|
|
|
|
import com.alibaba.csp.sentinel.dashboard.domain.cluster.config.ClusterClientConfig;
|
|
|
|
|
import com.alibaba.csp.sentinel.dashboard.domain.cluster.config.ServerFlowConfig;
|
|
|
|
|
import com.alibaba.csp.sentinel.dashboard.domain.cluster.config.ServerTransportConfig;
|
|
|
|
|
import com.alibaba.csp.sentinel.dashboard.domain.cluster.state.ClusterServerStateVO;
|
|
|
|
|
import com.alibaba.csp.sentinel.dashboard.domain.cluster.state.ClusterStateSimpleEntity;
|
|
|
|
|
import com.alibaba.csp.sentinel.dashboard.util.AsyncUtils;
|
|
|
|
|
import com.alibaba.csp.sentinel.dashboard.util.VersionUtils;
|
|
|
|
|
import com.alibaba.csp.sentinel.slots.block.Rule;
|
|
|
|
|
import com.alibaba.csp.sentinel.slots.block.authority.AuthorityRule;
|
|
|
|
|
import com.alibaba.csp.sentinel.slots.block.degrade.DegradeRule;
|
|
|
|
@ -46,22 +41,6 @@ import com.alibaba.csp.sentinel.slots.system.SystemRule;
|
|
|
|
|
import com.alibaba.csp.sentinel.util.AssertUtil;
|
|
|
|
|
import com.alibaba.csp.sentinel.util.StringUtil;
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.alibaba.csp.sentinel.dashboard.datasource.entity.SentinelVersion;
|
|
|
|
|
import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.AuthorityRuleEntity;
|
|
|
|
|
import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.DegradeRuleEntity;
|
|
|
|
|
import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.FlowRuleEntity;
|
|
|
|
|
import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.ParamFlowRuleEntity;
|
|
|
|
|
import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.RuleEntity;
|
|
|
|
|
import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.SystemRuleEntity;
|
|
|
|
|
import com.alibaba.csp.sentinel.dashboard.discovery.AppManagement;
|
|
|
|
|
import com.alibaba.csp.sentinel.dashboard.domain.cluster.ClusterClientInfoVO;
|
|
|
|
|
import com.alibaba.csp.sentinel.dashboard.domain.cluster.state.ClusterServerStateVO;
|
|
|
|
|
import com.alibaba.csp.sentinel.dashboard.domain.cluster.state.ClusterStateSimpleEntity;
|
|
|
|
|
import com.alibaba.csp.sentinel.dashboard.domain.cluster.config.ClusterClientConfig;
|
|
|
|
|
import com.alibaba.csp.sentinel.dashboard.domain.cluster.config.ServerFlowConfig;
|
|
|
|
|
import com.alibaba.csp.sentinel.dashboard.domain.cluster.config.ServerTransportConfig;
|
|
|
|
|
import com.alibaba.csp.sentinel.dashboard.util.VersionUtils;
|
|
|
|
|
|
|
|
|
|
import org.apache.http.Consts;
|
|
|
|
|
import org.apache.http.HttpResponse;
|
|
|
|
|
import org.apache.http.NameValuePair;
|
|
|
|
@ -71,6 +50,7 @@ import org.apache.http.client.methods.HttpPost;
|
|
|
|
|
import org.apache.http.client.methods.HttpUriRequest;
|
|
|
|
|
import org.apache.http.client.utils.URLEncodedUtils;
|
|
|
|
|
import org.apache.http.concurrent.FutureCallback;
|
|
|
|
|
import org.apache.http.conn.util.InetAddressUtils;
|
|
|
|
|
import org.apache.http.entity.ContentType;
|
|
|
|
|
import org.apache.http.impl.client.DefaultRedirectStrategy;
|
|
|
|
|
import org.apache.http.impl.nio.client.CloseableHttpAsyncClient;
|
|
|
|
@ -84,6 +64,15 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.lang.Nullable;
|
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
|
|
import java.net.URLEncoder;
|
|
|
|
|
import java.nio.charset.Charset;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.Map.Entry;
|
|
|
|
|
import java.util.concurrent.CompletableFuture;
|
|
|
|
|
import java.util.concurrent.ExecutionException;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Communicate with Sentinel client.
|
|
|
|
|
*
|
|
|
|
@ -282,6 +271,14 @@ public class SentinelApiClient {
|
|
|
|
|
future.completeExceptionally(new IllegalArgumentException("Bad URL or command name"));
|
|
|
|
|
return future;
|
|
|
|
|
}
|
|
|
|
|
if (!InetAddressUtils.isIPv4Address(ip) && !InetAddressUtils.isIPv6Address(ip)) {
|
|
|
|
|
future.completeExceptionally(new IllegalArgumentException("Bad IP"));
|
|
|
|
|
return future;
|
|
|
|
|
}
|
|
|
|
|
if (!StringUtil.isEmpty(app) && !appManagement.isValidMachineOfApp(app, ip)) {
|
|
|
|
|
future.completeExceptionally(new IllegalArgumentException("Given ip does not belong to given app"));
|
|
|
|
|
return future;
|
|
|
|
|
}
|
|
|
|
|
StringBuilder urlBuilder = new StringBuilder();
|
|
|
|
|
urlBuilder.append("http://");
|
|
|
|
|
urlBuilder.append(ip).append(':').append(port).append('/').append(api);
|
|
|
|
|