forked from wolfSSL/wolfssl
add server_ready file to externally monitor example server for ready to accept, -r option
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -40,6 +40,7 @@ examples/client/client
|
|||||||
examples/echoclient/echoclient
|
examples/echoclient/echoclient
|
||||||
examples/echoserver/echoserver
|
examples/echoserver/echoserver
|
||||||
examples/server/server
|
examples/server/server
|
||||||
|
server_ready
|
||||||
snifftest
|
snifftest
|
||||||
output
|
output
|
||||||
mcapi/test
|
mcapi/test
|
||||||
|
@@ -475,7 +475,8 @@ THREAD_RETURN CYASSL_THREAD server_test(void* args)
|
|||||||
SetupPkCallbacks(ctx, ssl);
|
SetupPkCallbacks(ctx, ssl);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
tcp_accept(&sockfd, &clientfd, (func_args*)args, port, useAnyAddr, doDTLS);
|
tcp_accept(&sockfd, &clientfd, (func_args*)args, port, useAnyAddr, doDTLS,
|
||||||
|
0);
|
||||||
if (!doDTLS)
|
if (!doDTLS)
|
||||||
CloseSocket(sockfd);
|
CloseSocket(sockfd);
|
||||||
|
|
||||||
|
@@ -475,7 +475,8 @@ THREAD_RETURN CYASSL_THREAD server_test(void* args)
|
|||||||
SetupPkCallbacks(ctx, ssl);
|
SetupPkCallbacks(ctx, ssl);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
tcp_accept(&sockfd, &clientfd, (func_args*)args, port, useAnyAddr, doDTLS);
|
tcp_accept(&sockfd, &clientfd, (func_args*)args, port, useAnyAddr, doDTLS,
|
||||||
|
0);
|
||||||
if (!doDTLS)
|
if (!doDTLS)
|
||||||
CloseSocket(sockfd);
|
CloseSocket(sockfd);
|
||||||
|
|
||||||
|
@@ -698,7 +698,7 @@ static INLINE void udp_accept(SOCKET_T* sockfd, SOCKET_T* clientfd,
|
|||||||
|
|
||||||
static INLINE void tcp_accept(SOCKET_T* sockfd, SOCKET_T* clientfd,
|
static INLINE void tcp_accept(SOCKET_T* sockfd, SOCKET_T* clientfd,
|
||||||
func_args* args, word16 port, int useAnyAddr,
|
func_args* args, word16 port, int useAnyAddr,
|
||||||
int udp)
|
int udp, int ready_file)
|
||||||
{
|
{
|
||||||
SOCKADDR_IN_T client;
|
SOCKADDR_IN_T client;
|
||||||
socklen_t client_len = sizeof(client);
|
socklen_t client_len = sizeof(client);
|
||||||
@@ -727,6 +727,17 @@ static INLINE void tcp_accept(SOCKET_T* sockfd, SOCKET_T* clientfd,
|
|||||||
ready->port = port;
|
ready->port = port;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (ready_file) {
|
||||||
|
#ifndef NO_FILESYSTEM
|
||||||
|
FILE* srf = fopen("./server_ready", "w+");
|
||||||
|
|
||||||
|
if (srf) {
|
||||||
|
fputs("ready", srf);
|
||||||
|
fclose(srf);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
*clientfd = accept(*sockfd, (struct sockaddr*)&client,
|
*clientfd = accept(*sockfd, (struct sockaddr*)&client,
|
||||||
(ACCEPT_THIRD_T)&client_len);
|
(ACCEPT_THIRD_T)&client_len);
|
||||||
#ifdef USE_WINDOWS_API
|
#ifdef USE_WINDOWS_API
|
||||||
|
@@ -131,6 +131,7 @@ static void Usage(void)
|
|||||||
printf("-u Use UDP DTLS,"
|
printf("-u Use UDP DTLS,"
|
||||||
" add -v 2 for DTLSv1 (default), -v 3 for DTLSv1.2\n");
|
" add -v 2 for DTLSv1 (default), -v 3 for DTLSv1.2\n");
|
||||||
printf("-f Fewer packets/group messages\n");
|
printf("-f Fewer packets/group messages\n");
|
||||||
|
printf("-r Create server ready file, for external monitor\n");
|
||||||
printf("-N Use Non-blocking sockets\n");
|
printf("-N Use Non-blocking sockets\n");
|
||||||
printf("-S <str> Use Host Name Indication\n");
|
printf("-S <str> Use Host Name Indication\n");
|
||||||
#ifdef HAVE_OCSP
|
#ifdef HAVE_OCSP
|
||||||
@@ -166,6 +167,7 @@ THREAD_RETURN CYASSL_THREAD server_test(void* args)
|
|||||||
int trackMemory = 0;
|
int trackMemory = 0;
|
||||||
int fewerPackets = 0;
|
int fewerPackets = 0;
|
||||||
int pkCallbacks = 0;
|
int pkCallbacks = 0;
|
||||||
|
int serverReadyFile = 0;
|
||||||
char* cipherList = NULL;
|
char* cipherList = NULL;
|
||||||
const char* verifyCert = cliCert;
|
const char* verifyCert = cliCert;
|
||||||
const char* ourCert = svrCert;
|
const char* ourCert = svrCert;
|
||||||
@@ -196,7 +198,7 @@ THREAD_RETURN CYASSL_THREAD server_test(void* args)
|
|||||||
fdOpenSession(Task_self());
|
fdOpenSession(Task_self());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
while ((ch = mygetopt(argc, argv, "?dbstnNufPp:v:l:A:c:k:S:oO:")) != -1) {
|
while ((ch = mygetopt(argc, argv, "?dbstnNufrPp:v:l:A:c:k:S:oO:")) != -1) {
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case '?' :
|
case '?' :
|
||||||
Usage();
|
Usage();
|
||||||
@@ -232,6 +234,10 @@ THREAD_RETURN CYASSL_THREAD server_test(void* args)
|
|||||||
fewerPackets = 1;
|
fewerPackets = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'r' :
|
||||||
|
serverReadyFile = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
case 'P' :
|
case 'P' :
|
||||||
#ifdef HAVE_PK_CALLBACKS
|
#ifdef HAVE_PK_CALLBACKS
|
||||||
pkCallbacks = 1;
|
pkCallbacks = 1;
|
||||||
@@ -482,7 +488,8 @@ THREAD_RETURN CYASSL_THREAD server_test(void* args)
|
|||||||
SetupPkCallbacks(ctx, ssl);
|
SetupPkCallbacks(ctx, ssl);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
tcp_accept(&sockfd, &clientfd, (func_args*)args, port, useAnyAddr, doDTLS);
|
tcp_accept(&sockfd, &clientfd, (func_args*)args, port, useAnyAddr, doDTLS,
|
||||||
|
serverReadyFile);
|
||||||
if (!doDTLS)
|
if (!doDTLS)
|
||||||
CloseSocket(sockfd);
|
CloseSocket(sockfd);
|
||||||
|
|
||||||
|
@@ -351,7 +351,7 @@ static THREAD_RETURN CYASSL_THREAD test_server_nofail(void* args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ssl = CyaSSL_new(ctx);
|
ssl = CyaSSL_new(ctx);
|
||||||
tcp_accept(&sockfd, &clientfd, (func_args*)args, port, 0, 0);
|
tcp_accept(&sockfd, &clientfd, (func_args*)args, port, 0, 0, 0);
|
||||||
CloseSocket(sockfd);
|
CloseSocket(sockfd);
|
||||||
|
|
||||||
CyaSSL_set_fd(ssl, clientfd);
|
CyaSSL_set_fd(ssl, clientfd);
|
||||||
@@ -551,7 +551,7 @@ static THREAD_RETURN CYASSL_THREAD run_cyassl_server(void* args)
|
|||||||
|
|
||||||
ssl = CyaSSL_new(ctx);
|
ssl = CyaSSL_new(ctx);
|
||||||
|
|
||||||
tcp_accept(&sfd, &cfd, (func_args*)args, port, 0, 0);
|
tcp_accept(&sfd, &cfd, (func_args*)args, port, 0, 0, 0);
|
||||||
CloseSocket(sfd);
|
CloseSocket(sfd);
|
||||||
|
|
||||||
CyaSSL_set_fd(ssl, cfd);
|
CyaSSL_set_fd(ssl, cfd);
|
||||||
|
Reference in New Issue
Block a user