Beispiel #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);
      }
    }
  }
Beispiel #2
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()));
    }
  }
Beispiel #3
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();
    }
  }
Beispiel #6
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);
  }
Beispiel #7
0
  public static boolean isUDPProbeOK(URL tracker_url) {
    String host = tracker_url.getHost();

    if (Constants.isAzureusDomain(host)) {

      return (false);
    }

    synchronized (udp_probe_results) {
      return (udp_probe_results.containsKey(host));
    }
  }
Beispiel #8
0
  public static void setUDPProbeResult(URL tracker_url, boolean probe_ok) {
    String key = tracker_url.getHost();

    synchronized (udp_probe_results) {
      boolean changed = false;

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

        if (probe_ok) {

          // arbitrary max size here just in case something weird happens

          if (udp_probe_results.size() > 512) {

            udp_probe_results.clear();
          }

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

          changed = true;
        }
      } else {

        if (!probe_ok) {

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

            changed = true;
          }
        }
      }

      if (changed) {

        COConfigurationManager.setParameter("Tracker Client UDP Probe Results", udp_probe_results);
      }
    }
  }
Beispiel #9
0
 public static boolean isHosting(URL url_in) {
   return (tracker_ip.length() > 0
       && UrlUtils.expandIPV6Host(url_in.getHost()).equalsIgnoreCase(tracker_ip));
 }