Documentation ¶
Index ¶
- Variables
- func BasicAuth(username, password string) string
- func BasicAuthHeader(username, password string) string
- func GenerateAuthToken() (string, error)
- func New(host host.Host, dealLogger *logs.DealLogger, opts ...Option) *httpTransport
- type AuthTokenDB
- func (db *AuthTokenDB) Delete(ctx context.Context, authToken string) error
- func (db *AuthTokenDB) DeleteExpired(ctx context.Context, before time.Time) ([]AuthValue, error)
- func (db *AuthTokenDB) Get(ctx context.Context, authToken string) (*AuthValue, error)
- func (db *AuthTokenDB) Put(ctx context.Context, authToken string, val AuthValue) error
- type AuthValue
- type EventListenerFn
- type Libp2pCarServer
- func (m Libp2pCarServer) CancelTransfer(ctx context.Context, id string) (*types.TransferState, error)
- func (m Libp2pCarServer) Get(id string) (*Libp2pTransfer, error)
- func (s *Libp2pCarServer) ID() peer.ID
- func (m Libp2pCarServer) Matching(match MatchFn) ([]*Libp2pTransfer, error)
- func (s *Libp2pCarServer) Start(ctx context.Context) error
- func (s *Libp2pCarServer) Stop(ctx context.Context) error
- func (m Libp2pCarServer) Subscribe(cb EventListenerFn) UnsubFn
- type Libp2pTransfer
- type MatchFn
- type Option
- type ServerConfig
- type UnsubFn
Constants ¶
This section is empty.
Variables ¶
var ErrTokenNotFound = errors.New("auth token not found")
ErrTokenNotFound is returned when an auth token is not found in the database
var ErrTransferNotFound = errors.New("transfer not found")
Functions ¶
func BasicAuth ¶
Copied from https://github.com/golang/go/blob/16d6a5233a183be7264295c66167d35c689f9372/src/net/http/client.go#L413-L421
See 2 (end of page 4) https://www.ietf.org/rfc/rfc2617.txt "To receive authorization, the client sends the userid and password, separated by a single colon (":") character, within a base64 encoded string in the credentials." It is not meant to be urlencoded.
func BasicAuthHeader ¶
func GenerateAuthToken ¶
Types ¶
type AuthTokenDB ¶
type AuthTokenDB struct {
// contains filtered or unexported fields
}
AuthTokenDB keeps a database of auth tokens with associated data
func NewAuthTokenDB ¶
func NewAuthTokenDB(ds datastore.Batching) *AuthTokenDB
func (*AuthTokenDB) Delete ¶
func (db *AuthTokenDB) Delete(ctx context.Context, authToken string) error
Delete auth token from the datastore
func (*AuthTokenDB) DeleteExpired ¶
Delete expired auth tokens and return the values for expired tokens
type EventListenerFn ¶
type EventListenerFn func(id string, st types.TransferState)
type Libp2pCarServer ¶
type Libp2pCarServer struct {
// contains filtered or unexported fields
}
Libp2pCarServer serves deal data by matching an auth token to the root CID of a DAG in a blockstore, and serving the data as a CAR
func NewLibp2pCarServer ¶
func NewLibp2pCarServer(h host.Host, auth *AuthTokenDB, bstore blockstore.Blockstore, cfg ServerConfig) *Libp2pCarServer
func (Libp2pCarServer) CancelTransfer ¶
func (m Libp2pCarServer) CancelTransfer(ctx context.Context, id string) (*types.TransferState, error)
CancelTransfer cancels the transfer with the given id (closing its read / write pipe), and waits for the error or completed event to be fired before returning. It returns the state that the transfer is in after being canceled (either completed or errored out).
func (Libp2pCarServer) Get ¶
func (m Libp2pCarServer) Get(id string) (*Libp2pTransfer, error)
Get gets a transfer by id. Returns ErrTransferNotFound if there is no active transfer with that id.
func (*Libp2pCarServer) ID ¶
func (s *Libp2pCarServer) ID() peer.ID
func (Libp2pCarServer) Matching ¶
func (m Libp2pCarServer) Matching(match MatchFn) ([]*Libp2pTransfer, error)
Matching returns all transfers selected by the match function
func (Libp2pCarServer) Subscribe ¶
func (m Libp2pCarServer) Subscribe(cb EventListenerFn) UnsubFn
type Libp2pTransfer ¶
type Libp2pTransfer struct { ID string PayloadCid cid.Cid ProposalCid cid.Cid CreatedAt time.Time AuthToken string LocalAddr string RemoteAddr string // contains filtered or unexported fields }
Libp2pTransfer keeps track of a data transfer
func (*Libp2pTransfer) State ¶
func (t *Libp2pTransfer) State() types.TransferState
type MatchFn ¶
type MatchFn func(xfer *Libp2pTransfer) (bool, error)
type ServerConfig ¶
type ServerConfig struct { BlockInfoCacheManager car.BlockInfoCacheManager ThrottleLimit uint }