本文整理汇总了Java中com.subgraph.orchid.data.IPv4Address类的典型用法代码示例。如果您正苦于以下问题:Java IPv4Address类的具体用法?Java IPv4Address怎么用?Java IPv4Address使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IPv4Address类属于com.subgraph.orchid.data包,在下文中一共展示了IPv4Address类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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]);
}
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
}
}
示例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);
}
}
示例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);
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}
示例12: BridgeRouterImpl
import com.subgraph.orchid.data.IPv4Address; //导入依赖的package包/类
BridgeRouterImpl(IPv4Address address, int port) {
this.address = address;
this.port = port;
}
示例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;
}
示例14: toString
import com.subgraph.orchid.data.IPv4Address; //导入依赖的package包/类
public String toString() {
IPv4Address a = new IPv4Address(network);
return a.toString() + "/" + bits;
}
示例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;
}