Пример #1
0
  private static ASNObj getDA_All(D_DirectoryEntry de, DirectoryRequest dr) {
    // boolean DEBUG = true;
    if (DEBUG) System.out.println("DS: getDA_All: not fully implemented!");
    DirectoryAnswerMultipleIdentities dami = new DirectoryAnswerMultipleIdentities();
    dami.directory_domain = dr.directory_domain;
    dami.directory_udp_port = dr.director_udp_port;

    addInstanceData(dami, dr.terms_default, de);
    for (D_DirectoryEntry de_crt : de.instances.values()) {
      // D_DirectoryEntry de_crt = de.instances.get(i.instance);
      addInstanceData(dami, dr.terms_default, de_crt);
    }

    // TODO Auto-generated method stub
    if (dami.remote_GIDhash == null) dami.remote_GIDhash = dr.globalIDhash;
    if (dami.remote_GIDhash == null) dami.remote_GIDhash = D_Peer.getGIDHashFromGID(dr.globalID);
    if (DEBUG) System.out.println("DS: getDA_All: done all with " + dami);
    return dami;
  }
Пример #2
0
  /**
   * Instance object passed for terms match check (not currently observed)
   *
   * @param dami
   * @param i
   * @param de
   */
  private static void addInstanceData(
      DirectoryAnswerMultipleIdentities dami,
      DIR_Terms_Preaccepted[] preaccepted, // DirectoryRequestPerInstance _i,
      D_DirectoryEntry de) {
    if (!de.known && (de.addresses == null || de.addresses.length == 0)) {
      if (DEBUG) System.out.println("DS: getDA_Only: unknown root de! " + de);
      return;
    }
    DirectoryAnswerInstance e = new DirectoryAnswerInstance();

    de.buildInstanceRequestedTerms();

    // DIR_Terms_Preaccepted[] preaccepted = null;
    // if (_i != null) preaccepted = _i.instance_terms;
    boolean termsMatch = termsMatch(preaccepted, de.instance_terms);
    if (!termsMatch) System.out.println("DS: getDA_Only: NO TERMS MATCH");
    // TODO
    // ... termsMatch = true;
    if (!termsMatch) {
      e.instance_terms = de.instance_terms;
    } else {
      if (e.branch == null) e.branch = de.branch;
      if (e.agent_version == null) e.agent_version = Util.getVersion(de.agent_version);
      if (de.addresses != null) {
        for (int k = 0; k < de.addresses.length; k++) {
          e.addresses.add(de.addresses[k]);
          if (e.branch == null) e.branch = de.addresses[k].branch;
          if (e.agent_version == null) e.agent_version = de.addresses[k].getAgentVersionInts();
        }
      }
      e.signature_peer = de.signature;
      e.date_last_contact = de.timestamp;
      dami.known |= de.known;
    }
    if (dami.remote_GIDhash == null) dami.remote_GIDhash = de.globalIDhash;
    if (dami.remote_GIDhash == null) dami.remote_GIDhash = D_Peer.getGIDHashFromGID(de.globalID);
    e.instance = de.instance;
    dami.instances.add(e);
    dami.date_most_recent_among_instances = e.date_last_contact = de.timestamp;
    if (DEBUG) System.out.println("DS: getDA_Only: added NULL instance " + e);
    return;
  }
Пример #3
0
  private static ASNObj getDA_Only(D_DirectoryEntry de, DirectoryRequest dr) {
    // boolean DEBUG = true;
    if (DEBUG) System.out.println("DS: getDA_Only: enter");
    DirectoryAnswerMultipleIdentities dami = new DirectoryAnswerMultipleIdentities();
    dami.directory_domain = dr.directory_domain;
    dami.directory_udp_port = dr.director_udp_port;
    // dami.version = DirectoryAnswerMultipleIdentities.V3;//dr.version;

    if ((dr == null) || (dr.req_instances == null)) {
      if (_DEBUG) System.out.println("DS: getDA_Only: enter null dr=" + dr);
      // may support old versions of requests not having terms.
      addInstanceData(dami, null, de);
    }

    if ((dr != null) && (dr.req_instances != null)) {
      for (DirectoryRequestPerInstance i : dr.req_instances) {
        if (DEBUG) System.out.println("DS: getDA_Only: analyzing query: " + i);
        if (i.instance == null) {
          addInstanceData(dami, i.instance_terms, de);
          continue;
        }

        if (DEBUG) System.out.println("DS: getDA_Only: non NULL instance \"" + i.instance + "\"");
        if (!de.instances.containsKey(i.instance)) {
          if (DEBUG) System.out.println("DS: getDA_Only: unknown instance \"" + i.instance + "\"");
          continue;
        }

        D_DirectoryEntry de_crt = de.instances.get(i.instance);
        addInstanceData(dami, i.instance_terms, de_crt);
        /*
        DirectoryAnswerInstance e = new DirectoryAnswerInstance();
        e.instance = de_crt.instance;
        //e.branch = de_crt.;
        //de_crt
        dami.known |= de_crt.known;
        e.signature_peer = de_crt.signature;
        dami.date_most_recent_among_instances = e.date_last_contact = de_crt.timestamp;
        if (de_crt.addresses != null) {
        	if (DEBUG) System.out.println("DS: getDA_Only: got addresses #"+de_crt.addresses.length);
        	for (int k=0; k < de_crt.addresses.length; k++) {
        		if (DEBUG) System.out.println("DS: getDA_Only: adding address \""+k+"="+de_crt.addresses[k]+"\"");
        		e.addresses.add(de_crt.addresses[k]);
        		if (e.branch == null)
        			e.branch = de_crt.addresses[k].branch;
        		if (e.agent_version == null)
        			e.agent_version = de_crt.addresses[k].getAgentVersionInts();
        		// here one can delete them from addresses and reset them later

        	}
        } else {
        	if (DEBUG) System.out.println("DS: getDA_Only: no addresses in de");
        }
        if (dami.remote_GIDhash == null) dami.remote_GIDhash = de_crt.globalIDhash;
        if (dami.remote_GIDhash == null) dami.remote_GIDhash = D_Peer.getGIDHashFromGID(de_crt.globalID);
        e.date_last_contact = de_crt.timestamp;
        dami.instances.add(e);
        if (DEBUG) System.out.println("DS: getDA_Only: added instance: "+e+" from "+de_crt+" of "+de);
        */
      }
    }
    if (dami.remote_GIDhash == null) dami.remote_GIDhash = dr.globalIDhash;
    if (dami.remote_GIDhash == null) dami.remote_GIDhash = D_Peer.getGIDHashFromGID(dr.globalID);
    return dami;
  }