skycoin / skywire-testnet

Skywire Meshnet and VPN
https://skycoin.net/skywire
161 stars 63 forks source link

Begin implementation of 'netutil' module. #298

Open evanlinjin opened 5 years ago

evanlinjin commented 5 years ago

Background

Currently, communication between manager-node and skywire-node is done via a rpc.Client to rpc.Server relationship. However, in the future, skywire-node will need to initiate communication with manager-node (e.g. for notifications, logging and Skywire App to Manager communication).

Description

The netutil module is to be a shared library to aid communication between Skywire services. Communication can be either via Transport (or higher level interfaces), or noise.Conn.

The first structure to be implemented is netutil.RPCDuplex. This structure implements an RPC Duplex connection via a single net.Conn implementation. In other words, both ends of the connection has a rpc.Server and a rpc.Client.

type RPCDuplex struct {
    net.Conn
    *rpc.Client
    *rpc.Server
}

func NewRPCDuplex(conn net.Conn) *RPCDuplex { /* ... */ }

// Serve serves the rpc.Server via net.Conn.
func (d *RPCDuplex) Serve() { /* ... */ }

// All the other members needed should be made available from the embedded structures.

Resources

Tasks

evanlinjin commented 5 years ago

Assigned for @atang152