• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java IPv4Address类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.subgraph.orchid.data.IPv4Address的典型用法代码示例。如果您正苦于以下问题:Java IPv4Address类的具体用法?Java IPv4Address怎么用?Java IPv4Address使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IPv4Address类属于com.subgraph.orchid.data包,在下文中一共展示了IPv4Address类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: createFromString

import com.subgraph.orchid.data.IPv4Address; //导入依赖的package包/类
public static Network createFromString(String networkString) {
	final String[] parts = networkString.split("/");
	final IPv4Address network = IPv4Address.createFromString(parts[0]);
	if(parts.length == 1)
		return new Network(network, 32, networkString);
	
	if(parts.length != 2)
		throw new TorParsingException("Invalid network CIDR notation: " + networkString);

	try {
		final int maskBits = Integer.parseInt(parts[1]);
		return new Network(network, maskBits, networkString);
	} catch(NumberFormatException e) {
		throw new TorParsingException("Invalid netblock mask bit value: " + parts[1]);
	}
}
 
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:17,代码来源:Network.java


示例2: testBridges

import com.subgraph.orchid.data.IPv4Address; //导入依赖的package包/类
@Test
public void testBridges() {
	final IPv4Address a1 = IPv4Address.createFromString("1.2.3.4");
	final IPv4Address a2 = IPv4Address.createFromString("4.4.4.4");
	final HexDigest fp = HexDigest.createFromString("0EA20CAA3CE696E561BC08B15E00106700E8F682");
	config.addBridge(a1, 88);
	config.addBridge(a2, 101, fp);
	List<TorConfigBridgeLine> bs = config.getBridges();
	assertEquals(2, bs.size());
	final TorConfigBridgeLine b1 = bs.get(0);
	final TorConfigBridgeLine b2 = bs.get(1);
	
	assertEquals(a1, b1.getAddress());
	assertEquals(a2, b2.getAddress());
	assertEquals(88, b1.getPort());
	assertEquals(101, b2.getPort());
	assertNull(b1.getFingerprint());
	assertSame(b2.getFingerprint(), fp);
}
 
开发者ID:DigiByte-Team,项目名称:digibytej-alice,代码行数:20,代码来源:TorConfigTest.java


示例3: setIPv4AddressData

import com.subgraph.orchid.data.IPv4Address; //导入依赖的package包/类
protected void setIPv4AddressData(byte[] data) throws SocksRequestException {
	logUnsafeSOCKS();

	if(data.length != 4)
		throw new SocksRequestException();
	addressData = data;
	
	int addressValue = 0;
	for(byte b: addressData) {
		addressValue <<= 8;
		addressValue |= (b & 0xFF);
	}
	address = new IPv4Address(addressValue);
}
 
开发者ID:DigiByte-Team,项目名称:digibytej-alice,代码行数:15,代码来源:SocksRequest.java


示例4: acceptsDestination

import com.subgraph.orchid.data.IPv4Address; //导入依赖的package包/类
public boolean acceptsDestination(IPv4Address address, int port) {
	if(address == null)
		return acceptsPort(port);

	for(PolicyRule r: rules) {
		if(r.matchesDestination(address, port)) 
			return r.isAcceptRule();
	}
	// Default accept (see dir-spec.txt section 2.1, 'accept'/'reject' keywords)
	return true;
}
 
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:12,代码来源:ExitPolicy.java


示例5: processNetInfo

import com.subgraph.orchid.data.IPv4Address; //导入依赖的package包/类
protected void processNetInfo(Cell netinfoCell) {
	remoteTimestamp = netinfoCell.getInt();
	myAddress = readAddress(netinfoCell);
	final int addressCount = netinfoCell.getByte();
	for(int i = 0; i < addressCount; i++) {
		IPv4Address addr = readAddress(netinfoCell);
		if(addr != null) {
			remoteAddresses.add(addr);
		}
	}
}
 
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:12,代码来源:ConnectionHandshake.java


示例6: exitPolicyAccepts

import com.subgraph.orchid.data.IPv4Address; //导入依赖的package包/类
public boolean exitPolicyAccepts(IPv4Address address, int port) {
	refreshDescriptor();
	if(descriptor == null) {
		return false;
	} else if(address == null) {
		return descriptor.exitPolicyAccepts(port);
	} else {
		return descriptor.exitPolicyAccepts(address, port);
	}
}
 
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:11,代码来源:RouterImpl.java


示例7: createAddressFilter

import com.subgraph.orchid.data.IPv4Address; //导入依赖的package包/类
private static RouterFilter createAddressFilter(String s) {
	final Matcher matcher = ADDRESS_BITS_PATTERN.matcher(s);
	if(!matcher.matches()) {
		throw new IllegalArgumentException();
	}
	final IPv4Address network = IPv4Address.createFromString(matcher.group(1));
	final int bits = Integer.parseInt(matcher.group(2));
	return new MaskFilter(network, bits);
}
 
开发者ID:DigiByte-Team,项目名称:digibytej-alice,代码行数:10,代码来源:ConfigNodeFilter.java


示例8: StreamExitRequest

import com.subgraph.orchid.data.IPv4Address; //导入依赖的package包/类
private StreamExitRequest(Object requestCompletionLock, boolean isAddress, String hostname, IPv4Address address, int port) {
	this.requestCompletionLock = requestCompletionLock;
	this.isAddress = isAddress;
	this.hostname = hostname;
	this.address = address;
	this.port = port;
	this.completionStatus = CompletionStatus.NOT_COMPLETED;
}
 
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:9,代码来源:StreamExitRequest.java


示例9: invokeBridgeAdd

import com.subgraph.orchid.data.IPv4Address; //导入依赖的package包/类
private void invokeBridgeAdd(Object[] args) {
	if(args.length >= 2 && (args[0] instanceof IPv4Address) && (args[1] instanceof Integer)) {
		if(args.length == 2) {
			bridges.add(new TorConfigBridgeLine((IPv4Address)args[0], (Integer)args[1], null));
			return;
		} else if(args.length == 3 && (args[2] instanceof HexDigest)) {
			bridges.add(new TorConfigBridgeLine((IPv4Address) args[0], (Integer) args[1], (HexDigest) args[2]));
			return;
		}
	}
	throw new IllegalArgumentException();
}
 
开发者ID:DigiByte-Team,项目名称:digibytej-alice,代码行数:13,代码来源:TorConfigProxy.java


示例10: seekCountry

import com.subgraph.orchid.data.IPv4Address; //导入依赖的package包/类
private int seekCountry(IPv4Address address) {
	if(database == null) {
		return 0;
	}
	
	final byte[] record = new byte[2 * MAX_RECORD_LENGTH];
	final int[] x = new int[2];
	final long ip = address.getAddressData() & 0xFFFFFFFFL;
	
	int offset = 0;
	for(int depth = 31; depth >= 0; depth--) {
		loadRecord(offset, record);

		x[0] = unpackRecordValue(record, 0);
		x[1] = unpackRecordValue(record, 1);
		
		int xx = ((ip & (1 << depth)) > 0) ? (x[1]) : (x[0]);
		
		if(xx >= COUNTRY_BEGIN) {
			final int idx = xx - COUNTRY_BEGIN;
			if(idx < 0 || idx > COUNTRY_CODES.length) {
				logger.warning("Invalid index calculated looking up country code record for ("+ address +") idx = "+ idx);
				return 0;
			} else {
				return idx;
			}
		} else {
			offset = xx;
		}
		
	}
	logger.warning("No record found looking up country code record for ("+ address + ")");
	return 0;
}
 
开发者ID:DigiByte-Team,项目名称:digibytej-alice,代码行数:35,代码来源:CountryCodeService.java


示例11: createRouterMockWithAddress

import com.subgraph.orchid.data.IPv4Address; //导入依赖的package包/类
private Router createRouterMockWithAddress(String ip) {
	final IPv4Address address = IPv4Address.createFromString(ip);
	final Router router = createMock("mockRouter", Router.class);
	expect(router.getAddress()).andReturn(address);
	replay(router);
	return router;
}
 
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:8,代码来源:ConfigNodeFilterTest.java


示例12: BridgeRouterImpl

import com.subgraph.orchid.data.IPv4Address; //导入依赖的package包/类
BridgeRouterImpl(IPv4Address address, int port) {
	this.address = address;
	this.port = port;
}
 
开发者ID:DigiByte-Team,项目名称:digibytej-alice,代码行数:5,代码来源:BridgeRouterImpl.java


示例13: MaskFilter

import com.subgraph.orchid.data.IPv4Address; //导入依赖的package包/类
MaskFilter(IPv4Address network, int bits) {
	this.bits = bits;
	this.mask = createMask(bits);
	this.network = network.getAddressData() & mask;
}
 
开发者ID:DigiByte-Team,项目名称:digibytej-alice,代码行数:6,代码来源:ConfigNodeFilter.java


示例14: toString

import com.subgraph.orchid.data.IPv4Address; //导入依赖的package包/类
public String toString() {
	IPv4Address a = new IPv4Address(network);
	return a.toString() + "/" + bits;
	
}
 
开发者ID:DigiByte-Team,项目名称:digibytej-alice,代码行数:6,代码来源:ConfigNodeFilter.java


示例15: Network

import com.subgraph.orchid.data.IPv4Address; //导入依赖的package包/类
Network(IPv4Address network, int bits, String originalString) {
	this.network = network;
	this.maskValue = createMask(bits);
	this.originalString = originalString;
}
 
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:6,代码来源:Network.java


示例16: areInSameSlash16

import com.subgraph.orchid.data.IPv4Address; //导入依赖的package包/类
private boolean areInSameSlash16(Router r1, Router r2) {
	final IPv4Address a1 = r1.getAddress();
	final IPv4Address a2 = r2.getAddress();
	final int mask = 0xFFFF0000;
	return (a1.getAddressData() & mask) == (a2.getAddressData() & mask);
}
 
开发者ID:DigiByte-Team,项目名称:digibytej-alice,代码行数:7,代码来源:CircuitPathChooser.java


示例17: setAddress

import com.subgraph.orchid.data.IPv4Address; //导入依赖的package包/类
public void setAddress(IPv4Address address) {
	this.address = address;
}
 
开发者ID:DigiByte-Team,项目名称:digibytej-alice,代码行数:4,代码来源:RouterMicrodescriptorImpl.java


示例18: getMyAddress

import com.subgraph.orchid.data.IPv4Address; //导入依赖的package包/类
IPv4Address getMyAddress() {
	return myAddress;
}
 
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:4,代码来源:ConnectionHandshake.java


示例19: putIPv4Address

import com.subgraph.orchid.data.IPv4Address; //导入依赖的package包/类
private void putIPv4Address(Cell cell, IPv4Address address) {
	final byte[] data = address.getAddressDataBytes();
	cell.putByte(Cell.ADDRESS_TYPE_IPV4);
	cell.putByte(data.length); 
	cell.putByteArray(data);
}
 
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:7,代码来源:ConnectionHandshake.java


示例20: maybeRejectInternalAddress

import com.subgraph.orchid.data.IPv4Address; //导入依赖的package包/类
private void maybeRejectInternalAddress(IPv4Address address) throws OpenFailedException {
	final InetAddress inetAddress = address.toInetAddress();
	if(inetAddress.isSiteLocalAddress() && config.getClientRejectInternalAddress()) {
		throw new OpenFailedException("Rejecting stream target with internal address: "+ address);
	}
}
 
开发者ID:DigiByte-Team,项目名称:digibytej-alice,代码行数:7,代码来源:CircuitManagerImpl.java



注:本文中的com.subgraph.orchid.data.IPv4Address类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java EntityPotion类代码示例发布时间:2022-05-22
下一篇:
Java ProtocolSignature类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap