Esempio n. 1
0
  public static void setAZTracker(URL tracker_url, boolean az_tracker) {
    String key = tracker_url.getHost() + ":" + tracker_url.getPort();

    synchronized (az_trackers) {
      boolean changed = false;

      if (az_trackers.get(key) == null) {

        if (az_tracker) {

          az_trackers.put(key, new Long(SystemTime.getCurrentTime()));

          changed = true;
        }
      } else {

        if (!az_tracker) {

          if (az_trackers.remove(key) != null) {

            changed = true;
          }
        }
      }

      if (changed) {

        COConfigurationManager.setParameter("Tracker Client AZ Instances", az_trackers);
      }
    }
  }
Esempio n. 2
0
  public static URL adjustURLForHosting(URL url_in) {
    if (isHosting(url_in)) {

      String url = url_in.getProtocol() + "://";

      if (bind_ip.length() < 7) {

        url += "127.0.0.1";

      } else {

        url += bind_ip;
      }

      int port = url_in.getPort();

      if (port != -1) {

        url += ":" + url_in.getPort();
      }

      url += url_in.getPath();

      String query = url_in.getQuery();

      if (query != null) {

        url += "?" + query;
      }

      try {
        return (new URL(url));

      } catch (MalformedURLException e) {

        Debug.printStackTrace(e);
      }
    }

    return (url_in);
  }
Esempio n. 3
0
  public static boolean isAZTracker(URL tracker_url) {
    String host = tracker_url.getHost();

    if (Constants.isAzureusDomain(host)) {

      return (true);
    }

    synchronized (az_trackers) {
      return (az_trackers.containsKey(host + ":" + tracker_url.getPort()));
    }
  }
Esempio n. 4
0
  public static void checkForBlacklistedURLs(URL url) throws IOException {

    for (int i = 0; i < BLACKLISTED_HOSTS.length; i++) {

      if (url.getHost().equalsIgnoreCase(BLACKLISTED_HOSTS[i])
          && url.getPort() == BLACKLISTED_PORTS[i]) {

        throw (new IOException(
            "http://" + BLACKLISTED_HOSTS[i] + ":" + BLACKLISTED_PORTS[i] + "/ is not a tracker"));
      }
    }
  }
  public void setAuthenticationOutcome(String realm, URL tracker, boolean success) {
    try {
      this_mon.enter();

      setAuthenticationOutcome(
          realm, tracker.getProtocol(), tracker.getHost(), tracker.getPort(), success);

    } finally {

      this_mon.exit();
    }
  }
  public PasswordAuthentication getAuthentication(String realm, URL tracker) {
    try {
      this_mon.enter();

      return (getAuthentication(
          realm, tracker.getProtocol(), tracker.getHost(), tracker.getPort()));

    } finally {

      this_mon.exit();
    }
  }