torutil

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 31, 2021 License: MIT Imports: 9 Imported by: 16

Documentation

Overview

Package torutil has generic utilities shared across the library.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EscapeSimpleQuotedString

func EscapeSimpleQuotedString(str string) string

EscapeSimpleQuotedString calls EscapeSimpleQuotedStringContents and then surrounds the entire string with double quotes.

func EscapeSimpleQuotedStringContents

func EscapeSimpleQuotedStringContents(str string) string

EscapeSimpleQuotedStringContents escapes backslashes, double quotes, newlines, and carriage returns in str.

func EscapeSimpleQuotedStringIfNeeded

func EscapeSimpleQuotedStringIfNeeded(str string) string

EscapeSimpleQuotedStringIfNeeded calls EscapeSimpleQuotedString only if the string contains a space, backslash, double quote, newline, or carriage return character.

func OnionServiceIDFromPrivateKey

func OnionServiceIDFromPrivateKey(key crypto.PrivateKey) string

OnionServiceIDFromPrivateKey generates the onion service ID from the given private key. This panics if the private key is not a 1024-bit crypto/*rsa.PrivateKey or github.com/cretz/bine/torutil/ed25519.KeyPair.

func OnionServiceIDFromPublicKey

func OnionServiceIDFromPublicKey(key crypto.PublicKey) string

OnionServiceIDFromPublicKey generates the onion service ID from the given public key. This panics if the public key is not a 1024-bit crypto/*rsa.PublicKey or github.com/cretz/bine/torutil/ed25519.PublicKey.

func OnionServiceIDFromV2PublicKey

func OnionServiceIDFromV2PublicKey(key *rsa.PublicKey) string

OnionServiceIDFromV2PublicKey generates a V2 service ID for the given RSA-1024 public key. Panics if not a 1024-bit key.

func OnionServiceIDFromV3PublicKey

func OnionServiceIDFromV3PublicKey(key ed25519.PublicKey) string

OnionServiceIDFromV3PublicKey generates a V3 service ID for the given ED25519 public key.

func PartitionString

func PartitionString(str string, ch byte) (string, string, bool)

PartitionString returns the two parts of a string delimited by the first occurrence of ch. If ch does not exist, the second string is empty and the resulting bool is false. Otherwise it is true.

func PartitionStringFromEnd

func PartitionStringFromEnd(str string, ch byte) (string, string, bool)

PartitionStringFromEnd is same as PartitionString except it delimts by the last occurrence of ch instead of the first.

func PublicKeyFromV3OnionServiceID

func PublicKeyFromV3OnionServiceID(id string) (ed25519.PublicKey, error)

PublicKeyFromV3OnionServiceID returns a public key for the given service ID or an error if the service ID is invalid.

func UnescapeSimpleQuotedString

func UnescapeSimpleQuotedString(str string) (string, error)

UnescapeSimpleQuotedString removes surrounding double quotes and calls UnescapeSimpleQuotedStringContents.

func UnescapeSimpleQuotedStringContents

func UnescapeSimpleQuotedStringContents(str string) (string, error)

UnescapeSimpleQuotedStringContents unescapes backslashes, double quotes, newlines, and carriage returns. Also errors if those aren't escaped.

func UnescapeSimpleQuotedStringIfNeeded

func UnescapeSimpleQuotedStringIfNeeded(str string) (string, error)

UnescapeSimpleQuotedStringIfNeeded calls UnescapeSimpleQuotedString only if str is surrounded with double quotes.

Types

This section is empty.

Directories

Path Synopsis
Package ed25519 implements Tor/BitTorrent-like ed25519 keys.
Package ed25519 implements Tor/BitTorrent-like ed25519 keys.
Package geoipembed contains embedded db files for GeoIP.
Package geoipembed contains embedded db files for GeoIP.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL