From nobody Mon Apr 29 16:20:44 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1499866120298546.2799911692016; Wed, 12 Jul 2017 06:28:40 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1638780E72; Wed, 12 Jul 2017 13:28:36 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0D87B703A9; Wed, 12 Jul 2017 13:28:35 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 0138F4A492; Wed, 12 Jul 2017 13:28:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v6CDSRhd030313 for ; Wed, 12 Jul 2017 09:28:27 -0400 Received: by smtp.corp.redhat.com (Postfix) id C2ABA600CE; Wed, 12 Jul 2017 13:28:26 +0000 (UTC) Received: from mx1.redhat.com (ext-mx01.extmail.prod.ext.phx2.redhat.com [10.5.110.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BE0DD704D0 for ; Wed, 12 Jul 2017 13:28:25 +0000 (UTC) Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8B7F788E60 for ; Wed, 12 Jul 2017 13:28:23 +0000 (UTC) Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 16665AD43 for ; Wed, 12 Jul 2017 13:28:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1638780E72 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 1638780E72 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8B7F788E60 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=thipp@suse.de DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 8B7F788E60 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Thomas Hipp To: libvir-list@redhat.com Date: Wed, 12 Jul 2017 15:28:13 +0200 Message-Id: <20170712132813.7724-1-thipp@suse.de> X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 203 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 12 Jul 2017 13:28:24 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 12 Jul 2017 13:28:24 +0000 (UTC) for IP:'195.135.220.15' DOMAIN:'mx2.suse.de' HELO:'mx1.suse.de' FROM:'thipp@suse.de' RCPT:'' X-RedHat-Spam-Score: -1.902 (BAYES_50, DCC_REPUT_00_12, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, SPF_PASS) 195.135.220.15 mx2.suse.de 195.135.220.15 mx2.suse.de X-Scanned-By: MIMEDefang 2.78 on 10.5.110.25 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH go-xml] Add support for DNS in network X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 12 Jul 2017 13:28:38 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add support for DNS in network, and add test code. Signed-off-by: Thomas Hipp --- network.go | 39 ++++++++++++++++++++++++++++++++++ network_test.go | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++-= ---- 2 files changed, 99 insertions(+), 5 deletions(-) diff --git a/network.go b/network.go index cc850a1..e0baa96 100644 --- a/network.go +++ b/network.go @@ -84,6 +84,44 @@ type NetworkRoute struct { Gateway string `xml:"gateway,attr,omitempty"` } =20 +type NetworkDNSForwarder struct { + Domain string `xml:"domain,attr,omitempty"` + Addr string `xml:"addr,attr,omitempty"` +} + +type NetworkDNSTXT struct { + Name string `xml:"name,attr"` + Value string `xml:"value,attr"` +} + +type NetworkDNSHostHostname struct { + Hostname string `xml:",chardata"` +} + +type NetworkDNSHost struct { + IP string `xml:"ip,attr"` + Hostnames []NetworkDNSHostHostname `xml:"hostname"` +} + +type NetworkDNSSRV struct { + Service string `xml:"service,attr"` + Protocol string `xml:"protocol,attr"` + Target string `xml:"target,attr,omitempty"` + Port uint `xml:"port,attr,omitempty"` + Priority uint `xml:"priority,attr,omitempty"` + Weight uint `xml:"weight,attr,omitempty"` + Domain string `xml:"domain,attr,omitempty"` +} + +type NetworkDNS struct { + Enable string `xml:"enable,attr,omitempty"` + ForwardPlainNames string `xml:"forwardPlainNames,attr,omit= empty"` + Forwarders []NetworkDNSForwarder `xml:"forwarder"` + TXTs []NetworkDNSTXT `xml:"txt"` + Host *NetworkDNSHost `xml:"host"` + SRVs []NetworkDNSSRV `xml:"srv"` +} + type Network struct { XMLName xml.Name `xml:"network"` IPv6 string `xml:"ipv6,attr,omitempty"` @@ -96,6 +134,7 @@ type Network struct { Domain *NetworkDomain `xml:"domain"` IPs []NetworkIP `xml:"ip"` Routes []NetworkRoute `xml:"route"` + DNS *NetworkDNS `xml:"dns"` } =20 func (s *Network) Unmarshal(doc string) error { diff --git a/network_test.go b/network_test.go index 5269398..2eb81ab 100644 --- a/network_test.go +++ b/network_test.go @@ -89,9 +89,9 @@ var networkTestData =3D []struct { }, }, NetworkIP{ - Family: "ipv6", - Address:"2001:db8:ca2:2::1", - Prefix: "64", + Family: "ipv6", + Address: "2001:db8:ca2:2::1", + Prefix: "64", DHCP: &NetworkDHCP{ Hosts: []NetworkDHCPHost{ NetworkDHCPHost{ @@ -99,13 +99,57 @@ var networkTestData =3D []struct { Name: "paul", }, NetworkDHCPHost{ - ID: "0:1:0:1:18:aa:62:fe:0:16:3e:44:55:66", - IP: "2001:db8:ca2:2:3::2", + ID: "0:1:0:1:18:aa:62:fe:0:16:3e:44:55:66", + IP: "2001:db8:ca2:2:3::2", }, }, }, }, }, + DNS: &NetworkDNS{ + Enable: "yes", + ForwardPlainNames: "no", + Forwarders: []NetworkDNSForwarder{ + NetworkDNSForwarder{ + Addr: "8.8.8.8", + }, + NetworkDNSForwarder{ + Domain: "example.com", + Addr: "8.8.4.4", + }, + NetworkDNSForwarder{ + Domain: "www.example.com", + }, + }, + TXTs: []NetworkDNSTXT{ + NetworkDNSTXT{ + Name: "example", + Value: "example value", + }, + }, + Host: &NetworkDNSHost{ + IP: "192.168.122.2", + Hostnames: []NetworkDNSHostHostname{ + NetworkDNSHostHostname{ + Hostname: "myhost", + }, + NetworkDNSHostHostname{ + Hostname: "myhostalias", + }, + }, + }, + SRVs: []NetworkDNSSRV{ + NetworkDNSSRV{ + Service: "name", + Protocol: "tcp", + Domain: "test-domain-name", + Target: ".", + Port: 1024, + Priority: 10, + Weight: 10, + }, + }, + }, }, Expected: []string{ ``, @@ -124,6 +168,17 @@ var networkTestData =3D []struct { ` `, ` `, ` `, + ` `, + ` `, + ` `, + ` `, + ` `, + ` `, + ` myhost`, + ` myhostalias`, + ` `, + ` `, + ` `, ``, }, }, --=20 2.13.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list