connector

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

internal/connector/connector.go

internal/connector/factory.go

internal/connector/ftp.go

internal/connector/matcher.go

internal/connector/nitrado.go

internal/connector/sftp.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MatchesPatterns

func MatchesPatterns(path string, include, exclude []string) bool

MatchesPatterns checks if a path matches include patterns and doesn't match exclude patterns

Types

type Config

type Config struct {
	Type       string
	Host       string
	Port       int
	Username   string
	Password   string
	KeyFile    string
	Passive    bool
	TLS        bool
	APIKey     string
	ServiceID  string
	RemotePath string
	Include    []string
	Exclude    []string

	// Retry settings
	RetryAttempts int
	RetryDelay    int
	RetryBackoff  bool
}

Config holds common connector configuration

type Connector

type Connector interface {
	// Connect establishes connection to the remote server
	Connect(ctx context.Context) error

	// List returns files matching patterns at remote_path
	List(ctx context.Context) ([]FileInfo, error)

	// Download retrieves a file and writes to the provided writer
	Download(ctx context.Context, remotePath string, w io.Writer) error

	// Upload reads from reader and writes to remote path
	Upload(ctx context.Context, r io.Reader, remotePath string) error

	// Close terminates the connection
	Close() error

	// Name returns a human-readable name for logging
	Name() string
}

Connector defines the interface for all backup connectors

func NewConnector

func NewConnector(cfg Config) (Connector, error)

NewConnector instantiates the correct connector implementation based on cfg.Type.

type FTPConnector

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

FTPConnector implements Connector for FTP servers

func NewFTPConnector

func NewFTPConnector(cfg Config) *FTPConnector

NewFTPConnector creates a new FTP connector

func (*FTPConnector) Close

func (f *FTPConnector) Close() error

Close terminates the FTP connection

func (*FTPConnector) Connect

func (f *FTPConnector) Connect(ctx context.Context) error

Connect establishes FTP connection

func (*FTPConnector) Download

func (f *FTPConnector) Download(ctx context.Context, remotePath string, w io.Writer) error

Download retrieves a file from FTP

func (*FTPConnector) List

func (f *FTPConnector) List(ctx context.Context) ([]FileInfo, error)

List returns files at remote_path matching include/exclude patterns

func (*FTPConnector) Name

func (f *FTPConnector) Name() string

Name returns the connector name for logging

func (*FTPConnector) Upload

func (f *FTPConnector) Upload(ctx context.Context, r io.Reader, remotePath string) error

Upload sends a file to FTP

type FileInfo

type FileInfo struct {
	Path    string
	Size    int64
	ModTime time.Time
	IsDir   bool
}

FileInfo represents a remote file

type NitradoConnector

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

NitradoConnector implements Connector for Nitrado game servers It fetches FTP credentials from Nitrado API and delegates to FTPConnector

func NewNitradoConnector

func NewNitradoConnector(cfg Config) *NitradoConnector

NewNitradoConnector creates a new Nitrado connector

func (*NitradoConnector) Close

func (n *NitradoConnector) Close() error

Close terminates the FTP connection

func (*NitradoConnector) Connect

func (n *NitradoConnector) Connect(ctx context.Context) error

Connect fetches FTP credentials from Nitrado API and establishes FTP connection

func (*NitradoConnector) Download

func (n *NitradoConnector) Download(ctx context.Context, remotePath string, w io.Writer) error

Download delegates to FTP connector

func (*NitradoConnector) List

func (n *NitradoConnector) List(ctx context.Context) ([]FileInfo, error)

List delegates to FTP connector

func (*NitradoConnector) Name

func (n *NitradoConnector) Name() string

Name returns the connector name for logging

func (*NitradoConnector) Upload

func (n *NitradoConnector) Upload(ctx context.Context, r io.Reader, remotePath string) error

Upload delegates to FTP connector

type SFTPConnector

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

SFTPConnector implements Connector for SFTP servers

func NewSFTPConnector

func NewSFTPConnector(cfg Config) *SFTPConnector

NewSFTPConnector creates a new SFTP connector

func (*SFTPConnector) Close

func (s *SFTPConnector) Close() error

Close terminates the SFTP connection

func (*SFTPConnector) Connect

func (s *SFTPConnector) Connect(ctx context.Context) error

Connect establishes SFTP connection

func (*SFTPConnector) Download

func (s *SFTPConnector) Download(ctx context.Context, remotePath string, w io.Writer) error

Download retrieves a file from SFTP

func (*SFTPConnector) List

func (s *SFTPConnector) List(ctx context.Context) ([]FileInfo, error)

List returns files at remote_path matching include/exclude patterns

func (*SFTPConnector) Name

func (s *SFTPConnector) Name() string

Name returns the connector name for logging

func (*SFTPConnector) Upload

func (s *SFTPConnector) Upload(ctx context.Context, r io.Reader, remotePath string) error

Upload sends a file to SFTP

Jump to

Keyboard shortcuts

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