Socket
Socket
Sign inDemoInstall

github.com/abhisek/asn-search-api

Package Overview
Dependencies
10
Maintainers
0
Alerts
File Explorer

Install Socket

Protect your apps from supply chain attacks

Install

github.com/abhisek/asn-search-api

    v0.0.0-20191219130021-a4cfb6bc73e5

Version published
Maintainers
0

Readme

# ASN Search API
A Golang API over MaxMind ASN database

[![CircleCI](https://circleci.com/gh/abhisek/asn-search-api.svg?style=svg)](https://circleci.com/gh/abhisek/asn-search-api)

* The API server requires a pre-built database in `data/asn.db`
* The API server listens on `0.0.0.0:8000` by default (Customize with `HOST` and `PORT` environment variable)
* Building database requires [MaxMind ASN CSV](https://dev.maxmind.com/geoip/geoip2/geolite2-asn-csv-database/)

## Getting Started

```bash
docker run -p 8000:8000 abh1sek/asn-search-api
```

## Use

```bash
curl -s http://localhost:8000/domain/example.com
curl -s http://localhost:8000/org/example+technologies
```

> `OrgName` should be [URL Encoded](https://www.w3schools.com/tags/ref_urlencode.asp)

## Build

> Ensure go tool chain is [setup correctly](https://golang.org/doc/install#testing)

```bash
make
```

## Generate ASN Database

1. Download MaxMind ASN Database in CSV Format
2. Use `asn-search-api` tool to create indexed database

```bash
./asn-search-api -mode mkdb \
  -db data/asn.db \
  -type ipv4 \
  -file GeoLite2-ASN-CSV_20190101/GeoLite2-ASN-Blocks-IPv4.csv 

./asn-search-api -mode mkdb \
  -db data/asn.db \
  -type ipv6 \
  -file GeoLite2-ASN-CSV_20190101/GeoLite2-ASN-Blocks-IPv6.csv 
```

## Deploy

### Google Cloud Run

```bash
gcloud run deploy \
  asn-search-api \
  --platform=managed \
  --image=gcr.io/<projectName>/asn-search-api:latest \
  --memory=512Mi \
  --timeout=30s \
  --labels=app=asn-search-api \
  --allow-unauthenticated \
  --region=us-central1
```

## TODO

- [ ] Extract ASN DB ops from `main.go` and create its own package
- [ ] Test cases

FAQs

Last updated on 19 Dec 2019

Did you know?

Socket installs a GitHub app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc