[Gd-chatter] r11074 - trunk/libraries/network/koala/sources/examples/buddha

hannes at gwydiondylan.org hannes at gwydiondylan.org
Mon Dec 18 03:00:33 CET 2006


Author: hannes
Date: Mon Dec 18 03:00:30 2006
New Revision: 11074

Modified:
   trunk/libraries/network/koala/sources/examples/buddha/buddha.dylan
   trunk/libraries/network/koala/sources/examples/buddha/config.dylan
   trunk/libraries/network/koala/sources/examples/buddha/ipv4.dylan
   trunk/libraries/network/koala/sources/examples/buddha/zone.dylan
Log:
Bug: 7257
more v6-related fixes

Modified: trunk/libraries/network/koala/sources/examples/buddha/buddha.dylan
==============================================================================
--- trunk/libraries/network/koala/sources/examples/buddha/buddha.dylan	(original)
+++ trunk/libraries/network/koala/sources/examples/buddha/buddha.dylan	Mon Dec 18 03:00:30 2006
@@ -988,46 +988,18 @@
                                           value => get-reference(dzone))
                                   end)),
                 h2("A-records"),
-                do(if (dzone.a-records.size > 0)
+                do(if (dzone.host-records.size > 0)
                      with-xml()
-                       table { tr { th("Hostname"), th("IP"), th("TTL"), th("Remove") },
-                              do(reset-color(dzone.a-records);
+                       table { tr { th("Hostname"), th("IPv4"), th("IPv6"), th("TTL"), th("Remove") },
+                              do(reset-color(dzone.host-records);
                                  map(method(x) with-xml()
-                                                 tr(class => next-color(dzone.a-records))
+                                                 tr(class => next-color(dzone.host-records))
                                                    {
                                                     td(x.host-name),
                                                     td(show(x.ipv4-address)),
-                                                    td(show(x.time-to-live)),
-                                                    td { do(remove-form(x, dzone.a-records,
-                                                                         url: "zone-detail",
-                                                                         xml: with-xml()
-                                                                           input(type => "hidden",
-                                                                                 name => "zone",
-                                                                                 value => get-reference(dzone))
-                                                                         end)) } }
-                                               end
-                                     end, dzone.a-records)) }
-                     end
-                   end),
-                do(add-form(<a-record>, #f, dzone.a-records,
-                            refer: "zone-detail",
-                            xml: with-xml()
-                                    input(type => "hidden",
-                                          name => "zone",
-                                          value => get-reference(dzone))
-                                  end)),
-                h2("AAAA-records"),
-                do(if (dzone.aaaa-records.size > 0)
-                     with-xml()
-                       table { tr { th("Hostname"), th("IP"), th("TTL"), th("Remove") },
-                              do(reset-color(dzone.a-records);
-                                 map(method(x) with-xml()
-                                                 tr(class => next-color(dzone.aaaa-records))
-                                                   {
-                                                    td(x.host-name),
                                                     td(show(x.ipv6-address)),
                                                     td(show(x.time-to-live)),
-                                                    td { do(remove-form(x, dzone.a-records,
+                                                    td { do(remove-form(x, dzone.host-records,
                                                                          url: "zone-detail",
                                                                          xml: with-xml()
                                                                            input(type => "hidden",
@@ -1035,10 +1007,10 @@
                                                                                  value => get-reference(dzone))
                                                                          end)) } }
                                                end
-                                     end, dzone.aaaa-records)) }
+                                     end, dzone.host-records)) }
                      end
                    end),
-                do(add-form(<aaaa-record>, #f, dzone.aaaa-records,
+                do(add-form(<host-record>, #f, dzone.host-records,
                             refer: "zone-detail",
                             xml: with-xml()
                                     input(type => "hidden",

Modified: trunk/libraries/network/koala/sources/examples/buddha/config.dylan
==============================================================================
--- trunk/libraries/network/koala/sources/examples/buddha/config.dylan	(original)
+++ trunk/libraries/network/koala/sources/examples/buddha/config.dylan	Mon Dec 18 03:00:30 2006
@@ -43,7 +43,7 @@
   if (any?(method(x) x.source = tcname.source end, tzone.cnames))
     signal(make(<web-error>,
                 error: "Same A record already exists"));
-  elseif (any?(method(x) x.host-name = tcname.source end, tzone.a-records))
+  elseif (any?(method(x) x.host-name = tcname.source end, tzone.host-records))
     signal(make(<web-error>,
                 error: "Same A record already exists"));
   elseif (any?(method(x) x.host-name = tcname.source end,
@@ -55,12 +55,12 @@
   end;
 end;
 
-define method check-in-context (tzone :: <zone>, a-record :: <a-record>) 
+define method check-in-context (tzone :: <zone>, a-record :: <host-record>) 
  => (res :: <boolean>)
   if (any?(method(x) x.source = a-record.host-name end, tzone.cnames))
     signal(make(<web-error>,
                 error: "Same A record already exists"));
-  elseif (any?(method(x) x.host-name = a-record.host-name end, tzone.a-records))
+  elseif (any?(method(x) x.host-name = a-record.host-name end, tzone.host-records))
     signal(make(<web-error>,
                 error: "Same A record already exists"));
   elseif (any?(method(x) x.host-name = a-record.host-name end,
@@ -92,7 +92,7 @@
     signal(make(<web-error>,
                 error: "Host with same name already exists in zone"));
   elseif (size(choose(method(x) x.host-name = host.host-name end,
-                      host.zone.a-records)) > 0)
+                      host.zone.host-records)) > 0)
     signal(make(<web-error>,
                 error: "A record for host already exists in zone"));
   elseif (size(choose(method(x) x.target = host.host-name end,

Modified: trunk/libraries/network/koala/sources/examples/buddha/ipv4.dylan
==============================================================================
--- trunk/libraries/network/koala/sources/examples/buddha/ipv4.dylan	(original)
+++ trunk/libraries/network/koala/sources/examples/buddha/ipv4.dylan	Mon Dec 18 03:00:30 2006
@@ -124,13 +124,15 @@
 // conversions (string, ip, integer)
 define method as (class == <string>, ip-address :: <ipv4-address>)
  => (res :: <string>)
-  let strings = make(<list>);
-  for (ele in ip-address)
-    strings := add(strings, integer-to-string(ele));
+  if (ip-address = $bottom-v4-address)
+    "no ipv4-address"
+  else
+    let strings = make(<list>);
+    for (ele in ip-address)
+      strings := add(strings, integer-to-string(ele));
+    end;
+    reduce1(method(x, y) concatenate(x, ".", y) end, reverse(strings));
   end;
-  reduce1(method(x, y)
-              concatenate(x, ".", y)
-          end, reverse(strings));
 end;
 
 define method as (class :: subclass(<ip-address>), netmask :: <integer>)
@@ -158,6 +160,7 @@
   make(<ipv4-address>, data: res);
 end;
 
+define constant $bottom-v4-address = make(<ipv4-address>, data: as(<byte-vector>, #(0, 0, 0, 0)));
 
 define method string-to-netmask (string :: <string>)
  => (netmask :: <integer>)

Modified: trunk/libraries/network/koala/sources/examples/buddha/zone.dylan
==============================================================================
--- trunk/libraries/network/koala/sources/examples/buddha/zone.dylan	(original)
+++ trunk/libraries/network/koala/sources/examples/buddha/zone.dylan	Mon Dec 18 03:00:30 2006
@@ -21,43 +21,28 @@
   a.source < b.source
 end;
 
-define web-class <a-record> (<object>)
+define web-class <host-record> (<object>)
   data host-name :: <string>;
-  data ipv4-address :: <ipv4-address>;
+  data ipv4-address :: <ipv4-address> = $bottom-v4-address;
+  data ipv6-address :: <ipv6-address> = $bottom-v6-address;
   data time-to-live :: <integer> = 300;
 end;
 
-define method print-object (a :: <a-record>, stream :: <stream>)
+define method print-object (a :: <host-record>, stream :: <stream>)
  => ();
   format(stream, "A: %s\n", as(<string>, a));
 end method;
 
-define method as (class == <string>, a :: <a-record>)
+define method as (class == <string>, a :: <host-record>)
  => (res :: <string>)
-  concatenate(a.host-name, " ", as(<string>, a.ipv4-address));
+  concatenate(a.host-name, " ", as(<string>, a.ipv4-address), " ", as(<string>, a.ipv6-address));
 end;
 
-define method \< (a :: <a-record>, b :: <a-record>)
+define method \< (a :: <host-record>, b :: <host-record>)
  => (res :: <boolean>)
   a.host-name < b.host-name
 end;
 
-define web-class <aaaa-record> (<object>)
-  data host-name :: <string>;
-  data ipv6-address :: <ipv6-address>;
-  data time-to-live :: <integer> = 300;
-end;
-
-define method as (class == <string>, a :: <aaaa-record>)
- => (res :: <string>)
-  concatenate(a.host-name, " ", as(<string>, a.ipv6-address));
-end;
-
-define method \< (a :: <aaaa-record>, b :: <aaaa-record>)
- => (res :: <boolean>)
-  a.host-name < b.host-name;
-end;
-
 define web-class <mail-exchange> (<object>)
   data mx-name :: <string>;
   data priority :: <integer> = 23;
@@ -111,8 +96,7 @@
   data minimum :: <integer> = 300;
   has-many nameserver :: <nameserver>;
   has-many mail-exchange :: <mail-exchange>;
-  has-many a-record :: <a-record>;
-  has-many aaaa-record :: <aaaa-record>;
+  has-many host-record :: <host-record>;
   //has-many text :: <string>;
 end;
 
@@ -191,13 +175,13 @@
     //Hosts
     do(method(x)
            if (reverse-table) reverse-table[as(<string>, x.ipv4-address)] := x.host-name end;
-           format(stream, "+%s.%s:%s:%d\n",
+           format(stream, "=%s.%s:%s:%d\n",
                   x.host-name,
                   print-zone.zone-name,
                   as(<string>, x.ipv4-address),
                   x.time-to-live);
            unless (x.ipv6-address = $bottom-v6-address)
-             format(stream, "3%s.%s:%s:%d\n",
+             format(stream, "6%s.%s:%s:%d\n",
                     x.host-name,
                     print-zone.zone-name,
                     as-dns-string(x.ipv6-address),
@@ -208,20 +192,21 @@
                    end, storage(<host>)));
     //A
     do(method(x)
+         unless (x.ipv4-address = $bottom-v4-address)
            format(stream, "+%s.%s:%s:%d\n",
                   x.host-name,
                   print-zone.zone-name,
                   as(<string>, x.ipv4-address),
                   x.time-to-live);
-       end, print-zone.a-records);
-    //AAAA
-    do(method(x)
-         format(stream, "3%s.%s:%s:%d\n",
-                x.host-name,
-                print-zone.zone-name,
-                as-dns-string(x.ipv6-address),
-                x.time-to-live);
-       end, print-zone.aaaa-records);
+         end;
+         unless (x.ipv6-address = $bottom-v6-address)
+           format(stream, "3%s.%s:%s:%d\n",
+                  x.host-name,
+                  print-zone.zone-name,
+                  as-dns-string(x.ipv6-address),
+                  x.time-to-live);
+         end;
+       end, print-zone.host-records);
     //CNAME
     do(method(x)
            format(stream, "C%s.%s:%s.%s\n",



More information about the chatter mailing list