git.frostfs.info/TrueCloudLab/frostfs-sdk-go@v0.0.0-20241022124111-5361f0ecebd3/ns/dns.go (about) 1 package ns 2 3 import ( 4 "net" 5 6 cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id" 7 ) 8 9 // DNS looks up FrostFS names using system DNS. 10 // 11 // See also net package. 12 type DNS struct{} 13 14 // ResolveContainerName looks up for DNS TXT records for the given domain name 15 // and returns the first one which represents valid container ID in a string format. 16 // Otherwise, returns an error. 17 // 18 // See also net.LookupTXT. 19 func (x *DNS) ResolveContainerName(name string) (id cid.ID, err error) { 20 records, err := net.LookupTXT(name) 21 if err != nil { 22 return 23 } 24 25 for i := range records { 26 err = id.DecodeString(records[i]) 27 if err == nil { 28 return 29 } 30 } 31 32 err = errNotFound 33 34 return 35 }