ipinfo.tw icon indicating copy to clipboard operation
ipinfo.tw copied to clipboard

Add timezone information to the available fields

Open skinny opened this issue 2 years ago β€’ 4 comments

My use case also uses the timezone information (available on ipinfo.io) but was not yet available in this self hosted soltution. This PR downloads the City geo database and uses that to return a "best guess" timezone for the users IP.

skinny avatar Apr 01 '24 13:04 skinny

Review Change Stack

πŸ“ Walkthrough

Walkthrough

Adds timezone support (GeoLite2-City), exposes /timezone and timezone in /json, updates nginx real IP handling, extends Docker build to fetch City DB, and adds Kubernetes manifests plus a GitHub Actions multi-arch build workflow.

Changes

Core Feature - Timezone Detection & API

Layer / File(s) Summary
Timezone features
nginx/conf.d/geoip2.conf, nginx/conf.d/ipinfo.conf, Dockerfile, README.md
Adds GeoLite2-City support in the Docker build, maps geoip2 time_zone to $ip_time_zone, adds /timezone endpoint, and includes timezone in /json responses; README updated with examples.

Infrastructure - Kubernetes Manifests

Layer / File(s) Summary
Kubernetes manifests
k8s/deployment.yaml, k8s/ingress.yaml, k8s/service.yaml
Adds deployment (eva-whoami, 2 replicas), Ingress with TLS/cert-manager for whoami.on-eva.io, and LoadBalancer Service with Azure annotations.

Documentation & CI/CD

Layer / File(s) Summary
Docs and CI
README.md, .github/workflows/build.yml
README documents new timezone endpoint and examples; new GitHub Actions workflow builds and pushes multi-arch Docker images with MAXMIND_LICENSE_KEY build-arg.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant nginx as nginx + geoip2
    participant GeoLite2 as GeoLite2-City DB
    participant Response

    Client->>nginx: GET /json (client IP)
    nginx->>GeoLite2: geoip2 lookup of client IP -> time_zone
    GeoLite2-->>nginx: return timezone data
    nginx->>nginx: set $ip_time_zone from lookup
    nginx-->>Response: JSON {ip, country, as, timezone}
    Response-->>Client: HTTP response with timezone field

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

πŸš₯ Pre-merge checks | βœ… 5
βœ… Passed checks (5 passed)
Check name Status Explanation
Description check βœ… Passed The description is directly related to the changeset, explaining the motivation and implementation approach for adding timezone data using the City geo database.
Docstring Coverage βœ… Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check βœ… Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check βœ… Passed Check skipped because no linked issues were found for this pull request.
Title check βœ… Passed The title 'Add timezone information to the available fields' directly and clearly describes the main objective of the changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
πŸ§ͺ Generate unit tests (beta)
  • [ ] Create PR with unit tests

[!TIP]

πŸ’¬ Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire orgβ€”no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-inβ€”scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

πŸ‘‰ Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❀️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Apr 01 '24 13:04 coderabbitai[bot]

@PeterDaveHello removed the comments, newlines and added a bit of documentation on the timezone field

skinny avatar Apr 02 '24 13:04 skinny

Code Review Summary

Status: 3 New Issues Found (15 existing) | Recommendation: Address before merge β€” significant scope contamination

Overview

Severity Count
CRITICAL 0
WARNING 2
SUGGESTION 1
Issue Details (click to expand)

WARNING

File Line Issue
nginx/conf.d/realip.conf 1 Switching trusted header from X-Real-IP to X-Forwarded-For with real_ip_recursive on is a breaking change unrelated to the timezone feature; allows IP spoofing via XFF from any RFC1918 source.
k8s/deployment.yaml 26 Image reference has no explicit tag (defaults to :latest) combined with imagePullPolicy: Always β€” rollouts become non-deterministic and rollback is impossible.

SUGGESTION

File Line Issue
nginx/conf.d/realip.conf 5 Missing trailing newline at end of file.
Other Observations (scope concerns, not in diff)

The stated PR scope is "add timezone information" but the diff also contains a large amount of fork-specific deployment configuration that does not belong in the upstream repository:

File Concern
.github/workflows/build.yml Pushes images to a private Azure registry (cratecache.azurecr.io/new-black/eva-whoami) using fork-specific secrets (ACR_USERNAME, ACR_PASSWORD). Not useful upstream.
k8s/deployment.yaml References private image, namespace platform-tools, and app name eva-whoami.
k8s/ingress.yaml Hard-codes private hostname whoami.on-eva.io and a private cluster issuer.
k8s/service.yaml Hard-codes a private nodePort 31514 and an Azure-specific load-balancer resource group annotation.
nginx/conf.d/realip.conf The header-trust change is unrelated to the timezone feature.

Recommend stripping these out so the PR contains only the changes needed for the /timezone endpoint: Dockerfile (City db), nginx/conf.d/geoip2.conf, nginx/conf.d/ipinfo.conf, and README.md.

Also note (informational, no diff line to comment on): when MaxMind cannot resolve a city for an IP (private ranges, unknown IPs), $ip_time_zone will be empty and /timezone returns just \n while /json returns "timezone":"". This is consistent with how other endpoints behave today, but worth documenting in the README so users aren't surprised.

Files Reviewed (9 files)
  • .github/workflows/build.yml β€” out of scope; existing comments cover concerns
  • Dockerfile β€” City db steps look correct (existing comment on line 26)
  • README.md β€” timezone docs added; existing comment on line 66
  • k8s/deployment.yaml β€” out of scope; 1 new issue (line 26 image tag)
  • k8s/ingress.yaml β€” out of scope; existing comment on line 7
  • k8s/service.yaml β€” out of scope
  • nginx/conf.d/geoip2.conf β€” City db block added; existing comments cover style
  • nginx/conf.d/ipinfo.conf β€” /timezone endpoint and JSON field look correct
  • nginx/conf.d/realip.conf β€” 2 new issues (header trust change, missing newline)

Fix these issues in Kilo Cloud


Reviewed by claude-opus-4.7 Β· 242,091 tokens

kilo-code-bot[bot] avatar May 15 '26 15:05 kilo-code-bot[bot]

@codex review

PeterDaveHello avatar May 15 '26 15:05 PeterDaveHello