项目作者: firekcc

项目描述 :
the chunzhen ip database
高级语言: Java
项目地址: git://github.com/firekcc/chunzhen-qqwry.git
创建时间: 2019-07-04T14:22:05Z
项目社区:https://github.com/firekcc/chunzhen-qqwry

开源协议:

下载


chunzhen-qqwry

the chunzhen ip database

纯真网络 cz88.net

  • dat文件更新脚本
    1. 1.cd ${MYWORKSPACE}/src/main/resources && pwd
    2. 2.docker run -it --rm --name my-running-script -v "$PWD":/usr/src/myapp -w /usr/src/myapp python:alpine python update_chunzhen.py qqwry.dat
  • 代码使用示例
    ```
    private static final String IP_REGEXP = “^(1\d{2}|2[0-4]\d|25[0-5]|[1-9]\d|[1-9])\.(00?\d|1\d{2}|2[0-4]\d|25[0-5]|[1-9]\d|\d)\.(00?\d|1\d{2}|2[0-4]\d|25[0-5]|[1-9]\d|\d)\.(00?\d|1\d{2}|2[0-4]\d|25[0-5]|[1-9]\d|\d)$”;

    private static boolean checkIp(String item) {

    1. if (StringUtils.isNotEmpty(item)) {
    2. Pattern pattern = Pattern.compile(IP_REGEXP);
    3. Matcher matcher = pattern.matcher(item);
    4. return matcher.find();
    5. }
    6. return false;

    }

    public static IPZone getIPZone(String ip) {

    1. if (!checkIp(ip)) {
    2. return null;
    3. }
    4. IPZone ipzone = null;
    5. try {
    6. ipzone = new QQWry().findIP(ip);
    7. } catch (IOException e) {
    8. logger.error("IPZone IO-ERROR ", e);
    9. } catch (IllegalArgumentException e) {
    10. logger.error("IPZone IllegalArgument-ERROR ", e);
    11. } catch (Exception e) {
    12. logger.error("IPZone ERROR ", e);
    13. }
    14. return ipzone;

    }

    Optional ipCity = Optional.ofNullable(getIPZone(ip));

```