Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support hostname target #1455

Merged
merged 7 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
@Constraint(validatedBy = HostParamValidator.class)
public @interface HostValid {

String message() default "Host need ipv4,ipv6 or domain,<br>EG:127.0.0.1 hertzbeat.com";
String message() default "Host need ipv4,ipv6,hostname or domain,<br>EG:127.0.0.1 hertzbeat.com";

Class<?>[] groups() default {};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
public class IpDomainUtil {

private static final Pattern DOMAIN_PATTERN =
Pattern.compile("^(?=^.{3,255}$)[_a-zA-Z0-9][-_a-zA-Z0-9]{0,62}(\\.[a-zA-Z0-9][-_a-zA-Z0-9]{0,62})+$");
Pattern.compile("^[-\\w]+(\\.[-\\w]+)*$");

private static final String LOCALHOST = "localhost";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,14 @@ void validateIpDomain() {
assertTrue(IpDomainUtil.validateIpDomain("good.didi"));
assertTrue(IpDomainUtil.validateIpDomain("spider_rds.sogou"));
assertTrue(IpDomainUtil.validateIpDomain("_redis.hn.sogou"));
assertFalse(IpDomainUtil.validateIpDomain("tmp"));
assertFalse(IpDomainUtil.validateIpDomain("good"));
assertTrue(IpDomainUtil.validateIpDomain("host"));
assertTrue(IpDomainUtil.validateIpDomain("host-1"));
assertFalse(IpDomainUtil.validateIpDomain("www.baidu.com."));
assertFalse(IpDomainUtil.validateIpDomain("good."));
assertFalse(IpDomainUtil.validateIpDomain(".good."));
assertFalse(IpDomainUtil.validateIpDomain("www.baidu..com"));
assertFalse(IpDomainUtil.validateIpDomain("www.baidu*com"));
assertFalse(IpDomainUtil.validateIpDomain("host$-1"));
}

@Test
Expand All @@ -54,4 +57,4 @@ void isHasSchema() {
assertFalse(IpDomainUtil.isHasSchema("www.baidu.com"));
assertFalse(IpDomainUtil.isHasSchema("https_www.baidu.com"));
}
}
}
Loading