-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge #93: ncdumpzone: Add mode for a URL list.
39fbbc0 ncdumpzone: Add mode for a URL list. (JeremyRand) Pull request description: This PR is intended to facilitate YaCy crawl jobs. ACKs for commit 39fbbc: Tree-SHA512: 070cfd9ad1ee4bc59286ec2c0c120379f30b4cfd761bd3eecd5e2a028b70091171b6dd054acb3c9205800d454187c88fed9e1be9c6591e087d808dd49e2ecda4
- Loading branch information
Showing
3 changed files
with
52 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package rrtourl | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/miekg/dns" | ||
"github.com/namecoin/ncdns/util" | ||
) | ||
|
||
// URLsFromRR returns a list of URL's derived from rr, which is suitable for | ||
// passing to a search engine crawler like YaCy. If no such list can be | ||
// derived, returns an empty string. | ||
func URLsFromRR(rr dns.RR) (string, error) { | ||
header := rr.Header() | ||
if header == nil { | ||
return "", fmt.Errorf("Nil RR header") | ||
} | ||
|
||
hostFQDN := header.Name | ||
|
||
// Remove things like "_443._tcp" in TLSA records | ||
for strings.HasPrefix(hostFQDN, "_") { | ||
_, hostFQDN = util.SplitDomainTail(hostFQDN) | ||
} | ||
|
||
// Remove the trailing period from FQDN's | ||
host := strings.TrimSuffix(hostFQDN, ".") | ||
|
||
// Remove wildcard subdomains (later we assume that they might be "www.") | ||
host = strings.TrimPrefix(host, "*.") | ||
|
||
return "http://" + host + "/" + "\n" + | ||
"http://www." + host + "/" + "\n" + | ||
"https://" + host + "/" + "\n" + | ||
"https://www." + host + "/" + "\n" + | ||
"ftp://" + host + "/" + "\n" + | ||
"ftp://www." + host + "/" + "\n" + | ||
"ftps://" + host + "/" + "\n" + | ||
"ftps://www." + host + "/" + "\n", nil | ||
} |