this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

identity: support skipping DNS resolution for some hosts (like bsky.social)

+31 -14
+2
atproto/identity/base_directory.go
··· 19 19 Resolver net.Resolver 20 20 // when doing DNS handle resolution, should this resolver attempt re-try against an authoritative nameserver if the first TXT lookup fails? 21 21 TryAuthoritativeDNS bool 22 + // set of handle domain suffixes for for which DNS handle resolution will be skipped 23 + SkipDNSDomainSuffixes []string 22 24 } 23 25 24 26 var _ Directory = (*BaseDirectory)(nil)
+27 -14
atproto/identity/handle.go
··· 124 124 125 125 func (d *BaseDirectory) ResolveHandle(ctx context.Context, handle syntax.Handle) (syntax.DID, error) { 126 126 // TODO: *could* do resolution in parallel, but expecting that sequential is sufficient to start 127 - start := time.Now() 128 - triedAuthoritative := false 129 - did, dnsErr := d.ResolveHandleDNS(ctx, handle) 130 - if dnsErr == ErrHandleNotFound && d.TryAuthoritativeDNS { 131 - slog.Info("attempting authoritative handle DNS resolution", "handle", handle) 132 - triedAuthoritative = true 133 - // try harder with authoritative lookup 134 - did, dnsErr = d.ResolveHandleDNSAuthoritative(ctx, handle) 127 + var dnsErr error 128 + var did syntax.DID 129 + 130 + tryDNS := true 131 + for _, suffix := range d.SkipDNSDomainSuffixes { 132 + if strings.HasSuffix(handle.String(), suffix) { 133 + tryDNS = false 134 + break 135 + } 135 136 } 136 - elapsed := time.Since(start) 137 - slog.Debug("resolve handle DNS", "handle", handle, "err", dnsErr, "did", did, "authoritative", triedAuthoritative, "duration_ms", elapsed.Milliseconds()) 138 - if nil == dnsErr { // if *not* an error 139 - return did, nil 137 + 138 + if tryDNS { 139 + start := time.Now() 140 + triedAuthoritative := false 141 + did, dnsErr = d.ResolveHandleDNS(ctx, handle) 142 + if dnsErr == ErrHandleNotFound && d.TryAuthoritativeDNS { 143 + slog.Info("attempting authoritative handle DNS resolution", "handle", handle) 144 + triedAuthoritative = true 145 + // try harder with authoritative lookup 146 + did, dnsErr = d.ResolveHandleDNSAuthoritative(ctx, handle) 147 + } 148 + elapsed := time.Since(start) 149 + slog.Debug("resolve handle DNS", "handle", handle, "err", dnsErr, "did", did, "authoritative", triedAuthoritative, "duration_ms", elapsed.Milliseconds()) 150 + if nil == dnsErr { // if *not* an error 151 + return did, nil 152 + } 140 153 } 141 154 142 - start = time.Now() 155 + start := time.Now() 143 156 did, httpErr := d.ResolveHandleWellKnown(ctx, handle) 144 - elapsed = time.Since(start) 157 + elapsed := time.Since(start) 145 158 slog.Debug("resolve handle HTTP well-known", "handle", handle, "err", httpErr, "did", did, "duration_ms", elapsed.Milliseconds()) 146 159 if nil == httpErr { // if *not* an error 147 160 return did, nil
+2
atproto/identity/identity.go
··· 61 61 }, 62 62 }, 63 63 TryAuthoritativeDNS: true, 64 + // primary Bluesky PDS instance only supports HTTP resolution method 65 + SkipDNSDomainSuffixes: []string{".bsky.social"}, 64 66 } 65 67 cached := NewCacheDirectory(&base, 10000, time.Hour*24, time.Minute*2) 66 68 return &cached