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
cc9b9d5d
Verified
Commit
cc9b9d5d
authored
Oct 22, 2019
by
Elias Ojala
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show domain name in unicode instead of ASCII on /dns/
parent
0e68df81
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
12 deletions
+23
-12
src/controllers/dns.controller.ts
src/controllers/dns.controller.ts
+15
-8
views/dns/show.twig
views/dns/show.twig
+8
-4
No files found.
src/controllers/dns.controller.ts
View file @
cc9b9d5d
...
...
@@ -17,10 +17,12 @@ function catcher(x) {
* Index
*/
router
.
get
(
"
/:domain
"
,
(
req
:
Request
,
res
:
Response
,
next
:
NextFunction
)
=>
{
if
(
isIp
(
req
.
params
.
domain
))
{
res
.
redirect
(
301
,
`/ip/
${
req
.
params
.
domain
}
`
);
}
else
if
(
domainNameRegex
.
test
(
req
.
params
.
domain
)
||
isDomainName
(
req
.
params
.
domain
))
{
axios
.
get
(
`https://api.telcodb.net/v1/resolve?format=json&q=
${
req
.
params
.
domain
}
`
)
const
asciiDomain
=
req
.
params
.
domain
;
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
)
...
...
@@ -32,11 +34,16 @@ router.get("/:domain", (req: Request, res: Response, next: NextFunction) => {
ipInfo
=
null
;
}
const
unicodeDomain
=
punycode
.
toUnicode
(
asciiDomain
);
res
.
render
(
"
dns/show.twig
"
,
{
"
title
"
:
`
${
req
.
params
.
d
omain
}
- DNS data`
,
"
title
"
:
`
${
unicodeD
omain
}
- DNS data`
,
"
disable_title_prefix
"
:
true
,
"
canonical_url
"
:
`/dns/
${
asciiDomain
}
`
,
"
domain
"
:
req
.
params
.
domain
,
"
asciiDomain
"
:
asciiDomain
,
"
unicodeDomain
"
:
unicodeDomain
,
"
data
"
:
response
.
data
,
...
...
@@ -45,8 +52,8 @@ router.get("/:domain", (req: Request, res: Response, next: NextFunction) => {
});
})
.
catch
(
next
);
}
else
if
(
isIdn
(
req
.
params
.
d
omain
))
{
res
.
redirect
(
`/dns/
${
punycode
.
toASCII
(
req
.
params
.
d
omain
)}
`
)
}
else
if
(
isIdn
(
asciiD
omain
))
{
res
.
redirect
(
`/dns/
${
punycode
.
toASCII
(
asciiD
omain
)}
`
)
}
else
{
next
();
}
...
...
views/dns/show.twig
View file @
cc9b9d5d
{%
extends
'layouts/default.twig'
%}
{%
block
body
%}
<h1>
DNS data for
{{
domain
}}
</h1>
<h1>
DNS data for
{{
unicodeDomain
}}
</h1>
{%
if
asciiDomain
!=
unicodeDomain
%}
<p>
Punycode:
<code>
{{
asciiDomain
}}
</code></p>
{%
endif
%}
<ul
class=
"nav nav-tabs"
id=
"myTab"
role=
"tablist"
>
<li
class=
"nav-item"
>
...
...
@@ -98,8 +102,8 @@
{# <div class="tab-pane fade" id="website-info" role="tabpanel" aria-labelledby="website-info-tab">
<p class="mb-0"><strong>Alexa Rank</strong>: INSERT_ALEXA_RANK</p>
<img class="img-thumbnail" alt="Screenshot of {{
d
omain }}"
src="https://screenshots.lelux.fi/api/png?url=http://{{
d
omain }}" />
<img class="img-thumbnail" alt="Screenshot of {{
unicodeD
omain }}"
src="https://screenshots.lelux.fi/api/png?url=http://{{
asciiD
omain }}" />
</div> #}
{%
endif
%}
{%
if
ipInfo
%}
...
...
@@ -114,7 +118,7 @@
{%
endblock
%}
{%
block
javascripts
%}
<script
src=
"/assets/js/pages/dns/show/whois.js"
data-query=
"
{{
d
omain
}}
"
></script>
<script
src=
"/assets/js/pages/dns/show/whois.js"
data-query=
"
{{
asciiD
omain
}}
"
></script>
<script
src=
"/assets/js/pages/dns/show/reverse-fetch.js"
async
defer
></script>
{# <script src="/assets/js/pages/dns/show/ip-badge.js"></script> #}
{%
endblock
%}
\ No newline at end of file
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