Add best-effort geolocation to the IP lookup from geojs and DB-IP City Lite (closes #239)
check / check (push) Successful in 1m41s
check / check (push) Successful in 1m41s
Every IP lookup result gains `geo`. One request to geojs carries all uncached addresses of a lookup, within 1 second. On a timeout, an error or an answer with no location, the lookup reads DB-IP City Lite, downloaded monthly into the state directory. Geojs answers stay in memory, at most 250,000, and in `cache.db` for 7 days. The home page footer credits DB-IP. Judgement call: a reserved address goes to neither source, and its `geo` is null. Judgement call: `updated` for a DB-IP answer is when the copy was downloaded. Deviation: the cache is SQLite, by sneak's words, not the JSON file the standing rule asks for. Model: opus-5-5
This commit was merged in pull request #249.
This commit is contained in:
1 parent
2c3f6f71dc
commit
cca402c73d
16 files changed
+2372
-22
No files matched your search
@@ -544,6 +544,8 @@
|
||||
<span>{{appLicense}}</span>
|
||||
<span class="separator">|</span>
|
||||
<span><a href="{{appGitCommitURL}}">{{appGitRevision}}</a></span>
|
||||
<span class="separator">|</span>
|
||||
<span>IP Geolocation by <a href="https://db-ip.com">DB-IP</a></span>
|
||||
</footer>
|
||||
|
||||
<script nonce="{{.CSPNonce}}">
|
||||
|
||||
@@ -67,6 +67,23 @@ func TestFooterLicense(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestHomePageCreditsDBIP expects the home page's footer to carry the credit
|
||||
// to DB-IP.
|
||||
func TestHomePageCreditsDBIP(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
const attribution = `IP Geolocation by <a href="https://db-ip.com">DB-IP</a>`
|
||||
|
||||
_, footer, found := strings.Cut(renderPage(t, templates.IndexTemplate()), "<footer")
|
||||
if !found {
|
||||
t.Fatal("the page has no footer")
|
||||
}
|
||||
|
||||
if !strings.Contains(footer, attribution) {
|
||||
t.Errorf("footer does not credit DB-IP: %q", footer)
|
||||
}
|
||||
}
|
||||
|
||||
// TestFreshnessIndicator renders the home and status pages and expects each to
|
||||
// have, right after the status element, the element where the page's script
|
||||
// shows its spinner or "stale".
|
||||
|
||||
Reference in new issue
Block a user