mirror of
https://github.com/go-i2p/go-gitlooseleaf.git
synced 2025-07-04 10:16:25 -04:00
add the dialer
This commit is contained in:
39
README.md
39
README.md
@ -37,46 +37,37 @@ var garlic, i2perr = onramp.NewGarlic("gitea-i2p", "127.0.0.1:7656", onramp.OPT_
|
||||
var torInstance, torerr = tor.Start(nil, nil)
|
||||
var onion, onionerr = torInstance.Listen(nil, 80)
|
||||
|
||||
// This implements the GetListener function for multiple protocols
|
||||
// This implements the GetListener function for I2P. Note the exemption for Unix sockets.
|
||||
func MultiGetListener(network, address string) (net.Listener, error) {
|
||||
// Add a deferral to say that we've tried to grab a listener
|
||||
defer GetManager().InformCleanup()
|
||||
switch network {
|
||||
case "tcp", "tcp4", "tcp6":
|
||||
// Regular TLS listener for clearnet access
|
||||
return DefaultGetListener(network, address)
|
||||
case "i2p", "i2pt":
|
||||
// I2P hidden service listener
|
||||
return garlic.Listen()
|
||||
case "onion":
|
||||
// Tor onion service listener
|
||||
return onion, nil
|
||||
case "unix", "unixpacket":
|
||||
// Unix sockets handled normally
|
||||
unixAddr, err := net.ResolveUnixAddr(network, address)
|
||||
// I2P isn't really a replacement for the stuff you use Unix sockets for and it's also not an anonymity risk, so treat them normally
|
||||
unixAddr, err := ResolveUnixAddr(network, address)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return GetListenerUnix(network, unixAddr)
|
||||
return GetListenerUnixWrapper(network, unixAddr)
|
||||
default:
|
||||
return nil, net.UnknownNetworkError(network)
|
||||
return mirror.Listen("tcp", address, "./certs", true)
|
||||
}
|
||||
}
|
||||
|
||||
// We use `init() to ensure that the appropriate Listeners and Dialers are correctly placed at runtime
|
||||
// We use `init() to ensure that the I2P Listeners and Dialers are correctly placed at runtime`
|
||||
func init() {
|
||||
if i2perr != nil {
|
||||
panic(i2perr)
|
||||
}
|
||||
if torerr != nil || onionerr != nil {
|
||||
panic("Tor setup failed")
|
||||
}
|
||||
|
||||
GetListener = MultiGetListener
|
||||
|
||||
// Configure the HTTP clients for each protocol
|
||||
// Default remains as-is for TLS connections
|
||||
/*httpClient := &http.Client{
|
||||
Transport: &http.Transport{
|
||||
Dial: garlic.Dial,
|
||||
},
|
||||
}
|
||||
|
||||
http.DefaultClient = httpClient
|
||||
http.DefaultTransport = httpClient.Transport*/
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
Caveats
|
||||
|
Reference in New Issue
Block a user