Commit Graph
53 Commits
Author SHA1 Message Date
NetworkCats c15d7ad36a fix: apply rustfmt and replace map_or with is_some_and per clippy 2026-03-22 18:23:22 +08:00
NetworkCats 5af03bf9b9 fix: PO parser escape order, proxy endpoint consistency, and accessibility bugs 2026-03-22 17:52:25 +08:00
NetworkCats 8fba47afd1 refactor: split models.rs into mmdb/api sub-modules with pub(crate) visibility
Split the 865-line models.rs into 3 focused files:
- models/mod.rs: conversion logic, helpers, re-exports, tests
- models/mmdb.rs: MMDB deserialization types (internal, pub(crate))
- models/api.rs: API serialization types (public) with From<MmdbProxy> impl

Mmdb types are now pub(crate) since they are internal deserialization details
that should not be part of the public API surface.
2026-03-22 17:33:40 +08:00
NetworkCats ee6ec1a28b refactor: split handlers.rs into focused sub-modules with DRY improvements
Split the 957-line handlers.rs into 4 focused files:
- handlers/mod.rs: shared state, IP resolution, non-browser request helper
- handlers/html.rs: HTML template rendering with Askama custom i18n filter,
  eliminating the Translations struct and ~250 lines of boilerplate
- handlers/api.rs: JSON/plain-text API endpoints with generic field_handler
  and proxy_field_handler helpers (consolidates 8 near-identical handlers)
- handlers/seo.rs: robots.txt, sitemap, OpenAPI, manifest

DRY improvements included:
- extract_ip_from_header() parameterized helper (deduplicates CF/IPv4 extraction)
- handle_non_browser_request() helper (deduplicates CLI/JSON early-return)
- append_ip_query() helper (deduplicates ?ip= redirect construction)
- field_handler/proxy_field_handler generics (consolidates 8 handlers)
- Askama #[filter_fn] custom filter for i18n (eliminates Translations struct)
2026-03-22 17:33:26 +08:00
NetworkCats 77410593f2 refactor: consolidate DB lookup boilerplate, UA detection, and polish error/module docs
Phase 1 (DRY):
- db.rs: extract with_reader() helper to eliminate repeated load-guard-lookup
  boilerplate across 6 lookup functions; use From<MmdbProxy> for ProxyInfo
- ua_detect.rs: extract matches_any_prefix() shared by both prefix-matching fns

Phase 4 (Quality polish):
- error.rs: implement Debug, Display, and std::error::Error on AppError
- Add module-level //! docs to all source modules
2026-03-22 17:33:09 +08:00
NetworkCats ccfa7decda feat: schedule DB updates at fixed daily UTC time instead of interval
Replace DB_UPDATE_INTERVAL_HOURS with DB_UPDATE_TIME_UTC (HH:MM format,
default 01:20) so the database update runs at a predictable time each day.
This ensures the update happens 20 minutes after the upstream Merged IP
Data release at 01:00 UTC.
2026-03-22 16:43:02 +08:00
NetworkCats d078859c5c relax rate limits: 100/50/30 RPM tiers at 0/300/500 RPS thresholds 2026-03-22 14:13:12 +08:00
NetworkCats 66a3db8901 style: restore import order to satisfy cargo fmt 2026-03-22 12:20:27 +08:00
NetworkCats 41016891eb fix: update proxy test assertions to match current MMDB data
45.77.77.77 no longer has is_hosting=true in the upstream database;
it now reports is_anonymous=true instead.
2026-03-22 12:17:20 +08:00
NetworkCats 797bb7c76a fix Fmt 2026-03-10 21:44:29 +00:00
NetworkCats 8567630f7a feat: add host-based routing and IPv4 domain handler with CORS 2026-03-11 04:38:10 +08:00
NetworkCats c876d17e8c feat: add IPV4_DOMAIN config for dual-stack IP detection 2026-03-11 04:33:01 +08:00
NetworkCats dd81766a03 fix: collapse nested if to satisfy clippy collapsible_if lint 2026-03-07 22:03:18 +08:00
NetworkCats 68555ef07c rust fmt 2026-03-07 21:59:20 +08:00
NetworkCats 5cda385928 fix: start server before DB download to prevent health check timeout
Decouple HTTP server startup from database initialization so the
/health endpoint responds immediately. On first deploy with an empty
volume, the DB download blocked the server from binding, causing
Docker health checks to time out after 60s.
2026-03-07 21:57:16 +08:00
NetworkCats 14e65937a2 fix: collapse nested if statements to satisfy clippy 2026-03-07 20:00:28 +08:00
NetworkCats 74512dcd10 style: apply cargo fmt formatting corrections 2026-03-07 19:56:11 +08:00
NetworkCats 2ed0bf3b6d feat: add click-to-copy IP address with localized tooltip 2026-03-07 03:56:05 +08:00
NetworkCats 30b65d5b25 refactor: extract inline JS into external static file with versioned caching 2026-03-07 03:28:23 +08:00
NetworkCats 79161773b6 feat: add JSON-LD and Microdata structured data for SEO 2026-03-06 21:03:19 +08:00
NetworkCats 5c3ba28495 feat: add favicon, icon meta tags, and PWA manifest 2026-03-06 20:46:39 +08:00
NetworkCats 512455bf72 feat: add noindex meta tag to IP query result pages 2026-03-06 20:28:03 +08:00
NetworkCats 878bebd0fd feat: update website title to emphasize proxy and geolocation 2026-03-06 20:06:37 +08:00
NetworkCats d256834dd2 feat: link ASN to bgp.tools page 2026-03-06 05:27:49 +08:00
NetworkCats 03a1a1bc99 feat: detect HTTP library User-Agents and return plain text responses 2026-03-06 00:18:55 +08:00
NetworkCats d0746f159b docs: revise FAQ content and update all translations 2026-03-05 02:24:53 +08:00
NetworkCats 8935e5f7c0 feat: reject non-public IP queries on both backend and frontend 2026-03-05 01:37:30 +08:00
NetworkCats 2eb11ad33a fix: redirect to root path on empty search query 2026-03-05 00:58:34 +08:00
NetworkCats 199384a280 fix: resolve trailing slash 404 and untranslated escaped-quote strings 2026-03-04 20:48:59 +08:00
NetworkCats 7e5a05b35a feat: add full i18n support for 14 languages with gettext PO translations
- Add i18n module with Locale enum, PO parser, and Accept-Language negotiation
- Create gettext .po translation files for en, es, de, ja, ko, id, fr, ru, pt, it, zh-Hant, zh-Hans, nl, ar
- Route HTML pages under /{lang}/ prefix using IETF language tags
- Auto-detect browser language and redirect from / to /{lang}/
- Add language selector dropdown in footer
- Localize geo names (country, city) from MMDB where available
- Add hreflang alternate links and multilingual sitemap for SEO
- Support RTL layout for Arabic
- Update integration tests for new routing structure
2026-03-04 20:11:16 +08:00
NetworkCats b67edf5a32 feat: generate OpenAPI server URL from SITE_DOMAIN at startup 2026-03-04 05:12:45 +08:00
NetworkCats ea291f3d30 feat: serve openapi.json at /openapi.json endpoint 2026-03-04 05:02:19 +08:00
NetworkCats f268e62958 style: apply rustfmt formatting fixes 2026-03-04 04:44:51 +08:00
NetworkCats 770470dad1 fix: improve db auto-update with streaming, temp cleanup, and tests 2026-03-04 04:44:46 +08:00
NetworkCats 50326c205f feat: add graceful shutdown with SIGTERM handling and updater cancellation 2026-03-04 04:20:35 +08:00
NetworkCats 6fbfe15b08 feat: add HTML error pages with browser alert popup for IP query errors 2026-03-04 03:21:32 +08:00
NetworkCats ab18484f58 feat: load .env file at startup via dotenvy 2026-03-04 02:39:27 +08:00
NetworkCats 3c0be53aca feat: add DEV_MODE for local development without Cloudflare 2026-03-04 02:30:16 +08:00
NetworkCats a8f253088a style: apply rustfmt formatting fixes 2026-03-04 02:30:10 +08:00
NetworkCats a068e382ae feat: add security headers, caching headers, and static file versioning 2026-03-03 03:36:22 +08:00
NetworkCats 5bc601e6e5 feat: improve SEO meta tags, robots.txt, sitemap.xml, and table accessibility 2026-03-03 03:14:40 +08:00
NetworkCats b0dea405ee style: apply rustfmt formatting to source and test files 2026-03-03 00:07:18 +08:00
NetworkCats efedf1cd59 test: add unit and integration tests for models, error, config, db, and edge cases 2026-03-02 23:56:51 +08:00
NetworkCats 0834a05c84 perf: reduce allocations and deserialization in handlers and models 2026-03-02 23:40:06 +08:00
NetworkCats da2f847faf fix: return 400 instead of 404 for missing client IP header 2026-03-02 23:27:30 +08:00
NetworkCats 7234dd4765 refactor: change default DB_PATH to relative data/ directory 2026-03-02 20:57:40 +08:00
NetworkCats 21db94891c test: add integration tests for all endpoints and CLI detection 2026-03-02 20:12:47 +08:00
NetworkCats 982479af6d feat: wire up main entry point with server and graceful shutdown 2026-03-02 20:03:59 +08:00
NetworkCats 9f3b38acac feat: add route handlers, router, SSR template, and CSS 2026-03-02 20:02:45 +08:00
NetworkCats 7b2adffb46 feat: add CLI user-agent detection and error types 2026-03-02 20:00:19 +08:00