models

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

universal-network-adapter models

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Blob

type Blob struct {
	// путь до файла
	FilePath string
	// contains filtered or unexported fields
}

Wrapper around remote file, implementing io.ReadCloser

func (*Blob) Close

func (blob *Blob) Close() error

func (*Blob) Read

func (blob *Blob) Read(p []byte) (n int, err error)

type Credentials

type Credentials struct {
	// username
	User string
	// password
	Password string
	// sftp private key
	RsaPrivateKey string
	// sftp private key passphrase
	RsaPrivateKeyPassphrase string
	TLSConfig               *tls.Config
	TLSMode                 TLSMode
}

Credentials to authorize on remote server

type Destination

type Destination struct {
	// remote file/dir url. Should start with protocol
	Url string
	// credentials to access the remote file/dir
	Credentials *Credentials
	// connection timeout
	Timeout time.Duration
}

Model of remote file/dir on remote server to be browsed/downloaded

func NewDestination

func NewDestination(url string, credentials *Credentials, timeout *time.Duration) *Destination

Constructor for Destination

type ParsedDestination

type ParsedDestination struct {
	// remote file/dir url
	Url string
	// credentials to access the remote file/dir
	Credentials Credentials
	// Url parsed by using net/url parser
	ParsedUrl *goUrl.URL
	// connection timeout. Defaults to 30 seconds, if NewDestination is used
	Timeout time.Duration
}

Processed Destination model for internal usage in universal network adapter

func ParseDestination

func ParseDestination(destination *Destination) (*ParsedDestination, error)

parses Destination to ParsedDestination

func (*ParsedDestination) GetHost

func (pd *ParsedDestination) GetHost() string

returns URL hostname

func (*ParsedDestination) GetPassword

func (pd *ParsedDestination) GetPassword() string

returns password from parsed Credentials

func (*ParsedDestination) GetPath

func (pd *ParsedDestination) GetPath() string

returns URL path

func (*ParsedDestination) GetRsaPrivateKey

func (pd *ParsedDestination) GetRsaPrivateKey() (ssh.Signer, error)

returns RSA private key for sftp connect from parsed Credentials

func (*ParsedDestination) GetScheme

func (pd *ParsedDestination) GetScheme() string

returns URL protocol

func (*ParsedDestination) GetUser

func (pd *ParsedDestination) GetUser() string

returns user from parsed Credentials

type RemoteFile

type RemoteFile struct {
	// filename
	Name string
	// filepath
	Path string
	// remote file parsed destination model
	ParsedDestination *ParsedDestination `json:"-"`
	// file size, bytes
	Size int64
	// file modification date
	Lastmod time.Time
}

Remote file model

func NewRemoteFile

func NewRemoteFile(destination *Destination) (*RemoteFile, error)

Constructor for RemoteFile

type RemoteFileContent

type RemoteFileContent struct {
	// filename
	Name string
	// filepath
	Path string
	// io.ReadCloser to read remote file content
	Blob io.ReadCloser
}

Downloaded remote file content model

type TLSMode

type TLSMode int

TLSMode represents the FTPS connection strategy. Servers cannot support both modes on the same port.

const (
	// TLSExplicit means the client first runs an explicit command ("AUTH TLS")
	// before switching to TLS.
	TLSExplicit TLSMode = 0

	// TLSImplicit means both sides already implicitly agree to use TLS, and the
	// client connects directly using TLS.
	TLSImplicit TLSMode = 1
)

type UnaError

type UnaError struct {
	Code    int
	Message string
}

func (*UnaError) Error

func (e *UnaError) Error() string

Jump to

Keyboard shortcuts

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