Skip to content

Commit

Permalink
[Server] Add xrdnetwork dyndns option for dynamic DNS handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
abh3 committed Jun 21, 2019
1 parent aaba3dc commit a3747a6
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Xrd/XrdConfig.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1252,7 +1252,7 @@ int XrdConfig::xbuf(XrdSysError *eDest, XrdOucStream &Config)
Purpose: To parse directive: network [wan] [[no]keepalive] [buffsz <blen>]
[kaparms parms] [cache <ct>] [[no]dnr]
[routes <rtype> [use <ifn1>,<ifn2>]]
[[no]rpipa]
[[no]rpipa] [[no]dyndns]
<rtype>: split | common | local
Expand All @@ -1264,6 +1264,7 @@ int XrdConfig::xbuf(XrdSysError *eDest, XrdOucStream &Config)
[no]dnr do [not] perform a reverse DNS lookup if not needed.
routes specifies the network configuration (see reference)
[no]rpipa do [not] resolve private IP addresses.
[no]dyndns This network does [not] use a dynamic DNS.
Output: 0 upon success or !0 upon failure.
*/
Expand All @@ -1272,7 +1273,7 @@ int XrdConfig::xnet(XrdSysError *eDest, XrdOucStream &Config)
{
char *val;
int i, n, V_keep = -1, V_nodnr = 0, V_iswan = 0, V_blen = -1, V_ct = -1, V_assumev4;
int v_rpip = -1;
int v_rpip = -1, V_dyndns = -1;
long long llp;
struct netopts {const char *opname; int hasarg; int opval;
int *oploc; const char *etxt;}
Expand All @@ -1286,6 +1287,8 @@ int XrdConfig::xnet(XrdSysError *eDest, XrdOucStream &Config)
{"cache", 2, 0, &V_ct, "cache time"},
{"dnr", 0, 0, &V_nodnr, "option"},
{"nodnr", 0, 1, &V_nodnr, "option"},
{"dyndns", 0, 1, &V_dyndns, "option"},
{"nodyndns", 0, 0, &V_dyndns, "option"},
{"routes", 3, 1, 0, "routes"},
{"rpipa", 0, 1, &v_rpip, "rpipa"},
{"norpipa", 0, 0, &v_rpip, "norpipa"},
Expand Down Expand Up @@ -1360,6 +1363,7 @@ int XrdConfig::xnet(XrdSysError *eDest, XrdOucStream &Config)
}

if (V_ct >= 0) XrdNetAddr::SetCache(V_ct);
if (V_dyndns >= 0) XrdNetAddr::SetDynDNS(V_dyndns != 0);
if (v_rpip >= 0) XrdInet::netIF.SetRPIPA(v_rpip != 0);
if (V_assumev4 >= 0) XrdInet::SetAssumeV4(true);
return 0;
Expand Down
9 changes: 9 additions & 0 deletions src/XrdNet/XrdNetAddr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ struct addrinfo *XrdNetAddr::huntHintsUDP = XrdNetAddr::Hints(2, SOCK_DGRAM);
// The following must be initialzed after all of the hint structures!
//
bool XrdNetAddr::useIPV4 = OnlyIPV4();
bool XrdNetAddr::dynDNS = false;

/******************************************************************************/
/* C o n s t r u c t o r */
Expand Down Expand Up @@ -267,6 +268,8 @@ const char *XrdNetAddr::Set(const char *hSpec, int pNum)
n = getaddrinfo(iP, 0, hostHints, &rP);
if (n || !rP)
{if (rP) freeaddrinfo(rP);
if (n == EAI_NONAME && dynDNS)
return "Dynamic name or service not yet registered";
return (n ? gai_strerror(n) : "host not found");
}
memcpy(&IP.Addr, rP->ai_addr, rP->ai_addrlen);
Expand Down Expand Up @@ -477,6 +480,12 @@ void XrdNetAddr::SetCache(int keeptime)
dnsCache = (keeptime > 0 ? &theCache : 0);
}

/******************************************************************************/
/* S e t D y n D N S */
/******************************************************************************/

void XrdNetAddr::SetDynDNS(bool onoff) {dynDNS = onoff;}

/******************************************************************************/
/* S e t I P V 4 */
/******************************************************************************/
Expand Down
19 changes: 19 additions & 0 deletions src/XrdNet/XrdNetAddr.hh
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ class XrdNetAddr : public XrdNetAddrInfo
{
public:

//------------------------------------------------------------------------------
//! Determine if dynamic DNS has been set.
//!
//! @return True Dynamic DNS has been set.
//! False Dynamic DNS has not been set.
//------------------------------------------------------------------------------

static bool DynDNS() {return dynDNS;}

//------------------------------------------------------------------------------
//! Determine if IPV4 mode has been set.
//!
Expand Down Expand Up @@ -174,6 +183,15 @@ const char *Set(struct addrinfo *rP, int port, bool mapit=false);

static void SetCache(int keeptime);

//------------------------------------------------------------------------------
//! Indicate whether or not dynamic DNS is being used. This method should only
//! be called during initialization time. The default is fixed DNS.
//!
//! @param onoff True if dynamic DNS is being used, false otherwise.
//------------------------------------------------------------------------------

static void SetDynDNS(bool onoff);

//------------------------------------------------------------------------------
//! Force this object to work in IPV4 mode only. This method permanently sets
//! IPV4 mode which cannot be undone without a restart. It is meant to bypass
Expand Down Expand Up @@ -243,5 +261,6 @@ static struct addrinfo *hostHints;
static struct addrinfo *huntHintsTCP;
static struct addrinfo *huntHintsUDP;
static bool useIPV4;
static bool dynDNS;
};
#endif

0 comments on commit a3747a6

Please sign in to comment.