mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-29 22:55:06 +03:00
Experimental (read: badly tested) support for srv:// and txt:// handlers
This commit is contained in:
parent
67c670ab4c
commit
246c60ae4d
1 changed files with 27 additions and 0 deletions
|
@ -102,6 +102,33 @@ func (l *link) call(uri string, sintf string) error {
|
|||
}
|
||||
pathtokens := strings.Split(strings.Trim(u.Path, "/"), "/")
|
||||
switch u.Scheme {
|
||||
case "srv":
|
||||
for _, proto := range []string{"tcp"} {
|
||||
if cname, srv, err := net.LookupSRV("yggdrasil", proto, u.Host); err == nil {
|
||||
for _, record := range srv {
|
||||
l.core.log.Debugln("SRV lookup for", u.Host, "found:", cname, record.Target, record.Port)
|
||||
switch proto {
|
||||
case "tcp":
|
||||
saddr := fmt.Sprintf("%s:%d", record.Target, record.Port)
|
||||
l.tcp.call(saddr, nil, sintf)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
l.core.log.Debugln("SRV lookup for", u.Host, "failed:", err)
|
||||
}
|
||||
}
|
||||
case "txt":
|
||||
recordname := fmt.Sprintf("_yggdrasil.%s", u.Host)
|
||||
if records, err := net.LookupTXT(recordname); err == nil {
|
||||
for _, record := range records {
|
||||
l.core.log.Debugln("Found TXT record:", record)
|
||||
if !strings.HasPrefix(record, "txt://") {
|
||||
l.call(record, sintf)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
l.core.log.Debugln("TXT lookup failed:", err)
|
||||
}
|
||||
case "tcp":
|
||||
l.tcp.call(u.Host, nil, sintf)
|
||||
case "socks":
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue