tordam

A library for peer discovery inside the Tor network
git clone https://git.parazyd.org/tordam
Log | Files | Refs | README | LICENSE

commit 42701591ffa8aea9cda274b3c77c7a8f79b128fd
parent 6c9368a6643840efd5af6a10eb3fec885b4c9ff6
Author: parazyd <parazyd@dyne.org>
Date:   Sun,  7 Mar 2021 22:35:34 +0100

Add more documentation.

Diffstat:
Mpeer.go | 14+++++++-------
Mrpc_announce.go | 1+
Msanity.go | 2++
Mtor.go | 6++++++
4 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/peer.go b/peer.go @@ -23,11 +23,11 @@ import ( // Peer is the base struct for any peer in the network. type Peer struct { - Pubkey ed25519.PublicKey - Portmap []string - Nonce string - SelfRevoke string // Our revoke key we use to update our data - PeerRevoke string // Peer's revoke key if they wish to update their data - LastSeen int64 - Trusted int // Trusted is int because of possible levels of trust + Pubkey ed25519.PublicKey // Peer's ed25519 public key + Portmap []string // Peer's port map in Tor + Nonce string // The nonce to be signed after announce init + SelfRevoke string // Our revoke key we use to update our data + PeerRevoke string // Peer's revoke key if they wish to update their data + LastSeen int64 // Timestamp of last announce + Trusted int // Trusted is int because of possible levels of trust } diff --git a/rpc_announce.go b/rpc_announce.go @@ -26,6 +26,7 @@ import ( "time" ) +// Ann is the struct for the announce JSON-RPC endpoint. type Ann struct{} // Init takes three parameters: diff --git a/sanity.go b/sanity.go @@ -40,6 +40,8 @@ func ValidateOnionAddress(addr string) error { return nil } +// ValidateOnionInternal takes someunlikelyname.onion:port as a parameter +// and validates its format. func ValidateOnionInternal(onionaddr string) error { splitOnion := strings.Split(onionaddr, ":") if len(splitOnion) != 2 { diff --git a/tor.go b/tor.go @@ -25,6 +25,8 @@ import ( "strings" ) +// newtorrc returns a torrc string that is fed as standard input to the Tor +// binary for its configuration. func newtorrc(listener, torlistener *net.TCPAddr, portmap []string) string { var pm []string @@ -46,6 +48,10 @@ HiddenServicePort %d %s listener.Port, listener.String(), strings.Join(pm, "\n")) } +// SpawnTor runs the system's Tor binary with the torrc created by newtorrc. +// It takes listener (which is the local JSON-RPC server net.TCPAddr), +// portmap (to map HiddenServicePort entries) and datadir (to store Tor files) +// as parameters. Returns exec.Cmd pointer and/or error. func SpawnTor(listener *net.TCPAddr, portmap []string, datadir string) (*exec.Cmd, error) { var err error