New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

ip-cache

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ip-cache

This is a IP to geolocation lookup server with cache.

latest
Source
npmnpm
Version
0.0.4
Version published
Maintainers
1
Created
Source

ip-cache

This is a IP to geolocation lookup server with cache.

IP info APIs costs money. e.g. ipgeolocation.io has a free tier of 30k requests/month

It's hard to request 30k unique ips in a month, but if the same ip address is checked frequently the free quota could be used up quickly. Thus I built this simple cache server. This cache server is used as a proxy server, requests sent to /api/<:ip> is forwarded to API service and cached in pocketbase.

make build # build docker image
make run # run docker image on port 8090

Usage

I wrote 2 versions, one with go and one with js hook.

Go is more performant, more flexible and easier to add more features. The JS hook version is created to deploy to pockethost.

  • http://localhost:8090/api/info/1.1.1.1
  • http://localhost:8090/api/ip-geo/1.1.1.1

To switch languages, please remove pb_data first.

Usage (Go)

Install air and run air to develop.

Usage (JS Hook)

To develop locally,

  • Run bun dev
  • Download pocketbase 0.25.* to root and run ./pocketbase serve.

To deploy to pockethost, copy the pb_migrations and pb_hooks to pockethost with FTP.

Library

npm install ip-cache
import { IpCache } from "ip-cache";

const ipCache = new IpCache("https://<your-pocketbase-url>");
const ipInfo = await ipCache.getIpInfo("1.1.1.1");
console.log(ipInfo);

FAQs

Package last updated on 26 Mar 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts