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
ac0d5e40
Verified
Commit
ac0d5e40
authored
Nov 24, 2019
by
Elias Ojala
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tor relay page and minor improvements
parent
bd132d56
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
64 additions
and
5 deletions
+64
-5
src/app.ts
src/app.ts
+5
-1
src/controllers/ipaddr.controller.ts
src/controllers/ipaddr.controller.ts
+3
-0
src/controllers/search.controller.ts
src/controllers/search.controller.ts
+3
-0
src/view-functions/hostnamePortSplitter.ts
src/view-functions/hostnamePortSplitter.ts
+16
-4
src/view-functions/removeBrackets.ts
src/view-functions/removeBrackets.ts
+9
-0
views/tor-relay/show.twig
views/tor-relay/show.twig
+28
-0
No files found.
src/app.ts
View file @
ac0d5e40
...
...
@@ -62,8 +62,12 @@ twig.extendFunction("portSizeProcessor", (rawSize: string) => {
import
txtParser
from
"
./view-functions/txtParser
"
;
twig
.
extendFunction
(
"
txtParser
"
,
txtParser
);
import
hostnamePortSplitter
from
"
./view-functions/hostnamePortSplitter
"
;
import
hostnamePortSplitter
,
{
splitHostname
}
from
"
./view-functions/hostnamePortSplitter
"
;
twig
.
extendFunction
(
"
hostnamePortSplitter
"
,
hostnamePortSplitter
);
twig
.
extendFunction
(
"
splitHostname
"
,
splitHostname
);
import
removeBrackets
from
"
./view-functions/removeBrackets
"
;
twig
.
extendFunction
(
"
removeBrackets
"
,
removeBrackets
);
twig
.
extendFunction
(
"
getReverse
"
,
(
ipAddr
:
string
):
string
=>
{
return
""
;
...
...
src/controllers/ipaddr.controller.ts
View file @
ac0d5e40
...
...
@@ -5,6 +5,7 @@ import axios from "axios";
import
compressIp
from
"
../functions/compressIp
"
;
import
dnsbl
from
"
dnsbl
"
;
import
{
dnsblConfiguration
}
from
"
../app
"
;
import
removeBrackets
from
"
../view-functions/removeBrackets
"
;
const
router
:
Router
=
Router
();
...
...
@@ -114,6 +115,8 @@ router.get("/:ip", (req: Request, res: Response, next: NextFunction) => {
})
.
catch
(
next
);
}
}
else
if
(
isIp
.
v6
(
removeBrackets
(
ipAddress
)))
{
res
.
redirect
(
301
,
`/ip/
${
removeBrackets
(
ipAddress
)}
`
);
}
else
{
next
();
}
...
...
src/controllers/search.controller.ts
View file @
ac0d5e40
...
...
@@ -7,6 +7,7 @@ import punycode from "punycode";
import
isDomainName
from
"
is-domain-name
"
;
import
{
URL
}
from
"
url
"
;
import
compressIp
from
"
../functions/compressIp
"
;
import
removeBrackets
from
"
../view-functions/removeBrackets
"
;
const
{
Resolver
}
=
require
(
'
dns
'
).
promises
;
const
resolver
=
new
Resolver
();
...
...
@@ -33,6 +34,8 @@ router.get("/", (req: Request, res: Response, next: NextFunction) => {
if
(
isIp
(
query
))
{
res
.
redirect
(
`/ip/
${
compressIp
(
query
)}
`
);
}
else
if
(
isIp
.
v6
(
removeBrackets
(
query
)))
{
res
.
redirect
(
`/ip/
${
compressIp
(
removeBrackets
(
query
))}
`
)
}
else
if
(
isAsn
(
query
.
toUpperCase
()))
{
res
.
redirect
(
`/
${
query
}
`
);
}
else
if
(
isCidr
(
query
))
{
...
...
src/view-functions/hostnamePortSplitter.ts
View file @
ac0d5e40
function
split
(
input
:
string
):
{
hostname
:
string
,
port
}
{
const
x
=
input
.
split
(
"
:
"
);
import
isIp
=
require
(
"
is-ip
"
);
function
splitHostname
(
input
:
string
):
{
hostname
:
string
,
port
}
{
let
x
:
string
[]
=
[];
if
(
input
.
includes
(
"
[
"
))
{
// IPv6
x
=
input
.
split
(
"
]:
"
);
x
[
0
]
+=
"
]
"
;
}
else
{
// IPv4 or hostname
x
=
input
.
split
(
"
:
"
);
}
return
{
hostname
:
x
[
0
],
...
...
@@ -8,9 +19,10 @@ function split(input: string): { hostname: string, port } {
}
function
hostnamePortSplitter
(
input
:
string
):
string
{
const
data
=
split
(
input
);
const
data
=
split
Hostname
(
input
);
return
`<a href="/search?q=
${
data
.
hostname
}
">
${
data
.
hostname
}
</a>:
${
data
.
port
}
`
;
}
export
default
hostnamePortSplitter
;
\ No newline at end of file
export
default
hostnamePortSplitter
;
export
{
splitHostname
};
\ No newline at end of file
src/view-functions/removeBrackets.ts
0 → 100644
View file @
ac0d5e40
/**
* Removes brackets from string
* @param input Input
*/
function
removeBrackets
(
input
:
string
):
string
{
return
input
.
replace
(
"
[
"
,
""
).
replace
(
"
]
"
,
""
);
}
export
default
removeBrackets
;
\ No newline at end of file
views/tor-relay/show.twig
View file @
ac0d5e40
...
...
@@ -3,5 +3,33 @@
{%
block
body
%}
<h1>
{{
title
|
e
}}
</h1>
{%
if
data.or_addresses
%}
<h2>
ORPorts
</h2>
<ul
class=
"pl-3"
>
{%
for
ipAndPort
in
data.or_addresses
|
sort
%}
{%
set
ipAddress
=
splitHostname
(
ipAndPort
)
.
hostname
%}
{%
set
port
=
splitHostname
(
ipAndPort
)
.
port
%}
<li
class=
"ipRecord"
data-ip=
"
{{
removeBrackets
(
ipAddress
)
}}
"
>
<a
href=
"/ip/
{{
removeBrackets
(
ipAddress
)
}}
"
>
{{
ipAddress
}}
</a>
:
{{
port
}}
</li>
{%
endfor
%}
</ul>
{%
endif
%}
{%
if
data.exit_addresses
%}
<h2>
Exit Addresses
</h2>
<ul
class=
"pl-3"
>
{%
for
ipAddress
in
data.exit_addresses
|
sort
%}
<li
class=
"ipRecord"
data-ip=
"
{{
removeBrackets
(
ipAddress
)
}}
"
>
<a
href=
"/ip/
{{
removeBrackets
(
ipAddress
)
}}
"
>
{{
ipAddress
}}
</a>
</li>
{%
endfor
%}
</ul>
{%
endif
%}
<pre><code>
{{
json_data
|
e
}}
</code></pre>
{%
endblock
%}
{%
block
javascripts
%}
<script
src=
"/assets/js/pages/dns/show/reverse-fetch.js"
async
defer
></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