[webapp,common]监控host参数修复校验,添加本地启动帮助
This commit is contained in:
@@ -21,7 +21,7 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
@Constraint(validatedBy = HostParamValidator.class)
|
||||
public @interface HostValid {
|
||||
|
||||
String message() default "Host value is invalid,must ipv4, ipv6 or domain";
|
||||
String message() default "监控Host必须是ipv4,ipv6或域名";
|
||||
|
||||
Class<?>[] groups() default {};
|
||||
|
||||
|
||||
@@ -15,10 +15,13 @@ public class IpDomainUtil {
|
||||
* 域名校验正则
|
||||
*/
|
||||
private static final Pattern DOMAIN_PATTERN =
|
||||
Pattern.compile("^([hH][tT]{2}[pP]://|[hH][tT]{2}[pP][sS]://)?(([A-Za-z0-9-~]+).)+([A-Za-z0-9-~\\/])+$");
|
||||
Pattern.compile("^(?=^.{3,255}$)[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+$");
|
||||
|
||||
private static final String LOCALHOST = "localhost";
|
||||
|
||||
/**
|
||||
* HTTP协议头校验规则
|
||||
*/
|
||||
private static final Pattern DOMAIN_SCHEMA = Pattern.compile("^([hH][tT]{2}[pP]://|[hH][tT]{2}[pP][sS]://){1}[^\\s]*");
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.usthe.common.util;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
* @author tom
|
||||
* @date 2022/2/19 20:32
|
||||
*/
|
||||
class IpDomainUtilTest {
|
||||
|
||||
@Test
|
||||
void validateIpDomain() {
|
||||
assertTrue(IpDomainUtil.validateIpDomain("127.7.5.3"));
|
||||
assertTrue(IpDomainUtil.validateIpDomain("255.255.4.3"));
|
||||
assertTrue(IpDomainUtil.validateIpDomain("255.255.255.255"));
|
||||
assertTrue(IpDomainUtil.validateIpDomain("tancloud.cn"));
|
||||
assertTrue(IpDomainUtil.validateIpDomain("tancloud.com.cn"));
|
||||
assertTrue(IpDomainUtil.validateIpDomain("student.dev.com.cn"));
|
||||
assertTrue(IpDomainUtil.validateIpDomain("www.student.dev.com.cn"));
|
||||
assertTrue(IpDomainUtil.validateIpDomain("www.baidu.com"));
|
||||
assertTrue(IpDomainUtil.validateIpDomain("good.didi"));
|
||||
assertFalse(IpDomainUtil.validateIpDomain("tmp"));
|
||||
assertFalse(IpDomainUtil.validateIpDomain("good"));
|
||||
assertFalse(IpDomainUtil.validateIpDomain("www.baidu.com."));
|
||||
assertFalse(IpDomainUtil.validateIpDomain("good."));
|
||||
assertFalse(IpDomainUtil.validateIpDomain(".good."));
|
||||
}
|
||||
|
||||
@Test
|
||||
void isHasSchema() {
|
||||
assertTrue(IpDomainUtil.isHasSchema("http://www.baidu.com"));
|
||||
assertTrue(IpDomainUtil.isHasSchema("https://www.baidu.com"));
|
||||
assertFalse(IpDomainUtil.isHasSchema("www.baidu.com"));
|
||||
assertFalse(IpDomainUtil.isHasSchema("https_www.baidu.com"));
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,22 @@
|
||||
|
||||
**面向开发者,易用友好的高性能监控云服务**
|
||||
|
||||
## 本地启动
|
||||
|
||||
### npm 方式
|
||||
1. 需要nodejs npm环境
|
||||
下载地址:https://nodejs.org/en/download
|
||||
2. 在前端工程目录web-app下执行 `npm install --registry=https://registry.npm.taobao.org`
|
||||
3. 全局安装angular-cli `npm install -g @angular/cli@12 --registry=https://registry.npm.taobao.org`
|
||||
4. 待本地后端启动后,在web-app目录下启动本地前端 `ng serve --open`
|
||||
|
||||
### yarn 方式
|
||||
1. 需要nodejs npm环境
|
||||
下载地址:https://nodejs.org/en/download
|
||||
2. 安装yarn `npm install -g yarn`
|
||||
3. 在前端工程目录web-app下执行 `yarn install`
|
||||
4. 全局安装angular-cli `npm install -g @angular/cli@12 --registry=https://registry.npm.taobao.org`
|
||||
5. 待本地后端启动后,在web-app目录下启动本地前端 `ng serve --open`
|
||||
|
||||
## 编译打包
|
||||
|
||||
@@ -15,4 +31,4 @@ manager目录下执行
|
||||
|
||||
```mvn package```
|
||||
|
||||
生成的安装包在 manager/target/hertz-beta-1.0.tar.gz
|
||||
生成的安装包在 manager/target/hertz-beta.tar.gz
|
||||
|
||||
Reference in New Issue
Block a user