Giter VIP home page Giter VIP logo

checkip's Introduction

Anomaly detection exercise

Set up Postgres

Connect to the DB and run these statement to create the table that holds the IPs:

--
-- PostgreSQL database dump
--

-- Dumped from database version 11.2
-- Dumped by pg_dump version 11.2

SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET client_min_messages = warning;
SET row_security = off;

SET default_tablespace = '';

SET default_with_oids = false;

--
-- Name: ip; Type: TABLE; Schema: public; Owner: me
--

CREATE TABLE public.ip (
    ip inet NOT NULL,
    source character varying,
    last_upd timestamp without time zone DEFAULT CURRENT_TIMESTAMP
);


ALTER TABLE public.ip OWNER TO me;

--
-- Name: ip ip_pkey; Type: CONSTRAINT; Schema: public; Owner: me
--

ALTER TABLE ONLY public.ip
    ADD CONSTRAINT ip_pkey PRIMARY KEY (ip);


--
-- Name: idx_name; Type: INDEX; Schema: public; Owner: me
--

CREATE INDEX idx_name ON public.ip USING gist (ip inet_ops);


--
-- PostgreSQL database dump complete
--

Query for an IP

  1. Start Postgres: brew services start postgresql
  2. Start Node: node index.js
  3. Send a GET request to the endpoint http://localhost:3000/IP, specifying the IP. For example: curl http://localhost:3000/IP/23.239.26.255

Sync IPs

  1. To download the latest file run: npm run clone
  2. To process the new files run: npm run sync

checkip's People

Contributors

mpaktiti avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.