source: npl/internetserver/djbdns/patches/0004-tinydns-data-SRV-axfr-get-SRV-PTR-patches.patch @ 37aaf89

Last change on this file since 37aaf89 was 37aaf89, checked in by Edwin Eefting <edwin@datux.nl>, 3 years ago

djbdns patches, so it works correctly with twitter etc

  • Property mode set to 100644
File size: 4.4 KB
  • axfr-get.c

    Description: tinydns-data SRV & axfr-get SRV/PTR patches
     Here's a combined patch that:
     .
     a) adds a native SRV type to tinydns-data
     .
     Sfqdn:ip:x:port:weight:priority:ttl:timestamp
     .
     Standard rules for ip, x, ttl, and timestamp apply. Port, weight, and
     priority all range from 0-65535. Weight and priority are optional; they
     default to zero if not provided.
     .
     Sconsole.zoinks.example.com:1.2.3.4:rack102-con1:2001:69:7:300:
     .
     b) makes axfr-get decompose SRV and PTR records and write them out in
     native format, rather than opaque. Again, this is necessary because if the
     DNAME fields in the records reference the same zone as fqdn, they can have
     compression pointers that are bogus outside the context of that specific
     packet, and which can't be correctly loaded into data.cdb by tinydns-data.
     .
     --michael
     .
     Laurent G. Bercot <ska-djbdns@skarnet.org> updated it for
     djbdns-1.05. Documentation patch by Alex Efros.
    Author: Michael Handler <handler@sub-rosa.com>
    Date: Thu, 14 Sep 2000 20:37:50 -0400
    Last-Update: 2020-07-26
    
    diff --git a/axfr-get.c b/axfr-get.c
    index 75db627..a5d5c0c 100644
    a b unsigned int doit(char *buf,unsigned int len,unsigned int pos) 
    209209    if (!stralloc_cats(&line,".:")) return 0;
    210210    if (!stralloc_catulong0(&line,dist,0)) return 0;
    211211  }
     212  else if (byte_equal(data,2,DNS_T_SRV)) {
     213    uint16 dist, weight, port;
     214    if (!stralloc_copys(&line,"S")) return 0;
     215    if (!dns_domain_todot_cat(&line,d1)) return 0;
     216    if (!stralloc_cats(&line,"::")) return 0;
     217    pos = x_copy(buf,len,pos,data,2);
     218    uint16_unpack_big(data,&dist);
     219    pos = x_copy(buf,len,pos,data,2);
     220    uint16_unpack_big(data,&weight);
     221    pos = x_copy(buf,len,pos,data,2);
     222    uint16_unpack_big(data,&port);
     223    x_getname(buf,len,pos,&d1);
     224    if (!dns_domain_todot_cat(&line,d1)) return 0;
     225    if (!stralloc_cats(&line,".:")) return 0;
     226    if (!stralloc_catulong0(&line,dist,0)) return 0;
     227    if (!stralloc_cats(&line,":")) return 0;
     228    if (!stralloc_catulong0(&line,weight,0)) return 0;
     229    if (!stralloc_cats(&line,":")) return 0;
     230    if (!stralloc_catulong0(&line,port,0)) return 0;
     231  }
    212232  else if (byte_equal(data,2,DNS_T_A) && (dlen == 4)) {
    213233    char ipstr[IP4_FMT];
    214234    if (!stralloc_copys(&line,"+")) return 0;
    unsigned int doit(char *buf,unsigned int len,unsigned int pos) 
    217237    x_copy(buf,len,pos,data,4);
    218238    if (!stralloc_catb(&line,ipstr,ip4_fmt(ipstr,data))) return 0;
    219239  }
     240  else if (byte_equal(data,2,DNS_T_PTR)) {
     241    if (!stralloc_copys(&line,"^")) return 0;
     242    if (!dns_domain_todot_cat(&line,d1)) return 0;
     243    if (!stralloc_cats(&line,":")) return 0;
     244    x_getname(buf,len,pos,&d1);
     245    if (!dns_domain_todot_cat(&line,d1)) return 0;
     246    if (!stralloc_cats(&line,".")) return 0;
     247  }
    220248  else {
    221249    unsigned char ch;
    222250    unsigned char ch2;
  • dns.h

    diff --git a/dns.h b/dns.h
    index 2f899ef..3849f4c 100644
    a b  
    2020#define DNS_T_SIG "\0\30"
    2121#define DNS_T_KEY "\0\31"
    2222#define DNS_T_AAAA "\0\34"
     23#define DNS_T_SRV "\0\41"
    2324#define DNS_T_AXFR "\0\374"
    2425#define DNS_T_ANY "\0\377"
    2526
  • tinydns-data.c

    diff --git a/tinydns-data.c b/tinydns-data.c
    index ba82f84..0137f09 100644
    a b int main() 
    196196  char type[2];
    197197  char soa[20];
    198198  char buf[4];
     199  char srv[6];
    199200
    200201  umask(022);
    201202
    int main() 
    369370          rr_finish(d2);
    370371        }
    371372        break;
     373       
     374      case 'S':
     375        if (!dns_domain_fromdot(&d1,f[0].s,f[0].len)) nomem();
     376        if (!stralloc_0(&f[6])) nomem();
     377        if (!scan_ulong(f[6].s,&ttl)) ttl = TTL_POSITIVE;
     378        ttdparse(&f[7],ttd);
     379        locparse(&f[8],loc);
     380
     381        if (!stralloc_0(&f[1])) nomem();
     382
     383        if (byte_chr(f[2].s,f[2].len,'.') >= f[2].len) {
     384          if (!stralloc_cats(&f[2],".srv.")) nomem();
     385          if (!stralloc_catb(&f[2],f[0].s,f[0].len)) nomem();
     386        }
     387        if (!dns_domain_fromdot(&d2,f[2].s,f[2].len)) nomem();
     388
     389        if (!stralloc_0(&f[4])) nomem();
     390        if (!scan_ulong(f[4].s,&u)) u = 0;
     391        uint16_pack_big(srv,u);
     392        if (!stralloc_0(&f[5])) nomem();
     393        if (!scan_ulong(f[5].s,&u)) u = 0;
     394        uint16_pack_big(srv + 2,u);
     395        if (!stralloc_0(&f[3])) nomem();
     396        if (!scan_ulong(f[3].s,&u)) nomem();
     397        uint16_pack_big(srv + 4,u);
     398
     399        rr_start(DNS_T_SRV,ttl,ttd,loc);
     400        rr_add(srv,6);
     401        rr_addname(d2);
     402        rr_finish(d1);
     403
     404        if (ip4_scan(f[1].s,ip)) {
     405          rr_start(DNS_T_A,ttl,ttd,loc);
     406          rr_add(ip,4);
     407          rr_finish(d2);
     408        }
     409        break;
    372410
    373411      case '^': case 'C':
    374412        if (!dns_domain_fromdot(&d1,f[0].s,f[0].len)) nomem();
Note: See TracBrowser for help on using the repository browser.