import configparser
import io
+import location
import ssl
import tempfile
import tornado.httpclient
def messages(self):
return messages.Messages(self)
+ @lazy_property
+ def location(self):
+ return location.Database("/var/lib/location/database.db")
+
@lazy_property
def ratelimiter(self):
return ratelimit.RateLimiter(self)
"zen.spamhaus.org",
)
-# Open location database
-db = location.Database("/var/lib/location/database.db")
-
class Address(Object):
def init(self, address):
self.address = ipaddress.ip_address(address)
@lazy_property
def network(self):
- return db.lookup("%s" % self.address)
+ return self.backend.location.lookup("%s" % self.address)
@property
def country_code(self):
if self.network:
return self.network.asn
+ @lazy_property
+ def autonomous_system(self):
+ if self.asn:
+ return self.backend.location.get_as(self.asn)
+
# Blacklist
def _make_blacklist_rr(self, blacklist):
{% block container %}
<header class="cover">
<div class="container d-flex h-100 align-items-center">
- <div class="row flex-fill">
- <div class="col-12 col-md-6 my-5 text-center">
- <i class="fas fa-globe-europe fa-10x py-5"></i>
-
- <h3>{{ address }}</h3>
- </div>
-
- <div class="col-12 col-md-6 align-self-center px-3">
- <h1 class="display-1">{{ _("Hey you!") }}</h1>
-
- <h6>{{ _("You are visiting us from") }}</h6>
-
- <dl class="row">
- <dt class="col-sm-3">{{ _("Country") }}</dt>
- <dd class="col-sm-9">
- {{ format_country_name(address.country_code) if address.country_code else _("N/A") }}
- </dd>
-
- <dt class="col-sm-3">{{ _("Network") }}</dt>
- <dd class="col-sm-9">{{ address.asn or _("Unknown") }}</dd>
- </dl>
+ <div class="row flex-fill justify-content-center">
+ <div class="col-12 col-lg-6 text-center">
+ <h1 class="mb-5">
+ {{ _("Hey, %s!" % address) }}
+ </h1>
+
+ {% if address.country_code %}
+ <div class="my-5">
+ <h1 class="display-4 flag-icon flag-icon-{{ address.country_code.lower() }}"></h1>
+
+ <p class="lead">
+ {{ _("You are visiting from %s") % format_country_name(address.country_code) }}
+ </p>
+ </div>
+ {% end %}
+
+ <a class="btn btn-light btn-block" href="/lookup/{{ address }}">
+ {{ _("Show Me More") }}
+ </a>
</div>
</div>
</div>
</dd>
{% end %}
- {% if address.asn %}
- <dt>{{ _("Autonomous System") }}</dt>
- <dd>{{ format_asn(address.asn) }}</dd>
- {% end %}
+ <dt>{{ _("Autonomous System") }}</dt>
+ <dd>{{ address.autonomous_system or _("N/A") }}</dd>
</dl>
<a class="btn btn-light btn-block" href="/lookup/{{ address }}/blacklists">