sshserver

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GeneralBranch      = 0
	ProtectedBranch    = 10
	ArchivedBranch     = 20
	ConfidentialBranch = 30
)
View Source
const (
	DefaultMaxTimeout  = 2 * time.Hour
	DefaultIdleTimeout = 5 * time.Minute
)
View Source
const (
	REQUIRED int = iota
	NOARG
	OPTIONAL
)

option argument type

View Source
const (
	DefaultUser       = "zeta"
	ServeCommand      = "zeta-serve"
	AnonymousUserName = "Anonymous"
)

Variables

View Source
var (
	ErrNilArgs       = errors.New("argv is nil")
	ErrUnExpectedArg = errors.New("unexpected argument '-'")
)

error

View Source
var (
	ErrPathNecessary = errors.New("path is necessary")
)
View Source
var (
	ErrRequiredContext = errors.New("required context")
)

Functions

func ZetaEncodeVND

func ZetaEncodeVND(w io.Writer, a any)

Types

type Addr

type Addr struct {
	IP   string
	Path string
	Port int
}

type Command

type Command interface {
	ParseArgs(args []string) error
	Exec(ctx *RunCtx) int
}

func NewCommand

func NewCommand(args []string) (Command, error)

type LsRemote

type LsRemote struct {
	Path      string
	Reference string
}

zeta-serve ls-remote "group/mono-zeta" --reference "${REFNAME}"

func (*LsRemote) Exec

func (c *LsRemote) Exec(ctx *RunCtx) int

func (*LsRemote) ParseArgs

func (c *LsRemote) ParseArgs(args []string) error

type Metadata

type Metadata struct {
	Path       string
	Revision   string
	Have       plumbing.Hash
	DeepenFrom plumbing.Hash
	Deepen     int
	Depth      int
	Batch      bool
	Sparse     bool
}

func (*Metadata) Exec

func (c *Metadata) Exec(ctx *RunCtx) int

func (*Metadata) ParseArgs

func (c *Metadata) ParseArgs(args []string) error

type Objects

type Objects struct {
	Path   string
	OID    plumbing.Hash
	Offset int64
	Batch  bool
	Share  bool
}

func (*Objects) Exec

func (c *Objects) Exec(ctx *RunCtx) int

func (*Objects) ParseArgs

func (c *Objects) ParseArgs(args []string) error

type ParseArgs

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

ParseArgs todo

func (*ParseArgs) Add

func (p *ParseArgs) Add(longName string, rule int, shortName rune) *ParseArgs

Add option

func (*ParseArgs) Parse

func (p *ParseArgs) Parse(args []string, fn ParseOptionHandler) error

func (*ParseArgs) Unresolved

func (p *ParseArgs) Unresolved(index int) (string, bool)

Unresolved todo

type ParseOptionHandler

type ParseOptionHandler func(index rune, nextArg string, raw string) error

type Push

type Push struct {
	Path       string
	Reference  string
	OID        plumbing.Hash
	Size       int64
	OldRev     plumbing.Hash
	NewRev     plumbing.Hash
	BatchCheck bool
}

func (*Push) Exec

func (c *Push) Exec(ctx *RunCtx) int

func (*Push) ParseArgs

func (c *Push) ParseArgs(args []string) error

type RunCtx

type RunCtx struct {
	S       *Server
	Session *Session
}

type Server

type Server struct {
	*ServerConfig
	// contains filtered or unexported fields
}

zeta co zeta@zeta.io:zeta-dev/zeta

func NewServer

func NewServer(sc *ServerConfig) (*Server, error)

func (*Server) BatchCheck

func (s *Server) BatchCheck(e *Session, refname string) int

func (*Server) BatchMetadata

func (s *Server) BatchMetadata(e *Session, depth int) int

func (*Server) BatchObjects

func (s *Server) BatchObjects(e *Session) int

func (*Server) BranchPush

func (s *Server) BranchPush(e *Session, branchName string, oldRev, newRev plumbing.Hash) int

func (*Server) FetchMetadata

func (s *Server) FetchMetadata(e *Session, c *Metadata) int

func (*Server) GetObject

func (s *Server) GetObject(e *Session, oid plumbing.Hash, offset int64) int

func (*Server) GetSparseMetadata

func (s *Server) GetSparseMetadata(e *Session, c *Metadata) int

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() error

func (*Server) LsBranchReference

func (s *Server) LsBranchReference(e *Session, branchName string) int

func (*Server) LsRemote

func (s *Server) LsRemote(e *Session, repoPath, refname string) int

func (*Server) LsTagReference

func (s *Server) LsTagReference(e *Session, tagName string) int

func (*Server) NewSession

func (s *Server) NewSession(se ssh.Session) (*Session, error)

func (*Server) OnKey

func (s *Server) OnKey(ctx ssh.Context, key ssh.PublicKey) bool

func (*Server) OnSession

func (s *Server) OnSession(sess ssh.Session)

func (*Server) Push

func (s *Server) Push(e *Session, referenceName string, oldRev, newRev plumbing.Hash) int

func (*Server) PutObject

func (s *Server) PutObject(e *Session, refname string, oid plumbing.Hash, compressedSize int64) int

func (*Server) ShareObjects

func (s *Server) ShareObjects(e *Session) int

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

func (*Server) TagPush

func (s *Server) TagPush(e *Session, tagName string, oldRev, newRev plumbing.Hash) int

type ServerConfig

type ServerConfig struct {
	Listen          string          `toml:"listen"`
	Repositories    string          `toml:"repositories"`
	Endpoint        string          `toml:"endpoint"`
	MaxTimeout      serve.Duration  `toml:"max_timeout,omitempty"`
	IdleTimeout     serve.Duration  `toml:"idle_timeout,omitempty"`
	BannerVersion   string          `toml:"banner_version,omitempty"`
	HostPrivateKeys []string        `toml:"host_private_keys"` // private keys
	DecryptedKey    string          `toml:"decrypted_key,omitempty"`
	Cache           *serve.Cache    `toml:"cache,omitempty"`
	DB              *serve.Database `toml:"database,omitempty"`
	ZetaOSS         *serve.OSS      `toml:"oss,omitempty"`
}

func NewServerConfig

func NewServerConfig(file string, expandEnv bool) (*ServerConfig, error)

type Session

type Session struct {
	ssh.Session
	*SessionCtx
	// contains filtered or unexported fields
}

func (*Session) ExitError

func (e *Session) ExitError(err error) int

func (*Session) ExitFormat

func (e *Session) ExitFormat(code int, format string, a ...any) int

func (*Session) Getenv

func (e *Session) Getenv(k string) string

func (*Session) HasEnv

func (e *Session) HasEnv(k string) bool

func (*Session) LookupEnv

func (e *Session) LookupEnv(k string) (string, bool)

func (*Session) Read

func (e *Session) Read(data []byte) (int, error)

Read reads up to len(data) bytes from the channel.

func (*Session) W

func (e *Session) W(message string) string

func (*Session) Write

func (e *Session) Write(data []byte) (int, error)

Write writes len(data) bytes to the channel.

func (*Session) WriteError

func (e *Session) WriteError(format string, args ...any)

WriteError: format error after write to session.Stderr

type SessionCtx

type SessionCtx struct {
	UserName        string
	DisplayName     string
	UID             int64
	KID             int64
	SessionID       string
	ClientVersion   string
	UniqueID        int64
	KeyType         string
	Fingerprint     string
	IsDeployKey     bool
	RemoteAddress   *Addr
	LocalAddress    *Addr
	IsAdministrator bool
}

Directories

Path Synopsis
Package rainbow prints texts in beautiful rainbows in terminal.
Package rainbow prints texts in beautiful rainbows in terminal.

Jump to

Keyboard shortcuts

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