MCPcopy Create free account
hub / github.com/ashkulz/NppFTP / SocketOnConnected

Method SocketOnConnected

UTCP/src/ftp_c.cpp:3291–3370  ·  view source on GitHub ↗

SocketOnConnected(SOCKET s, const char *lpszName) If the security is enabled then perform te SSL neogotiation otherwise just return a success and let the plain text FTP handles the comunication To let the server know that we are looking for SSL or TLS we need to send the following command FEAT The Feature negotiation mechanism for

Source from the content-addressed store, hash-verified

3289
3290**************************************************************/
3291int CUT_FTPClient::SocketOnConnected(SOCKET /*s*/, const char * /*lpszName*/){
3292
3293 int rt = UTE_SUCCESS;
3294
3295 bool performAuth = (m_sMode == FTPES);
3296 bool performProt = (m_sMode != FTP);
3297
3298 m_dataSecLevel = performProt?1:0; //do not call the function yet, let FTPConnect handle that after authentication
3299
3300 if (m_sMode == FTPS) { //just connect ssl
3301 rt = ConnectSSL();
3302 if (rt != UTE_SUCCESS)
3303 return OnError(rt);
3304 }
3305
3306 {
3307 // if the security is enabled then
3308 // Attempt to send the auth command
3309 rt = GetResponseCode(this);
3310
3311 if(rt == 0)
3312 return OnError(UTE_NO_RESPONSE); //no response
3313
3314 if(rt < 200 || rt > 399)
3315 return OnError(UTE_CONNECT_FAILED); //negative response
3316
3317
3318 /*
3319 // Check for abortion flag
3320 if(IsAborted())
3321 {
3322 return OnError(UTE_ABORTED);
3323 }
3324 */
3325 }
3326
3327 if (performAuth)
3328 {
3329 Send("AUTH TLS\r\n"); // Send the TLS negotiation command
3330
3331 rt = GetResponseCode(this);
3332
3333 if(rt == 0)
3334 return OnError(UTE_NO_RESPONSE); //no response
3335
3336 // check the response
3337 if(rt < 200 || rt > 399)
3338 {
3339 Send("AUTH SSL\r\n"); // Send the TLS negotiation command
3340
3341 rt = GetResponseCode(this);
3342
3343 if(rt == 0)
3344 return OnError(UTE_NO_RESPONSE); //no response
3345
3346 if(rt < 200 || rt > 399)
3347 {
3348 return OnError(UTE_CONNECT_FAIL_NO_SSL_SUPPORT); //negative response

Callers

nothing calls this directly

Calls 1

SetSecurityModeMethod · 0.45

Tested by

no test coverage detected