Code Monkey home page Code Monkey logo

ipdatabase's Introduction

ipdatabase

一个ip地址数据库

数据

该IP库采用2015年广告协会制定的标准库,是**互联网广告行业统一采用的IP库。

原理

实现IP查询,首先将10进制IPV4地址转化为二进制构建二叉树,利用二叉树搜索进行搜索,查询速度log2n复杂度,比传统IP库n的复杂度速度高出一个量级。

接口

根据IP查询城市或地区的接口是IpHelper类中的findRegionByIp接口,说明如下:

    /**
     * 静态方法,传入ip地址,返回ip地址所在城市或地区
     * @param ip    IP地址,例:58.30.15.255
     * @return  返回IP地址所在城市或地区,例:北京市
     */
    public static String findRegionByIp(String ip)

example

     public void example() throws Exception {
        String ip = "58.30.15.255";
        String region = IpHelper.findRegionByIp(ip);
        System.out.println(region);
     }

ipdatabase's People

Contributors

wzhe06 avatar

Watchers

James Cloos avatar yejunyu 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.