Documentation
¶
Index ¶
Constants ¶
const ( // EncodedPublicKeyApproxSize is the size, in bytes, of the public key when // encoded using the approximate encoder. EncodedPublicKeyApproxSize = 51 // EncodedPublicKeySize is the size, in bytes, of the public key when encoded // using the real encoder. EncodedPublicKeySize = 56 )
Variables ¶
This section is empty.
Functions ¶
func SaveOnionAddress ¶
func SaveOnionAddress(dir string, addr *OnionAddress) error
SaveOnionAddress saves the hostname, public key, and secret key from the given OnionAddress to the destination directory. It creates a sub-directory named after the hostname in the destination directory, then it creates 3 files inside the created sub-directory:
hs_ed25519_public_key hs_ed25519_secret_key hostname
Types ¶
type MultiMatcher ¶
type MultiMatcher struct { Inner []Matcher // If All is true, then all the Inner matchers must match. If false, then only 1 of them // must match. All bool }
func (MultiMatcher) Match ¶
func (m MultiMatcher) Match(exact []byte) bool
func (MultiMatcher) MatchApprox ¶
func (m MultiMatcher) MatchApprox(approx []byte) bool
type OnionAddress ¶
type OnionAddress struct { PublicKey ed25519.PublicKey SecretKey ed25519.PrivateKey }
func GenerateOnionAddress ¶
func GenerateOnionAddress(rand io.Reader) (*OnionAddress, error)
func MineOnionHostName ¶
func ReadOnionAddress ¶ added in v0.6.0
func ReadOnionAddress(dir string) (*OnionAddress, error)
ReadOnionAddress reads the public key and secret key from the files in the given directory, then it parses the keys from the files inside the directory and validates that they are valid keys to use as an onion address.
The provided directory must be one created either by the SaveOnionAddress function or any other program that outputs the keys in the same format. The directory must contain the following files:
hs_ed25519_public_key hs_ed25519_secret_key
func ReadOnionAddressFS ¶ added in v0.6.0
func ReadOnionAddressFS(fsys fs.FS) (*OnionAddress, error)
ReadOnionAddressFS does the same thing as ReadOnionAddress. The only difference is that it accepts an fs.FS to abstract away the underlying file system.
func (*OnionAddress) HostName ¶
func (addr *OnionAddress) HostName(hostname []byte)
HostName returns the .onion address representation of the public key stored in the OnionAddress. The .onion TLD is not included.
func (*OnionAddress) HostNameApprox ¶
func (addr *OnionAddress) HostNameApprox(hostname []byte)
HostNameApprox returns an approximate .onion address representation of the public key stored in the OnionAddress. The start of the address is accurate, the last few characters at the end are not. The .onion TLD is not included.
func (*OnionAddress) HostNameString ¶
func (addr *OnionAddress) HostNameString() string
HostNameString returns the .onion address representation of the public key stored in the OnionAddress as a string. Unlike HostName and HostNameApprox, this method does include the .onion TLD in the returned hostname.
type StartEndMatcher ¶
func (StartEndMatcher) Match ¶
func (m StartEndMatcher) Match(exact []byte) bool
func (StartEndMatcher) MatchApprox ¶
func (m StartEndMatcher) MatchApprox(approx []byte) bool
func (StartEndMatcher) Validate ¶ added in v0.6.1
func (m StartEndMatcher) Validate() error