p2p

command module
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2026 License: MIT Imports: 15 Imported by: 0

README

p2p - implementing a peer-to-peer network client on Golnag

Specification

Common information about each peer
  1. Its ID in UUID format.
  2. The port is open for the connections.

There will be more in the future:

  • Available files.
Exploring
UDP Multicasting

To use multicast UDP set at least multicast filed in the config.

All available params:

explorer:
  multicast:
    address: 235.5.5.11
    port: 8001
    interface-name: wlan0 # system name of interface (`ip a` on Unix or `ipconfig` on Windows)

[!IMPORTANT] Peers must use the same multicast UDP addresses and ports to detect each other.

Read more there.

UDP Broadcasting

To use broadcast UDP set at least broadcast filed in the config.

All available params:

explorer:
  broadcast:
    address: 255.255.255.255
    port: 8001
Communication

The current implementation uses WebSocket as a communication protocol and Protobuf to describe unified data representation schemes in binary format.

All peers must listen http trafik on the selected port and have at least 2 endpoits:

  1. /ping - return 200 OK if peer ready to communicate else 503 Status Service Unavailable.
  2. /ws - requires specifying the PeerID in the header, which should identify the client.
Http handshake on /ws endpoint
  1. Client send GET request with self ID in the PeerID in the header.
  2. Server searches for the incoming PeerID in its own database of peers.
    • if found send a response with the necessary headers, which are defined by the WebSocket specification and upgrade connection to WebScoket.
    • else return 403 Forbidden.
WebScoket messaging

After upgrading the connection to WebSocker, peers must send and wait for messages that are described by the Message message in the proto/message.proto file.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
internal
config
Package config provide struct that are representatio of service configuration.
Package config provide struct that are representatio of service configuration.
server
Package server contains intarface which define schema of exchange between peers
Package server contains intarface which define schema of exchange between peers

Jump to

Keyboard shortcuts

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