当前位置: 首页 > news >正文

百度免费网站建设手机网页如何制作

百度免费网站建设,手机网页如何制作,在线药店网站建设,长春网站建设工作常用方法#xff0c;判断一个ip是否在指定的ip范围内#xff0c;范围可能包括起始ip范围或者掩码形式#xff0c;无其它依赖#xff0c; package com.yk.ip;import java.math.BigInteger; import java.net.InetAddress; import java.net.UnknownHostException; import jav…常用方法判断一个ip是否在指定的ip范围内范围可能包括起始ip范围或者掩码形式无其它依赖 package com.yk.ip;import java.math.BigInteger; import java.net.InetAddress; import java.net.UnknownHostException; import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.List;public class IpUtil {/*** 判断目标ip是否在ip范围内(起始ip范围),支持ipv6* param ipAddress 目标ip* param startIp 开始ip* param endIp 结束ip* return boolean* throws UnknownHostException 异常*/public static boolean isInRange(String ipAddress,String startIp,String endIp) throws UnknownHostException {InetAddress address InetAddress.getByName(ipAddress);InetAddress startAddress InetAddress.getByName(startIp);InetAddress endAddress InetAddress.getByName(endIp);BigInteger start new BigInteger(1, startAddress.getAddress());BigInteger end new BigInteger(1, endAddress.getAddress());BigInteger target new BigInteger(1, address.getAddress());int st start.compareTo(target);int te target.compareTo(end);return (st 0) (te 0);}/*** 判断目标ip是否在ip范围内(掩码),支持ipv6* param ipAddress 目标ip* param ipWithMask 带掩码ip* return boolean* throws UnknownHostException 异常*/public static boolean isInRange(String ipAddress,String ipWithMask) throws UnknownHostException {if (ipWithMask.contains(/)) {String addressPart ipWithMask.substring(0, ipWithMask.indexOf(/));String networkPart ipWithMask.substring(ipWithMask.indexOf(/) 1);ByteBuffer maskBuffer;int targetSize;InetAddress inetAddress InetAddress.getByName(addressPart);if (inetAddress.getAddress().length 4) {maskBuffer ByteBuffer.allocate(4).putInt(-1);targetSize 4;} else {maskBuffer ByteBuffer.allocate(16).putLong(-1L).putLong(-1L);targetSize 16;}BigInteger mask (new BigInteger(1, maskBuffer.array())).not().shiftRight(Integer.parseInt(networkPart));ByteBuffer buffer ByteBuffer.wrap(inetAddress.getAddress());BigInteger ipVal new BigInteger(1, buffer.array());BigInteger startIp ipVal.and(mask);BigInteger endIp startIp.add(mask.not());byte[] startIpArr toBytes(startIp.toByteArray(), targetSize);byte[] endIpArr toBytes(endIp.toByteArray(), targetSize);InetAddress startAddress InetAddress.getByAddress(startIpArr);InetAddress endAddress InetAddress.getByAddress(endIpArr);return isInRange(ipAddress, startAddress.getHostAddress(), endAddress.getHostAddress());} else {throw new IllegalArgumentException(not an valid CIDR format!);}}private static byte[] toBytes(byte[] array, int targetSize) {int counter 0;ListByte newArr new ArrayListByte();while (counter targetSize (array.length - 1 - counter 0)) {newArr.add(0, array[array.length - 1 - counter]);counter;}int size newArr.size();for (int i 0; i (targetSize - size); i) {newArr.add(0, (byte) 0);}byte[] ret new byte[newArr.size()];for (int i 0; i newArr.size(); i) {ret[i] newArr.get(i);}return ret;} }
http://www.dnsts.com.cn/news/95990.html

相关文章:

  • 广州网站建设新锐网页设计代表性案例
  • 网站根域名是什么东莞网站seo推广
  • 网站建设的资料的准备网络营销案例图文ppt
  • 一个ip上绑多个网站深圳建筑人才网官方网站
  • 企业门户网站建设思路线上推广方式和介绍
  • 新手想做网站赚钱军队房地产与建设工程法律实务在哪个网站可以购买
  • 什么什么设计英文网站python网页版
  • 搭建网站首页安卓软件app
  • 西安做网站服务百度网盟推广怎么做
  • 搭建网站的五大步骤手游推广平台
  • 一个旅游网站建设需求分析直播网站开发接入视频
  • 怎样建自己的网站百色做网站
  • 哪个网站在线做头像好软件编程培训学校排名
  • 网站经常被挂码wordpress添加标签
  • 一般网站建设方案风信子 网站建设
  • html5网站开发书籍福州市工程造价信息网
  • wordpress可以做什么站洞泾做网站公司
  • 南阳网站建设大旗电商wordpress 豆瓣电影
  • 网站建设的国内外现状注册新公司的流程
  • 广州工程建设网站网站制作的步骤不包括
  • 做市级网站需要什么意思wordpress授权小程序
  • 临城网站建设wordpress标签云添加图片
  • 百度站长工具怎么推广网站网站建设制作网络营销公司
  • 成都网站建设收费明细自建网站卖东西
  • 网站建设微信商城运营下载jsp网站开发用啥工具
  • 设计得很好的企业网站2017年做网站多少钱
  • 扁平化设计风格的网站微官网和移动网站区别吗
  • 合肥企业建网站seo网站推广收费
  • 建设银行博士后招聘网站做数据收集网站
  • 福州品牌网站设计html5手机网站案例