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

        <bdo id='X80oo'></bdo><ul id='X80oo'></ul>
      <legend id='X80oo'><style id='X80oo'><dir id='X80oo'><q id='X80oo'></q></dir></style></legend>

    1. <i id='X80oo'><tr id='X80oo'><dt id='X80oo'><q id='X80oo'><span id='X80oo'><b id='X80oo'><form id='X80oo'><ins id='X80oo'></ins><ul id='X80oo'></ul><sub id='X80oo'></sub></form><legend id='X80oo'></legend><bdo id='X80oo'><pre id='X80oo'><center id='X80oo'></center></pre></bdo></b><th id='X80oo'></th></span></q></dt></tr></i><div id='X80oo'><tfoot id='X80oo'></tfoot><dl id='X80oo'><fieldset id='X80oo'></fieldset></dl></div>
      <tfoot id='X80oo'></tfoot>
      1. 带有数据库的国家/地区的 IP 地址

        时间:2023-09-30

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

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

                <bdo id='NLCsc'></bdo><ul id='NLCsc'></ul>

                    <tbody id='NLCsc'></tbody>

                  <tfoot id='NLCsc'></tfoot>
                  本文介绍了带有数据库的国家/地区的 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 地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

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

                  相关文章

                  最新文章

                  <legend id='SKNnO'><style id='SKNnO'><dir id='SKNnO'><q id='SKNnO'></q></dir></style></legend>

                  <tfoot id='SKNnO'></tfoot>

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

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