pie

package
v0.0.0-...-eea8d2e Latest Latest
Warning

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

Go to latest
Published: May 17, 2022 License: GPL-3.0 Imports: 20 Imported by: 1

Documentation

Index

Constants

View Source
const (
	KSize = 24
	Alpha = 3
)
View Source
const (
	IDLen             = KSize
	UserCertHashLen   = 20
	ServerCertHashLen = 50
)
View Source
const (
	MetaDataRedundancy = 12
	FileDataRedundancy = 4
)
View Source
const (
	UserTLSProto    = "pie-q-u-1"
	TrackerTLSProto = "pie-q-t-1"
)
View Source
const (
	SessErrNoReason = iota
	SessErrNotFound
)
View Source
const (
	MaxMessageLen = 2 * 1024 * 1024
)

Variables

View Source
var (
	ErrProtoEOF   = errors.New("protobuf bytes EOF")
	ErrMsgTooLong = errors.New("message too long")
	ErrEmptyMsg   = errors.New("empty message")
	ErrInvalidMsg = errors.New("invalid message")
)
View Source
var (
	ErrNoAddr = errors.New("no available address")
)
View Source
var (
	Logger = &log.Logger{}
)

Functions

func CloseLogFile

func CloseLogFile()

func GenerateKeyPair

func GenerateKeyPair() (*tls.Certificate, []byte, []byte, error)

func HashBytes

func HashBytes(data []byte, hashLen int) []byte

HashBytes : max length of output is 128 bytes

func Log

func Log(noLog []bool, v ...any)

func MaxInt

func MaxInt(a, b int) int

func MinInt

func MinInt(a, b int) int

func SetLogOutput

func SetLogOutput(output string)

func X509KeyPair

func X509KeyPair(certPEM, keyPEM []byte) (*tls.Certificate, error)

Types

type ID

type ID big.Int

func (*ID) Scan

func (i *ID) Scan(value any) error

func (ID) Value

func (i ID) Value() (driver.Value, error)

type IDA

type IDA [IDLen]byte

type Server

type Server struct {
	Listener quic.EarlyListener
	CertHash []byte
}

func ListenNet

func ListenNet(listenAddr string, tlsConfig *tls.Config, quicConfig_ *quic.Config) (*Server, error)

func (*Server) AcceptSession

func (s *Server) AcceptSession(ctx context.Context, noLog ...bool) (*Session, error)

func (*Server) Close

func (s *Server) Close()

func (*Server) VerifyClientCert

func (s *Server) VerifyClientCert(clientCertDER []byte, serverCertSign []byte) error

type Session

type Session struct {
	Session quic.EarlySession
}

func Connect

func Connect(ctx context.Context, tlsConfig *tls.Config, addrList ...string) (*Session, error)

func (*Session) AcceptStream

func (s *Session) AcceptStream(ctx context.Context, recvBuf []byte, noLog ...bool) (*Stream, error)

func (*Session) Close

func (s *Session) Close(errCode uint64)

func (*Session) GetPeerIDByCertHash

func (s *Session) GetPeerIDByCertHash() []byte

func (*Session) OpenStream

func (s *Session) OpenStream(recvBuf ...[]byte) (*Stream, error)

func (*Session) SendCert

func (s *Session) SendCert(cert *tls.Certificate, id ...[]byte) error

type Stream

type Stream struct {
	Stream quic.Stream
	// contains filtered or unexported fields
}

func NewStream

func NewStream(stream quic.Stream, recvBufArg ...[]byte) *Stream

func (*Stream) Close

func (s *Stream) Close()

func (*Stream) RecvData

func (s *Stream) RecvData(deadline time.Time, noLog ...bool) ([]byte, int, int, error)

func (*Stream) RecvMessage

func (s *Stream) RecvMessage(deadline time.Time) (*pb.NetMessage, error)

func (*Stream) SendData

func (s *Stream) SendData(data []byte, deadline time.Time) error

func (*Stream) SendMessage

func (s *Stream) SendMessage(message *pb.NetMessage) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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