lib/util/handshake.js
function handshake_collect(mesh, id, handshake, pipe, message)
{
  handshake = handshake_bootstrap(handshake);
  if (!handshake)
    return false;

  var valid = handshake_validate(id,handshake, message, mesh);
  if (!valid)
    return false;

  // get all from cache w/ matching at, by type
  var types = handshake_types(handshake, id);

  // bail unless we have a link
  if(!types.link)
  {
    log.debug('handshakes w/ no link yet',id,types);
    return false;
  }

  // build a from json container
  var from = handshake_from(handshake, pipe, types.link)

  // if we already linked this hashname, just update w/ the new info
  if(mesh.index[from.hashname])
  {
    log.debug('refresh link handshake')
    from.sync = false; // tell .link to not auto-sync!
    return mesh.link(from);
  } else {
    
  }

  log.debug('untrusted hashname',from);
  from.received = {packet:types.link._message, pipe:pipe} // optimization hints as link args
  from.handshake = types; // include all handshakes
  if(mesh.accept)
    mesh.accept(from);
  return false;
}
function handshake_collect(mesh, id, handshake, pipe, message)
{
  handshake = handshake_bootstrap(handshake);
  if (!handshake)
    return false;

  var valid = handshake_validate(id,handshake, message, mesh);
  if (!valid)
    return false;

  // get all from cache w/ matching at, by type
  var types = handshake_types(handshake, id);

  // bail unless we have a link
  if(!types.link)
  {
    log.debug('handshakes w/ no link yet',id,types);
    return false;
  }

  // build a from json container
  var from = handshake_from(handshake, pipe, types.link)

  // if we already linked this hashname, just update w/ the new info
  if(mesh.index[from.hashname])
  {
    log.debug('refresh link handshake')
    from.sync = false; // tell .link to not auto-sync!
    return mesh.link(from);
  } else {
    
  }

  log.debug('untrusted hashname',from);
  from.received = {packet:types.link._message, pipe:pipe} // optimization hints as link args
  from.handshake = types; // include all handshakes
  if(mesh.accept)
    mesh.accept(from);
  return false;
}
function handshake_collect ( mesh , id , handshake , pipe , message ) { handshake = handshake_bootstrap ( handshake ) ; if ( ! handshake ) return false ; var valid = handshake_validate ( id , handshake , message , mesh ) ; if ( ! valid ) return false ; // get all from cache w/ matching at, by type var types = handshake_types ( handshake , id ) ; // bail unless we have a link if ( ! types . link ) { log . debug ( 'handshakes w/ no link yet' , id , types ) ; return false ; } // build a from json container var from = handshake_from ( handshake , pipe , types . link ) // if we already linked this hashname, just update w/ the new info if ( mesh . index [ from . hashname ] ) { log . debug ( 'refresh link handshake' ) from . sync = false ; // tell .link to not auto-sync! return mesh . link ( from ) ; } else { } log . debug ( 'untrusted hashname' , from ) ; from . received = { packet : types . link . _message , pipe : pipe } // optimization hints as link args from . handshake = types ; // include all handshakes if ( mesh . accept ) mesh . accept ( from ) ; return false ; }
collect incoming handshakes to accept them
@param {object} id
@param {handshake} handshake
@param {pipe} pipe
@param {Buffer} message
collect incoming handshakes to accept them