Skip to content

Commit 1539cf8

Browse files
Timo Sirainencras
Timo Sirainen
authored and
cras
committed
Added OpenSSL support by vjt@users.sf.net. Also fixes a possible crash after
using /SERVER ADD -ircnet. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2890 dbcabf3a-b0e7-0310-adc4-f8d773084564
1 parent 13effe8 commit 1539cf8

14 files changed

+392
-12
lines changed

acconfig.h

+3
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,6 @@
3636
#undef HAVE_GETTEXT
3737
#undef HAVE_LC_MESSAGES
3838
#undef HAVE_STPCPY
39+
40+
/* SSL */
41+
#undef HAVE_OPENSSL

configure.in

+66-7
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ if test "x$prefix" != "xNONE"; then
112112
fi
113113

114114
AC_ARG_WITH(tests,
115-
[ --with-glib2 Use GLIB 2.0 instead of 1.2],
115+
[ --with-glib2 Use GLIB 2.0 instead of 1.2],
116116
if test x$withval = xyes; then
117117
want_glib2=yes
118118
else
@@ -126,7 +126,7 @@ AC_ARG_WITH(tests,
126126

127127
AC_ARG_WITH(perl-staticlib,
128128
[ --with-perl-staticlib Specify that we want to link perl libraries
129-
statically in irssi, default is no],
129+
statically in irssi, default is no],
130130
if test x$withval = xyes; then
131131
want_staticperllib=yes
132132
else
@@ -141,7 +141,7 @@ AC_ARG_WITH(perl-staticlib,
141141

142142
AC_ARG_WITH(perl-lib,
143143
[ --with-perl-lib=[site|vendor|DIR] Specify where to install the
144-
Perl libraries for irssi, default is site],
144+
Perl libraries for irssi, default is site],
145145
if test "x$withval" = xyes; then
146146
want_perl=yes
147147
elif test "x$withval" = xno; then
@@ -170,8 +170,8 @@ AC_ARG_WITH(perl-lib,
170170

171171
AC_ARG_WITH(perl,
172172
[ --with-perl[=yes|no|module] Build with Perl support - also specifies
173-
if it should be built into main irssi binary
174-
(static, default) or as module],
173+
if it should be built into main irssi binary
174+
(static, default) or as module],
175175
if test x$withval = xyes; then
176176
want_perl=static
177177
elif test x$withval = xstatic; then
@@ -196,6 +196,62 @@ AC_ARG_ENABLE(ipv6,
196196
fi,
197197
want_ipv6=no)
198198

199+
dnl **
200+
dnl ** SSL Library checks (OpenSSL)
201+
dnl **
202+
203+
AC_ARG_ENABLE(ssl,
204+
[ --disable-ssl Turn on Secure Sockets Layer support [default=yes]],,
205+
enable_ssl=yes)
206+
207+
AC_ARG_WITH(openssl-includes,
208+
[ --with-openssl-includes Specify location of OpenSSL header files],
209+
[openssl_inc_prefix=-I$withval])
210+
211+
AC_ARG_WITH(openssl-libs,
212+
[ --with-openssl-libs Specify location of OpenSSL libs],
213+
[openssl_prefix=$withval],
214+
[openssl_prefix=/usr/lib])
215+
216+
if test "x$enable_ssl" = xyes; then
217+
###
218+
### Check for OpenSSL
219+
###
220+
save_CFLAGS=$CFLAGS;
221+
CFLAGS="-lcrypto";
222+
223+
enable_openssl="no";
224+
OPENSSL_LDFLAGS="";
225+
AC_CHECK_LIB(ssl, SSL_read,
226+
AC_CHECK_LIB(crypto, X509_new,
227+
AC_CHECK_HEADERS(openssl/ssl.h openssl/err.h,
228+
[
229+
enable_openssl="yes";
230+
OPENSSL_LDFLAGS="-lssl -lcrypto"
231+
],
232+
AC_ERROR([Cannot find OpenSSL includes !])),
233+
AC_ERROR([Cannot find libCrypto !])),
234+
AC_ERROR([Cannot find libSSL !]))
235+
CFLAGS=$save_CFLAGS
236+
237+
if test "x$enable_openssl" = xyes; then
238+
AC_DEFINE(HAVE_OPENSSL)
239+
OPENSSL_LIBS="-L$openssl_prefix $OPENSSL_LDFLAGS"
240+
OPENSSL_CFLAGS="$openssl_inc_prefix"
241+
else
242+
OPENSSL_LIBS=
243+
OPENSSL_CFLAGS=
244+
fi
245+
246+
AC_SUBST(OPENSSL_CFLAGS)
247+
AC_SUBST(OPENSSL_LIBS)
248+
LIBS="$LIBS $OPENSSL_LIBS"
249+
CFLAGS="$CFLAGS $OPENSSL_CFLAGS"
250+
else
251+
enable_openssl="no"
252+
fi
253+
254+
199255
dnl **
200256
dnl ** just some generic stuff...
201257
dnl **
@@ -830,7 +886,6 @@ fi
830886
echo "Building text frontend ..... : $text"
831887
echo "Building irssi bot ......... : $want_irssibot"
832888
echo "Building irssi proxy ....... : $want_irssiproxy"
833-
echo "Building with IPv6 support . : $want_ipv6"
834889
if test "x$have_gmodule" = "xyes"; then
835890
echo "Building with module support : yes"
836891
else
@@ -877,8 +932,12 @@ if test "x$want_perl" != "xno"; then
877932
echo " Anyway, installing perl to this directory should work just as well."
878933
fi
879934
fi
880-
881935
echo "Install prefix ............. : $prefix"
882936

937+
echo
938+
939+
echo "Building with IPv6 support . : $want_ipv6"
940+
echo "Building with SSL support .. : ${enable_openssl}"
941+
883942
echo
884943
echo "If there was any problems, read the INSTALL file."

src/core/Makefile.am

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ libcore_a_SOURCES = \
3030
net-nonblock.c \
3131
net-sendbuffer.c \
3232
network.c \
33+
network-openssl.c \
3334
nicklist.c \
3435
nickmatch-cache.c \
3536
pidwait.c \

src/core/chat-commands.c

+7-3
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,16 @@ static SERVER_CONNECT_REC *get_server_connect(const char *data, int *plus_addr,
8888
else if (g_hash_table_lookup(optlist, "4") != NULL)
8989
conn->family = AF_INET;
9090

91+
if(g_hash_table_lookup(optlist, "ssl") != NULL)
92+
conn->use_ssl = TRUE;
93+
9194
if (g_hash_table_lookup(optlist, "!") != NULL)
9295
conn->no_autojoin_channels = TRUE;
9396

9497
if (g_hash_table_lookup(optlist, "noproxy") != NULL)
9598
g_free_and_null(conn->proxy);
9699

100+
97101
*rawlog_file = g_strdup(g_hash_table_lookup(optlist, "rawlog"));
98102

99103
host = g_hash_table_lookup(optlist, "host");
@@ -108,7 +112,7 @@ static SERVER_CONNECT_REC *get_server_connect(const char *data, int *plus_addr,
108112
return conn;
109113
}
110114

111-
/* SYNTAX: CONNECT [-4 | -6] [-ircnet <ircnet>] [-host <hostname>]
115+
/* SYNTAX: CONNECT [-4 | -6] [-ssl] [-ircnet <ircnet>] [-host <hostname>]
112116
<address>|<chatnet> [<port> [<password> [<nick>]]] */
113117
static void cmd_connect(const char *data)
114118
{
@@ -209,7 +213,7 @@ static void sig_default_command_server(const char *data, SERVER_REC *server,
209213
signal_emit("command server connect", 3, data, server, item);
210214
}
211215

212-
/* SYNTAX: SERVER [-4 | -6] [-ircnet <ircnet>] [-host <hostname>]
216+
/* SYNTAX: SERVER [-4 | -6] [-ssl] [-ircnet <ircnet>] [-host <hostname>]
213217
[+]<address>|<chatnet> [<port> [<password> [<nick>]]] */
214218
static void cmd_server_connect(const char *data, SERVER_REC *server)
215219
{
@@ -439,7 +443,7 @@ void chat_commands_init(void)
439443

440444
signal_add("default command server", (SIGNAL_FUNC) sig_default_command_server);
441445

442-
command_set_options("connect", "4 6 !! +host noproxy -rawlog");
446+
command_set_options("connect", "4 6 !! ssl +host noproxy -rawlog");
443447
command_set_options("join", "invite");
444448
command_set_options("msg", "channel nick");
445449
}

0 commit comments

Comments
 (0)