<legend id='HRFH5'><style id='HRFH5'><dir id='HRFH5'><q id='HRFH5'></q></dir></style></legend>
  1. <i id='HRFH5'><tr id='HRFH5'><dt id='HRFH5'><q id='HRFH5'><span id='HRFH5'><b id='HRFH5'><form id='HRFH5'><ins id='HRFH5'></ins><ul id='HRFH5'></ul><sub id='HRFH5'></sub></form><legend id='HRFH5'></legend><bdo id='HRFH5'><pre id='HRFH5'><center id='HRFH5'></center></pre></bdo></b><th id='HRFH5'></th></span></q></dt></tr></i><div id='HRFH5'><tfoot id='HRFH5'></tfoot><dl id='HRFH5'><fieldset id='HRFH5'></fieldset></dl></div>

      <tfoot id='HRFH5'></tfoot>

    1. <small id='HRFH5'></small><noframes id='HRFH5'>

      • <bdo id='HRFH5'></bdo><ul id='HRFH5'></ul>
    2. 带有数据库的国家/地区的 IP 地址

      时间:2023-05-27
      • <bdo id='aVzAY'></bdo><ul id='aVzAY'></ul>

          • <i id='aVzAY'><tr id='aVzAY'><dt id='aVzAY'><q id='aVzAY'><span id='aVzAY'><b id='aVzAY'><form id='aVzAY'><ins id='aVzAY'></ins><ul id='aVzAY'></ul><sub id='aVzAY'></sub></form><legend id='aVzAY'></legend><bdo id='aVzAY'><pre id='aVzAY'><center id='aVzAY'></center></pre></bdo></b><th id='aVzAY'></th></span></q></dt></tr></i><div id='aVzAY'><tfoot id='aVzAY'></tfoot><dl id='aVzAY'><fieldset id='aVzAY'></fieldset></dl></div>
          • <legend id='aVzAY'><style id='aVzAY'><dir id='aVzAY'><q id='aVzAY'></q></dir></style></legend><tfoot id='aVzAY'></tfoot>

                  <tbody id='aVzAY'></tbody>

                <small id='aVzAY'></small><noframes id='aVzAY'>

                本文介绍了带有数据库的国家/地区的 IP 地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我已下载 ip-to-country.csv,其中包含映射到国家/地区的 IP 范围.我应该如何将这些数据存储到数据库中,如何查询 IP 地址在什么范围内才能知道 IP 地址来自哪里?

                I have downloaded ip-to-country.csv that has ip ranges that are mapped to countries. How should I store this data to database and how can I query in what range Ip address is to know where Ip address is coming from?

                推荐答案

                我写了一个小库,叫做 ip2c 做到这一点.它使用来自 webhosting.info 的数据库,但也支持来自 Software77.

                I wrote a small lib called ip2c to do just that. it uses the database from webhosting.info but also supports that from Software77.

                它将 CSV 信息转换为紧凑的二进制格式,并且可以直接在文件、内存或内存映射文件中进行搜索.

                It converts the CSV info a compact binary format and can do the search straight on the file, in memory or in a memory mapped file.

                Java API 用法类似:

                The Java API usage is similar to this:

                String ip = 85.64.225.159;
                int caching1 = IP2Country.NO_CACHE;  // Straight on file, Fastest startup, slowest queries
                int caching2 = IP2Country.MEMORY_MAPPED; // Memory mapped file, fast startup, fast queries.
                int caching3 = IP2Country.MEMORY_CACHE; // load file into memory, slowerst startup, fastest queries
                IP2Country ip2c = new IP2Country(caching1);
                Country c = ip2c.getCountry(ip);
                if (c == null)
                {
                        System.out.println("UNKNOWN");                          
                }
                else
                {
                        // will output IL ISR ISRAEL
                        System.out.println(c.get2cStr() + " " + c.get3cStr() + " " + c.getName());      
                }
                

                这篇关于带有数据库的国家/地区的 IP 地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:从一个坐标到另一个坐标的方位角 下一篇:如何从 IP 地址获知地理位置

                相关文章

                1. <legend id='37kwn'><style id='37kwn'><dir id='37kwn'><q id='37kwn'></q></dir></style></legend>
                2. <i id='37kwn'><tr id='37kwn'><dt id='37kwn'><q id='37kwn'><span id='37kwn'><b id='37kwn'><form id='37kwn'><ins id='37kwn'></ins><ul id='37kwn'></ul><sub id='37kwn'></sub></form><legend id='37kwn'></legend><bdo id='37kwn'><pre id='37kwn'><center id='37kwn'></center></pre></bdo></b><th id='37kwn'></th></span></q></dt></tr></i><div id='37kwn'><tfoot id='37kwn'></tfoot><dl id='37kwn'><fieldset id='37kwn'></fieldset></dl></div>

                    • <bdo id='37kwn'></bdo><ul id='37kwn'></ul>
                  1. <tfoot id='37kwn'></tfoot>
                  2. <small id='37kwn'></small><noframes id='37kwn'>