diff -Nru old/configure ssl/configure
--- old/configure	2003-11-01 09:58:36.000000000 +0300
+++ ssl/configure	2003-12-05 19:38:30.562500000 +0300
@@ -6297,7 +6297,7 @@
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lcrypto  $LIBS"
+LIBS="-lcrypto -lssl  $LIBS"
 cat >conftest.$ac_ext <<_ACEOF
 #line $LINENO "configure"
 /* confdefs.h.  */
@@ -6350,12 +6350,12 @@
 #define HAVE_LIBCRYPTO 1
 _ACEOF
 
-  LIBS="-lcrypto $LIBS"
+  LIBS="-lcrypto -lssl $LIBS"
 
 fi
 
 		if test "$ac_cv_lib_crypto_RSA_free" = yes; then
-			LIBS="$LIBS -lcrypto"
+			LIBS="$LIBS -lcrypto -lssl"
 			cf_openssl_ciphers=''
 
 for ac_func in EVP_bf_cfb
@@ -6862,7 +6862,7 @@
 done
 
 		fi
-		SSL_LIBS="$SSL_LIBS -lcrypto"
+		SSL_LIBS="$SSL_LIBS -lcrypto -lssl"
 		SSL_SRCS_ENABLE='$(SSL_SRCS)'
 	else
 	        echo "$as_me:$LINENO: result: no - OpenSSL support disabled" >&5
diff -Nru old/contrib/m_whois.c ssl/contrib/m_whois.c
--- old/contrib/m_whois.c	2003-10-21 06:31:10.000000000 +0400
+++ ssl/contrib/m_whois.c	2003-12-05 19:42:49.937500000 +0300
@@ -426,6 +426,12 @@
 
   if (MyConnect(target_p)) /* Can't do any of this if not local! db */
   {
+#ifdef HAVE_LIBCRYPTO
+    if (target_p->ssl)
+      sendto_one(source_p, form_str(RPL_USINGSSL),
+                 me.name, source_p->name, target_p->name);	
+#endif
+
     if ((glob) || (MyClient(source_p) && (IsOper(source_p) ||
         !ConfigServerHide.hide_servers)) || (source_p == target_p))
     {
diff -Nru old/etc/example.conf ssl/etc/example.conf
--- old/etc/example.conf	2003-10-13 06:15:22.000000000 +0400
+++ ssl/etc/example.conf	2003-12-05 22:07:04.687500000 +0300
@@ -92,6 +92,23 @@
 	 *	chmod 0644 rsa.pub
 	 */
 	#rsa_private_key_file = "/usr/local/ircd/etc/rsa.key";
+
+	/* SSL certificate file, used for client SSL connections
+	 *
+	 * Assuming your private RSA key is stored in rsa.key, you
+	 * must first create a certificate request, then sign it:
+	 *
+	 *  openssl req -new -key rsa.key -out cert.csr
+	 *  openssl x509 -req -in cert.csr -extensions v3_ca \
+	 *   -signkey rsa.key -out cert.pem -trustout
+	 */
+	#ssl_certificate_file = "/usr/local/ircd/etc/cert.pem";
+
+	/* Certification Authority certificate file, used to sign
+	 * ssl_certificate_file. Shouldn't be used if certificate
+	 * is self-signed
+        */
+       #ssl_ca_certificate_file = "/usr/local/ircd/etc/ca.pem";
 };
 
 /* admin {}: contains admin information about the server. (OLD A:) */
@@ -186,14 +203,19 @@
 	/* port: listen on all available IPs, ports 6665 to 6669 */
 	port = 6665 .. 6669;
 
+	/* sslport: listen for SSL connections on all available IPs, ports 7000 to 7005 */
+	sslport = 7000 .. 7005;
+
 	/* host: set a specific IP/host the ports after the line will listen 
 	 * on.  This may be ipv4 or ipv6.
 	 */
 	host = "1.2.3.4";
 	port = 7000, 7001;
+	sslport = 7099;
 
 	host = "3ffe:1234:a:b:c::d";
 	port = 7002;
+	sslport = 7199;
 };
 
 /* auth {}: allow users to connect to the ircd (OLD I:) */
diff -Nru old/include/client.h ssl/include/client.h
--- old/include/client.h	2003-10-17 03:13:46.000000000 +0400
+++ ssl/include/client.h	2003-12-05 19:38:30.687500000 +0300
@@ -130,6 +130,11 @@
 					   * bit mapped lazylink servers 
 					   * mapped here
 					   */
+
+#ifdef HAVE_LIBCRYPTO
+  SSL *ssl;
+#endif
+  
   /*
    * client->name is the unique name for a client nick or host
    */
@@ -367,7 +372,7 @@
 #define FLAGS_BLOCKED     0x01000000 /* must wait for COMM_SELECT_WRITE          */
 #define FLAGS_SBLOCKED    0x02000000 /* slinkq is blocked                        */
 #define FLAGS_USERHOST    0x04000000 /* client is in userhost hash               */
-/*                        0x08000000  */
+#define FLAGS_SSL         0x08000000 /* client connected thru SSL                */
 /*                        0x10000000  */
 /*                        0x20000000  */
 /*                        0x40000000  */
@@ -448,6 +453,8 @@
 #define IsCanFlood(x)		((x)->flags & FLAGS_CANFLOOD)
 #define IsDefunct(x)            ((x)->flags & (FLAGS_DEADSOCKET|FLAGS_CLOSING| \
 					       FLAGS_KILLED))
+#define SetSSL(x)               ((x)->flags |= FLAGS_SSL)
+#define IsSSL(x)                (((x)->flags & FLAGS_SSL) && (x)->ssl)					       
 
 /* oper flags */
 #define MyOper(x)               (MyConnect(x) && IsOper(x))
diff -Nru old/include/dh.h ssl/include/dh.h
--- old/include/dh.h	1970-01-01 03:00:00.000000000 +0300
+++ ssl/include/dh.h	2003-12-05 19:46:38.656250000 +0300
@@ -0,0 +1,69 @@
+/*
+ *  ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
+ *  dh.h: Diffie-Hellman key exchange header.
+ *
+ *  Copyright (C) 2003 by the past and present ircd coders, and others.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
+ *  USA
+ *
+ *  $Id: dh.h,v 1.0 2003/12/03 20:17:11 Sakura Exp $
+ */
+
+#ifndef INCLUDED_dh_h
+#define INCLUDED_dh_h
+
+#include "setup.h"
+
+#ifdef HAVE_LIBCRYPTO
+#include "client.h"
+
+#define KEY_BITS 512
+
+#define RAND_BITS KEY_BITS
+#define RAND_BYTES (RAND_BITS / 8)
+#define RAND_BYTES_HEX ((RAND_BYTES * 2) + 1)
+
+#define PRIME_BITS 1024
+#define PRIME_BYTES (PRIME_BITS / 8)
+#define PRIME_BYTES_HEX ((PRIME_BYTES * 2) + 1)
+
+struct dh_session {
+   DH *dh;
+   char *session_shared;
+   int session_shared_length;
+};
+
+extern void dh_init(void);
+extern int dh_generate_shared(struct dh_session *, char *);
+extern int dh_get_s_shared(char *, int *, struct dh_session *);
+extern int dh_hexstr_to_raw(char *, unsigned char *, int *);
+extern void dh_end_session(struct dh_session *);
+extern struct dh_session *dh_start_session(void);
+extern char *dh_get_s_secret(char *, int, struct dh_session *);
+extern char *dh_get_s_public(char *, int, struct dh_session *);
+
+extern int safe_SSL_read(struct Client *, void *, int);
+extern int safe_SSL_write(struct Client *, const void *, int);
+extern int safe_SSL_accept(struct Client *, int);
+extern int SSL_smart_shutdown(SSL *);
+extern int initssl(void);
+extern SSL_CTX *ircdssl_ctx;
+
+#endif
+
+extern void ircd_init_ssl(void);
+
+#endif  /* INCLUDED_dh_h */
diff -Nru old/include/listener.h ssl/include/listener.h
--- old/include/listener.h	2003-06-26 16:19:45.000000000 +0400
+++ ssl/include/listener.h	2003-12-05 19:38:30.750000000 +0300
@@ -46,9 +46,10 @@
   struct irc_ssaddr addr;              /* virtual address or INADDR_ANY */
   struct DNSQuery   *dns_query;
   char             vhost[HOSTLEN + 1]; /* virtual name of listener */
+  int    is_ssl;                       /* if our listener is a SSL listener */
 };
 
-extern void add_listener(int port, const char *vaddr_ip);
+extern void add_listener(int port, const char *vaddr_ip, int is_ssl);
 extern void close_listeners(void);
 extern const char *get_listener_name(const struct Listener *listener);
 extern void show_ports(struct Client *source_p);
diff -Nru old/include/numeric.h ssl/include/numeric.h
--- old/include/numeric.h	2003-06-12 07:40:29.000000000 +0400
+++ ssl/include/numeric.h	2003-12-05 19:38:30.796875000 +0300
@@ -162,6 +162,8 @@
 #define RPL_LOCALUSERS       265
 #define RPL_GLOBALUSERS      266
 
+#define RPL_USINGSSL         275
+
 #define RPL_ACCEPTLIST	     281
 #define RPL_ENDOFACCEPT      282
 #define RPL_ISMESSAGING	     283
diff -Nru old/include/patchlevel.h ssl/include/patchlevel.h
--- old/include/patchlevel.h	2003-03-02 11:06:19.000000000 +0300
+++ ssl/include/patchlevel.h	2003-12-05 19:38:30.828125000 +0300
@@ -23,5 +23,5 @@
  */
 
 #ifndef PATCHLEVEL
-#define PATCHLEVEL   "hybrid-7-CURRENT"
+#define PATCHLEVEL   "hybrid-7-CURRENT-SSL"
 #endif
diff -Nru old/include/s_conf.h ssl/include/s_conf.h
--- old/include/s_conf.h	2003-11-24 01:36:53.000000000 +0300
+++ ssl/include/s_conf.h	2003-12-05 19:54:37.671875000 +0300
@@ -27,6 +27,7 @@
 #include "setup.h"
 #ifdef HAVE_LIBCRYPTO
 #include <openssl/rsa.h>
+#include <openssl/ssl.h>
 #endif
 #include "fileio.h"             /* FBFILE */
 #include "ircd_defs.h"
@@ -367,6 +368,10 @@
 #ifdef HAVE_LIBCRYPTO
   char *rsa_private_key_file;
   RSA *rsa_private_key;
+  char *ssl_certificate_file;
+  char *ssl_ca_certificate_file;
+  SSL_CTX *ctx;
+  SSL_METHOD *meth;
 #endif
   char *sid;
   int hub;
diff -Nru old/include/stdinc.h ssl/include/stdinc.h
--- old/include/stdinc.h	2003-06-28 22:01:54.000000000 +0400
+++ ssl/include/stdinc.h	2003-12-05 19:38:30.906250000 +0300
@@ -65,6 +65,17 @@
 # endif
 #endif
 
+#ifdef HAVE_LIBCRYPTO
+#include <openssl/rand.h>
+#include <openssl/err.h>
+#include <openssl/bn.h>
+#include <openssl/dh.h>
+#include <openssl/rsa.h> 
+#include <openssl/crypto.h>
+#include <openssl/pem.h>
+#include <openssl/ssl.h>
+#endif
+
 #ifdef HAVE_CRYPT_H
 #include <crypt.h>
 #endif
diff -Nru old/include/supported.h ssl/include/supported.h
--- old/include/supported.h	2003-09-28 06:16:03.000000000 +0400
+++ ssl/include/supported.h	2003-12-05 19:38:30.953125000 +0300
@@ -31,6 +31,17 @@
 
 #define CASEMAP "rfc1459"
 
+#ifdef HAVE_LIBCRYPTO
+#define FEATURES "SSL WALLCHOPS"   \
+                 "s%s%s"           \
+                 " MODES=%i"       \
+                 " MAXCHANNELS=%i" \
+                 " MAXBANS=%i"     \
+                 " MAXTARGETS=%i"  \
+                 " NICKLEN=%i"     \
+                 " TOPICLEN=%i"    \
+                 " KICKLEN=%i"
+#else
 #define FEATURES "WALLCHOPS"       \
                  "%s%s%s"          \
                  " MODES=%i"       \
@@ -40,6 +51,7 @@
                  " NICKLEN=%i"     \
                  " TOPICLEN=%i"    \
                  " KICKLEN=%i"
+#endif		 
 
 #define FEATURESVALUES ConfigChannel.use_knock ? " KNOCK" : "", \
         ConfigChannel.use_except ? " EXCEPTS" : "", \
diff -Nru old/include/tools.h ssl/include/tools.h
--- old/include/tools.h	2003-10-24 15:38:43.000000000 +0400
+++ ssl/include/tools.h	2003-12-05 19:38:30.984375000 +0300
@@ -64,6 +64,7 @@
 extern void dlinkAddBefore(dlink_node *b, void *data, dlink_node *m, dlink_list *list);
 extern void dlinkAddTail(void *data, dlink_node *m, dlink_list *list);
 extern void dlinkDelete(dlink_node *m, dlink_list *list);
+extern void dlinkDeleteNode(dlink_node *m, dlink_list *list);
 extern void dlinkMoveList(dlink_list *from, dlink_list *to);
 extern dlink_node *dlinkFind(dlink_list *m, void *data);
 extern dlink_node *dlinkFindDelete(dlink_list *m, void *data);
diff -Nru old/modules/m_whois.c ssl/modules/m_whois.c
--- old/modules/m_whois.c	2003-10-21 05:27:39.000000000 +0400
+++ ssl/modules/m_whois.c	2003-12-05 19:42:05.546875000 +0300
@@ -422,6 +422,11 @@
 
   if (MyConnect(target_p)) /* Can't do any of this if not local! db */
   {
+#ifdef HAVE_LIBCRYPTO
+    if (target_p->ssl)
+      sendto_one(source_p, form_str(RPL_USINGSSL),
+                 me.name, source_p->name, target_p->name);	
+#endif
     if ((glob) ||
          (MyClient(source_p) && (IsOper(source_p) ||
                                   !ConfigServerHide.hide_servers)) ||
Files old/servlink/servlink.exe and ssl/servlink/servlink.exe differ
diff -Nru old/src/Makefile.in ssl/src/Makefile.in
--- old/src/Makefile.in	2003-09-11 08:19:54.000000000 +0400
+++ ssl/src/Makefile.in	2003-12-05 19:38:31.062500000 +0300
@@ -109,7 +109,9 @@
  @SSL_SRCS_ENABLE@ \
  @DYNLINK_C@ \
  tools.c \
- whowas.c
+ whowas.c \
+ dh.c \
+ ssl.c
 
 SRCS = ${BASE_SRCS} $(NETIO_SRC)
 OBJS = ${SRCS:.c=.o}
diff -Nru old/src/dh.c ssl/src/dh.c
--- old/src/dh.c	1970-01-01 03:00:00.000000000 +0300
+++ ssl/src/dh.c	2003-12-05 19:38:31.078125000 +0300
@@ -0,0 +1,245 @@
+/*
+ *  ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
+ *  dh.c: Diffie-Hellman key exchange.
+ *
+ *  Copyright (C) 2003 by the past and present ircd coders, and others.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
+ *  USA
+ *
+ *  $Id: dh.c,v 1.00 2003/12/03 20:33:17 Sakura Exp $
+ */
+
+
+#include "setup.h"
+#ifdef HAVE_LIBCRYPTO
+
+#include "memory.h"
+#include "dh.h"
+
+static unsigned int dh_gen_1024;
+static unsigned char dh_prime_1024[];
+static char *hex_to_string[256];
+
+static BIGNUM *ircd_prime;
+static BIGNUM *ircd_generator;
+
+static int verify_is_hex(char *string)
+{
+    int l = strlen(string);
+    char tmp[4] = { '\0', '\0', '\0', '\0' };
+    int tmpidx = 0;
+
+    if (l & 0x01) {		/* check if it's odd length */
+	l++;
+	tmp[tmpidx++] = '0';	/* pad with zero */
+    }
+
+    while (*string) {
+	tmp[tmpidx++] = *string++;
+	if (tmpidx == 2) {
+    char *eptr;
+    unsigned char x;
+
+	    tmpidx = 0;
+
+	    x = strtol(tmp, &eptr, 16);
+	    if (*eptr != '\0') {
+		return 0;
+	    }
+	}
+    }
+    return 1;
+}
+
+static void create_prime()
+{
+char buf[PRIME_BYTES_HEX];
+int i;
+int bufpos = 0;
+
+    for (i = 0; i < PRIME_BYTES; i++) {
+char *x = hex_to_string[dh_prime_1024[i]];
+	while (*x)
+	    buf[bufpos++] = *x++;
+    }
+    buf[bufpos] = '\0';
+
+    ircd_prime = NULL;
+    BN_hex2bn(&ircd_prime, buf);
+    ircd_generator = BN_new();
+    BN_set_word(ircd_generator, dh_gen_1024);
+}
+
+void dh_init(void)
+{
+    ERR_load_crypto_strings();
+
+    printf("Importing prime...\n");
+    create_prime();
+    printf("Prime imported.\n");
+}
+
+int dh_generate_shared(struct dh_session *si, char *public_key)
+{
+    BIGNUM *tmp;
+    int len;
+
+    if (verify_is_hex(public_key) == 0 || !si || si->session_shared)
+	return 0;
+
+    tmp = NULL;
+    BN_hex2bn(&tmp, public_key);
+    if (!tmp)
+	return 0;
+
+    si->session_shared_length = DH_size(si->dh);
+    si->session_shared = (char *) MyMalloc(DH_size(si->dh));
+    len = DH_compute_key(si->session_shared, tmp, si->dh);
+    BN_free(tmp);
+
+    if (len < 0)
+	return 0;
+
+    si->session_shared_length = len;
+
+    return 1;
+}
+
+struct dh_session *dh_start_session(void)
+{
+    struct dh_session *si = (struct dh_session *) MyMalloc(sizeof(struct dh_session));
+    if (!si)
+	abort();
+
+    memset(si, 0, sizeof(struct dh_session));
+
+    si->dh = DH_new();
+    si->dh->p = BN_dup(ircd_prime);
+    si->dh->g = BN_dup(ircd_generator);
+
+    if (!DH_generate_key(si->dh)) {
+	DH_free(si->dh);
+	MyFree(si);
+	return NULL;
+    }
+
+    return (void *) si;
+}
+
+void dh_end_session(struct dh_session *si)
+{
+    if (si->dh) {
+	DH_free(si->dh);
+	si->dh = NULL;
+    }
+
+    if (si->session_shared) {
+	memset(si->session_shared, 0, si->session_shared_length);
+	MyFree(si->session_shared);
+	si->session_shared = NULL;
+    }
+
+    MyFree(si);
+}
+
+char *dh_get_s_public(char *buf, int maxlen, struct dh_session *si)
+{
+    char *tmp;
+
+    if (!si || !si->dh || !si->dh->pub_key)
+	return NULL;
+
+    tmp = BN_bn2hex(si->dh->pub_key);
+    if (!tmp)
+	return NULL;
+
+    if (strlen(tmp) + 1 > maxlen) {
+	OPENSSL_free(tmp);
+	return NULL;
+    }
+    strcpy(buf, tmp);
+    OPENSSL_free(tmp);
+
+    return buf;
+}
+
+int dh_get_s_shared(char *buf, int *maxlen, struct dh_session *si)
+{
+    if (!si || !si->session_shared || *maxlen < si->session_shared_length)
+	return 0;
+
+    *maxlen = si->session_shared_length;
+    memcpy(buf, si->session_shared, *maxlen);
+
+    return 1;
+}
+
+static char *hex_to_string[256] = {
+    "00", "01", "02", "03", "04", "05", "06", "07",
+    "08", "09", "0a", "0b", "0c", "0d", "0e", "0f",
+    "10", "11", "12", "13", "14", "15", "16", "17",
+    "18", "19", "1a", "1b", "1c", "1d", "1e", "1f",
+    "20", "21", "22", "23", "24", "25", "26", "27",
+    "28", "29", "2a", "2b", "2c", "2d", "2e", "2f",
+    "30", "31", "32", "33", "34", "35", "36", "37",
+    "38", "39", "3a", "3b", "3c", "3d", "3e", "3f",
+    "40", "41", "42", "43", "44", "45", "46", "47",
+    "48", "49", "4a", "4b", "4c", "4d", "4e", "4f",
+    "50", "51", "52", "53", "54", "55", "56", "57",
+    "58", "59", "5a", "5b", "5c", "5d", "5e", "5f",
+    "60", "61", "62", "63", "64", "65", "66", "67",
+    "68", "69", "6a", "6b", "6c", "6d", "6e", "6f",
+    "70", "71", "72", "73", "74", "75", "76", "77",
+    "78", "79", "7a", "7b", "7c", "7d", "7e", "7f",
+    "80", "81", "82", "83", "84", "85", "86", "87",
+    "88", "89", "8a", "8b", "8c", "8d", "8e", "8f",
+    "90", "91", "92", "93", "94", "95", "96", "97",
+    "98", "99", "9a", "9b", "9c", "9d", "9e", "9f",
+    "a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7",
+    "a8", "a9", "aa", "ab", "ac", "ad", "ae", "af",
+    "b0", "b1", "b2", "b3", "b4", "b5", "b6", "b7",
+    "b8", "b9", "ba", "bb", "bc", "bd", "be", "bf",
+    "c0", "c1", "c2", "c3", "c4", "c5", "c6", "c7",
+    "c8", "c9", "ca", "cb", "cc", "cd", "ce", "cf",
+    "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7",
+    "d8", "d9", "da", "db", "dc", "dd", "de", "df",
+    "e0", "e1", "e2", "e3", "e4", "e5", "e6", "e7",
+    "e8", "e9", "ea", "eb", "ec", "ed", "ee", "ef",
+    "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7",
+    "f8", "f9", "fa", "fb", "fc", "fd", "fe", "ff"
+};
+
+static unsigned int dh_gen_1024 = 2;
+static unsigned char dh_prime_1024[] = {
+    0xF4, 0x88, 0xFD, 0x58, 0x4E, 0x49, 0xDB, 0xCD,
+    0x20, 0xB4, 0x9D, 0xE4, 0x91, 0x07, 0x36, 0x6B,
+    0x33, 0x6C, 0x38, 0x0D, 0x45, 0x1D, 0x0F, 0x7C,
+    0x88, 0xB3, 0x1C, 0x7C, 0x5B, 0x2D, 0x8E, 0xF6,
+    0xF3, 0xC9, 0x23, 0xC0, 0x43, 0xF0, 0xA5, 0x5B,
+    0x18, 0x8D, 0x8E, 0xBB, 0x55, 0x8C, 0xB8, 0x5D,
+    0x38, 0xD3, 0x34, 0xFD, 0x7C, 0x17, 0x57, 0x43,
+    0xA3, 0x1D, 0x18, 0x6C, 0xDE, 0x33, 0x21, 0x2C,
+    0xB5, 0x2A, 0xFF, 0x3C, 0xE1, 0xB1, 0x29, 0x40,
+    0x18, 0x11, 0x8D, 0x7C, 0x84, 0xA7, 0x0A, 0x72,
+    0xD6, 0x86, 0xC4, 0x03, 0x19, 0xC8, 0x07, 0x29,
+    0x7A, 0xCA, 0x95, 0x0C, 0xD9, 0x96, 0x9F, 0xAB,
+    0xD0, 0x0A, 0x50, 0x9B, 0x02, 0x46, 0xD3, 0x08,
+    0x3D, 0x66, 0xA4, 0x5D, 0x41, 0x9F, 0x9C, 0x7C,
+    0xBD, 0x89, 0x4B, 0x22, 0x19, 0x26, 0xBA, 0xAB,
+    0xA2, 0x5E, 0xC3, 0x55, 0xE9, 0x2F, 0x78, 0xC7
+};
+
+#endif
diff -Nru old/src/ircd.c ssl/src/ircd.c
--- old/src/ircd.c	2003-10-30 01:37:15.000000000 +0300
+++ ssl/src/ircd.c	2003-12-05 19:38:31.125000000 +0300
@@ -62,6 +62,7 @@
 #include "hook.h"
 #include "ircd_getopt.h"
 #include "balloc.h"
+#include "dh.h"
 
 
 /* Try and find the correct name to use with getrlimit() for setting the max.
@@ -554,6 +555,22 @@
   else
     print_startup(getpid());
 
+#ifdef HAVE_LIBCRYPTO
+  dh_init();
+  fprintf(stderr, "SSL: Initialize\n");
+
+  SSL_load_error_strings();
+  SSLeay_add_ssl_algorithms();
+  ServerInfo.ctx = SSL_CTX_new(SSLv23_server_method());
+
+  if (!ServerInfo.ctx) {
+       ERR_print_errors_fp(stderr);
+       return 0;
+  }
+
+  fprintf(stderr, "SSL: Client based SSL connections are enabled.\n");
+#endif
+  
   setup_signals();
   /* We need this to initialise the fd array before anything else */
   fdlist_init();
diff -Nru old/src/ircd_lexer.l ssl/src/ircd_lexer.l
--- old/src/ircd_lexer.l	2003-10-04 23:31:19.000000000 +0400
+++ ssl/src/ircd_lexer.l	2003-12-05 19:48:21.406250000 +0300
@@ -242,6 +242,7 @@
 ping_cookie	{ return PING_COOKIE; }
 ping_time	{ return PING_TIME; }
 port		{ return PORT; }
+sslport         { return SSLPORT; }
 quarantine	{ return RESV; }
 quiet_on_ban    { return QUIET_ON_BAN; }
 reason		{ return REASON; }
@@ -254,6 +255,8 @@
 resv		{ return RESV; }
 rsa_private_key_file		{ return RSA_PRIVATE_KEY_FILE; }
 rsa_public_key_file		{ return RSA_PUBLIC_KEY_FILE; }
+ssl_certificate_file            { return SSL_CERTIFICATE_FILE; }
+ssl_ca_certificate_file		{ return SSL_CA_CERTIFICATE_FILE; }
 send_password	{ return SEND_PASSWORD; }
 sendq		{ return SENDQ; }
 serverhide	{ return SERVERHIDE; }
diff -Nru old/src/ircd_parser.y ssl/src/ircd_parser.y
--- old/src/ircd_parser.y	2003-10-04 23:31:19.000000000 +0400
+++ ssl/src/ircd_parser.y	2003-12-05 19:54:10.859375000 +0300
@@ -256,6 +256,7 @@
 %token  PING_COOKIE
 %token  PING_TIME
 %token  PORT
+%token  SSLPORT
 %token  QSTRING
 %token  QUIET_ON_BAN
 %token  REASON
@@ -266,6 +267,8 @@
 %token  RESTRICTED
 %token  RSA_PRIVATE_KEY_FILE
 %token  RSA_PUBLIC_KEY_FILE
+%token  SSL_CERTIFICATE_FILE
+%token  SSL_CA_CERTIFICATE_FILE
 %token  RESV
 %token  SECONDS MINUTES HOURS DAYS WEEKS
 %token  SENDQ
@@ -458,7 +461,9 @@
                         serverinfo_hub | serverinfo_description |
                         serverinfo_network_name | serverinfo_network_desc |
                         serverinfo_max_clients | 
-                        serverinfo_rsa_private_key_file | serverinfo_vhost6 |
+                        serverinfo_rsa_private_key_file | serverinfo_ssl_certificate_file |
+                        serverinfo_ssl_ca_certificate_file |
+                        serverinfo_vhost6 |
                         serverinfo_sid |
 			error;
 
@@ -531,6 +536,79 @@
   }
 };
 
+serverinfo_ssl_certificate_file: SSL_CERTIFICATE_FILE '=' QSTRING ';'
+  {
+#ifdef HAVE_LIBCRYPTO
+    if (ypass == 2)
+    {
+      if (ServerInfo.ctx) {
+	
+        if (ServerInfo.ssl_certificate_file)
+        {
+          MyFree(ServerInfo.ssl_certificate_file);
+          ServerInfo.ssl_certificate_file = NULL;
+        }
+
+        DupString(ServerInfo.ssl_certificate_file, yylval.string);
+
+        if (!ServerInfo.rsa_private_key_file) {
+          yyerror("Ignoring config file entry ssl_certificate -- no rsa_private_key");
+          break;
+        }
+
+        if (SSL_CTX_use_certificate_file(ServerInfo.ctx, 
+            ServerInfo.ssl_certificate_file, SSL_FILETYPE_PEM) <= 0) {
+          yyerror(strncat("Error using config file entry ssl_certificate -- ",
+                               ERR_error_string(ERR_get_error(), NULL),
+                               strlen(ERR_error_string(ERR_get_error(), NULL))));
+          break;
+        }
+
+        if (SSL_CTX_use_PrivateKey_file(ServerInfo.ctx, 
+            ServerInfo.rsa_private_key_file, SSL_FILETYPE_PEM) <= 0) {
+          yyerror(strncat("Error using config file entry rsa_private_key -- ",
+                               ERR_error_string(ERR_get_error(), NULL),
+                               strlen(ERR_error_string(ERR_get_error(), NULL))));
+          break;
+        }
+
+        if (!SSL_CTX_check_private_key(ServerInfo.ctx)) {
+          yyerror("RSA private key doesn't match the SSL certificate public key!");
+          break;
+        }
+      }
+    }
+#endif
+  };
+
+serverinfo_ssl_ca_certificate_file: SSL_CA_CERTIFICATE_FILE '=' QSTRING ';'
+  {
+#ifdef HAVE_LIBCRYPTO
+    if (ypass == 2)
+    {
+      if (ServerInfo.ctx) {
+	
+        if (ServerInfo.ssl_ca_certificate_file)
+        {
+          MyFree(ServerInfo.ssl_ca_certificate_file);
+          ServerInfo.ssl_ca_certificate_file = NULL;
+        }
+
+        DupString(ServerInfo.ssl_ca_certificate_file, yylval.string);
+
+        if (ServerInfo.ssl_ca_certificate_file != NULL &&
+            SSL_CTX_load_verify_locations(ServerInfo.ctx,
+            ServerInfo.ssl_ca_certificate_file, NULL) != 1) {
+          yyerror(strncat("Error using config file entry ssl_ca_certificate -- ",
+                               ERR_error_string(ERR_get_error(), NULL),
+                               strlen(ERR_error_string(ERR_get_error(), NULL))));
+          break;
+        }
+      }
+    }
+#endif
+  };
+
 serverinfo_sid: SID '=' QSTRING ';' 
 {
   /* this isn't rehashable */
@@ -1280,7 +1358,7 @@
 };
 
 listen_items:   listen_items listen_item | listen_item;
-listen_item:    listen_port | listen_address | listen_host | error;
+listen_item:    listen_port | listen_sslport | listen_address | listen_host | error;
 
 listen_port: PORT '=' port_items ';' ;
 
@@ -1289,7 +1367,7 @@
 port_item: NUMBER
 {
   if (ypass == 2)
-    add_listener($1, listener_address);
+    add_listener($1, listener_address, 0);
 } | NUMBER TWODOTS NUMBER
 {
   if (ypass == 2)
@@ -1298,7 +1376,28 @@
 
     for (i = $1; i <= $3; i++)
     {
-      add_listener(i, listener_address);
+      add_listener(i, listener_address, 0);
+    }
+  }
+};
+
+listen_sslport: SSLPORT '=' sslport_items ';' ;
+
+sslport_items: sslport_items ',' sslport_item | sslport_item;
+
+sslport_item: NUMBER
+{
+  if (ypass == 2)
+    add_listener($1, listener_address, 1);
+} | NUMBER TWODOTS NUMBER
+{
+  if (ypass == 2)
+  {
+    int i;
+    
+    for (i = $1; i <= $3; i++)
+    {
+      add_listener(i, listener_address, 1);
     }
   }
 };
diff -Nru old/src/listener.c ssl/src/listener.c
--- old/src/listener.c	2003-08-10 07:54:21.000000000 +0400
+++ ssl/src/listener.c	2003-12-05 19:38:31.250000000 +0300
@@ -112,7 +112,7 @@
     listener = ptr->data;
     sendto_one(source_p, form_str(RPL_STATSPLINE),
                me.name, source_p->name,
-               'P', listener->port,
+               listener->is_ssl ? 'S' : 'P', listener->port,
                IsAdmin(source_p) ? listener->name : me.name,
                listener->ref_count,
                (listener->active)?"active":"disabled");
@@ -245,7 +245,7 @@
  * the format "255.255.255.255"
  */
 void 
-add_listener(int port, const char* vhost_ip)
+add_listener(int port, const char* vhost_ip, int is_ssl)
 {
   struct Listener *listener;
   struct irc_ssaddr vaddr;
@@ -313,7 +313,7 @@
   {
     /* add the ipv4 listener if we havent already */
     pass = 1;
-    add_listener(port, "0.0.0.0");
+    add_listener(port, "0.0.0.0", is_ssl);
   }
   pass = 0;
 #endif
@@ -326,6 +326,7 @@
   else
   {
     listener = make_listener(port, &vaddr);
+    listener->is_ssl = is_ssl;
     dlinkAdd(listener, &listener->listener_node, &ListenerPollList);
   }
 
diff -Nru old/src/messages.tab ssl/src/messages.tab
--- old/src/messages.tab	2003-09-29 09:09:39.000000000 +0400
+++ ssl/src/messages.tab	2003-12-05 19:38:31.312500000 +0300
@@ -295,7 +295,7 @@
 /* 272 */  {NULL, NULL, NULL},
 /* 273 */  {NULL, NULL, NULL},
 /* 274 */  {NULL, NULL, NULL},
-/* 275 */  {NULL, NULL, NULL},
+/* 275 */  {"RPL_USINGSSL", ":%s 275 %s %s :connected via SSL (secure link)", NULL},
 /* 276 */  {NULL, NULL, NULL},
 /* 277 */  {NULL, NULL, NULL},
 /* 278 */  {NULL, NULL, NULL},
diff -Nru old/src/packet.c ssl/src/packet.c
--- old/src/packet.c	2003-06-06 08:31:50.000000000 +0400
+++ ssl/src/packet.c	2003-12-05 19:38:31.343750000 +0300
@@ -37,6 +37,7 @@
 #include "memory.h"
 #include "hook.h"
 #include "send.h"
+#include "dh.h"
 
 static char readBuf[READBUF_SIZE];
 static void client_dopacket(struct Client *client_p, char *buffer, size_t length);
@@ -426,7 +427,12 @@
    * I personally think it makes the code too hairy to make sane.
    *     -- adrian
    */
-  length = recv(fd_r, readBuf, READBUF_SIZE, 0);
+#ifdef HAVE_LIBCRYPTO
+  if (IsSSL(client_p))
+    length = safe_SSL_read(client_p, readBuf, READBUF_SIZE);
+  else
+#endif
+    length = recv(fd_r, readBuf, READBUF_SIZE, 0);
 
   if (length <= 0)
   {
diff -Nru old/src/s_auth.c ssl/src/s_auth.c
--- old/src/s_auth.c	2003-08-19 22:13:56.000000000 +0400
+++ ssl/src/s_auth.c	2003-12-05 19:38:31.390625000 +0300
@@ -53,6 +53,7 @@
 #include "s_stats.h"
 #include "send.h"
 #include "memory.h"
+#include "dh.h"
 
 /*
  * a bit different approach
@@ -85,8 +86,16 @@
   REPORT_HOST_TOOLONG
 };
 
+#ifdef HAVE_LIBCRYPTO
+#define sendheader(c, r) \
+   if (IsSSL(c)) \
+     safe_SSL_write(c, HeaderMessages[(r)].message, HeaderMessages[(r)].length); \
+   else \
+     send((c)->localClient->fd, HeaderMessages[(r)].message, HeaderMessages[(r)].length, 0)
+#else
 #define sendheader(c, r) \
    send((c)->localClient->fd, HeaderMessages[(r)].message, HeaderMessages[(r)].length, 0)
+#endif
 
 /*
  * Ok, the original was confusing.
diff -Nru old/src/s_bsd.c ssl/src/s_bsd.c
--- old/src/s_bsd.c	2003-09-20 02:13:13.000000000 +0400
+++ ssl/src/s_bsd.c	2003-12-05 19:38:31.437500000 +0300
@@ -49,6 +49,7 @@
 #include "s_stats.h"
 #include "send.h"
 #include "memory.h"
+#include "dh.h"
 
 #ifndef IN_LOOPBACKNET
 #define IN_LOOPBACKNET        0x7f
@@ -66,6 +67,7 @@
 static PF comm_connect_timeout;
 static void comm_connect_dns_callback(void *vptr, struct DNSReply *reply);
 static PF comm_connect_tryconnect;
+static void comm_tryssl_callback(int fd, void *data);
 
 /* close_all_connections() can be used *before* the system come up! */
 void
@@ -376,8 +378,11 @@
   struct Client*     new_client;
   socklen_t len = sizeof(struct irc_ssaddr);
   struct irc_ssaddr   irn;
+#ifdef HAVE_LIBCRYPTO
+  int new_ssl = 0;
+#endif  
   assert(NULL != listener);
-
+  
 #ifdef USE_IAUTH
   if (iAuth.socket == NOSOCK)
   {
@@ -444,11 +449,54 @@
   new_client->localClient->listener  = listener;
   ++listener->ref_count;
 
+#ifdef HAVE_LIBCRYPTO
+  if ((listener->is_ssl) && !(new_client->ssl))
+  {
+    new_ssl = 1;
+
+    /*SSL client init */
+    if((new_client->ssl = SSL_new(ServerInfo.ctx)) == NULL)
+    {
+      dlink_node * m;
+      m = dlinkFind(&unknown_list, new_client);
+      if (m)
+        dlinkDeleteNode(m, &unknown_list);
+      report_error(L_ALL, "Could not create new ssl connection %s :%s",
+          get_listener_name(listener), errno);
+      ServerStats->is_ref++;
+      free_client(new_client);
+      return;
+    }
+    SetSSL(new_client);
+  }
+#endif
+
+
   if (!set_non_blocking(new_client->localClient->fd))
     report_error(L_ALL, NONB_ERROR_MSG, get_client_name(new_client, SHOW_IP), errno);
   if (!disable_sock_options(new_client->localClient->fd))
     report_error(L_ALL, OPT_ERROR_MSG, get_client_name(new_client, SHOW_IP), errno);
-  start_auth(new_client);
+
+#ifdef HAVE_LIBCRYPTO
+  if (IsSSL(new_client) && new_ssl)
+  {
+    SSL_set_fd(new_client->ssl, new_client->localClient->fd);
+    if (!safe_SSL_accept(new_client, new_client->localClient->fd))
+    {
+      dlink_node * m;
+      m = dlinkFind(&unknown_list, new_client);
+      if (m)
+        dlinkDeleteNode(m, &unknown_list);
+      SSL_set_shutdown(new_client->ssl, SSL_RECEIVED_SHUTDOWN);
+      SSL_smart_shutdown(new_client->ssl);
+      SSL_free(new_client->ssl);
+      ServerStats->is_ref++;
+      free_client(new_client);
+      return;
+    }
+  }
+#endif
+  comm_setselect(fd, FDLIST_SERVER, COMM_SELECT_WRITE, comm_tryssl_callback, new_client, 0);
 }
 
 /*
@@ -747,6 +795,40 @@
  comm_connect_callback(fd, COMM_OK);
 }
 
+static void
+comm_tryssl_callback(int fd, void *data)
+{
+  int doauth = -1;
+  struct Client *new_client = data;
+
+  fdlist_t fdlist = FDLIST_NONE;
+
+  fdlist = FDLIST_SERVER;
+  doauth = 1;
+
+#ifdef HAVE_LIBCRYPTO
+  if (IsSSL(new_client))
+  {
+    if (!SSL_is_init_finished(new_client->ssl))
+    {
+      if (!safe_SSL_accept(new_client, new_client->localClient->fd))
+      {
+        dead_link_on_read(new_client, errno);
+        return;
+      }
+      else
+      {
+        comm_setselect(fd, fdlist, COMM_SELECT_WRITE, comm_tryssl_callback, new_client, 0);
+        return;
+      }
+    }
+  }
+#endif
+
+  if (doauth == 1)
+    start_auth(new_client);
+}
+
 /*
  * comm_errorstr() - return an error string for the given error condition
  */
diff -Nru old/src/send.c ssl/src/send.c
--- old/src/send.c	2003-11-10 06:45:43.000000000 +0300
+++ ssl/src/send.c	2003-12-05 19:38:31.484375000 +0300
@@ -42,6 +42,7 @@
 #include "s_log.h"
 #include "memory.h"
 #include "hook.h"
+#include "dh.h"
 
 #define LOG_BUFSIZE 2048
 
@@ -276,6 +277,14 @@
 #endif
     do {
       first = to->localClient->buf_sendq.blocks.head->data;
+#ifdef HAVE_LIBCRYPTO
+      if(IsSSL(to))
+      {
+        if ((retlen = safe_SSL_write(to, first->data, first->size)) <= 0)
+	  break;
+      }
+      else
+#endif      
       if ((retlen = send(to->localClient->fd, first->data,
                          first->size, 0)) <= 0)
         break;
diff -Nru old/src/ssl.c ssl/src/ssl.c
--- old/src/ssl.c	1970-01-01 03:00:00.000000000 +0300
+++ ssl/src/ssl.c	2003-12-05 19:38:31.515625000 +0300
@@ -0,0 +1,185 @@
+/*
+ *  ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
+ *  ssl.c: Client ssl connections.
+ *
+ *  Copyright (C) 2003 by the past and present ircd coders, and others.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
+ *  USA
+ *
+ * $Id: ssl.c,v 1.0 2003/12/03 21:22:43 Sakura Exp $
+ *
+ */
+
+#include "stdinc.h"
+#include "common.h"
+#include "s_conf.h"
+#include "dh.h"
+#include "send.h"
+#include "s_bsd.h"
+
+#define SAFE_SSL_READ  1
+#define SAFE_SSL_WRITE  2
+#define SAFE_SSL_ACCEPT  3
+
+#ifdef HAVE_LIBCRYPTO
+
+static int fatal_ssl_error(int, int, struct Client *);
+
+int safe_SSL_read(struct Client *acptr, void *buf, int sz)
+{
+  int len, ssl_err;
+
+  len = SSL_read(acptr->ssl, buf, sz);
+
+  if (len <= 0) {
+    switch (ssl_err = SSL_get_error(acptr->ssl, len)) {
+      case SSL_ERROR_SYSCALL:
+        if (errno == EWOULDBLOCK || errno == EAGAIN || errno == EINTR) {
+      case SSL_ERROR_WANT_READ:
+        errno = EWOULDBLOCK;
+          return -1;
+        }
+      case SSL_ERROR_SSL:
+        if (errno == EAGAIN)
+          return -1;
+      default:
+        return fatal_ssl_error(ssl_err, SAFE_SSL_READ, acptr);
+    }
+  }
+  return len;
+}
+
+int safe_SSL_write(struct Client *acptr, const void *buf, int sz)
+{
+  int len, ssl_err;
+
+  len = SSL_write(acptr->ssl, buf, sz);
+  if (len <= 0) {
+    switch (ssl_err = SSL_get_error(acptr->ssl, len)) {
+      case SSL_ERROR_SYSCALL:
+        if (errno == EWOULDBLOCK || errno == EAGAIN || errno == EINTR) {
+      case SSL_ERROR_WANT_WRITE:
+        errno = EWOULDBLOCK;
+          return 0;
+        }
+      case SSL_ERROR_SSL:
+        if (errno == EAGAIN)
+          return 0;
+      default:
+        return fatal_ssl_error(ssl_err, SAFE_SSL_WRITE, acptr);
+    }
+  }
+  return len;
+}
+
+int safe_SSL_accept(struct Client *acptr, int fd)
+{
+
+  int ssl_err;
+
+  if ((ssl_err = SSL_accept(acptr->ssl)) <= 0) {
+    switch (ssl_err = SSL_get_error(acptr->ssl, ssl_err)) {
+      case SSL_ERROR_SYSCALL:
+        if (errno == EINTR || errno == EWOULDBLOCK || errno == EAGAIN)
+      case SSL_ERROR_WANT_READ:
+      case SSL_ERROR_WANT_WRITE:
+        /* handshake will be completed later . . */
+        return 1;
+      default:
+        return fatal_ssl_error(ssl_err, SAFE_SSL_ACCEPT, acptr);
+    }
+  /* NOTREACHED */
+  return 0;
+  }
+  return 1;
+}
+
+int SSL_smart_shutdown(SSL * ssl)
+{
+  int i;
+  int rc;
+
+  rc = 0;
+  for (i = 0; i < 4; i++) {
+    if ((rc = SSL_shutdown(ssl)))
+      break;
+  }
+
+  return rc;
+}
+
+static int fatal_ssl_error(int ssl_error, int where, struct Client *sptr)
+{
+  /* don't alter errno */
+  int errtmp = errno;
+  char *errstr = strerror(errtmp);
+  char *ssl_errstr, *ssl_func;
+
+  switch (where) {
+    case SAFE_SSL_READ:
+      ssl_func = "SSL_read()";
+      break;
+    case SAFE_SSL_WRITE:
+      ssl_func = "SSL_write()";
+      break;
+    case SAFE_SSL_ACCEPT:
+      ssl_func = "SSL_accept()";
+      break;
+    default:
+      ssl_func = "undefined SSL func [this is a bug]";
+  }
+
+  switch (ssl_error) {
+    case SSL_ERROR_NONE:
+      ssl_errstr = "No error";
+      break;
+    case SSL_ERROR_SSL:
+      ssl_errstr = "Internal OpenSSL error or protocol error";
+      break;
+    case SSL_ERROR_WANT_READ:
+      ssl_errstr = "OpenSSL functions requested a read()";
+      break;
+    case SSL_ERROR_WANT_WRITE:
+      ssl_errstr = "OpenSSL functions requested a write()";
+      break;
+    case SSL_ERROR_WANT_X509_LOOKUP:
+      ssl_errstr = "OpenSSL requested a X509 lookup which didn`t arrive";
+      break;
+    case SSL_ERROR_SYSCALL:
+      ssl_errstr = "Underlying syscall error";
+      break;
+    case SSL_ERROR_ZERO_RETURN:
+      ssl_errstr = "Underlying socket operation returned zero";
+      break;
+    case SSL_ERROR_WANT_CONNECT:
+      ssl_errstr = "OpenSSL functions wanted a connect()";
+      break;
+    default:
+      ssl_errstr = "Unknown OpenSSL error (huh?)";
+  }
+
+  /*
+  report_error(L_ADMIN, "%s to %s aborted with%serror (%s). [%s]",
+               ssl_func, get_client_name(sptr, SHOW_IP), (errno > 0) ? " " : " no ", errstr, ssl_errstr);
+  report_error(L_OPER, "%s to %s aborted with%serror (%s). [%s]",
+               ssl_func, get_client_name(sptr, MASK_IP), (errno > 0) ? " " : " no ", errstr, ssl_errstr);
+  */
+
+  errno = errtmp ? errtmp : EIO;  /* Stick a generic I/O error */
+  sptr->flags |= FLAGS_DEADSOCKET;
+  return 0;
+}
+#endif
diff -Nru old/src/tools.c ssl/src/tools.c
--- old/src/tools.c	2003-10-24 15:38:44.000000000 +0400
+++ ssl/src/tools.c	2003-12-05 19:38:31.546875000 +0300
@@ -27,6 +27,7 @@
 
 #include "stdinc.h"
 #include "tools.h"
+#include "list.h"
 
 
 #ifndef NDEBUG
@@ -133,6 +134,12 @@
   list->length--;
 }
 
+void dlinkDeleteNode(dlink_node *m, dlink_list *list)
+{
+    dlinkDelete(m, list);
+    free_dlink_node(m);
+}
+
 
 /*
  * dlinkFind
