|
|
|
@ -11,12 +11,16 @@ import java.net.URL;
@@ -11,12 +11,16 @@ import java.net.URL;
|
|
|
|
|
import java.net.URLConnection; |
|
|
|
|
import java.nio.charset.StandardCharsets; |
|
|
|
|
import java.security.cert.X509Certificate; |
|
|
|
|
import java.util.regex.Matcher; |
|
|
|
|
import java.util.regex.Pattern; |
|
|
|
|
import javax.net.ssl.HostnameVerifier; |
|
|
|
|
import javax.net.ssl.HttpsURLConnection; |
|
|
|
|
import javax.net.ssl.SSLContext; |
|
|
|
|
import javax.net.ssl.SSLSession; |
|
|
|
|
import javax.net.ssl.TrustManager; |
|
|
|
|
import javax.net.ssl.X509TrustManager; |
|
|
|
|
|
|
|
|
|
import cn.hutool.core.util.RuntimeUtil; |
|
|
|
|
import org.slf4j.Logger; |
|
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
|
import com.ruoyi.common.constant.Constants; |
|
|
|
@ -24,7 +28,7 @@ import com.ruoyi.common.utils.StringUtils;
@@ -24,7 +28,7 @@ import com.ruoyi.common.utils.StringUtils;
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 通用http发送方法 |
|
|
|
|
* |
|
|
|
|
* |
|
|
|
|
* @author ruoyi |
|
|
|
|
*/ |
|
|
|
|
public class HttpUtils |
|
|
|
@ -271,4 +275,15 @@ public class HttpUtils
@@ -271,4 +275,15 @@ public class HttpUtils
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private final static Pattern PATTERN= Pattern.compile("(\\d+ms)(\\s+)(TTL=\\d+)", Pattern.CASE_INSENSITIVE); |
|
|
|
|
public static boolean checkPing(String ip) { |
|
|
|
|
//若line含有=18ms TTL=16字样,说明已经ping通,返回true,否則返回false.
|
|
|
|
|
String result = RuntimeUtil.execForStr("ping " + ip + " -n 2 -w 2000"); |
|
|
|
|
Matcher matcher = PATTERN.matcher(result); |
|
|
|
|
if (matcher.find()) { |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|