Changeset 60dfbf


Ignore:
Timestamp:
09/20/09 23:10:39 (3 years ago)
Author:
J. A. Bezemer <J.A.Bezemer@…>
Branches:
master
Children:
d87432
Parents:
05e99c
git-author:
J. A. Bezemer <J.A.Bezemer@…> (09/20/09 23:10:39)
git-committer:
Erik Ekman <erik@…> (02/04/12 20:34:04)
Message:

merge dns and user #76

Location:
src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/dns.c

    r595116 r60dfbf  
    357357                readshort(packet, &data, &class); 
    358358                 
     359                /* if CHECKLEN okay, then we're sure to have a proper name */ 
     360                if (q != NULL) { 
     361                        /* We only need the first char to check it */ 
     362                        q->name[0] = name[0]; 
     363                        q->name[1] = '\0'; 
     364                } 
     365 
    359366                /* Assume that first answer is NULL/CNAME that we wanted */ 
    360367                readname(packet, packetlen, &data, name, sizeof(name)); 
  • src/iodined.c

    rd4d88d r60dfbf  
    377377                                users[userid].inpacket.fragment = 0; 
    378378                                users[userid].fragsize = 100; /* very safe */ 
     379                                users[userid].conn = CONN_DNS_NULL; 
    379380                        } else { 
    380381                                /* No space for another user */ 
  • src/user.c

    rb6eb8d r60dfbf  
    7979                        created_users++; 
    8080                } 
    81                 users[i].inpacket.len = 0; 
    82                 users[i].inpacket.offset = 0; 
    83                 users[i].outpacket.len = 0; 
    84                 users[i].q.id = 0; 
    85                 users[i].out_acked_seqno = 0; 
    86                 users[i].out_acked_fragment = 0; 
    87                 users[i].fragsize = 4096; 
    88                 users[i].conn = CONN_DNS_NULL; 
     81                users[i].active = 0; 
     82                /* Rest is reset on login ('V' packet) */ 
    8983        } 
    9084 
     
    130124int 
    131125all_users_waiting_to_send() 
     126/* If this returns true, then reading from tun device is blocked. 
     127   So only return true when all clients have at least one packet in 
     128   the outpacket-queue, so that sending back-to-back is possible 
     129   without going through another select loop. 
     130*/ 
    132131{ 
    133132        time_t now; 
     
    140139                if (users[i].active && !users[i].disabled && 
    141140                        users[i].last_pkt + 60 > now && 
    142                         ((users[i].outpacket.len == 0 && users[i].conn == CONN_DNS_NULL)  
    143                                 || users[i].conn == CONN_RAW_UDP)) { 
     141                        ((users[i].conn == CONN_RAW_UDP) ||  
     142                        ((users[i].conn == CONN_DNS_NULL)  
     143#ifdef OUTPACKETQ_LEN 
     144                                && users[i].outpacketq_filled < 1 
     145#else 
     146                                && users[i].outpacket.len == 0 
     147#endif 
     148                        ))) { 
    144149 
    145150                        ret = 0; 
  • src/user.h

    rc2bc50 r60dfbf  
    2020#define USERS 16 
    2121 
     22#define OUTPACKETQ_LEN 4                /* Note: 16 users * 1 packet = 1MB */ 
     23/* Undefine to have no queue for packets coming in from tun device, which may 
     24   lead to massive dropping in multi-user situations with high traffic. */ 
     25 
     26#define DNSCACHE_LEN 4 
     27/* Undefine to disable. MUST be less than 7; also see comments in iodined.c */ 
     28 
    2229struct user { 
    2330        char id; 
     
    2936        struct in_addr host; 
    3037        struct query q; 
     38        struct query q_prev; 
     39        struct query q_sendrealsoon; 
     40        int q_sendrealsoon_new; 
    3141        struct packet inpacket; 
    3242        struct packet outpacket; 
     43        int outfragresent; 
    3344        struct encoder *encoder; 
    3445        char downenc; 
     
    3748        int fragsize; 
    3849        enum connection conn; 
     50        int lazy; 
     51#ifdef OUTPACKETQ_LEN 
     52        struct packet outpacketq[OUTPACKETQ_LEN]; 
     53        int outpacketq_nexttouse; 
     54        int outpacketq_filled; 
     55#endif 
     56#ifdef DNSCACHE_LEN 
     57        struct query dnscache_q[DNSCACHE_LEN]; 
     58        char dnscache_answer[DNSCACHE_LEN][4096]; 
     59        int dnscache_answerlen[DNSCACHE_LEN]; 
     60        int dnscache_lastfilled; 
     61#endif 
    3962}; 
    4063 
Note: See TracChangeset for help on using the changeset viewer.