Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: Allow plugins to skip nslookup #458

Open
fdcastel opened this issue Sep 28, 2023 · 2 comments
Open

Proposal: Allow plugins to skip nslookup #458

fdcastel opened this issue Sep 28, 2023 · 2 comments

Comments

@fdcastel
Copy link
Contributor

fdcastel commented Sep 28, 2023

When implementing #454 I found another problem which I left to solve later.

It is related to this code in cache.c:

/* XXX: Possibly move this exception to each plugin */
const char *except[] = {
	"[email protected]",
	"[email protected]"
};
const char *name = info->system->name;
size_t i, j;
int nonslookup = 0;

/* Exceptions -- no name to lookup */
for (i = 0; i < NELEMS(except); i++) {
	if (!strncmp(name, except[i], strlen(name))) {
		nonslookup = 1;
		break;
	}
}

              // XXX: TODO better plugin identifiction here
for (j = 0; j < info->alias_count; j++)
	read_one(&info->alias[j], name, nonslookup);

My current implementation for Cloudflare round-robin suffers from this problem, too. When passing a cloudflare ID this code tries to nslookup it giving the error:

Failed resolving hostname MY_CLOUDFLARE_ID: Temporary failure in name resolution

and always forcing the update.

It is a small problem, it won't stop the update, but I would like to fix it anyways.

To the best of my understanding there are currently 2 workarounds in the code for this:

  1. the above code, already cited; and
  2. inside the read_one() function (a special handling for all.dnsomatic.com):
    /* Exception for dnsomatic's special global hostname */
    if (nonslookup || !strncmp(alias->name, "all.dnsomatic.com", sizeof(alias->name)))
        return;
    
    /* Try a DNS lookup of our last known IP#. */
    nslookup(alias);

My first question would be:

I'm missing something or this special handling for all.dnsomatic.com is totally unneeded? Couldn't it just be added to this array?

@fdcastel
Copy link
Contributor Author

fdcastel commented Sep 28, 2023

Second: What about to add an optional function pointer in ddns_system_t:

const int    *skip_nslookup;

which would

  1. receive the hostname as an input argument; and
  2. return a boolean telling if the nslookup should be skipped.

Of course, if the function pointer is null the default would be false.

This would allow us to remove the special handling and also to solve my problem with Cloudflare round-robin entries.

All that said, I understand this is a very specific hook for a very specific situation being added to an entire plugin system. This is just my first idea. Any other suggestions to solve this problem are welcome.

@troglobit
Copy link
Owner

You're right, this looks like a mess currently. I'm not so sure about the collapsing all.dnsomatic.com into that array though. The first is per provider and the latter is an exception for when a user selects updating all their dns entries for the given provider. (But then again, I'm still a bit off due to this flu I'm dragging along, and I've just woken up :)

Anyway, I think your proposal is a good one. The code needs a bit of refactoring, so please go ahead!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants