Package freenet.io.comm

Examples of freenet.io.comm.FreenetInetAddress


  }

  public InetAddress[] getInetAddresses() {
    ArrayList<InetAddress> v = new ArrayList<InetAddress>();
    for(Peer peer: getHandshakeIPs()) {
      FreenetInetAddress fa = peer.getFreenetAddress().dropHostname();
      if(fa == null) continue;
      InetAddress ia = fa.getAddress();
      if(v.contains(ia)) continue;
      v.add(ia);
    }
    if(v.isEmpty()) {
      Logger.error(this, "No valid addresses for seed node "+this);
View Full Code Here


        Logger.minor(this, "2: maybeUpdateHandshakeIPs got a result of: " + handshakeIPsToString());
      return;
    }

    // Hack for two nodes on the same IP that can't talk over inet for routing reasons
    FreenetInetAddress localhost = node.fLocalhostAddress;
    Peer[] nodePeers = outgoingMangler.getPrimaryIPAddress();

    List<Peer> localPeers = null;
    synchronized(this) {
      localPeers = new ArrayList<Peer>(nominalPeer);
    }

    boolean addedLocalhost = false;
    Peer detectedDuplicate = null;
    for(Peer p: myNominalPeer) {
      if(p == null)
        continue;
      if(localDetectedPeer != null) {
        if((p != localDetectedPeer) && p.equals(localDetectedPeer)) {
          // Equal but not the same object; need to update the copy.
          detectedDuplicate = p;
        }
      }
      FreenetInetAddress addr = p.getFreenetAddress();
      if(addr.equals(localhost)) {
        if(addedLocalhost)
          continue;
        addedLocalhost = true;
      }
      for(Peer nodePeer: nodePeers) {
        // REDFLAG - Two lines so we can see which variable is null when it NPEs
        FreenetInetAddress myAddr = nodePeer.getFreenetAddress();
        if(myAddr.equals(addr)) {
          if(!addedLocalhost)
            localPeers.add(new Peer(localhost, p.getPort()));
          addedLocalhost = true;
        }
      }
View Full Code Here

    }
    long loopTime1 = System.currentTimeMillis();
    List<Peer> validIPs = new ArrayList<Peer>(localHandshakeIPs.length);
    boolean allowLocalAddresses = allowLocalAddresses();
    for(Peer peer: localHandshakeIPs) {
      FreenetInetAddress addr = peer.getFreenetAddress();
      if(peer.getAddress(false) == null) {
        if(logMINOR) Logger.minor(this, "Not sending handshake to "+peer+" for "+getPeer()+" because the DNS lookup failed or it's a currently unsupported IPv6 address");
        continue;
      }
      if(!peer.isRealInternetAddress(false, false, allowLocalAddresses)) {
View Full Code Here

  /** Does this PeerNode match the given IP address?
   * @param strict If true, only match if the IP is actually in use. If false,
   * also match from nominal IP addresses and domain names etc. */
  public synchronized boolean matchesIP(FreenetInetAddress addr, boolean strict) {
    if(detectedPeer != null) {
      FreenetInetAddress a = detectedPeer.getFreenetAddress();
      if(a != null) {
        if(strict ? a.equals(addr) : a.laxEquals(addr))
          return true;
      }
    }
    if((!strict) && nominalPeer != null) {
      for(Peer p : nominalPeer) {
        if(p == null) continue;
        FreenetInetAddress a = p.getFreenetAddress();
        if(a == null) continue;
        if(a.laxEquals(addr)) return true;
      }
    }
    return false;
  }
View Full Code Here

    for(PeerNode p: peers) {
      if(p.isDisabled()) continue;
      // Don't count localhost, LAN addresses.
      Peer peer = p.getPeer();
      if(peer == null) continue;
      FreenetInetAddress a = peer.getFreenetAddress();
      if(a == null) continue; // Not much chance of connecting.
      InetAddress addr = a.getAddress(false);
      if(addr != null) {
        if(!IPUtil.isValidAddress(addr, false)) continue;
      }
      boolean skip = false;
      for(FreenetInetAddress nodeAddr: nodeAddrs) {
        if(a.equals(nodeAddr)) {
          skip = true;
          break;
        }
      }
      if(skip) continue;
View Full Code Here

    try {

    int port = config.getPort();

    FreenetInetAddress bindto = config.getBindTo();

    UdpSocketHandler u = null;

    if(port > 65535) {
      throw new NodeInitException(NodeInitException.EXIT_IMPOSSIBLE_USM_PORT, "Impossible port number: "+port);
    } else if(port == -1) {
      // Pick a random port
      for(int i=0;i<200000;i++) {
        int portNo = 1024 + random.nextInt(65535-1024);
        try {
          u = new UdpSocketHandler(portNo, bindto.getAddress(), node, startupTime, getTitle(portNo), node.collector);
          port = u.getPortNumber();
          break;
        } catch (Exception e) {
          Logger.normal(this, "Could not use port: "+bindto+ ':' +portNo+": "+e, e);
          System.err.println("Could not use port: "+bindto+ ':' +portNo+": "+e);
          e.printStackTrace();
          continue;
        }
      }
      if(u == null)
        throw new NodeInitException(NodeInitException.EXIT_NO_AVAILABLE_UDP_PORTS, "Could not find an available UDP port number for FNP (none specified)");
    } else {
      try {
        u = new UdpSocketHandler(port, bindto.getAddress(), node, startupTime, getTitle(port), node.collector);
      } catch (Exception e) {
        Logger.error(this, "Caught "+e, e);
        System.err.println(e);
        e.printStackTrace();
        throw new NodeInitException(NodeInitException.EXIT_IMPOSSIBLE_USM_PORT, "Could not bind to port: "+port+" (node already running?)");
View Full Code Here

TOP

Related Classes of freenet.io.comm.FreenetInetAddress

Copyright © 2018 www.massapicom. 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.