Initial repo setup for IP Address Lookup
Add Cloudflare Worker source code, configuration files, GitHub Actions workflow, and documentation for the IP Address Lookup service. Includes geolocation lookup worker, deployment workflow, API documentation, and project metadata.
This commit is contained in:
commit
b005193261
9 files changed
+1509
No files matched your search
@@ -0,0 +1,2 @@
|
||||
custom: https://xi-xu.me/#sponsorships
|
||||
buy_me_a_coffee: xixu
|
||||
@@ -0,0 +1,19 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "github-actions"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
day: "monday"
|
||||
time: "09:00"
|
||||
open-pull-requests-limit: 5
|
||||
commit-message:
|
||||
prefix: "ci"
|
||||
include: "scope"
|
||||
labels:
|
||||
- "dependencies"
|
||||
- "github-actions"
|
||||
reviewers:
|
||||
- "xixu-me"
|
||||
assignees:
|
||||
- "xixu-me"
|
||||
@@ -0,0 +1,39 @@
|
||||
name: Deploy to Cloudflare Workers
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths-ignore:
|
||||
- "**.md"
|
||||
- "LICENSE"
|
||||
- ".gitignore"
|
||||
- ".editorconfig"
|
||||
- ".vscode/**"
|
||||
- "docs/**"
|
||||
- ".prettierrc*"
|
||||
- ".eslintrc*"
|
||||
- ".github/ISSUE_TEMPLATE/**"
|
||||
- ".github/PULL_REQUEST_TEMPLATE/**"
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 15
|
||||
permissions:
|
||||
contents: read
|
||||
deployments: write
|
||||
steps:
|
||||
- name: Checkout main branch
|
||||
uses: actions/checkout@v5
|
||||
|
||||
- name: Deploy to Cloudflare Workers
|
||||
uses: cloudflare/wrangler-action@v3
|
||||
with:
|
||||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
# Dependencies
|
||||
node_modules/
|
||||
package-lock.json
|
||||
yarn.lock
|
||||
pnpm-lock.yaml
|
||||
|
||||
# Wrangler
|
||||
.wrangler/
|
||||
.dev.vars
|
||||
.mf/
|
||||
|
||||
# Build outputs
|
||||
dist/
|
||||
worker/
|
||||
|
||||
# Environment variables
|
||||
.env
|
||||
.env.local
|
||||
.env.production
|
||||
|
||||
# Editor directories
|
||||
.vscode/
|
||||
.idea/
|
||||
*.swp
|
||||
*.swo
|
||||
*~
|
||||
|
||||
# OS files
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
# Logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2025 Xi Xu
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -0,0 +1,161 @@
|
||||
# IP Address Lookup
|
||||
|
||||
Fast, secure, and modern IP address geolocation lookup service built with Cloudflare Workers. Provides comprehensive location data, ISP information, timezone detection, and more for IPv4, IPv6 addresses, and domain names via web interface and REST API.
|
||||
|
||||
## Live Demo
|
||||
|
||||
**[https://ip.xi-xu.me](https://ip.xi-xu.me)**
|
||||
|
||||
## Features
|
||||
|
||||
- **Universal Support**: Query IPv4, IPv6 addresses, and domain names
|
||||
- **Comprehensive Data**: Location, ISP, timezone, coordinates, reverse DNS, and more
|
||||
- **Modern Web UI**: Beautiful, responsive interface with real-time lookups
|
||||
- **REST API**: Simple JSON API for programmatic access
|
||||
- **Edge Computing**: Powered by Cloudflare Workers for global low-latency responses
|
||||
- **Security Features**: Input validation, CORS support, CSP headers
|
||||
- **SEO Optimized**: Complete with meta tags, structured data, sitemap, and robots.txt
|
||||
- **Health Monitoring**: Built-in health check endpoint for uptime monitoring
|
||||
|
||||
## API Reference
|
||||
|
||||
### Endpoints
|
||||
|
||||
#### `GET /api/lookup`
|
||||
|
||||
Look up geolocation data for an IP address or domain name.
|
||||
|
||||
**Query Parameters:**
|
||||
|
||||
- `ip` (optional): IPv4, IPv6 address, or domain name to look up
|
||||
- If omitted or set to `me`, returns your own IP address information
|
||||
|
||||
**Example Requests:**
|
||||
|
||||
```bash
|
||||
# Look up your own IP
|
||||
curl https://ip.xi-xu.me/api/lookup
|
||||
|
||||
# Look up a specific IPv4 address
|
||||
curl https://ip.xi-xu.me/api/lookup?ip=8.8.8.8
|
||||
|
||||
# Look up an IPv6 address
|
||||
curl https://ip.xi-xu.me/api/lookup?ip=2001:4860:4860::8888
|
||||
|
||||
# Look up a domain name
|
||||
curl https://ip.xi-xu.me/api/lookup?ip=example.com
|
||||
```
|
||||
|
||||
**Example Response:**
|
||||
|
||||
```json
|
||||
{
|
||||
"status": "success",
|
||||
"continent": "North America",
|
||||
"continentCode": "NA",
|
||||
"country": "United States",
|
||||
"countryCode": "US",
|
||||
"region": "VA",
|
||||
"regionName": "Virginia",
|
||||
"city": "Ashburn",
|
||||
"district": "",
|
||||
"zip": "20149",
|
||||
"lat": 39.03,
|
||||
"lon": -77.5,
|
||||
"timezone": "America/New_York",
|
||||
"offset": -18000,
|
||||
"currency": "USD",
|
||||
"isp": "Google LLC",
|
||||
"org": "Google Public DNS",
|
||||
"as": "AS15169 Google LLC",
|
||||
"asname": "GOOGLE",
|
||||
"reverse": "dns.google",
|
||||
"mobile": false,
|
||||
"proxy": false,
|
||||
"hosting": true,
|
||||
"query": "8.8.8.8"
|
||||
}
|
||||
```
|
||||
|
||||
**Error Response:**
|
||||
|
||||
```json
|
||||
{
|
||||
"status": "fail",
|
||||
"message": "Invalid format. Please enter a valid IPv4, IPv6 address, or domain name."
|
||||
}
|
||||
```
|
||||
|
||||
#### `GET /health`
|
||||
|
||||
Health check endpoint for monitoring service availability.
|
||||
|
||||
**Example Request:**
|
||||
|
||||
```bash
|
||||
curl https://ip.xi-xu.me/health
|
||||
```
|
||||
|
||||
**Example Response:**
|
||||
|
||||
```json
|
||||
{
|
||||
"status": "healthy",
|
||||
"service": "ip-address-lookup",
|
||||
"timestamp": "2025-01-15T10:30:00.000Z"
|
||||
}
|
||||
```
|
||||
|
||||
### Rate Limits
|
||||
|
||||
This service uses [IP-API.com](https://ip-api.com) for geolocation data, which has the following limits for non-commercial use:
|
||||
|
||||
- **45 requests per minute** from the same IP address
|
||||
- Requests are cached for 5 minutes to reduce rate limit hits
|
||||
|
||||
If you exceed the rate limit, you'll receive a `429 Too Many Requests` response.
|
||||
|
||||
## Features in Detail
|
||||
|
||||
### Security
|
||||
|
||||
- Input validation using strict regex patterns for IPv4, IPv6, and domain names
|
||||
- Content Security Policy (CSP) headers
|
||||
- CORS support for cross-origin requests
|
||||
- Protection against XSS and injection attacks
|
||||
- X-Content-Type-Options and X-Frame-Options headers
|
||||
|
||||
### Performance
|
||||
|
||||
- Edge caching with 5-minute TTL for geolocation data
|
||||
- Smart placement mode for optimal routing
|
||||
- Minimal JavaScript footprint
|
||||
- Single-file architecture for fast cold starts
|
||||
- Pre-cached HTML page to avoid regeneration
|
||||
|
||||
### SEO & Discoverability
|
||||
|
||||
- Comprehensive meta tags (Open Graph, Twitter Cards)
|
||||
- Schema.org structured data (WebApplication)
|
||||
- Sitemap.xml for search engine indexing
|
||||
- Robots.txt with crawl directives
|
||||
- Semantic HTML with ARIA labels
|
||||
|
||||
### User Experience
|
||||
|
||||
- Automatic lookup of visitor's IP on page load
|
||||
- Responsive design for mobile and desktop
|
||||
- Dark theme optimized for readability
|
||||
- Loading states and error handling
|
||||
- Keyboard shortcuts (Escape to clear)
|
||||
- Accessibility features (ARIA labels, screen reader support)
|
||||
|
||||
## License
|
||||
|
||||
Copyright (c) Xi Xu. All rights reserved.
|
||||
|
||||
This repository is licensed under the [MIT License](LICENSE) - see the LICENSE file for details.
|
||||
|
||||
---
|
||||
|
||||
**Note**: This service is provided for free and is suitable for non-commercial use. Please respect the rate limits and terms of service of the underlying IP-API.com service.
|
||||
@@ -0,0 +1,46 @@
|
||||
{
|
||||
"author": "Xi Xu",
|
||||
"description": "Fast, secure, and modern IP address geolocation lookup service built with Cloudflare Workers. Provides comprehensive location data, ISP information, timezone detection, and more for IPv4, IPv6 addresses, and domain names via web interface and REST API.",
|
||||
"devDependencies": {
|
||||
"wrangler": "^3.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16.0.0"
|
||||
},
|
||||
"keywords": [
|
||||
"cloudflare",
|
||||
"workers",
|
||||
"cloudflare-workers",
|
||||
"ip-lookup",
|
||||
"ip-address-lookup",
|
||||
"geolocation",
|
||||
"geolocation-api",
|
||||
"ip-geolocation",
|
||||
"edge-computing",
|
||||
"serverless",
|
||||
"ipv4",
|
||||
"ipv6",
|
||||
"dns-lookup",
|
||||
"reverse-dns",
|
||||
"isp-lookup",
|
||||
"ip-location",
|
||||
"ip-api",
|
||||
"what-is-my-ip",
|
||||
"ip-info",
|
||||
"location-api"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "src/worker.js",
|
||||
"name": "ip-address-lookup",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/xixu-me/IP-Address-Lookup"
|
||||
},
|
||||
"scripts": {
|
||||
"deploy": "wrangler deploy",
|
||||
"dev": "wrangler dev",
|
||||
"tail": "wrangler tail",
|
||||
"test": "wrangler dev --test"
|
||||
},
|
||||
"version": "1.0.0"
|
||||
}
|
||||
+1163
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,22 @@
|
||||
name = "ip-address-lookup"
|
||||
main = "src/worker.js"
|
||||
compatibility_date = "2025-11-18"
|
||||
workers_dev = false
|
||||
|
||||
[placement]
|
||||
mode = "smart"
|
||||
|
||||
[observability]
|
||||
enabled = false
|
||||
head_sampling_rate = 1
|
||||
|
||||
[observability.logs]
|
||||
enabled = true
|
||||
head_sampling_rate = 1
|
||||
persist = true
|
||||
invocation_logs = true
|
||||
|
||||
[observability.traces]
|
||||
enabled = true
|
||||
persist = true
|
||||
head_sampling_rate = 1
|
||||
Reference in new issue
Block a user