tordam

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

commit 3e58d2fb3e30da2e28c8fbc94731f64ecd645ef9
parent 8596a0e87151c540e7f189a25434aa800dbc1f02
Author: parazyd <parazyd@dyne.org>
Date:   Mon,  8 Mar 2021 00:20:16 +0100

Add JSON to Peer struct.

Diffstat:
Mcmd/tor-dam/tor-dam.go | 11+++++++++--
Mpeer.go | 14+++++++-------
2 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/cmd/tor-dam/tor-dam.go b/cmd/tor-dam/tor-dam.go @@ -21,6 +21,7 @@ import ( "crypto/ed25519" "crypto/rand" "encoding/base64" + "encoding/json" "flag" "fmt" "io/ioutil" @@ -41,7 +42,7 @@ var ( generate = flag.Bool("g", false, "(Re)generate keys and exit") portmap = flag.String("m", "13010:13010,13011:13011", "Map of ports forwarded to/from Tor") listen = flag.String("l", "127.0.0.1:49371", "Local listen address") - datadir = flag.String("datadir", os.Getenv("HOME")+"/.dam", "Data directory") + datadir = flag.String("d", os.Getenv("HOME")+"/.dam", "Data directory") seeds = flag.String("s", "p7qaewjgnvnaeihhyybmoofd5avh665kr3awoxlh5rt6ox743kjdr6qd.onion:49371", "List of initial peers (comma-separated)") @@ -181,8 +182,14 @@ func main() { wg.Wait() if succ < 1 { - log.Fatal("No successful announces.") + log.Println("No successful announces.") } else { log.Printf("Successfully announced to %d peers.", succ) } + + j, err := json.Marshal(tordam.Peers) + if err != nil { + log.Fatal(err) + } + log.Println(string(j)) } 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 // 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 + Pubkey ed25519.PublicKey `json:"pubkey"` // Peer's ed25519 public key + Portmap []string `json:"portmap"` // Peer's port map in Tor + Nonce string `json:"nonce"` // The nonce to be signed after announce init + SelfRevoke string `json:"selfrevoke"` // Our revoke key we use to update our data + PeerRevoke string `json:"peerrevoke"` // Peer's revoke key if they wish to update their data + LastSeen int64 `json:"lastseen"` // Timestamp of last announce + Trusted int `json:"trusted"` // Trusted is int because of possible levels of trust }