Examples of IPv4Address


Examples of com.subgraph.orchid.data.IPv4Address

    assertEquals(TorConfig.AutoBoolValue.AUTO, config.getUseNTorHandshake());
  }
 
  @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());
View Full Code Here

Examples of com.subgraph.orchid.data.IPv4Address

    testAddress("CA", "132.216.177.160")// www.mcgill.ca
    testAddress("US", "38.229.72.14");     // www.torproject.net
  }
 
  private void testAddress(String expectedCC, String address) {
    IPv4Address a = IPv4Address.createFromString(address);
    String cc = ccs.getCountryCodeForAddress(a);
    assertEquals("Country Code lookup for "+ address, expectedCC, cc);
  }
View Full Code Here

Examples of com.subgraph.orchid.data.IPv4Address

    for(String s: validStrings) { assertTrue(s, ConfigNodeFilter.isCountryCodeString(s)); }
    for(String s: invalidStrings) { assertFalse(s, ConfigNodeFilter.isCountryCodeString(s)); }
  }
 
  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;
  }
View Full Code Here

Examples of com.subgraph.orchid.data.IPv4Address

    cell.putByteArray(data);
  }
 
  private void putMyAddresses(Cell cell) {
    cell.putByte(1);
    putIPv4Address(cell, new IPv4Address(0));
  }
View Full Code Here

Examples of com.subgraph.orchid.data.IPv4Address

  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);
      }
    }
  }
View Full Code Here

Examples of com.subgraph.orchid.data.IPv4Address

  private IPv4Address readAddress(Cell cell) {
    final int type = cell.getByte();
    final int len = cell.getByte();
    if(type == Cell.ADDRESS_TYPE_IPV4 && len == 4) {
      return new IPv4Address(cell.getInt());
    }
    final byte[] buffer = new byte[len];
    cell.getByteArray(buffer);
    return null;
  }
View Full Code Here

Examples of com.subgraph.orchid.data.IPv4Address

public class Network {
  public static final Network ALL_ADDRESSES = new Network(IPv4Address.createFromString("0.0.0.0"), 0, "*");
  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);
View Full Code Here

Examples of com.subgraph.orchid.data.IPv4Address

  public boolean isAddressTarget() {
    return false;
  }

  public IPv4Address getAddress() {
    return new IPv4Address(0);
  }
View Full Code Here

Examples of com.subgraph.orchid.data.IPv4Address

    return false;
  }

  // Are routers r1 and r2 in the same /16 network
  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);
  }
View Full Code Here

Examples of com.subgraph.orchid.data.IPv4Address

  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);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.