From b86b31c6823447c553fcb459a95352c2c39e2728 Mon Sep 17 00:00:00 2001 From: Alexander Shevtsov Date: Sun, 24 Mar 2024 20:10:15 +0100 Subject: [PATCH] moved back fetch of full domain --- prove/external.go | 7 ++++--- prove/prove.go | 1 - sync/hnsd.go | 9 +++++++++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/prove/external.go b/prove/external.go index f8e1385..e99afda 100644 --- a/prove/external.go +++ b/prove/external.go @@ -23,10 +23,9 @@ type DNSSECJson struct { var timeout = 1 * time.Second func fetchDNSSEC(domain string, externalServices []string) ([]byte, error) { - labels := dns.SplitDomainName(domain) - tld := labels[len(labels)-1] for _, link := range externalServices { - if result, err := fetchOneDNSSEC(tld, link); err == nil { + //fetch full domain + if result, err := fetchOneDNSSEC(domain, link); err == nil { return result, nil } debuglog.Logger.Debugf("couldn't fetch dnssec data for domain %s from %s", domain, link) @@ -39,6 +38,7 @@ func fetchUrkel(domain string, externalServices []string) ([]byte, error) { labels := dns.SplitDomainName(domain) tld := labels[len(labels)-1] for _, link := range externalServices { + //fetch only tld if result, err := fetchOneUrkel(tld, link); err == nil { return result, nil } @@ -48,6 +48,7 @@ func fetchUrkel(domain string, externalServices []string) ([]byte, error) { } func fetchOneDNSSEC(domain, server string) ([]byte, error) { + if !strings.HasSuffix(server, "/") { server += "/" } diff --git a/prove/prove.go b/prove/prove.go index ffed109..e877017 100644 --- a/prove/prove.go +++ b/prove/prove.go @@ -141,7 +141,6 @@ func verifyDomain(domain string, cert x509.Certificate, roots []sync.BlockInfo, if !foundDnssec { if len(externalServices) == 0 { - // if externalServices == []"" { return fmt.Errorf("certificate does not have dnssec chain extension and external service is disabled") } dnssecExtension, err = fetchDNSSEC(domain, externalServices) diff --git a/sync/hnsd.go b/sync/hnsd.go index 918d3c4..be6a6aa 100644 --- a/sync/hnsd.go +++ b/sync/hnsd.go @@ -117,7 +117,16 @@ func GetRoots(pathToExecutable string, confPath string, pathToCheckpoint string) log.Fatalf("error creating directory at %s : %s", pathToCheckpoint, err) } + //writes the empty array for the sync time rootPath := path.Join(confPath, rootsFileName) + if _, err := os.Stat(rootPath); os.IsNotExist(err) { + if err := os.WriteFile(rootPath, []byte("[]"), 0644); err != nil { + log.Fatal(err) + } + } else if err != nil { + log.Fatal(err) + } + ctx := context.Background() ctx, cancel := context.WithCancel(ctx) cmd := exec.CommandContext(ctx, pathToExecutable, "-n", dnsAddress, "-p", "4", "-r", "127.0.0.1:12345", "-t", "-x", pathToCheckpoint)