venti

package module
v0.0.0-...-8b31643 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2020 License: ISC Imports: 9 Imported by: 0

README

Venti is a group of libraries for writing venti servers and clients.

This is not mature enough for real use, yet.

Documentation

Overview

Package venti is a group of libraries for writing venti(7) servers.

Index

Constants

View Source
const MaxFileSize = (1 << 48) - 1

MaxFileSize is the biggest file venti supports.

Variables

View Source
var (
	// ErrBadVersion is sent to the client if they attempt to initiate a
	// connection with no common version.
	ErrBadVersion = fmt.Errorf("no common version")
)

Functions

func ListenAndServe

func ListenAndServe(addr string, h Handshake) error

ListenAndServe listens on the TCP address "addr" and calls Serve on the resulting net.Listener.

func ParseVersion

func ParseVersion(ver string) []string

ParseVersion returns the versions out of a venti version string.

func Serve

func Serve(l net.Listener, h Handshake) error

Serve accepts connections on l and runs the supplied Handshake function and, if successful, the returned Handler.

Types

type Client

type Client struct {
	net.Conn

	Version string
	// contains filtered or unexported fields
}

func Dial

func Dial(addr string) (*Client, error)

func NewClient

func NewClient(conn net.Conn) (*Client, error)

func (*Client) Close

func (c *Client) Close() error

func (*Client) Ping

func (c *Client) Ping() error

func (*Client) Read

func (c *Client) Read(t Type, s Score, ct int64) (io.ReadCloser, error)

func (*Client) Sync

func (c *Client) Sync() error

func (*Client) Write

func (c *Client) Write(t Type, r io.Reader) (Score, error)

type Entry

type Entry struct {
	Gen        uint32
	PoiterSize uint32
	DataSize   uint32
	Type       uint8
	Flags      uint8
	Size       uint64
	Score      Score
}

Entry is a stub from libventi.h

type Handler

type Handler interface {
	// Read requests the block identified by the provided score, type pair. The
	// count argument is the maximum expected size of the response.
	//
	// If the supplied io.Reader satifies the io.ReadCloser interface, Close will be
	// called when its consumed.
	Read(score Score, kind Type, count int64) (io.Reader, error)

	// Write requests that the provided data of the given type be written.
	// The returned score should be a hash of the data using the negotiated
	// algorithm.
	//
	// The passed-in io.Reader is only valid for the length of the function
	// call and should not be retained.
	Write(kind Type, data io.Reader) (Score, error)

	// Sync is called when the client has requested that the previous writes be
	// persisted. It should delay returning until this is done.
	Sync() error
}

Handler is the interface a venti server implementation must provide.

Semantics documented here take precidence over those described in venti(7).

type Handshake

type Handshake func(*Thello) (*Rhello, Handler, error)

Handshake takes the parameters sent by the client's hello, and returns a Handler if it can continue, or an error otherwise.

If a nil is returned instead of an Rhello struct, a default handshaking function will be used.

type Rhello

type Rhello struct {
	// SID is the identity of the server.
	SID string

	// Crypto and Codec are the response to the crypto and compression
	// negotiation.
	Crypto uint8
	Codec  uint8
}

Rhello is the server's response to a Thello.

All current implementations ignore all these fields.

type Root

type Root struct {
	Name      string
	Type      []byte
	Score     Score
	BlockSize uint32
	Prev      Score
}

Root is a stub from libventi.h

type Score

type Score []byte

Score is the hash of a block.

Currently the score function clients recognize is SHA1.

func ParseScore

func ParseScore(s string) (Score, error)

ParseScore returns a score from its hex representation

func (Score) String

func (s Score) String() string

String returns the hex representation of a score

type Thello

type Thello struct {
	// UID is the identity of the connecting user.
	UID string
	// Strength is flags to negotiate authentication, encryption, and
	// compression.
	Strength uint8

	// Crypto and Codec are arguments to the negotiation indicated by Strength
	Crypto []byte
	Codec  []byte
}

Thello is the client's hello message.

All current implementations ignore all these fields.

type Type

type Type byte

Type is a stub from libventi.h

const (
	VtData Type = iota << 3
	VtDir
	VtRoot
)

These are the Type constants.

Directories

Path Synopsis
cmd
devnull
Devnull is a reimplementation of src/venti/cmd/devnull.c.
Devnull is a reimplementation of src/venti/cmd/devnull.c.
errsrv
Errsrv returns an error for all messages besides the initial handshake and pings.
Errsrv returns an error for all messages besides the initial handshake and pings.
ping
Ping pings a venti server.
Ping pings a venti server.
internal
msg
Package msg is all the wire types and their packing.
Package msg is all the wire types and their packing.
pack
Package pack is the message packing scheme for venti, and some convenience functions for reading/writing venti packets.
Package pack is the message packing scheme for venti, and some convenience functions for reading/writing venti packets.

Jump to

Keyboard shortcuts

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