Skip to content

Commit

Permalink
moved back fetch of full domain
Browse files Browse the repository at this point in the history
  • Loading branch information
randomlogin committed Mar 24, 2024
1 parent 924961a commit b86b31c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
7 changes: 4 additions & 3 deletions prove/external.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
}
Expand All @@ -48,6 +48,7 @@ func fetchUrkel(domain string, externalServices []string) ([]byte, error) {
}

func fetchOneDNSSEC(domain, server string) ([]byte, error) {

if !strings.HasSuffix(server, "/") {
server += "/"
}
Expand Down
1 change: 0 additions & 1 deletion prove/prove.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions sync/hnsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b86b31c

Please sign in to comment.