zoukankan      html  css  js  c++  java
  • xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

    npm ip

    webpack

    $ 
    
    
    

    ip address

    var ip = require('ip');
     
    ip.address() // my ip address
    ip.isEqual('::1', '::0:1'); // true
    ip.toBuffer('127.0.0.1') // Buffer([127, 0, 0, 1])
    ip.toString(new Buffer([127, 0, 0, 1])) // 127.0.0.1
    ip.fromPrefixLen(24) // 255.255.255.0
    ip.mask('192.168.1.134', '255.255.255.0') // 192.168.1.0
    ip.cidr('192.168.1.134/26') // 192.168.1.128
    ip.not('255.255.255.0') // 0.0.0.255
    ip.or('192.168.1.134', '0.0.0.255') // 192.168.1.255
    ip.isPrivate('127.0.0.1') // true
    ip.isV4Format('127.0.0.1'); // true
    ip.isV6Format('::ffff:127.0.0.1'); // true
     
    // operate on buffers in-place
    var buf = new Buffer(128);
    var offset = 64;
    ip.toBuffer('127.0.0.1', buf, offset);  // [127, 0, 0, 1] at offset 64
    ip.toString(buf, offset, 4);            // '127.0.0.1'
     
    // subnet information
    ip.subnet('192.168.1.134', '255.255.255.192')
    // { networkAddress: '192.168.1.128',
    //   firstAddress: '192.168.1.129',
    //   lastAddress: '192.168.1.190',
    //   broadcastAddress: '192.168.1.191',
    //   subnetMask: '255.255.255.192',
    //   subnetMaskLength: 26,
    //   numHosts: 62,
    //   length: 64,
    //   contains: function(addr){...} }
    ip.cidrSubnet('192.168.1.134/26')
    // Same as previous.
     
    // range checking
    ip.cidrSubnet('192.168.1.134/26').contains('192.168.1.190') // true
     
     
    // ipv4 long conversion
    ip.toLong('127.0.0.1'); // 2130706433
    ip.fromLong(2130706433); // '127.0.0.1'
    
    

    refs



    ©xgqfrms 2012-2020

    www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!


  • 相关阅读:
    ural 1146. Maximum Sum(动态规划)
    ural 1119. Metro(动态规划)
    ural 1013. K-based Numbers. Version 3(动态规划)
    Floyd算法
    杭电21题 Palindrome
    杭电20题 Human Gene Functions
    杭电15题 The Cow Lexicon
    杭电三部曲一、基本算法;19题 Cow Bowling
    杭电1002 Etaoin Shrdlu
    Qt 学习之路 2(37):文本文件读写
  • 原文地址:https://www.cnblogs.com/xgqfrms/p/14235305.html
Copyright © 2011-2022 走看看