Menu

#1 patch to make better offline behaviour

open
nobody
None
5
2001-11-01
2001-11-01
No

The following patch makes dproxy-ng send error
replies to all lookup when a PPP connection is not
active (and the detect PPP option is set; otherwise
patch has no effect to behavior).

Previous behavior would return any cached entries,
causing apps to believe they were online, which would
mean they would attempt a connect() and then break
after a long timeout.

The disadvantage to this patch is that if you are
using dproxy as a server by placing names in
/etc/hosts, it will return error responses for local
lookups which could be served, if offline.

Here is the patch for dproxy.c, the only file I
modified.

*** dproxy-nexgen/dproxy.c Mon Mar 20 00:50:50 2000
--- dproxy-nexgen.mcm/dproxy.c Thu Nov 1 11:40:58
2001
***************
*** 82,87 ****
--- 82,95 ----
struct in_addr in;
int retval = -1;

+ /* If not connected, always return not found */
+ if(!is_connected()) {
+ debug("Not connected **\n");
+ dns_construct_error_reply(m);
+ dns_write_packet( dns_sock, m->src_addr,
m->src_port, m );
+ return;
+ }
+
if( m->message.question[0].type == A ||
m->message.question[0].type == AAA){ /* standard
query */
retval = cache_lookup_name( m->cname, m->ip );
***************
*** 95,111 ****
switch( retval )
{
case 0:
- if( is_connected() ){
debug("Adding to list-> id: %d\n",
m->message.header.id);
dns_request_list = dns_list_add(
dns_request_list, m );
/* relay the query untouched */
inet_aton( config.name_server, &in );
dns_write_packet( dns_sock, in, PORT, m );
- }else{
- debug("Not connected **\n");
- dns_construct_error_reply(m);
- dns_write_packet( dns_sock, m->src_addr,
m->src_port, m );
- }
break;
case 1:
dns_construct_reply( m );
--- 103,113 ----

Discussion


Log in to post a comment.