Monorepo for Tangled
0
fork

Configure Feed

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

knotmirror: check host from DB before guessing SSL

Signed-off-by: Seongmin Lee <git@boltless.me>

authored by

Seongmin Lee and committed by tangled.org bea881c4 362c2b25

+13 -5
+1
knotmirror/tapclient.go
··· 129 129 } 130 130 } 131 131 132 + t.logger.Debug("tap: upserting repo with knot", "knot", repo.KnotDomain) 132 133 if err := db.UpsertRepo(ctx, t.db, repo); err != nil { 133 134 return fmt.Errorf("upserting repo to db: %w", err) 134 135 }
+11 -5
knotmirror/xrpc/proxy.go
··· 70 70 71 71 record := out.Value.Val.(*tangled.Repo) 72 72 knotURL := record.Knot 73 - if !strings.Contains(knotURL, "://") { 74 - scheme := "http" 75 - if x.cfg.KnotUseSSL { 76 - scheme = "https" 73 + if !strings.Contains(record.Knot, "://") { 74 + if host, _ := db.GetHost(ctx, x.db, record.Knot); host != nil { 75 + knotURL = host.URL() 76 + } else { 77 + x.logger.Warn("repo is from unknown knot") 78 + if x.cfg.KnotUseSSL { 79 + knotURL = "https://" + knotURL 80 + } else { 81 + knotURL = "http://" + knotURL 82 + } 77 83 } 78 - knotURL = scheme + "://" + knotURL 79 84 } 80 85 81 86 go func() { ··· 88 93 KnotDomain: knotURL, 89 94 State: models.RepoStatePending, 90 95 } 96 + x.logger.Debug("pending: upserting repo with knot", "knot", pending.KnotDomain) 91 97 if upsertErr := db.UpsertRepo(bgCtx, x.db, pending); upsertErr != nil { 92 98 x.logger.Error("failed to upsert repo after proxy resolution", "err", upsertErr) 93 99 }
+1
knotmirror/xrpc/sync_request_crawl.go
··· 83 83 RetryCount: 0, 84 84 } 85 85 86 + x.logger.Debug("requestCrawl: upserting repo with knot", "knot", repo.KnotDomain) 86 87 if err := db.UpsertRepo(ctx, x.db, repo); err != nil { 87 88 l.Error("failed to upsert repo", "err", err) 88 89 writeErr(w, err)