From b77924b368731f146b79c8ea15ca73c90ae48aa1 Mon Sep 17 00:00:00 2001 From: Gioacchino Mazzurco Date: Tue, 1 Oct 2019 17:43:52 +0200 Subject: [PATCH] Fix setting port when adding from short invite with dyndns --- libretroshare/src/pqi/p3peermgr.cc | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/libretroshare/src/pqi/p3peermgr.cc b/libretroshare/src/pqi/p3peermgr.cc index 1adf191d1..62b64e090 100644 --- a/libretroshare/src/pqi/p3peermgr.cc +++ b/libretroshare/src/pqi/p3peermgr.cc @@ -1111,7 +1111,18 @@ bool p3PeerMgrIMPL::addSslOnlyFriend( const RsPeerId& sslId, const RsPgpId& pgp_ pstate.id = sslId; if(!dt.name.empty()) pstate.name = dt.name; - if(!dt.dyndns.empty()) pstate.dyndns = dt.dyndns; + if(!dt.dyndns.empty()) + { + pstate.dyndns = dt.dyndns; + if(dt.extPort) + { + /* If there is no IPv4 address available yet add a placeholder to + * not loose the port, because the address is invalid. */ + if(!sockaddr_storage_isValidNet(pstate.serveraddr)) + sockaddr_storage_inet_pton(pstate.serveraddr, "192.0.2.0"); + sockaddr_storage_setport(pstate.serveraddr, dt.extPort); + } + } pstate.hiddenNode = dt.isHiddenNode; if(!dt.hiddenNodeAddress.empty()) pstate.hiddenDomain = dt.hiddenNodeAddress;