Improved IP address regex.
This commit is contained in:
parent
35d8be009e
commit
65e221a4f6
2 changed files with 6 additions and 4 deletions
|
@ -54,9 +54,8 @@ class Lookup : AbstractModule() {
|
||||||
event.respondWith(nslookup(args).prependIndent())
|
event.respondWith(nslookup(args).prependIndent())
|
||||||
} catch (ignore: UnknownHostException) {
|
} catch (ignore: UnknownHostException) {
|
||||||
if (args.matches(
|
if (args.matches(
|
||||||
("(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\." +
|
("(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)")
|
||||||
"(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\." +
|
.toRegex()
|
||||||
"(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)").toRegex()
|
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -45,8 +45,11 @@ class LookupTest {
|
||||||
@Test
|
@Test
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testLookup() {
|
fun testLookup() {
|
||||||
val result = nslookup("apple.com")
|
var result = nslookup("apple.com")
|
||||||
assertThat(result, "lookup(apple.com)").contains("17.253.144.10")
|
assertThat(result, "lookup(apple.com)").contains("17.253.144.10")
|
||||||
|
|
||||||
|
result = nslookup("204.122.17.9")
|
||||||
|
assertThat(result, "lookup(204.122.17.9)").contains("nix3.thauvin.us")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue