コード例 #1
0
  public InetAddress getExternalIpAddressHTTP(boolean v6) throws Exception {

    Map reply = executeHTTP(new HashMap(), v6);

    byte[] address = (byte[]) reply.get("source_ip_address");

    return (InetAddress.getByName(new String(address)));
  }
コード例 #2
0
  public InetAddress getExternalIpAddressUDP(InetAddress bind_ip, int bind_port, boolean v6)
      throws Exception {
    Map reply = executeUDP(new HashMap(), bind_ip, bind_port, v6);

    byte[] address = (byte[]) reply.get("source_ip_address");

    return (InetAddress.getByName(new String(address)));
  }
コード例 #3
0
  protected String getHost(boolean v6, String v6_address, String v4_address) {
    if (v6) {

      try {
        return (InetAddress.getByName(v6_address).getHostAddress());

      } catch (UnknownHostException e) {

        try {
          return (DNSUtils.getIPV6ByName(v6_address).getHostAddress());

        } catch (UnknownHostException f) {

          return (v6_address);
        }
      }
    } else {

      return (v4_address);
    }
  }
コード例 #4
0
  protected void preProcessReply(Map reply, final boolean v6) {
    NetworkAdmin admin = NetworkAdmin.getSingleton();

    try {
      byte[] address = (byte[]) reply.get("source_ip_address");

      InetAddress my_ip = InetAddress.getByName(new String(address));

      NetworkAdminASN old_asn = admin.getCurrentASN();

      NetworkAdminASN new_asn = admin.lookupCurrentASN(my_ip);

      if (!new_asn.sameAs(old_asn)) {

        // kick off a secondary version check to communicate the new information

        if (!secondary_check_done) {

          secondary_check_done = true;

          new AEThread("Secondary version check", true) {
            public void runSupport() {
              getVersionCheckInfoSupport(REASON_SECONDARY_CHECK, false, true, v6);
            }
          }.start();
        }
      }
    } catch (Throwable e) {

      Debug.printStackTrace(e);
    }

    Long as_advice = (Long) reply.get("as_advice");

    if (as_advice != null) {

      NetworkAdminASN current_asn = admin.getCurrentASN();

      String asn = current_asn.getASName();

      if (asn != null) {

        long advice = as_advice.longValue();

        if (advice != 0) {

          // require crypto

          String done_asn = COConfigurationManager.getStringParameter("ASN Advice Followed", "");

          if (!done_asn.equals(asn)) {

            COConfigurationManager.setParameter("ASN Advice Followed", asn);

            boolean change = advice == 1 || advice == 2;
            boolean alert = advice == 1 || advice == 3;

            if (!COConfigurationManager.getBooleanParameter(
                "network.transport.encrypted.require")) {

              if (change) {

                COConfigurationManager.setParameter("network.transport.encrypted.require", true);
              }

              if (alert) {

                String msg = MessageText.getString("crypto.alert.as.warning", new String[] {asn});

                Logger.log(new LogAlert(false, LogAlert.AT_WARNING, msg));
              }
            }
          }
        }
      }
    }

    // set ui.toolbar.uiswitcher based on instructions from tracker
    // Really shouldn't be in VersionCheck client, but instead have some
    // listener and have the code elsewhere.  Simply calling
    // getVersionCheckInfo from "code elsewhere" (to get the cached result)
    // caused a deadlock at startup.
    Long lEnabledUISwitcher = (Long) reply.get("ui.toolbar.uiswitcher");
    if (lEnabledUISwitcher != null) {
      COConfigurationManager.setBooleanDefault(
          "ui.toolbar.uiswitcher", lEnabledUISwitcher.longValue() == 1);
    }
  }