diff -pru dillo-cli/src/dillo.c dillo-local/src/dillo.c --- dillo-cli/src/dillo.c Tue Aug 6 18:18:38 2002 +++ dillo-local/src/dillo.c Tue Aug 6 18:23:16 2002 @@ -50,15 +50,17 @@ #define DILLO_CLI_HELP_MESSAGE \ "\nUsage: dillo [OPTIONS] [URL|FILE]...\n" \ "Options:\n" \ + " -l allow only local host browsing.\n" \ " -h display this help message and exit.\n" \ " -v display version info and exit.\n" \ " URL URL to browse.\n" \ " FILE local FILE to view.\n" -#define DILLO_CLI_OPTIONS "hv" +#define DILLO_CLI_OPTIONS "hvl" #define DILLO_CLI_HELP 1 << 0 #define DILLO_CLI_VERSION 1 << 1 +#define DILLO_CLI_LOCAL 1 << 2 /* * Forward declarations @@ -98,6 +100,9 @@ gint main(int argc, char *argv[]) Dillo_print_version(); return 0; break; + case 'l': + cli_option |= DILLO_CLI_LOCAL; + break; default: printf("Unknown option.\n"); Dillo_print_help(); @@ -114,7 +119,7 @@ gint main(int argc, char *argv[]) g_free(file); a_Prefs_init(); - a_Dns_init(); + a_Dns_init(cli_option & DILLO_CLI_LOCAL); a_Http_init(); a_Mime_init(); a_Cache_init(); diff -pru dillo-cli/src/dns.c dillo-local/src/dns.c --- dillo-cli/src/dns.c Tue Aug 6 18:03:56 2002 +++ dillo-local/src/dns.c Tue Aug 6 18:19:48 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 -pru dillo-cli/src/dns.h dillo-local/src/dns.h --- dillo-cli/src/dns.h Tue Aug 6 18:03:56 2002 +++ dillo-local/src/dns.h Tue Aug 6 18:19:48 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);