Start working on client listener
This commit is contained in:
46
rmps.c
46
rmps.c
@@ -1,7 +1,9 @@
|
||||
#include "log.h"
|
||||
#include "confparser.h"
|
||||
#include "thread_pool.h"
|
||||
#include "agent_pool.h"
|
||||
#include "client_pool.h"
|
||||
#include "rmps.h"
|
||||
#include <pthread.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
@@ -197,8 +199,8 @@ static SSL_CTX* init_server_ctx(const char *cipherlist)
|
||||
SSL_CTX *ctx;
|
||||
char ciphers[1024];
|
||||
|
||||
OpenSSL_add_all_algorithms(); /* load & register all cryptos, etc. */
|
||||
OpenSSL_add_all_ciphers(); /* load & register all cryptos, etc. */
|
||||
// OpenSSL_add_all_algorithms(); /* load & register all cryptos, etc. */
|
||||
// OpenSSL_add_all_ciphers(); /* load & register all cryptos, etc. */
|
||||
SSL_load_error_strings(); /* load all error messages */
|
||||
SSL_library_init();
|
||||
|
||||
@@ -257,11 +259,12 @@ void load_certificates(SSL_CTX* ctx, const char *certfile,
|
||||
|
||||
}
|
||||
|
||||
int launch_rmps(struct conf_table *conf, int fork_flag)
|
||||
void launch_rmps(struct conf_table *conf, int fork_flag)
|
||||
{
|
||||
int server;
|
||||
log(INFO, "Starting up RMPS...");
|
||||
pthread_t pool[2];
|
||||
struct pool_data pool_args[2];
|
||||
|
||||
log(INFO, "Starting up RMPS...");
|
||||
/* Set signal handling */
|
||||
set_env();
|
||||
/* Deamonize */
|
||||
@@ -270,20 +273,31 @@ int launch_rmps(struct conf_table *conf, int fork_flag)
|
||||
/* Spawn & lock pidfile */
|
||||
spawn_pidfile(conf->rmps.pidfile);
|
||||
|
||||
SSL_CTX *ctx;
|
||||
ctx = init_server_ctx(conf->rmps.cipherlist);
|
||||
/* openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days XXX -nodes
|
||||
* -nodes is for not protecing with a passphrase
|
||||
* http://stackoverflow.com/questions/10175812/how-to-create-a-self-signed-certificate-with-openssl
|
||||
*/
|
||||
log(VERBOSE, "Loading crypto certs and keys.");
|
||||
load_certificates(ctx, conf->rmps.certfile, conf->rmps.keyfile, conf->rmps.cafile);
|
||||
pool_args[0].ctx = init_server_ctx(conf->rmps.cipherlist);
|
||||
log(VERBOSE, "Loading agent certs and keys.");
|
||||
load_certificates(pool_args[0].ctx, conf->rmps.agent_tls_crt,
|
||||
conf->rmps.agent_tls_key, conf->rmps.cafile);
|
||||
log(VERBOSE, "Starting agent listener on port: %d", atoi(conf->rmps.agent_port));
|
||||
pool_args[0].srv = open_listener(atoi(conf->rmps.agent_port));
|
||||
pool_args[0].size = conf->rmps.agent_poolsize;
|
||||
log(VERBOSE, "Creating agent thread pool (mutex).");
|
||||
pthread_create(&pool[0], NULL, agent_pool, &pool_args[0]);
|
||||
|
||||
log(VERBOSE, "Starting listener on port: %d", atoi(conf->rmps.bind_on_port));
|
||||
server = open_listener(atoi(conf->rmps.bind_on_port));
|
||||
|
||||
log(VERBOSE, "Creating mutex for thread pool.");
|
||||
ssl_pt_mutex(server, ctx, conf->rmps.threadpoolsize);
|
||||
pool_args[1].ctx = init_server_ctx(conf->rmps.cipherlist);
|
||||
log(VERBOSE, "Loading client certs and keys.");
|
||||
load_certificates(pool_args[1].ctx, conf->rmps.client_tls_crt,
|
||||
conf->rmps.client_tls_key, conf->rmps.cafile);
|
||||
log(VERBOSE, "Starting client listener on port: %d", atoi(conf->rmps.client_port));
|
||||
pool_args[1].srv = open_listener(atoi(conf->rmps.client_port));
|
||||
pool_args[1].size = conf->rmps.client_poolsize;
|
||||
log(VERBOSE, "Creating client thread pool (mutex).");
|
||||
pthread_create(&pool[1], NULL, client_pool, &pool_args[1]);
|
||||
|
||||
return 0;
|
||||
pthread_join(pool[0], NULL);
|
||||
pthread_join(pool[1], NULL);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user