2022-08-03 22:00:55 -04:00
|
|
|
# Onramp I2P and Tor Library
|
|
|
|
|
|
|
|
[](http://pkg.go.dev/.)
|
|
|
|
[](https://goreportcard.com/report/.)
|
|
|
|
|
|
|
|
## Variables
|
|
|
|
|
|
|
|
I2P_KEYSTORE_PATH is the place where I2P Keys will be saved.
|
|
|
|
it defaults to the directory "i2pkeys" current working directory
|
|
|
|
reference it by calling I2PKeystorePath() to check for errors
|
|
|
|
|
|
|
|
```golang
|
|
|
|
var I2P_KEYSTORE_PATH = i2pdefault
|
|
|
|
```
|
|
|
|
|
|
|
|
ONION_KEYSTORE_PATH is the place where Onion Keys will be saved.
|
|
|
|
it defaults to the directory "onionkeys" current working directory
|
|
|
|
reference it by calling OnionKeystorePath() to check for errors
|
|
|
|
|
|
|
|
```golang
|
|
|
|
var ONION_KEYSTORE_PATH = tordefault
|
|
|
|
```
|
|
|
|
|
|
|
|
```golang
|
|
|
|
var OPT_DEFAULTS = sam3.Options_Default
|
|
|
|
```
|
|
|
|
|
2022-08-03 23:47:24 -04:00
|
|
|
SAM_ADDR is the default I2P SAM address. It can be overridden by the
|
|
|
|
struct or by changing this variable.
|
|
|
|
|
|
|
|
```golang
|
|
|
|
var SAM_ADDR = "127.0.0.1:7656"
|
|
|
|
```
|
|
|
|
|
2022-08-03 22:05:08 -04:00
|
|
|
## Functions
|
|
|
|
|
2022-08-04 17:21:46 -04:00
|
|
|
### func [CloseAllGarlic](/garlic.go#L211)
|
2022-08-03 22:05:08 -04:00
|
|
|
|
2022-08-04 17:15:12 -04:00
|
|
|
`func CloseAllGarlic()`
|
2022-08-03 22:05:08 -04:00
|
|
|
|
2022-08-04 17:15:12 -04:00
|
|
|
CloseAllGarlic closes all garlics managed by the onramp package. It does not
|
|
|
|
affect objects instantiated by an app.
|
2022-08-03 22:05:08 -04:00
|
|
|
|
2022-08-04 17:21:46 -04:00
|
|
|
### func [CloseAllOnion](/onion.go#L174)
|
2022-08-03 22:05:08 -04:00
|
|
|
|
2022-08-04 17:15:12 -04:00
|
|
|
`func CloseAllOnion()`
|
2022-08-03 22:05:08 -04:00
|
|
|
|
2022-08-04 17:21:46 -04:00
|
|
|
CloseAllOnion closes all onions managed by the onramp package. It does not
|
2022-08-03 22:05:08 -04:00
|
|
|
affect objects instantiated by an app.
|
|
|
|
|
2022-08-04 17:21:46 -04:00
|
|
|
### func [CloseGarlic](/garlic.go#L220)
|
2022-08-04 17:15:12 -04:00
|
|
|
|
|
|
|
`func CloseGarlic(tunName string)`
|
|
|
|
|
|
|
|
CloseGarlic closes the Garlic at the given index. It does not affect Garlic
|
|
|
|
objects instantiated by an app.
|
|
|
|
|
2022-08-04 17:21:46 -04:00
|
|
|
### func [CloseOnion](/onion.go#L183)
|
2022-08-04 17:15:12 -04:00
|
|
|
|
|
|
|
`func CloseOnion(tunName string)`
|
|
|
|
|
|
|
|
CloseOnion closes the Onion at the given index. It does not affect Onion
|
|
|
|
objects instantiated by an app.
|
|
|
|
|
2022-08-04 17:21:46 -04:00
|
|
|
### func [DeleteGarlicKeys](/garlic.go#L159)
|
|
|
|
|
|
|
|
`func DeleteGarlicKeys(tunName string) error`
|
|
|
|
|
|
|
|
DeleteGarlicKeys deletes the key file at the given path as determined by
|
|
|
|
keystore + tunName.
|
|
|
|
This is permanent and irreversible, and will change the onion service
|
|
|
|
address.
|
|
|
|
|
2022-08-04 17:27:52 -04:00
|
|
|
### func [DeleteI2PKeyStore](/common.go#L60)
|
2022-08-04 00:02:05 -04:00
|
|
|
|
|
|
|
`func DeleteI2PKeyStore() error`
|
|
|
|
|
|
|
|
DeleteI2PKeyStore deletes the I2P Keystore.
|
|
|
|
|
2022-08-04 17:21:46 -04:00
|
|
|
### func [DeleteOnionKeys](/onion.go#L216)
|
2022-08-04 00:02:05 -04:00
|
|
|
|
2022-08-04 17:21:46 -04:00
|
|
|
`func DeleteOnionKeys(tunName string) error`
|
2022-08-04 00:02:05 -04:00
|
|
|
|
2022-08-04 17:21:46 -04:00
|
|
|
DeleteOnionKeys deletes the key file at the given path as determined by
|
2022-08-04 00:02:05 -04:00
|
|
|
keystore + tunName.
|
|
|
|
|
2022-08-04 17:27:52 -04:00
|
|
|
### func [DeleteTorKeyStore](/common.go#L78)
|
2022-08-04 00:02:05 -04:00
|
|
|
|
|
|
|
`func DeleteTorKeyStore() error`
|
|
|
|
|
|
|
|
DeleteTorKeyStore deletes the Onion Keystore.
|
|
|
|
|
2022-08-04 17:27:52 -04:00
|
|
|
### func [Dial](/common.go#L85)
|
|
|
|
|
|
|
|
`func Dial(network, addr string) (net.Conn, error)`
|
|
|
|
|
|
|
|
Dial returns a connection for the given network and address.
|
|
|
|
network is ignored. If the address ends in i2p, it returns an I2P connection.
|
|
|
|
if the address ends in anything else, it returns a Tor connection.
|
|
|
|
|
2022-08-04 17:21:46 -04:00
|
|
|
### func [DialGarlic](/garlic.go#L246)
|
2022-08-04 17:15:12 -04:00
|
|
|
|
|
|
|
`func DialGarlic(network, addr string) (net.Conn, error)`
|
|
|
|
|
|
|
|
DialGarlic returns a net.Conn for a garlic structure's keys
|
|
|
|
corresponding to a structure managed by the onramp library
|
|
|
|
and not instantiated by an app.
|
2022-08-03 22:05:08 -04:00
|
|
|
|
2022-08-04 17:21:46 -04:00
|
|
|
### func [DialOnion](/onion.go#L205)
|
2022-08-03 22:05:08 -04:00
|
|
|
|
2022-08-04 17:15:12 -04:00
|
|
|
`func DialOnion(network, addr string) (net.Conn, error)`
|
|
|
|
|
2022-08-04 17:21:46 -04:00
|
|
|
DialOnion returns a net.Conn for a onion structure's keys
|
2022-08-03 22:05:08 -04:00
|
|
|
corresponding to a structure managed by the onramp library
|
|
|
|
and not instantiated by an app.
|
|
|
|
|
2022-08-04 17:27:52 -04:00
|
|
|
### func [GetJoinedWD](/common.go#L17)
|
2022-08-03 22:05:08 -04:00
|
|
|
|
|
|
|
`func GetJoinedWD(dir string) (string, error)`
|
|
|
|
|
|
|
|
GetJoinedWD returns the working directory joined with the given path.
|
|
|
|
|
2022-08-04 17:21:46 -04:00
|
|
|
### func [I2PKeys](/garlic.go#L173)
|
2022-08-03 22:05:08 -04:00
|
|
|
|
|
|
|
`func I2PKeys(tunName, samAddr string) (i2pkeys.I2PKeys, error)`
|
|
|
|
|
|
|
|
I2PKeys returns the I2PKeys at the keystore directory for the given
|
|
|
|
tunnel name. If none exist, they are created and stored.
|
|
|
|
|
2022-08-04 17:27:52 -04:00
|
|
|
### func [I2PKeystorePath](/common.go#L49)
|
2022-08-03 22:05:08 -04:00
|
|
|
|
|
|
|
`func I2PKeystorePath() (string, error)`
|
|
|
|
|
|
|
|
I2PKeystorePath returns the path to the I2P Keystore. If the
|
|
|
|
path is not set, it returns the default path. If the path does
|
|
|
|
not exist, it creates it.
|
|
|
|
|
2022-08-04 17:27:52 -04:00
|
|
|
### func [Listen](/common.go#L101)
|
|
|
|
|
|
|
|
`func Listen(network, keys string) (net.Listener, error)`
|
|
|
|
|
|
|
|
Listen returns a listener for the given network and address.
|
|
|
|
if network is i2p or garlic, it returns an I2P listener.
|
|
|
|
if network is tor or onion, it returns an Onion listener.
|
|
|
|
if keys ends with ".i2p", it returns an I2P listener.
|
|
|
|
|
2022-08-04 17:21:46 -04:00
|
|
|
### func [ListenGarlic](/garlic.go#L234)
|
2022-08-04 17:15:12 -04:00
|
|
|
|
|
|
|
`func ListenGarlic(network, keys string) (net.Listener, error)`
|
2022-08-03 22:05:08 -04:00
|
|
|
|
2022-08-04 17:15:12 -04:00
|
|
|
ListenGarlic returns a net.Listener for a garlic structure's keys
|
|
|
|
corresponding to a structure managed by the onramp library
|
|
|
|
and not instantiated by an app.
|
|
|
|
|
2022-08-04 17:21:46 -04:00
|
|
|
### func [ListenOnion](/onion.go#L193)
|
2022-08-04 17:15:12 -04:00
|
|
|
|
|
|
|
`func ListenOnion(network, keys string) (net.Listener, error)`
|
2022-08-03 22:05:08 -04:00
|
|
|
|
2022-08-04 17:21:46 -04:00
|
|
|
ListenOnion returns a net.Listener for a onion structure's keys
|
2022-08-03 22:05:08 -04:00
|
|
|
corresponding to a structure managed by the onramp library
|
|
|
|
and not instantiated by an app.
|
|
|
|
|
2022-08-04 17:21:46 -04:00
|
|
|
### func [TorKeys](/onion.go#L135)
|
2022-08-04 17:15:12 -04:00
|
|
|
|
|
|
|
`func TorKeys(keyName string) (ed25519.KeyPair, error)`
|
|
|
|
|
2022-08-04 17:21:46 -04:00
|
|
|
TorKeys returns a key pair which will be stored at the given key
|
|
|
|
name in the key store. If the key already exists, it will be
|
|
|
|
returned. If it does not exist, it will be generated.
|
|
|
|
|
2022-08-04 17:27:52 -04:00
|
|
|
### func [TorKeystorePath](/common.go#L67)
|
2022-08-03 22:05:08 -04:00
|
|
|
|
|
|
|
`func TorKeystorePath() (string, error)`
|
|
|
|
|
|
|
|
TorKeystorePath returns the path to the Onion Keystore. If the
|
|
|
|
path is not set, it returns the default path. If the path does
|
|
|
|
not exist, it creates it.
|
|
|
|
|
|
|
|
## Types
|
|
|
|
|
|
|
|
### type [Garlic](/garlic.go#L19)
|
|
|
|
|
|
|
|
`type Garlic struct { ... }`
|
|
|
|
|
|
|
|
Garlic is a ready-made I2P streaming manager. Once initialized it always
|
|
|
|
has a valid I2PKeys and StreamSession.
|
|
|
|
|
2022-08-04 00:02:05 -04:00
|
|
|
#### func [NewGarlic](/garlic.go#L140)
|
2022-08-03 22:05:08 -04:00
|
|
|
|
|
|
|
`func NewGarlic(tunName, samAddr string, options []string) (*Garlic, error)`
|
|
|
|
|
|
|
|
NewGarlic returns a new Garlic struct. It is immediately ready to use with
|
|
|
|
I2P streaming.
|
|
|
|
|
|
|
|
#### func (*Garlic) [Close](/garlic.go#L111)
|
|
|
|
|
|
|
|
`func (g *Garlic) Close() error`
|
|
|
|
|
|
|
|
Close closes the Garlic structure's sessions and listeners.
|
|
|
|
|
2022-08-04 00:02:05 -04:00
|
|
|
#### func (*Garlic) [DeleteKeys](/garlic.go#L134)
|
|
|
|
|
|
|
|
`func (g *Garlic) DeleteKeys() error`
|
|
|
|
|
2022-08-03 22:05:08 -04:00
|
|
|
#### func (*Garlic) [Dial](/garlic.go#L99)
|
|
|
|
|
|
|
|
`func (g *Garlic) Dial(net, addr string) (net.Conn, error)`
|
|
|
|
|
|
|
|
Dial returns a net.Conn for the Garlic structure's I2P keys.
|
|
|
|
|
|
|
|
#### func (*Garlic) [Keys](/garlic.go#L126)
|
|
|
|
|
|
|
|
`func (g *Garlic) Keys() (i2pkeys.I2PKeys, error)`
|
|
|
|
|
|
|
|
Keys returns the I2PKeys for the Garlic structure. If none
|
|
|
|
exist, they are created and stored.
|
|
|
|
|
|
|
|
#### func (*Garlic) [Listen](/garlic.go#L81)
|
|
|
|
|
|
|
|
`func (g *Garlic) Listen() (net.Listener, error)`
|
|
|
|
|
|
|
|
Listen returns a net.Listener for the Garlic structure's I2P keys.
|
|
|
|
|
2022-08-04 17:21:46 -04:00
|
|
|
### type [Onion](/onion.go#L24)
|
2022-08-03 22:05:08 -04:00
|
|
|
|
|
|
|
`type Onion struct { ... }`
|
|
|
|
|
2022-08-04 17:21:46 -04:00
|
|
|
Onion represents a structure which manages an onion service and
|
|
|
|
a Tor client. The onion service will automatically have persistent
|
|
|
|
keys.
|
|
|
|
|
|
|
|
#### func [NewOnion](/onion.go#L126)
|
2022-08-04 17:15:12 -04:00
|
|
|
|
|
|
|
`func NewOnion(name string) (*Onion, error)`
|
|
|
|
|
2022-08-04 17:21:46 -04:00
|
|
|
NewOnion returns a new Onion object.
|
|
|
|
|
|
|
|
#### func (*Onion) [Close](/onion.go#L109)
|
2022-08-04 17:15:12 -04:00
|
|
|
|
|
|
|
`func (o *Onion) Close() error`
|
|
|
|
|
2022-08-04 17:21:46 -04:00
|
|
|
Close closes the Onion Service and all associated resources.
|
|
|
|
|
|
|
|
#### func (*Onion) [DeleteKeys](/onion.go#L121)
|
|
|
|
|
|
|
|
`func (g *Onion) DeleteKeys() error`
|
|
|
|
|
|
|
|
DeleteKeys deletes the keys at the given key name in the key store.
|
|
|
|
This is permanent and irreversible, and will change the onion service
|
|
|
|
address.
|
|
|
|
|
|
|
|
#### func (*Onion) [Dial](/onion.go#L104)
|
2022-08-04 17:15:12 -04:00
|
|
|
|
|
|
|
`func (o *Onion) Dial(net, addr string) (net.Conn, error)`
|
|
|
|
|
2022-08-04 17:21:46 -04:00
|
|
|
Dial returns a net.Conn to the given onion address or clearnet address.
|
|
|
|
|
|
|
|
#### func (*Onion) [Keys](/onion.go#L114)
|
2022-08-04 17:15:12 -04:00
|
|
|
|
|
|
|
`func (o *Onion) Keys() (ed25519.KeyPair, error)`
|
|
|
|
|
2022-08-04 17:21:46 -04:00
|
|
|
Keys returns the keys for the Onion
|
|
|
|
|
|
|
|
#### func (*Onion) [Listen](/onion.go#L99)
|
2022-08-04 17:15:12 -04:00
|
|
|
|
|
|
|
`func (o *Onion) Listen() (net.Listener, error)`
|
|
|
|
|
2022-08-04 17:21:46 -04:00
|
|
|
ListenOnion returns a net.Listener which will listen on an onion
|
|
|
|
address, and will automatically generate a keypair and store it.
|
|
|
|
|
2022-08-03 22:00:55 -04:00
|
|
|
---
|
|
|
|
Readme created from Go doc with [goreadme](https://github.com/posener/goreadme)
|