Esempio n. 1
0
  public void testUDPPingRequest() {
    PingRequest pr = pingRequestFactory.createUDPPing();
    assertTrue(pr.supportsCachedPongs());

    // Test +UP +TLS
    UltrapeerSettings.MIN_CONNECT_TIME.setValue(0);
    UltrapeerSettings.FORCE_ULTRAPEER_MODE.setValue(true);
    ConnectionSettings.EVER_ACCEPTED_INCOMING.setValue(true);
    ConnectionSettings.LOCAL_IS_PRIVATE.setValue(false);
    UltrapeerSettings.EVER_ULTRAPEER_CAPABLE.setValue(true);
    UltrapeerSettings.NEED_MIN_CONNECT_TIME.setValue(false);
    tlsManager.setIncomingTLSEnabled(true);
    assertTrue(connectionServices.isSupernode());
    pr = pingRequestFactory.createUDPPing();
    assertFalse(pr.requestsIP());
    byte[] data = pr.getSupportsCachedPongData();
    assertEquals(0x1, data[0] & 0x1);
    assertEquals(0x2, data[0] & 0x2);

    // +UP -TLS
    tlsManager.setIncomingTLSEnabled(false);
    assertTrue(connectionServices.isSupernode());
    pr = pingRequestFactory.createUDPPing();
    assertFalse(pr.requestsIP());
    data = pr.getSupportsCachedPongData();
    assertEquals(0x1, data[0] & 0x1);
    assertEquals(0x0, data[0] & 0x2);

    // Test -UP +TLS
    UltrapeerSettings.DISABLE_ULTRAPEER_MODE.setValue(true);
    UltrapeerSettings.FORCE_ULTRAPEER_MODE.setValue(false);
    tlsManager.setIncomingTLSEnabled(true);
    assertFalse(connectionServices.isSupernode());
    pr = pingRequestFactory.createUDPPing();
    assertFalse(pr.requestsIP());
    data = pr.getSupportsCachedPongData();
    assertEquals(0x0, data[0] & 0x1);
    assertEquals(0x2, data[0] & 0x2);

    // Test -UP -TLS
    tlsManager.setIncomingTLSEnabled(false);
    assertFalse(connectionServices.isSupernode());
    pr = pingRequestFactory.createUDPPing();
    assertFalse(pr.requestsIP());
    data = pr.getSupportsCachedPongData();
    assertEquals(0x0, data[0] & 0x1);
    assertEquals(0x0, data[0] & 0x2);

    ConnectionSettings.EVER_ACCEPTED_INCOMING.setValue(false);
    pr = pingRequestFactory.createUDPPing();
    assertTrue(pr.requestsIP());
  }
Esempio n. 2
0
  public void testDoesNotPromoteIfSupernodeDisabled() throws Exception {
    ConnectionSettings.EVER_ACCEPTED_INCOMING.setValue(true);
    ApplicationSettings.AVERAGE_UPTIME.setValue(UltrapeerSettings.MIN_AVG_UPTIME.getValue() + 1);
    assertFalse(UltrapeerSettings.EVER_ULTRAPEER_CAPABLE.getValue());

    // user disabled
    UltrapeerSettings.DISABLE_ULTRAPEER_MODE.setValue(true);
    // everything else fine
    mockery.checking(buildBandwdithExpectations(true));
    mockery.checking(buildUltrapeerExpectations(true, true, 0l, false, DHTMode.INACTIVE, false));
    mockery.checking(buildPromotionExpectations(false));

    assignerRunnable.run();
    assertFalse(UltrapeerSettings.EVER_ULTRAPEER_CAPABLE.getValue());
    mockery.assertIsSatisfied();
  }
Esempio n. 3
0
 @SuppressWarnings({"unused"})
 private static void doSettings() throws Exception {
   String localIP = InetAddress.getLocalHost().getHostAddress();
   FilterSettings.BLACK_LISTED_IP_ADDRESSES.set(new String[] {"*.*.*.*"});
   FilterSettings.WHITE_LISTED_IP_ADDRESSES.set(
       new String[] {"127.*.*.*", "192.168.*.*", "10.254.*.*", localIP});
   NetworkSettings.PORT.setValue(SERVER_PORT);
   ConnectionSettings.CONNECT_ON_STARTUP.setValue(false);
   UltrapeerSettings.EVER_ULTRAPEER_CAPABLE.setValue(false);
   UltrapeerSettings.DISABLE_ULTRAPEER_MODE.setValue(true);
   UltrapeerSettings.FORCE_ULTRAPEER_MODE.setValue(false);
   ConnectionSettings.NUM_CONNECTIONS.setValue(0);
   ConnectionSettings.LOCAL_IS_PRIVATE.setValue(false);
   ConnectionSettings.WATCHDOG_ACTIVE.setValue(false);
   SearchSettings.MINIMUM_SEARCH_QUALITY.setValue(-2);
 }
Esempio n. 4
0
 private void setSettings() throws Exception {
   FilterSettings.BLACK_LISTED_IP_ADDRESSES.set(new String[] {"*.*.*.*"});
   // Set the local host to not be banned so pushes can go through
   String ip = InetAddress.getLocalHost().getHostAddress();
   FilterSettings.WHITE_LISTED_IP_ADDRESSES.set(new String[] {ip, "127.*.*.*"});
   NetworkSettings.PORT.setValue(TEST_PORT);
   ConnectionSettings.CONNECT_ON_STARTUP.setValue(false);
   ConnectionSettings.LOCAL_IS_PRIVATE.setValue(false);
   // reset the node capabilities settings
   UltrapeerSettings.FORCE_ULTRAPEER_MODE.setValue(false);
   UltrapeerSettings.EVER_ULTRAPEER_CAPABLE.setValue(false);
   UltrapeerSettings.NEED_MIN_CONNECT_TIME.setValue(true);
   UltrapeerSettings.DISABLE_ULTRAPEER_MODE.setValue(false);
   DHTSettings.DISABLE_DHT_USER.setValue(false);
   DHTSettings.DISABLE_DHT_NETWORK.setValue(false);
   DHTSettings.EXCLUDE_ULTRAPEERS.setValue(true);
   DHTSettings.FORCE_DHT_CONNECT.setValue(false);
   DHTSettings.ENABLE_PASSIVE_DHT_MODE.setValue(true);
   DHTSettings.ENABLE_PASSIVE_LEAF_DHT_MODE.setValue(true);
 }
  @Override
  protected void setSettings() throws Exception {

    ConnectionSettings.NUM_CONNECTIONS.setValue(4);
    SearchSettings.GUESS_ENABLED.setValue(true);
    UltrapeerSettings.DISABLE_ULTRAPEER_MODE.setValue(false);
    UltrapeerSettings.EVER_ULTRAPEER_CAPABLE.setValue(true);
    UltrapeerSettings.FORCE_ULTRAPEER_MODE.setValue(true);
    ConnectionSettings.EVER_ACCEPTED_INCOMING.setValue(true);
    ConnectionSettings.CONNECT_ON_STARTUP.setValue(false);
    ConnectionSettings.LOCAL_IS_PRIVATE.setValue(false);
    FilterSettings.BLACK_LISTED_IP_ADDRESSES.set(new String[] {"*.*.*.*"});
    FilterSettings.WHITE_LISTED_IP_ADDRESSES.set(
        new String[] {"127.*.*.*", InetAddress.getLocalHost().getHostAddress()});

    ConnectionSettings.WATCHDOG_ACTIVE.setValue(false);
    ConnectionSettings.ALLOW_WHILE_DISCONNECTED.setValue(true);
    //        ConnectionSettings.PORT.setValue(6332);

    UltrapeerSettings.NEED_MIN_CONNECT_TIME.setValue(false);
  }