Documentation ¶
Overview ¶
Based on https://github.com/pkg/sftp/tree/master/examples/go-sftp-server An example SFTP server implementation using the golang SSH package. Serves the whole filesystem visible to the user, and has a hard-coded username and password, so not for real use!
Index ¶
- Constants
- Variables
- func CreateSFTPServer(workdir string) sftpserver
- func DefaultFTPConfig() *ftpConfiguration
- type AuthenticationMethod
- type BufferedConn
- type ConnectionAndSessionInstance
- type ConnectionInstance
- type ConnectionType
- type ErrorType
- type FTPConfiguration
- type FTPType
- type FileNameGeneration
- type Handler
- type LINEBREAK
- type ReadFilePolicy
- type SecureConnectionOptions
- type Session
- type TCPClientConfiguration
- type TCPServerConfiguration
Constants ¶
View Source
const TESTSTRING = "٤ḞԍНǏ𝙅ƘԸⲘ"
Variables ¶
View Source
var DefaultFTPClientTimings = TCPServerConfiguration{ Timeout: time.Second * 5, PollInterval: time.Second * 60, }
View Source
var DefaultTCPClientSettings = TCPClientConfiguration{ Timeout: time.Second * 3, Deadline: time.Millisecond * 200, FlushBufferTimoutMs: 500, PollInterval: time.Second * 60, SessionAfterFirstByte: true, SessionInitationTimeout: time.Second * 0, SourceIP: "", }
View Source
var DefaultTCPServerSettings = TCPServerConfiguration{ Timeout: time.Second * 3, Deadline: time.Millisecond * 200, FlushBufferTimoutMs: 500, PollInterval: time.Second * 60, SessionAfterFirstByte: true, SessionInitationTimeout: time.Second * 0, }
Functions ¶
func CreateSFTPServer ¶ added in v0.4.3
func CreateSFTPServer(workdir string) sftpserver
func DefaultFTPConfig ¶ added in v0.4.1
func DefaultFTPConfig() *ftpConfiguration
Types ¶
type AuthenticationMethod ¶ added in v0.4.1
type AuthenticationMethod int
const PASSWORD AuthenticationMethod = 1
const PUBKEY AuthenticationMethod = 2
type BufferedConn ¶ added in v0.2.5
type BufferedConn struct { net.Conn // So that most methods are embedded // contains filtered or unexported fields }
-------------------------------------------------------------------------------------------- BufferedConn wrapping the net.Conn yet compatible for better reading performance and a peek preview. --------------------------------------------------------------------------------------------
func (BufferedConn) FirstByteOrError ¶ added in v0.2.5
func (b BufferedConn) FirstByteOrError(howLong time.Duration) error
type ConnectionAndSessionInstance ¶
type ConnectionAndSessionInstance interface { Connect() error ConnectionInstance Session }
func CreateNewTCPClient ¶
func CreateNewTCPClient(hostname string, port int, lowLevelProtocol protocol.Implementation, proxy ConnectionType, timing ...TCPClientConfiguration) ConnectionAndSessionInstance
type ConnectionInstance ¶
type ConnectionInstance interface { // Send data directly from instance. This will not work if the instance Send(data [][]byte) (int, error) //Receive data directly from instance. This will not work if the instance handles many connections like TCP-Servers Receive() ([]byte, error) // Run - Main-Loop Run(handler Handler) // Stop the main-loop of the Run-handler Stop() // Retrieve a session by IP. Do not use this for a normal protocol conversion of a server... Can return nil FindSessionsByIp(ip string) []Session }
func CreateNewTCPServerInstance ¶
func CreateNewTCPServerInstance(listeningPort int, protocolReceiveve protocol.Implementation, connectionType ConnectionType, maxConnections int, timingConfig ...TCPServerConfiguration) ConnectionInstance
func CreateSFTPClient ¶ added in v0.4.2
type ConnectionType ¶ added in v0.2.5
type ConnectionType int
const ( NoLoadBalancer ConnectionType = 1 HAProxySendProxyV2 ConnectionType = 2 )
type ErrorType ¶
type ErrorType int
const ( ErrorConnect ErrorType = 1 ErrorSend ErrorType = 2 ErrorReceive ErrorType = 3 ErrorDisconnect ErrorType = 4 ErrorInternal ErrorType = 5 ErrorConnectionLimit ErrorType = 6 ErrorAccept ErrorType = 7 // error for Server ErrorMaxConnections ErrorType = 8 ErrorCreateSession ErrorType = 9 // server only ErrorConfiguration ErrorType = 10 // Error in configuration ErrorLogin ErrorType = 11 )
type FTPConfiguration ¶ added in v0.4.1
type FileNameGeneration ¶
type FileNameGeneration int
const ( Default FileNameGeneration = 1 TimeStamp FileNameGeneration = 1 )
type Handler ¶
type Handler interface { //DataReceived event is triggered whenever the underlying protocol delivered a complete block(file/transmission) of data DataReceived(session Session, data []byte, receiveTimestamp time.Time) error // Connected event is triggered when connection is established. For client as well as for servers. For clients in addition every time the connection had // to be reestablished. If this method returns anything other but null, the connections // is declined and the thread ends Connected(session Session) error // Disconnected event is triggered when connection // is terminated. //For Servers: when the client ends the session // For clients: when the only client connection ends (inc.eof) Disconnected(session Session) // Error is called from async process (Run) when // status messages regarding the connection is available Error(session Session, typeOfError ErrorType, err error) }
type LINEBREAK ¶ added in v0.4.2
type LINEBREAK int
const LINEBREAK_CR LINEBREAK = 0x0d
const LINEBREAK_CRLF LINEBREAK = 0x0d0a
const LINEBREAK_LF LINEBREAK = 0x0a
type ReadFilePolicy ¶
type ReadFilePolicy int
const ( ReadAndLeaveFile ReadFilePolicy = 1 DeleteWhenRead ReadFilePolicy = 2 RenameWhenRead ReadFilePolicy = 3 )
type SecureConnectionOptions ¶ added in v0.2.3
type SecureConnectionOptions struct {
PublicKey string
}
type TCPClientConfiguration ¶ added in v0.4.0
type TCPClientConfiguration struct { Timeout time.Duration Deadline time.Duration FlushBufferTimoutMs int PollInterval time.Duration SessionAfterFirstByte bool SessionInitationTimeout time.Duration SourceIP string }
func (TCPClientConfiguration) SetSourceIP ¶ added in v0.4.0
func (s TCPClientConfiguration) SetSourceIP(sourceIP string) TCPClientConfiguration
Source Files ¶
Click to show internal directories.
Click to hide internal directories.