Sming Framework API
Sming - Open Source framework for high efficiency WiFi SoC ESP8266 native development with C++ language.
FtpServer Class Reference
Inheritance diagram for FtpServer:
TcpServer TcpConnection

Public Member Functions

void addUser (const String &login, const String &pass)
 
bool checkUser (const String &login, const String &pass)
 
virtual bool listen (int port, bool useSsl=false)
 
void setKeepAlive (uint16_t seconds)
 
void shutdown ()
 
void setServerKeyCert (const SslKeyCertPair &serverKeyCert) SMING_DEPRECATED
 Adds SSL support and specifies the server certificate and private key. More...
 
virtual bool connect (const String &server, int port, bool useSsl=false, uint32_t sslOptions=0)
 
virtual bool connect (IPAddress addr, uint16_t port, bool useSsl=false, uint32_t sslOptions=0)
 
virtual void close ()
 
int writeString (const char *data, uint8_t apiflags=TCP_WRITE_FLAG_COPY)
 
int writeString (const String &data, uint8_t apiflags=TCP_WRITE_FLAG_COPY)
 
virtual int write (const char *data, int len, uint8_t apiflags=TCP_WRITE_FLAG_COPY)
 Base write operation. More...
 
int write (IDataSourceStream *stream)
 
uint16_t getAvailableWriteSize ()
 
void flush ()
 
void setTimeOut (uint16_t waitTimeOut)
 
IPAddress getRemoteIp () const
 
uint16_t getRemotePort () const
 
void setDestroyedDelegate (TcpConnectionDestroyedDelegate destroyedDelegate)
 Sets a callback to be called when the object instance is destroyed. More...
 
void addSslOptions (uint32_t sslOptions)
 
bool setSslClientKeyCert (const uint8_t *key, int keyLength, const uint8_t *certificate, int certificateLength, const char *keyPassword=nullptr, bool freeAfterHandshake=false) SMING_DEPRECATED
 Sets client private key, certificate and password from memory. More...
 
bool setSslClientKeyCert (const SslKeyCertPair &clientKeyCert, bool freeAfterHandshake=false) SMING_DEPRECATED
 Sets client private key, certificate and password from memory. More...
 
void freeSslClientKeyCert () SMING_DEPRECATED
 Frees the memory used for the key and certificate pair. More...
 
bool setSslKeyCert (const uint8_t *key, int keyLength, const uint8_t *certificate, int certificateLength, const char *keyPassword=nullptr, bool freeAfterHandshake=false)
 Sets private key, certificate and password from memory for the SSL connection If this methods is called from a client then it sets the client key and certificate If it is called from a server then it sets the server certificate and key. Server and Client certificates differ. Client certificate is used for identification. Server certificate is used for encrypt/decrypt the data. Make sure to use the correct certificate for the desired goal. More...
 
bool setSslKeyCert (const SslKeyCertPair &keyCert, bool freeAfterHandshake=false)
 Sets private key, certificate and password from memory for the SSL connection If this methods is called from a client then it sets the client key and certificate If it is called from a server then it sets the server certificate and key. Server and Client certificates differ. Client certificate is used for identification. Server certificate is used for encrypt/decrypt the data. Make sure to use the correct certificate for the desired goal. More...
 
void freeSslKeyCert ()
 Frees the memory used for the key and certificate pair. More...
 
void setSsl (SSL *ssl)
 
SSL * getSsl ()
 

Public Attributes

uint16_t activeClients = 0
 

Static Public Attributes

static uint16_t totalConnections
 

Protected Member Functions

TcpConnectioncreateClient (tcp_pcb *clientTcp) override
 
virtual bool onCommand (String cmd, String data, FtpServerConnection &connection)
 
virtual err_t onAccept (tcp_pcb *clientTcp, err_t err)
 
virtual void onClient (TcpClient *client)
 
virtual bool onClientReceive (TcpClient &client, char *data, int size)
 
virtual void onClientComplete (TcpClient &client, bool successful)
 
virtual void onClientDestroy (TcpConnection &connection)
 
void initialize (tcp_pcb *pcb)
 
bool internalConnect (IPAddress addr, uint16_t port)
 
virtual err_t onConnected (err_t err)
 
virtual err_t onReceive (pbuf *buf)
 
virtual err_t onSent (uint16_t len)
 
virtual err_t onPoll ()
 
virtual void onError (err_t err)
 
virtual void onReadyToSendData (TcpConnectionEvent sourceEvent)
 
virtual err_t onSslConnected (SSL *ssl)
 
err_t internalOnConnected (err_t err)
 
err_t internalOnReceive (pbuf *p, err_t err)
 
err_t internalOnSent (uint16_t len)
 
err_t internalOnPoll ()
 
void internalOnError (err_t err)
 
void internalOnDnsResponse (const char *name, LWIP_IP_ADDR_T *ipaddr, int port)
 

Protected Attributes

int sslSessionCacheSize = 50
 
size_t minHeapSize = 16384
 
bool active = true
 
Vector< TcpConnection * > connections
 
tcp_pcb * tcp = nullptr
 
uint16_t sleep = 0
 
uint16_t timeOut = USHRT_MAX
 By default a TCP connection does not have a time out. More...
 
bool canSend = true
 
bool autoSelfDestruct = true
 
SSL * ssl = nullptr
 
SSLCTX * sslContext = nullptr
 
SSL_EXTENSIONS * sslExtension = nullptr
 
bool sslConnected = false
 
uint32_t sslOptions = 0
 
SslKeyCertPair sslKeyCert
 
bool freeKeyCertAfterHandshake = false
 
SslSessionIdsslSessionId = nullptr
 
bool useSsl = false
 

Friends

class FtpServerConnection
 

Member Function Documentation

void TcpConnection::freeSslClientKeyCert ( )
inlineinherited

Frees the memory used for the key and certificate pair.

Deprecated:
Use freeSslKeyCert() instead
void TcpConnection::freeSslKeyCert ( )
inlineinherited

Frees the memory used for the key and certificate pair.

void TcpConnection::setDestroyedDelegate ( TcpConnectionDestroyedDelegate  destroyedDelegate)
inlineinherited

Sets a callback to be called when the object instance is destroyed.

Parameters
TcpServerConnectionDestroyedDelegatedestroyedDelegate - callback
void TcpServer::setServerKeyCert ( const SslKeyCertPair serverKeyCert)
inlineinherited

Adds SSL support and specifies the server certificate and private key.

Deprecated:
Use setSslKeyCert() instead
bool TcpConnection::setSslClientKeyCert ( const uint8_t *  key,
int  keyLength,
const uint8_t *  certificate,
int  certificateLength,
const char *  keyPassword = nullptr,
bool  freeAfterHandshake = false 
)
inlineinherited

Sets client private key, certificate and password from memory.

Deprecated:
Use setSslKeyCert(const uint8_t*, int, const uint8_t*, int, const char*, bool) instead
Note
This method makes copy of the data.
Parameters
constuint8_t *keyData
intkeyLength
constuint8_t *certificateData
intcertificateLength
constchar *keyPassword
boolfreeAfterHandshake
Returns
bool true of success, false or failure
bool TcpConnection::setSslClientKeyCert ( const SslKeyCertPair clientKeyCert,
bool  freeAfterHandshake = false 
)
inlineinherited

Sets client private key, certificate and password from memory.

Deprecated:
Use setSslKeyCert(const SslKeyCertPair&, bool) instead
Note
This method passes the certificate key chain by reference
Parameters
SSLKeyCertPair
boolfreeAfterHandshake
Returns
bool true of success, false or failure
bool TcpConnection::setSslKeyCert ( const uint8_t *  key,
int  keyLength,
const uint8_t *  certificate,
int  certificateLength,
const char *  keyPassword = nullptr,
bool  freeAfterHandshake = false 
)
inlineinherited

Sets private key, certificate and password from memory for the SSL connection If this methods is called from a client then it sets the client key and certificate If it is called from a server then it sets the server certificate and key. Server and Client certificates differ. Client certificate is used for identification. Server certificate is used for encrypt/decrypt the data. Make sure to use the correct certificate for the desired goal.

Note
This method makes copy of the data.
Parameters
constuint8_t *keyData
intkeyLength
constuint8_t *certificateData
intcertificateLength
constchar *keyPassword
boolfreeAfterHandshake
Returns
bool true of success, false or failure
bool TcpConnection::setSslKeyCert ( const SslKeyCertPair keyCert,
bool  freeAfterHandshake = false 
)
inlineinherited

Sets private key, certificate and password from memory for the SSL connection If this methods is called from a client then it sets the client key and certificate If it is called from a server then it sets the server certificate and key. Server and Client certificates differ. Client certificate is used for identification. Server certificate is used for encrypt/decrypt the data. Make sure to use the correct certificate for the desired goal.

Note
This method passes the certificate key chain by reference
Parameters
SSLKeyCertPair
boolfreeAfterHandshake
Returns
bool true of success, false or failure
virtual int TcpConnection::write ( const char *  data,
int  len,
uint8_t  apiflags = TCP_WRITE_FLAG_COPY 
)
virtualinherited

Base write operation.

Parameters
data
len
apiflagsTCP_WRITE_FLAG_COPY, TCP_WRITE_FLAG_MORE
Return values
int-1 on error

Reimplemented in FtpDataStream.

Member Data Documentation

uint16_t TcpConnection::timeOut = USHRT_MAX
protectedinherited

By default a TCP connection does not have a time out.

uint16_t TcpServer::totalConnections
staticinherited
Deprecated:
not updated by framework