tAdd more documentation. - tordam - A library for peer discovery inside the Tor network HTML git clone https://git.parazyd.org/tordam DIR Log DIR Files DIR Refs DIR README DIR LICENSE --- DIR commit 42701591ffa8aea9cda274b3c77c7a8f79b128fd DIR parent 6c9368a6643840efd5af6a10eb3fec885b4c9ff6 HTML Author: parazyd <parazyd@dyne.org> Date: Sun, 7 Mar 2021 22:35:34 +0100 Add more documentation. Diffstat: M peer.go | 14 +++++++------- M rpc_announce.go | 1 + M sanity.go | 2 ++ M tor.go | 6 ++++++ 4 files changed, 16 insertions(+), 7 deletions(-) --- DIR diff --git a/peer.go b/peer.go t@@ -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 } DIR diff --git a/rpc_announce.go b/rpc_announce.go t@@ -26,6 +26,7 @@ import ( "time" ) +// Ann is the struct for the announce JSON-RPC endpoint. type Ann struct{} // Init takes three parameters: DIR diff --git a/sanity.go b/sanity.go t@@ -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 { DIR diff --git a/tor.go b/tor.go t@@ -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 t@@ -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