server

package
v0.0.32 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2021 License: Apache-2.0 Imports: 61 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PushNoteReactorChannel is the channel id sending/receiving push notes
	PushNoteReactorChannel = byte(0x32)
	// PushEndReactorChannel is the channel id for sending/receiving push endorsements
	PushEndReactorChannel = byte(0x33)
)

Variables

View Source
var (
	ErrPushTokenRequired = fmt.Errorf("push token must be provided")
	ErrMalformedToken    = fmt.Errorf("malformed token")
)

Functions

func DecodePushToken

func DecodePushToken(v string) (*remotetypes.TxDetail, error)

DecodePushToken decodes a push request token.

func MakeAndApplyPushTokenToRemote

func MakeAndApplyPushTokenToRemote(repo remotetypes.LocalRepo, args *MakeAndApplyPushTokenToRemoteArgs) error

MakeAndApplyPushTokenToRemote creates and applies signed push token(s) to each remote passed to it. It applies the token(s) to the username part of one or more URLs of a remote. Note:

  • The tokens are cached in the repocfg file.
  • A URL can have multiple tokens for different references applied to it.
  • If the target reference has an existing token, it is replaced with a new one.
  • Setting args.ResetTokens will remove all existing tokens.

func MakePushToken

func MakePushToken(key types.StoredKey, txDetail *remotetypes.TxDetail) string

MakePushToken creates a push request token

Types

type AuthenticatorFunc

type AuthenticatorFunc func(
	txDetails []*remotetypes.TxDetail,
	repo *state.Repository,
	namespace *state.Namespace,
	keepers core.Keepers,
	checkTxDetail validation.TxDetailChecker) (policy.EnforcerFunc, error)

AuthenticatorFunc describes a function for performing authentication. txDetails: The transaction details for pushed references repo: The target repository state. namespace: The target namespace. keepers: The application states keeper

type BroadcastEndorsementFunc

type BroadcastEndorsementFunc func(endorsement pushtypes.Endorsement)

BroadcastEndorsementFunc describes a function for broadcasting endorsement

type BroadcastNoteAndEndorsementFunc

type BroadcastNoteAndEndorsementFunc func(note pushtypes.PushNote) error

BroadcastNoteAndEndorsementFunc describes a function for broadcasting a push note and an endorsement of it.

type BroadcastPushNoteFunc

type BroadcastPushNoteFunc func(pushNote pushtypes.PushNote)

BroadcastPushNoteFunc describes a function for broadcasting a push note

type CreateEndorsementFunc

type CreateEndorsementFunc func(validatorKey *ed25519.Key, note pushtypes.PushNote) (*pushtypes.PushEndorsement, error)

CreateEndorsementFunc describes a function for creating an endorsement for the given push note

type CreatePushTxFunc

type CreatePushTxFunc func(noteID string) error

CreatePushTxFunc describes a function that takes a push note and creates a push transaction which is then added to the mempool.

type MakeAndApplyPushTokenToRemoteArgs

type MakeAndApplyPushTokenToRemoteArgs struct {

	// TargetRemote the name of the remote to update.
	TargetRemote string

	// TxDetail is the transaction information to include in the push token.
	TxDetail *remotetypes.TxDetail

	// PushKey is the key to sign the token.
	PushKey types.StoredKey

	// ResetTokens forces removes all tokens from all URLS before updating.
	ResetTokens bool

	Stderr io.Writer
}

MakeAndApplyPushTokenToRemoteArgs contains arguments for MakeAndApplyPushTokenToRemote

type MakeAndApplyPushTokenToRemoteFunc

type MakeAndApplyPushTokenToRemoteFunc func(targetRepo remotetypes.LocalRepo, args *MakeAndApplyPushTokenToRemoteArgs) error

MakeAndApplyPushTokenToRemoteFunc describes a function for creating, signing and applying push tokens on a repo's remote(s)

type MaybeProcessPushNoteFunc

type MaybeProcessPushNoteFunc func(note pushtypes.PushNote,
	txDetails []*remotetypes.TxDetail,
	polEnforcer policy.EnforcerFunc) error

MaybeProcessPushNoteFunc is a function for processing a push note

type Peer

type Peer interface {
	tmservice.Service
	FlushStop()

	ID() p2p.ID           // peer's cryptographic ID
	RemoteIP() net.IP     // remote IP of the connection
	RemoteAddr() net.Addr // remote address of the connection

	IsOutbound() bool   // did we dial the peer
	IsPersistent() bool // do we redial this peer when we disconnect

	CloseConn() error // close original connection

	NodeInfo() p2p.NodeInfo // peer's info
	Status() p2p.ConnectionStatus
	SocketAddr() *p2p.NetAddress // actual address of the socket

	Send(byte, []byte) bool
	TrySend(byte, []byte) bool

	Set(string, interface{})
	Get(string) interface{}
}

Peer is an interface representing a peer connected on a reactor.

type PushHandlerFunc

type PushHandlerFunc func(
	targetRepo remotetypes.LocalRepo,
	txDetails []*remotetypes.TxDetail,
	enforcer policy.EnforcerFunc) pushtypes.Handler

PushHandlerFunc describes a function for creating a push handler

type RequestContext

type RequestContext struct {
	W           http.ResponseWriter
	R           *http.Request
	TxDetails   []*types.TxDetail
	PolEnforcer policy.EnforcerFunc
	PushHandler types2.Handler
	Repo        types.LocalRepo
	RepoDir     string
	Operation   string
	ServiceName string
	GitBinPath  string
	// contains filtered or unexported fields
}

RequestContext describes a request from the git remote server

type ScheduleReSyncFunc

type ScheduleReSyncFunc func(note pushtypes.PushNote, ref string, fromBeginning bool) error

type Server

type Server struct {
	p2p.BaseReactor
	// contains filtered or unexported fields
}

Server implements types.Server. It provides a system for managing and service a git repositories through http and ssh protocols.

func New

func New(
	cfg *config.AppConfig,
	addr string,
	appLogic core.Logic,
	dht dht2.DHT,
	mempool core.Mempool,
	nodeService nodeService.Service,
	blockGetter core.BlockGetter,
) *Server

New creates an instance of Server

func (*Server) Announce

func (sv *Server) Announce(objType int, repo string, hash []byte, doneCB func(error)) bool

Announce announces a key on the DHT network

func (*Server) BroadcastMsg

func (sv *Server) BroadcastMsg(ch byte, msg []byte)

BroadcastMsg broadcast messages to peers

func (*Server) BroadcastNoteAndEndorsement

func (sv *Server) BroadcastNoteAndEndorsement(note pushtypes.PushNote) error

BroadcastNoteAndEndorsement broadcasts a push note and an endorsement of it. The node has to be a top host to broadcast an endorsement.

func (*Server) Cfg

func (sv *Server) Cfg() *config.AppConfig

Cfg returns the application config

func (*Server) CheckNote

func (sv *Server) CheckNote(note pushtypes.PushNote) error

CheckNote validates a push note

func (*Server) GetChannels

func (sv *Server) GetChannels() []*p2p.ChannelDescriptor

GetChannels implements Reactor.

func (*Server) GetDHT

func (sv *Server) GetDHT() dht2.DHT

GetDHT returns the dht service

func (*Server) GetFetcher

func (sv *Server) GetFetcher() fetcher.ObjectFetcher

GetFetcher returns the fetcher service

func (*Server) GetLogic

func (sv *Server) GetLogic() core.Logic

GetLogic returns the application logic provider

func (*Server) GetMempool

func (sv *Server) GetMempool() core.Mempool

GetMempool returns the transaction pool

func (*Server) GetPrivateValidatorKey

func (sv *Server) GetPrivateValidatorKey() *ed25519.Key

GetPrivateValidatorKey implements RepositoryManager

func (*Server) GetPushKeyGetter

func (sv *Server) GetPushKeyGetter() core.PushKeyGetter

GetPushKeyGetter implements RepositoryManager

func (*Server) GetPushPool

func (sv *Server) GetPushPool() pushtypes.PushPool

GetPushPool returns the push pool

func (*Server) GetRPCHandler

func (sv *Server) GetRPCHandler() *rpc.Handler

GetRPCHandler returns the RPC handler

func (*Server) GetRepo

func (sv *Server) GetRepo(name string) (remotetypes.LocalRepo, error)

GetRepo get a local repository

func (*Server) GetRepoState

func (sv *Server) GetRepoState(repo remotetypes.LocalRepo, options ...remotetypes.KVOption) (remotetypes.RepoRefsState, error)

GetRepoState implements RepositoryManager

func (*Server) HasRepository

func (sv *Server) HasRepository(name string) bool

HasRepository returns true if a valid repository exist for the given name

func (*Server) InitRepository

func (sv *Server) InitRepository(name string) error

InitRepository creates a bare git repository

func (*Server) Log

func (sv *Server) Log() logger.Logger

Log returns the logger

func (*Server) Receive

func (sv *Server) Receive(chID byte, peer p2p.Peer, msgBytes []byte)

Receive implements Reactor

func (*Server) SetRootDir

func (sv *Server) SetRootDir(dir string)

SetRootDir sets the directory where repositories are stored

func (*Server) Shutdown

func (sv *Server) Shutdown(ctx context.Context)

Shutdown shuts down the server

func (*Server) Start

func (sv *Server) Start() error

Start starts the server that serves the repos. Implements p2p.Reactor

func (*Server) Stop

func (sv *Server) Stop() error

Stop implements Reactor

func (*Server) TryScheduleReSync

func (sv *Server) TryScheduleReSync(note pushtypes.PushNote, ref string, fromBeginning bool) error

TryScheduleReSync may schedule a local reference for resynchronization if the pushed reference old state does not match the current network state of the reference

func (*Server) Wait

func (sv *Server) Wait()

Wait can be used by the caller to wait till the server terminates

Jump to

Keyboard shortcuts

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