openssl module working on windows, added configuration option for setting the ssl module
This commit is contained in:
parent
50affd176a
commit
517394e7f9
@ -36,6 +36,7 @@ struct irc_conn
|
||||
#else
|
||||
FILE *srv_fd;
|
||||
#endif
|
||||
char ssl_module[256];
|
||||
char nick[50];
|
||||
char user[50];
|
||||
char admin[256];
|
||||
|
BIN
mods/openssl.dll
BIN
mods/openssl.dll
Binary file not shown.
BIN
mods/openssl.lib
BIN
mods/openssl.lib
Binary file not shown.
@ -15,8 +15,10 @@ int ssl_fd;
|
||||
SSL *ssl;
|
||||
SSL_CTX *ctx;
|
||||
|
||||
MY_API void sslmod_init(struct irc_conn *bot)
|
||||
MY_API void sslmod_init()
|
||||
{
|
||||
struct irc_conn *bot = get_bot();
|
||||
|
||||
SSL_library_init();
|
||||
SSL_load_error_strings();
|
||||
ctx = SSL_CTX_new(SSLv23_client_method());
|
||||
@ -25,12 +27,14 @@ MY_API void sslmod_init(struct irc_conn *bot)
|
||||
eprint("Error: Cannot create SSL context\n");
|
||||
}
|
||||
|
||||
if (bot->verify_ssl)
|
||||
if (bot->verify_ssl == true)
|
||||
{
|
||||
printf("SSL: Verifying server certificate\n");
|
||||
SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("SSL: Not verifying server certificate\n");
|
||||
SSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, NULL);
|
||||
}
|
||||
|
||||
@ -42,12 +46,12 @@ MY_API void sslmod_init(struct irc_conn *bot)
|
||||
|
||||
MY_API int get_ssl_fd()
|
||||
{
|
||||
printf("ssl_fd: %d\n", ssl_fd);
|
||||
return ssl_fd;
|
||||
}
|
||||
|
||||
MY_API void sslmod_connect()
|
||||
{
|
||||
unsigned long ssl_err;
|
||||
struct irc_conn *bot = get_bot();
|
||||
|
||||
#ifdef _WIN32
|
||||
@ -62,6 +66,12 @@ MY_API void sslmod_connect()
|
||||
if (SSL_connect(ssl) != 1)
|
||||
{
|
||||
eprint("Error: Cannot connect to SSL server\n");
|
||||
|
||||
ssl_err = ERR_get_error();
|
||||
if (ssl_err)
|
||||
{
|
||||
eprint("SSL error: %s\n", ERR_error_string(ssl_err, NULL));
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
|
20
src/config.c
20
src/config.c
@ -14,8 +14,9 @@ struct irc_conn read_config(struct irc_conn bot, char *file)
|
||||
const char *base = (const char*)malloc(sizeof(char) * 1024);
|
||||
const char *mod = NULL;
|
||||
int boolbase;
|
||||
char *modpath = (char *)malloc(sizeof(char) * 500);
|
||||
|
||||
bot.verify_ssl = 0;
|
||||
bot.use_ssl = 0;
|
||||
|
||||
cf = &cfg;
|
||||
config_init(cf);
|
||||
@ -90,6 +91,22 @@ void run_autoload(struct irc_conn *bot)
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if (bot->use_ssl)
|
||||
{
|
||||
if (config_lookup_string(cf, "server.ssl_module", &base))
|
||||
{
|
||||
strlcpy(bot->ssl_module, base, sizeof bot->ssl_module);
|
||||
|
||||
// Load the SSL module
|
||||
#ifdef _WIN32
|
||||
sprintf(modpath, "./mods/%s.dll", bot->ssl_module);
|
||||
#else
|
||||
sprintf(modpath, "./mods/%s.so", bot->ssl_module);
|
||||
#endif
|
||||
load_module(bot, "main", "runtime", modpath);
|
||||
}
|
||||
}
|
||||
|
||||
autoload = config_lookup(cf, "mods.autoload");
|
||||
count = config_setting_length(autoload);
|
||||
|
||||
@ -105,4 +122,5 @@ void run_autoload(struct irc_conn *bot)
|
||||
}
|
||||
|
||||
config_destroy(cf);
|
||||
free(modpath);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user