diff --git a/echoip_test.toml b/echoip_test.toml index f8f410d..2e1dc2d 100644 --- a/echoip_test.toml +++ b/echoip_test.toml @@ -30,8 +30,8 @@ hidden_suffixes = [".com"] # Path to geoip databses # Currently only the mmdb format is supported # Official databases can be obtained from maxmind.com -#asn_database = "mmdb/GeoLite2-ASN.mmdb" -#location_database = "mmdb/GeoLite2-City.mmdb" +asn_database = "mmdb/GeoLite2-ASN.mmdb" +location_database = "mmdb/GeoLite2-City.mmdb" # If anyone knows a free (as in freedom) groip database # please open an issue so I can integrate it diff --git a/src/main.rs b/src/main.rs index 108548b..d3d09e8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -285,7 +285,7 @@ async fn format_and_language_middleware( next.run(req).await } -async fn hello_world_handler( +async fn not_found_handler( State(arc_state): State>, Extension(settings): Extension, ) -> Response { @@ -297,7 +297,7 @@ async fn hello_world_handler( ).await } -async fn not_found_handler( +async fn hello_world_handler( State(arc_state): State>, Extension(settings): Extension, ) -> Response { diff --git a/templates/asn.html b/templates/asn.html new file mode 100644 index 0000000..9d94746 --- /dev/null +++ b/templates/asn.html @@ -0,0 +1,31 @@ +{% extends "base.html" %} +{% import "helpers.html" as helper %} +{% import "links.html" as links %} + +{% block title %}AS{{ data.asn }}{% endblock %} +{% block og_title %}AS{{ data.asn }}{% endblock %} +{% block h1 %}AS{{ data.asn }}{% endblock %} + +{% block og_path %}/?query=AS{{ data.asn }}{% endblock %} + +{% block content %} +{% if data.result.idn %} +{% set idn = data.result.idn %} +
+

Internationalized Domain Names

+

Because of some limitations the DNS has, Unicode caracters need a special encoding.

+ {% if idn.original_was == "unicode" %} +

Your Unicode query has been encoded as the IDN {{ idn.idn }} to generate the results below.

+ {% else %} +

Your IDN would decode to {{ idn.unicode }}.

+ {% endif %} +
+{% endif %} + +
+

Other Services

+ {{ links::asn_links(asn=data.asn) }} +
+ +{% endblock %} + diff --git a/templates/base.html b/templates/base.html index 9ddea4e..e4dbbf4 100644 --- a/templates/base.html +++ b/templates/base.html @@ -19,6 +19,7 @@ {% if extra.stylesheet %}{% endif %} {% if extra.favicon %}{% endif %} +
@@ -27,7 +28,7 @@ diff --git a/templates/dig.html b/templates/dig.html index acac17b..8abbc1f 100644 --- a/templates/dig.html +++ b/templates/dig.html @@ -1,9 +1,10 @@ {% extends "base.html" %} {% import "helpers.html" as helper %} +{% import "links.html" as links %} {% block title %}dig {{ data.query }}{% endblock %} {% block og_title %}dig {{ data.query }}{% endblock %} -{% block h1 %}dig {{ data.query }}{% endblock %} +{% block h1 %}dig {{ helper::breadcrumb_domain(extra=extra, name=data.query) }}{% endblock %} {% block og_path %}/dig/{{ data.query | urlencode_strict }}{% endblock %} @@ -65,4 +66,10 @@ {% endif %} +
+

Other Services

+ {{ links::domain_name_links(name=idn.idn|default(value=data.query))}} +
+ + {% endblock %} diff --git a/templates/extra.toml b/templates/extra.toml index a84326f..b8cb950 100644 --- a/templates/extra.toml +++ b/templates/extra.toml @@ -11,3 +11,8 @@ stylesheet = "https://slatecave.net/assets/site_slatecave/slatecave_v3.css" # favicon = "" # favicon_mimetype = "image/png" # favicon_mimetype = "image/jpeg" + +[404] +# configure the 404 page, this is available for other pages too! +title = "Nothing here" +description = "Page not found" diff --git a/templates/helpers.html b/templates/helpers.html index 826f846..61589a6 100644 --- a/templates/helpers.html +++ b/templates/helpers.html @@ -17,3 +17,14 @@ {{ ip }} {% endmacro dig %} +{% macro breadcrumb_domain(extra, name) %} +{% set_global dot = "" %} +{% set crumbs = name | split(pat=".") %} +{% set_global i = 0 %} +{% for crumb in crumbs %} + {{-dot}}{{crumb}} + {%- set_global dot = "." -%} + {%- set_global i = i+1 -%} +{% endfor %} + +{% endmacro breadcrumb_domain %} diff --git a/templates/ip.html b/templates/ip.html index b9b91dc..5cb42df 100644 --- a/templates/ip.html +++ b/templates/ip.html @@ -1,5 +1,6 @@ {% extends "base.html" %} {% import "helpers.html" as helper %} +{% import "links.html" as links %} {% block title %}{{ data.result.address }}{% endblock %} {% block og_title %}Lookup {{ data.result.address }}{% endblock %} @@ -13,7 +14,7 @@

Network Information

Type of Address -
{{r.ip_info.scope}} {{r.ip_info.cast}} IPv{% if r.ip_info.is_v6_address %}6{% else %}4{% endif %}
+
{{r.ip_info.scope | title}} {{r.ip_info.cast | title}} IPv{% if r.ip_info.is_v6_address %}6{% else %}4{% endif %}
{% if r.hostname %} Hostname
{{ helper::dig(extra=extra, name=r.hostname) }}
@@ -25,6 +26,7 @@
{{ r.asn.name }}
{% endif %} + {% block other_ip_button %}{% endblock %} {% if r.location %}
@@ -32,8 +34,12 @@
{{ helper::place_dl(place=r.location.continent, label="Continent") }} {{ helper::place_dl(place=r.location.country, label="Country") }} + {% if r.location.country.iso_code | default(value="") != r.location.registered_country.iso_code | default(value="") %} {{ helper::place_dl(place=r.location.registered_country, label="Registred in") }} + {% endif %} + {% if r.location.country.iso_code | default(value="") != r.location.represented_country.iso_code | default(value="")%} {{ helper::place_dl(place=r.location.represented_country, label="Represents") }} + {% endif %} {% if r.location.subdivisions %} {% for sd in r.location.subdivisions %} {{ helper::place_dl(place=sd, label="Subdivision", iso_code_prefix=r.location.country.iso_code|default(value="")) }} @@ -57,5 +63,12 @@
{% endif %} {% block extra_content %}{% endblock %} +
+

Other Services

+ {{ links::ip_address_links(address=r.address)}} + {% if r.asn %} + {{ links::asn_links(asn=r.asn.asn, org_name=r.asn.name) }} + {% endif %} +
{% endblock %} diff --git a/templates/links.html b/templates/links.html new file mode 100644 index 0000000..5c0bf55 --- /dev/null +++ b/templates/links.html @@ -0,0 +1,36 @@ +{% macro ip_address_links(address) %} +

Look up {{address}}

+ +{% endmacro ip_address_links %} + +{% macro domain_name_links(name) %} +

Look up {{name}}

+ +{% endmacro domain_name_links %} + +{% macro asn_links(asn, org_name="") %} +

Look up AS{{asn}}{% if org_name%} ({{org_name}}){% endif %} …

+ +{% endmacro asn_links %} + +{% macro map_link(lat, lon) %} + https://www.openstreetmap.org/export/embed.html?bbox={{lon-0.03}}%2C{{lat-0.03}}%2C{{lon+0.03}}%2C{{lat+0.03}}&layer=mapnik&marker={{lat}}%2C{{lon}} +{% endmacro map_link %} diff --git a/templates/message.html b/templates/message.html index e7ad376..44caa00 100644 --- a/templates/message.html +++ b/templates/message.html @@ -5,5 +5,5 @@ {% block h1 %}{{ data.title }}{% endblock %} {% block content %} -

{{data.mesage}}

+

{{data.message}}

{% endblock %}