use clearnet by default instead of tor

This commit is contained in:
Kay Faraday 2021-07-28 04:19:11 +00:00
parent de384e3af0
commit a68b2c2ddc
1 changed files with 8 additions and 6 deletions

14
main.go
View File

@ -36,13 +36,14 @@ func (h *httpProxyHandler) dialOut(addr string) (net.Conn, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
if strings.HasSuffix(host, ".loki") { if strings.HasSuffix(host, ".onion") {
return net.Dial("tcp", addr) return h.onion.Dial("tcp", addr)
} }
if strings.HasSuffix(host, ".i2p") { if strings.HasSuffix(host, ".i2p") {
return h.i2p.Dial("tcp", addr) return h.i2p.Dial("tcp", addr)
} }
return h.onion.Dial("tcp", addr) // fallthrough for clearnet and .loki
return net.Dial("tcp", addr)
} }
func (h *httpProxyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { func (h *httpProxyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
@ -118,13 +119,14 @@ func main() {
if err != nil { if err != nil {
return nil, err return nil, err
} }
if strings.HasSuffix(host, ".loki") { if strings.HasSuffix(host, ".onion") {
return net.Dial("tcp", addr) return onionsock.Dial("tcp", addr)
} }
if strings.HasSuffix(host, ".i2p") { if strings.HasSuffix(host, ".i2p") {
return i2psock.Dial("tcp", addr) return i2psock.Dial("tcp", addr)
} }
return onionsock.Dial("tcp", addr) // fallthrough for clearnet and loki
return net.Dial("tcp", addr)
}, },
}) })