[PATCH] Bug 9076 - Whois using a non working host for queries by default
Vito Mulè
mule.vito at gmail.com
Mon Jul 4 18:25:00 UTC 2016
Disregard my previous patch, this should work better.
I added some logic to use $domain.whois-servers.net as server based on the
query's domain.
Signed-off-by: vmule <mulevito at gmail.com>
diff --git a/networking/whois.c b/networking/whois.c
index bf33033..9a73bbc 100644
--- a/networking/whois.c
+++ b/networking/whois.c
@@ -47,13 +47,32 @@ static void pipe_out(int fd)
int whois_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int whois_main(int argc UNUSED_PARAM, char **argv)
{
+
+ char *host = malloc(67 * sizeof(char));
+ char domain[49];
+ char* token;
+
int port = 43;
- const char *host = "whois-servers.net";
+ const char *unqualified_host = ".whois-servers.net";
opt_complementary = "-1:p+";
getopt32(argv, "h:p:", &host, &port);
-
argv += optind;
+
+ if (strlen(host) < 1) {
+ size_t query_len = strlen(*argv);
+ char *str_token = malloc(query_len * sizeof(char));
+ strncpy(str_token, *argv, query_len);
+
+ token = strtok(str_token, ".");
+ while (token != NULL) {
+ strcpy(domain, token);
+ token = strtok(NULL, ".");
+ }
+ strncpy(host, domain, strlen(domain));
+ strncat(host, unqualified_host, 18);
+ }
+
do {
int fd = create_and_connect_stream_or_die(host, port);
fdprintf(fd, "%s\r\n", *argv);
On 4 July 2016 at 17:24, Vito Mulè <mule.vito at gmail.com> wrote:
> Patch attached in the bug:
> https://bugs.busybox.net/show_bug.cgi?id=9076
>
> Signed-off-by: vmule <mulevito at gmail.com>
>
> diff --git a/networking/whois.c b/networking/whois.c
> index bf33033..5a3dc51 100644
> --- a/networking/whois.c
> +++ b/networking/whois.c
> @@ -48,7 +48,7 @@ int whois_main(int argc, char **argv)
> MAIN_EXTERNALLY_VISIBLE;
> int whois_main(int argc UNUSED_PARAM, char **argv)
> {
> int port = 43;
> - const char *host = "whois-servers.net";
> + const char *host = "whois.nic.it.";
>
> opt_complementary = "-1:p+";
> getopt32(argv, "h:p:", &host, &port);
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20160704/fb2d135e/attachment.html>
More information about the busybox
mailing list