SSL in NeoIRCd works like a dream...
BTW, thanks shadowmaster :)
This commit is contained in:
fishwaldo 2002-11-04 08:50:46 +00:00
parent 609190b2fb
commit 9f6e987e37
5 changed files with 19 additions and 13 deletions

View file

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
* $Id: linebuf.h,v 1.4 2002/11/04 08:14:00 fishwaldo Exp $
* $Id: linebuf.h,v 1.5 2002/11/04 08:50:46 fishwaldo Exp $
*/
#ifndef __LINEBUF_H__
@ -78,7 +78,7 @@ extern int linebuf_get(buf_head_t *, char *, int, int, int);
extern void linebuf_putmsg(buf_head_t *, const char *, va_list *,
const char *, ...);
#ifdef USE_SSL
extern int linebuf_flush(int, buf_head_t *, SSL *);
extern int linebuf_flush(int, buf_head_t *, void *);
#else
extern int linebuf_flush(int, buf_head_t *);
#endif

View file

@ -20,7 +20,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
* $Id: linebuf.c,v 1.6 2002/11/04 08:14:00 fishwaldo Exp $
* $Id: linebuf.c,v 1.7 2002/11/04 08:50:46 fishwaldo Exp $
*/
#include "stdinc.h"
@ -631,13 +631,14 @@ linebuf_putmsg(buf_head_t *bufhead, const char *format, va_list *va_args,
*/
#ifdef USE_SSL
int
linebuf_flush(int fd, buf_head_t *bufhead, SSL *ssl)
linebuf_flush(int fd, buf_head_t *bufhead, void *data)
#else
int
linebuf_flush(int fd, buf_head_t *bufhead)
#endif
{
buf_line_t *bufline;
struct Client *client_p = data;
int retval;
/* Check we actually have a first buffer */
@ -666,8 +667,8 @@ linebuf_flush(int fd, buf_head_t *bufhead)
/* Now, try writing data */
#ifdef USE_SSL
if (ssl != NULL)
retval = safe_SSL_write(ssl, bufline->buf + bufhead->writeofs, bufline->len - bufhead->writeofs);
if (IsSSL(client_p))
retval = safe_SSL_write(client_p, bufline->buf + bufhead->writeofs, bufline->len - bufhead->writeofs);
else
#endif
retval = send(fd, bufline->buf + bufhead->writeofs, bufline->len

View file

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
* $Id: packet.c,v 1.6 2002/11/04 08:14:00 fishwaldo Exp $
* $Id: packet.c,v 1.7 2002/11/04 08:50:46 fishwaldo Exp $
*/
#include "stdinc.h"
#include "tools.h"
@ -379,7 +379,7 @@ read_packet(int fd, void *data)
*/
#ifdef USE_SSL
if (IsSSL(client_p))
if (IsSSL(client_p)) {
length = safe_SSL_read(client_p, readBuf, READBUF_SIZE);
if (!IsSSLOK(client_p) && length > 0) {
SetSSLOK(client_p);
@ -389,7 +389,7 @@ read_packet(int fd, void *data)
return;
}
else
} else
#endif
length = recv(fd_r, readBuf, READBUF_SIZE, 0);
@ -444,6 +444,8 @@ printf("leng %d\n", length);
lclient_p->actually_read += lbuf_len;
if (client_p->next == NULL)
return;
/* Attempt to parse what we have */
parse_client_queued(client_p);

View file

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
* $Id: send.c,v 1.10 2002/11/04 08:14:00 fishwaldo Exp $
* $Id: send.c,v 1.11 2002/11/04 08:50:46 fishwaldo Exp $
*/
#include "stdinc.h"
@ -298,7 +298,7 @@ send_queued_write(int fd, void *data)
{
#ifdef USE_SSL
while((retlen = linebuf_flush(to->localClient->fd, &to->localClient->buf_sendq, to->localClient->ssl)) > 0)
while((retlen = linebuf_flush(to->localClient->fd, &to->localClient->buf_sendq, to)) > 0)
#else
while((retlen = linebuf_flush(to->localClient->fd, &to->localClient->buf_sendq)) > 0)
#endif

View file

@ -20,7 +20,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
* $Id: ssl.c,v 1.1 2002/11/04 08:14:01 fishwaldo Exp $
* $Id: ssl.c,v 1.2 2002/11/04 08:50:46 fishwaldo Exp $
*/
#include "stdinc.h"
@ -88,14 +88,17 @@ safe_SSL_read (struct Client * client_p, void *buf, int sz)
{
int len, ssl_err;
bzero(buf, sz);
len = SSL_read(client_p->localClient->ssl, buf, sz);
printf("ssl read %s\n", buf);
printf("ssl read %s\n\nlen %d (%d)", buf, len, sz);
if (len <= 0)
{
printf("len is less than 0 (%d)\n", len);
switch (ssl_err = SSL_get_error (client_p->localClient->ssl, len))
{
case SSL_ERROR_SYSCALL:
printf("SSL_ERROR_SYSCALL\n");
if (errno == EWOULDBLOCK || errno == EAGAIN || errno == EINTR)
{
case SSL_ERROR_WANT_READ: