libp2pvsock

package module
v0.0.0-...-e457918 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2023 License: MIT Imports: 10 Imported by: 0

README

go-libp2p-vsock

go-libp2p's VSOCK transport

Package go-libp2p-vsock is a libp2p transport. It uses virtio-vsock enable communication channel to relays at Nitro Enclaves.

Install

go get github.com/balena/go-libp2p-vsock

Testing w/ AWS Nitro Enclaves

Prepare your AWS Nitro Enclave as documented in AWS Nitro Enclaves User Guide.

Then, create a Dockerfile at the root of this repository with:

FROM golang:1.19.5-alpine3.17 as builder
WORKDIR /build
COPY ./ .
RUN cd libp2p-vsock && go build

FROM alpine:3.17
COPY --from=builder /build/libp2p-vsock/libp2p-vsock /
CMD /libp2p-vsock -l /vsock/x/xtcp/5000

Then build the enclave:

nitro-cli build-enclave --docker-dir ./ --docker-uri libp2p-vsock:latest --output-file libp2p-vsock.eif

And run it, in debug mode:

nitro-cli run-enclave --eif-path libp2p-vsock.eif --cpu-count 1 --enclave-cid 6 --memory 256 --debug-mode

Open the debug console with:

nitro-cli console --enclave-name libp2p-vsock

At the end of the Kernel messages, you should see the following log:

2023/02/02 23:13:40 I am /vsock/6/xtcp/5000/p2p/Qmdpa...9tAN
2023/02/02 23:13:40 listening for connections
2023/02/02 23:13:40 Now run "./libp2p-vsock -l /vsock/x/xtcp/5001 -d /vsock/6/xtcp/5000/p2p/Qmdpa...9tAN" on a different terminal

Now execute the indicated command from the host:

./libp2p-vsock -l /vsock/x/xtcp/5001 -d /vsock/6/xtcp/5000/p2p/Qmdpa...9tAN
2023/02/02 23:14:51 I am /vsock/3/xtcp/5001/p2p/QmStHj...zH3R
2023/02/02 23:14:51 sender opening stream
2023/02/02 23:14:51 sender saying hello
2023/02/02 23:14:51 read reply: "Hello, world!\n"

Contribute

Feel free to join in. All welcome. Open an issue!

This repository falls under the libp2p Code of Conduct.

Want to hack on libp2p?

License

MIT © 2023 Guilherme Versiani

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*VsockTransport) error

type VsockTransport

type VsockTransport struct {
	// contains filtered or unexported fields
}

VsockTransport is the VSOCK transport.

func New

func New(upgrader transport.Upgrader, rcmgr network.ResourceManager, opts ...Option) (*VsockTransport, error)

New creates a VSOCK transport object that tracks dialers and listeners created.

func (*VsockTransport) CanDial

func (t *VsockTransport) CanDial(addr ma.Multiaddr) bool

CanDial returns true if this transport believes it can dial the given multiaddr.

func (*VsockTransport) Dial

Dial dials the peer at the remote address.

func (*VsockTransport) Listen

func (t *VsockTransport) Listen(laddr ma.Multiaddr) (transport.Listener, error)

Listen listens on the given multiaddr.

func (*VsockTransport) Protocols

func (t *VsockTransport) Protocols() []int

Protocols returns the list of terminal protocols this transport can dial.

func (*VsockTransport) Proxy

func (t *VsockTransport) Proxy() bool

Proxy always returns false for the VSOCK transport.

func (*VsockTransport) String

func (t *VsockTransport) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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