Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
TelcoDB
Web Frontend
Commits
f7592c75
Verified
Commit
f7592c75
authored
Oct 27, 2019
by
Elias Ojala
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
toLowerCase domains on punycode convert (uppercase "not a legal IDNA2008 name")
parent
379cce79
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
30 deletions
+47
-30
src/controllers/dns.controller.ts
src/controllers/dns.controller.ts
+46
-29
src/controllers/search.controller.ts
src/controllers/search.controller.ts
+1
-1
No files found.
src/controllers/dns.controller.ts
View file @
f7592c75
...
...
@@ -13,6 +13,10 @@ function catcher(x) {
return
;
}
function
punyCodeLower
(
input
:
string
):
string
{
return
punycode
.
toASCII
(
punycode
.
toUnicode
(
input
).
toLowerCase
());
}
/**
* Index
*/
...
...
@@ -22,36 +26,49 @@ router.get("/:domain", (req: Request, res: Response, next: NextFunction) => {
if
(
isIp
(
asciiDomain
))
{
res
.
redirect
(
301
,
`/ip/
${
asciiDomain
}
`
);
}
else
if
(
domainNameRegex
.
test
(
asciiDomain
)
||
isDomainName
(
asciiDomain
))
{
axios
.
get
(
`https://api.telcodb.net/v1/resolve?format=json&q=
${
asciiDomain
}
`
)
.
then
((
response
)
=>
{
Promise
.
all
([
getIpInfo
(
response
.
data
).
catch
(
catcher
)
])
.
then
(
x
=>
x
[
0
])
.
then
(
ipInfo
=>
{
// Nullify IP info if undefined
if
(
ipInfo
[
0
]
==
undefined
)
{
ipInfo
=
null
;
}
const
unicodeDomain
=
punycode
.
toUnicode
(
asciiDomain
);
res
.
render
(
"
dns/show.twig
"
,
{
"
title
"
:
`
${
unicodeDomain
}
- DNS data`
,
"
disable_title_prefix
"
:
true
,
"
canonical_url
"
:
`/dns/
${
asciiDomain
}
`
,
"
asciiDomain
"
:
asciiDomain
,
"
unicodeDomain
"
:
unicodeDomain
,
"
data
"
:
response
.
data
,
"
ipInfo
"
:
ipInfo
,
if
(
asciiDomain
.
toLowerCase
()
!=
asciiDomain
)
{
res
.
redirect
(
`/dns/
${
asciiDomain
.
toLowerCase
()}
`
);
}
else
if
(
punyCodeLower
(
asciiDomain
)
!==
asciiDomain
)
{
/**
* Example: https://telcodb.net/dns/xn--ggle-lmaa.com ("gÖÖgle.com")
*
* dig: 'xn--ggle-lmaa.com' is not a legal IDNA2008 name (domain label has character forbidden in non-transitional mode (TR46)), use +noidnin
*
* "dig gÖÖgle.com" returns results for xn--ggle-5qaa.com
*/
res
.
redirect
(
301
,
`/dns/
${
punyCodeLower
(
asciiDomain
)}
`
);
}
else
{
axios
.
get
(
`https://api.telcodb.net/v1/resolve?format=json&q=
${
asciiDomain
}
`
)
.
then
((
response
)
=>
{
Promise
.
all
([
getIpInfo
(
response
.
data
).
catch
(
catcher
)
])
.
then
(
x
=>
x
[
0
])
.
then
(
ipInfo
=>
{
// Nullify IP info if undefined
if
(
ipInfo
[
0
]
==
undefined
)
{
ipInfo
=
null
;
}
const
unicodeDomain
=
punycode
.
toUnicode
(
asciiDomain
);
res
.
render
(
"
dns/show.twig
"
,
{
"
title
"
:
`
${
unicodeDomain
}
- DNS data`
,
"
disable_title_prefix
"
:
true
,
"
canonical_url
"
:
`/dns/
${
asciiDomain
}
`
,
"
asciiDomain
"
:
asciiDomain
,
"
unicodeDomain
"
:
unicodeDomain
,
"
data
"
:
response
.
data
,
"
ipInfo
"
:
ipInfo
,
});
});
})
;
})
.
catch
(
next
);
})
.
catch
(
next
);
}
}
else
if
(
isIdn
(
asciiDomain
))
{
res
.
redirect
(
`/dns/
${
punycode
.
toASCII
(
asciiDomain
)}
`
)
}
else
{
...
...
src/controllers/search.controller.ts
View file @
f7592c75
...
...
@@ -38,7 +38,7 @@ router.get("/", (req: Request, res: Response, next: NextFunction) => {
}
else
if
(
isCidr
(
query
))
{
res
.
redirect
(
`/net/
${
query
}
`
);
}
else
if
(
domainNameRegex
.
test
(
punycode
.
toASCII
(
query
)))
{
res
.
redirect
(
`/dns/
${
punycode
.
toASCII
(
query
)}
`
);
res
.
redirect
(
`/dns/
${
punycode
.
toASCII
(
query
.
toLowerCase
()
)}
`
);
}
else
{
let
skip_tld_check
:
boolean
=
false
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment