From f62322aee40919139fceb2b1f4655132dba688fd Mon Sep 17 00:00:00 2001 From: eyedeekay Date: Thu, 1 May 2025 19:09:46 -0400 Subject: [PATCH] switch to metadialer for gitea too --- gitea/dialer.go | 40 ++++------------------------------------ 1 file changed, 4 insertions(+), 36 deletions(-) diff --git a/gitea/dialer.go b/gitea/dialer.go index e4afafd..4afe2f6 100644 --- a/gitea/dialer.go +++ b/gitea/dialer.go @@ -3,48 +3,16 @@ package gitea import ( "net" "net/http" - "net/url" - "strings" "time" - "github.com/go-i2p/gitlab-to-gitea/utils" - "github.com/go-i2p/onramp" -) - -var ( - Garlic, GarlicErr = onramp.NewGarlic("git-looseleaf", "127.0.0.1:7656", onramp.OPT_WIDE) - Onion, OnionErr = onramp.NewOnion("git-looseleaf") + metadialer "github.com/go-i2p/go-meta-dialer" ) func Dial(network, addr string) (net.Conn, error) { - // convert the addr to a URL - url, err := url.Parse(addr) - if err != nil { - return nil, err - } - // get the domain name - domain := url.Hostname() - // get the top-level domain - fr := strings.Split(domain, ".") - tld := fr[len(fr)-1] - utils.PrintInfo("Dialing " + tld + " " + addr) - switch tld { - case "i2p": - if GarlicErr != nil { - return nil, GarlicErr - } - // I2P is a special case, we need to use the garlic dialer - return Garlic.Dial("i2p", addr) - case "onion": - if OnionErr != nil { - return nil, OnionErr - } - // Onion is a special case, we need to use the onion dialer - return Onion.Dial("onion", addr) - default: - // For everything else, we can use the default dialer - return net.Dial(network, addr) + if metadialer.ANON { + metadialer.ANON = false } + return metadialer.Dial(network, addr) } func init() {