diff -pur dillo/src/dillo.c dillo-local/src/dillo.c --- dillo/src/dillo.c Wed Aug 14 11:36:10 2002 +++ dillo-local/src/dillo.c Wed Aug 14 11:41:30 2002 @@ -61,6 +61,7 @@ typedef struct { } DilloCLIOptions; enum { + DILLO_CLI_LOCAL = 1 << 0, DILLO_CLI_HELP = 1 << 29, DILLO_CLI_VERSION = 1 << 30, DILLO_CLI_ERROR = 1 << 31 @@ -90,6 +91,8 @@ gint main(int argc, char *argv[]) gint i; char **opt_argv = NULL; DilloCLIOptions dillo_options[] = { + {"-l", "--localonly", 0, DILLO_CLI_LOCAL, + " -l, --localonly Allow only local host browsing."}, {"-v", "--version", 0, DILLO_CLI_VERSION, " -v, --version Display version info and exit."}, {"-h", "--help", 0, DILLO_CLI_HELP, @@ -122,6 +125,8 @@ gint main(int argc, char *argv[]) Dillo_print_help(dillo_options); return 0; break; + case DILLO_CLI_LOCAL: + break; default: printf("Error in command line options.\n"); return -1; @@ -141,7 +146,7 @@ gint main(int argc, char *argv[]) g_free(file); a_Prefs_init(); - a_Dns_init(); + a_Dns_init(cli_options & DILLO_CLI_LOCAL); a_Http_init(); a_Mime_init(); a_Cache_init(); diff -pur dillo/src/dns.c dillo-local/src/dns.c --- dillo/src/dns.c Tue Aug 6 18:03:56 2002 +++ dillo-local/src/dns.c Wed Aug 14 11:37:06 2002 @@ -85,6 +85,7 @@ static gint Dns_timeout_client(gpointer /* * Local Data */ +static gboolean dns_block_non_local; static DnsServer dns_server[G_DNS_MAX_SERVERS]; static gint num_servers; static GDnsCache *dns_cache; @@ -184,11 +185,13 @@ static void Dns_cache_add(char *hostname /* * Initializer function */ -void a_Dns_init(void) +void a_Dns_init(gboolean block_non_local) { gint i; DEBUG_MSG(5, "dillo_dns_init: Here we go!\n"); + dns_block_non_local = block_non_local; + dns_queue_size = 0; dns_queue_size_max = 16; dns_queue = g_new(GDnsQueue, dns_queue_size_max); @@ -247,6 +250,8 @@ static void *Dns_server(void *data) } else { memcpy(&ip_addr, host->h_addr_list[0], sizeof(ip_addr)); ip_addr = ntohl(ip_addr); + if (dns_block_non_local && (ip_addr & 0xff000000) != 0x7f000000) + ip_addr = 0; } /* write hostname to client */ diff -pur dillo/src/dns.h dillo-local/src/dns.h --- dillo/src/dns.h Tue Aug 6 18:03:56 2002 +++ dillo-local/src/dns.h Wed Aug 14 11:37:06 2002 @@ -8,7 +8,7 @@ extern "C" { #endif /* __cplusplus */ -void a_Dns_init (void); +void a_Dns_init (gboolean block_non_local); void a_Dns_freeall(void); void a_Dns_ccc(int Op, int Br, ChainLink *Info, void *Data, void *ExtraData);