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

Return unresolved hosts list in gvm_hosts_resolve(). #211

Merged
merged 2 commits into from
Apr 8, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions base/hosts.c
Original file line number Diff line number Diff line change
Expand Up @@ -1329,11 +1329,14 @@ gvm_hosts_reverse (gvm_hosts_t *hosts)
* iterator.
*
* @param[in] hosts The hosts collection from which to exclude.
*
* @return List of unresolved hostnames.
*/
void
GSList *
gvm_hosts_resolve (gvm_hosts_t *hosts)
{
size_t i, new_entries = 0;
GSList *unresolved = NULL;

for (i = 0; i < hosts->count; i++)
{
Expand Down Expand Up @@ -1372,19 +1375,20 @@ gvm_hosts_resolve (gvm_hosts_t *hosts)
}
/* Remove hostname from list, as it was either replaced by IPs, or
* is unresolvable. */
gvm_host_free (host);
hosts->hosts[i] = NULL;
hosts->count--;
hosts->removed++;
if (!list)
g_warning ("Couldn't resolve hostname %s", host->name);
unresolved = g_slist_prepend (unresolved, g_strdup (host->name));
else
gvm_hosts_fill_gaps (hosts);
gvm_host_free (host);
g_slist_free_full (list, g_free);
}
if (new_entries)
gvm_hosts_deduplicate (hosts);
hosts->current = 0;
return unresolved;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion base/hosts.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ gvm_hosts_shuffle (gvm_hosts_t *);
void
gvm_hosts_reverse (gvm_hosts_t *);

void
GSList *
gvm_hosts_resolve (gvm_hosts_t *);

int
Expand Down