} catch (IOException e) {
throw new MessageInvalidException(ProtocolErrorMessage.REF_PARSE_ERROR, "Error parsing ref from file <"+fileString+">: "+e.getMessage(), identifier, false);
}
}
fs.setEndMarker( "End" );
PeerNode pn;
boolean isOpennetRef = fs.getBoolean("opennet", false);
if(isOpennetRef) {
try {
pn = node.createNewOpennetNode(fs);
} catch (FSParseException e) {
throw new MessageInvalidException(ProtocolErrorMessage.REF_PARSE_ERROR, "Error parsing ref: "+e.getMessage(), identifier, false);
} catch (OpennetDisabledException e) {
throw new MessageInvalidException(ProtocolErrorMessage.OPENNET_DISABLED, "Error adding ref: "+e.getMessage(), identifier, false);
} catch (PeerParseException e) {
throw new MessageInvalidException(ProtocolErrorMessage.REF_PARSE_ERROR, "Error parsing ref: "+e.getMessage(), identifier, false);
} catch (ReferenceSignatureVerificationException e) {
throw new MessageInvalidException(ProtocolErrorMessage.REF_SIGNATURE_INVALID, "Error adding ref: "+e.getMessage(), identifier, false);
}
if(Arrays.equals(pn.getPubKeyHash(), node.getOpennetPubKeyHash()))
throw new MessageInvalidException(ProtocolErrorMessage.CANNOT_PEER_WITH_SELF, "Node cannot peer with itself", identifier, false);
if(!node.addPeerConnection(pn)) {
throw new MessageInvalidException(ProtocolErrorMessage.DUPLICATE_PEER_REF, "Node already has a peer with that identity", identifier, false);
}
System.out.println("Added opennet peer: "+pn);
} else {
try {
pn = node.createNewDarknetNode(fs, trust, visibility);
} catch (FSParseException e) {
throw new MessageInvalidException(ProtocolErrorMessage.REF_PARSE_ERROR, "Error parsing ref: "+e.getMessage(), identifier, false);
} catch (PeerParseException e) {
throw new MessageInvalidException(ProtocolErrorMessage.REF_PARSE_ERROR, "Error parsing ref: "+e.getMessage(), identifier, false);
} catch (ReferenceSignatureVerificationException e) {
throw new MessageInvalidException(ProtocolErrorMessage.REF_SIGNATURE_INVALID, "Error adding ref: "+e.getMessage(), identifier, false);
}
if(Arrays.equals(pn.getPubKeyHash(), node.getDarknetPubKeyHash()))
throw new MessageInvalidException(ProtocolErrorMessage.CANNOT_PEER_WITH_SELF, "Node cannot peer with itself", identifier, false);
if(!node.addPeerConnection(pn)) {
throw new MessageInvalidException(ProtocolErrorMessage.DUPLICATE_PEER_REF, "Node already has a peer with that identity", identifier, false);
}
System.out.println("Added darknet peer: "+pn);