Remove the ssl hook files, since we don't need them any more.
authorThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Fri, 3 Jul 2009 04:53:21 +0000 (01:53 -0300)
committerThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Fri, 3 Jul 2009 04:53:21 +0000 (01:53 -0300)
Makefile.am
ssl.c [deleted file]
ssl.h [deleted file]
ssl_server.c [deleted file]

index 2e9f9f1..039dcb7 100644 (file)
@@ -2,7 +2,7 @@ bin_PROGRAMS = popproxy ppmanager
 popproxy_SOURCES = popproxy.c log.c log.h nethook.c nethook.h \
        tcp_connect.h tcp_connect.c tcp_server.c \
        hcconn.c hcconn.h hcconn_internal.h hcconn_ssl.c \
-       null.c null.h ssl.c ssl.h \
-       ssl_server.c pop.c pop.h usermap.c usermap.h
+       null.c null.h \
+       pop.c pop.h usermap.c usermap.h
 dist_sysconf_DATA = popproxy.conf
 ppmanager = ppmanager.c
diff --git a/ssl.c b/ssl.c
deleted file mode 100644 (file)
index 7c75483..0000000
--- a/ssl.c
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
-** Copyright (C) 2006 Thadeu Lima de Souza Cascardo <cascardo@minaslivre.org>
-** Copyright (C) 2009 Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
-**  
-** 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.
-**  
-*/
-
-#include <gnutls/gnutls.h>
-#include <glib.h>
-#include <string.h>
-#include <errno.h>
-#include "ssl.h"
-
-static void
-ssl_connect (net_hook_t *hook)
-{
-}
-
-static void
-ssl_close (net_hook_t *hook)
-{
-  if (hook->peer)
-    {
-      hook->peer->peer = NULL;
-      hc_conn_close (hook->peer->conn);
-    }
-  hc_conn_close (hook->conn);
-  g_slice_free (net_hook_t, hook);
-}
-
-static void
-ssl_read (net_hook_t *hook, gchar *buffer, size_t len)
-{
-  struct ssl_data *ssl = hook->peer->data;
-  gnutls_record_send (ssl->session, buffer, len);
-}
-
-static void
-ssl_error (net_hook_t *hook)
-{
-}
-
-net_hook_t *
-ssl_hook_new (HCConn *conn, char *server, char *port)
-{
-  net_hook_t *hook;
-  hook = g_slice_new (net_hook_t);
-  hook->conn = conn;
-  hook->peer = NULL;
-  hook->server = FALSE;
-  hook->connect = ssl_connect;
-  hook->close = ssl_close;
-  hook->read = ssl_read;
-  hook->data = NULL;
-  hook->peer = ssl_server_hook_new (hook, server, port);
-  hc_conn_set_callback (hook->conn, nethook_event, hook);
-  return hook;
-}
-
-void
-ssl_destroy (net_hook_t *hook)
-{
-  g_slice_free (net_hook_t, hook);
-}
diff --git a/ssl.h b/ssl.h
deleted file mode 100644 (file)
index 62e75d5..0000000
--- a/ssl.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
-** Copyright (C) 2006 Thadeu Lima de Souza Cascardo <cascardo@minaslivre.org>
-** Copyright (C) 2009 Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
-**  
-** 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.
-**  
-*/
-
-#ifndef POPPROXY_SSL_H
-#define POPPROXY_SSL_H
-
-#include "nethook.h"
-#include "hcconn.h"
-
-struct ssl_data
-{
-  char *server;
-  gnutls_session_t session;
-  GString *buffer;
-  gboolean handshaking;
-};
-
-net_hook_t* ssl_hook_new (HCConn*, char*, char *);
-void ssl_destroy (net_hook_t*);
-
-net_hook_t * ssl_server_hook_new (net_hook_t *, char *, char *);
-
-#endif
diff --git a/ssl_server.c b/ssl_server.c
deleted file mode 100644 (file)
index 270e7bd..0000000
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
-** Copyright (C) 2006 Thadeu Lima de Souza Cascardo <cascardo@minaslivre.org>
-** Copyright (C) 2009 Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
-**  
-** 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.
-**  
-*/
-
-#include <gnutls/gnutls.h>
-#include <glib.h>
-#include <string.h>
-#include <errno.h>
-#include "ssl.h"
-
-static struct ssl_data *
-ssl_data_new (void)
-{
-  struct ssl_data *ssl;
-  int kx_prio[] = {GNUTLS_KX_RSA, 0};
-  gnutls_certificate_credentials cred;
-  gnutls_certificate_allocate_credentials (&cred);
-  ssl = g_slice_new (struct ssl_data);
-  gnutls_init (&ssl->session, GNUTLS_CLIENT);
-  gnutls_set_default_priority (ssl->session);
-  gnutls_set_default_priority (ssl->session);
-  gnutls_kx_set_priority (ssl->session, kx_prio);
-  gnutls_credentials_set (ssl->session, GNUTLS_CRD_CERTIFICATE, cred);
-  ssl->buffer = g_string_sized_new (4096);
-  ssl->handshaking = FALSE;
-  return ssl;
-}
-
-static void
-ssl_data_destroy (struct ssl_data *ssl)
-{
-  gnutls_deinit (ssl->session);
-  g_string_free (ssl->buffer, TRUE);
-  g_slice_free (struct ssl_data, ssl);
-}
-
-static ssize_t
-ssl_push (gnutls_transport_ptr_t ptr, const void *buffer, size_t len)
-{
-  net_hook_t *hook = ptr;
-  struct ssl_data *ssl = hook->data;
-  int r;
-  if (ssl->handshaking == TRUE)
-    {
-      hc_conn_write (hook->conn, (void *) buffer, len);
-      return len;
-    }
-  hc_conn_write (hook->conn, (void *) buffer, len);
-  return len;
-}
-
-static ssize_t
-ssl_pull (gnutls_transport_ptr_t ptr, void *buffer, size_t len)
-{
-  net_hook_t *hook = ptr;
-  struct ssl_data *ssl = hook->data;
-  int r;
-  if (ssl->handshaking == TRUE)
-    {
-      r = hc_conn_read (hook->conn, buffer, len);
-      return r;
-    }
-  if (len > ssl->buffer->len)
-    {
-      r = ssl->buffer->len;
-      memcpy (buffer, ssl->buffer->str, r);
-      g_string_truncate (ssl->buffer, 0);
-    }
-  else
-    {
-      r = len;
-      memcpy (buffer, ssl->buffer->str, r);
-      g_string_erase (ssl->buffer, 0, r);
-    }
-  if (r == 0)
-    {
-      gnutls_transport_set_errno (ssl->session, EAGAIN);
-      return -1;
-    }
-  return r;
-}
-
-static void
-ssl_server_connect (net_hook_t *hook)
-{
-  struct ssl_data *ssl = hook->data;
-  int error;
-  gnutls_transport_set_ptr (ssl->session, (gnutls_transport_ptr_t) hook);
-  gnutls_transport_set_push_function (ssl->session, ssl_push);
-  gnutls_transport_set_pull_function (ssl->session, ssl_pull);
-  ssl->handshaking = TRUE;
-  if ((error = gnutls_handshake (ssl->session)) < 0)
-    {
-      if (gnutls_error_is_fatal (error))
-        g_critical ("Fatal error while doing TLS handshaking: %s\n",
-                    gnutls_strerror (error));
-    }
-  if (error != GNUTLS_E_AGAIN && error != GNUTLS_E_INTERRUPTED)
-    {
-      ssl->handshaking = FALSE;
-    }
-}
-
-static void
-ssl_server_close (net_hook_t *hook)
-{
-  struct ssl_data *ssl = hook->data;
-  if (hook->peer)
-    {
-      hook->peer->peer = NULL;
-      hc_conn_close (hook->peer->conn);
-    }
-  hc_conn_close (hook->conn);
-  if (ssl != NULL)
-    {
-      gnutls_bye (ssl->session, GNUTLS_SHUT_RDWR);
-      ssl_data_destroy (ssl);
-    }
-  g_slice_free (net_hook_t, hook);
-}
-
-static void
-ssl_server_read (net_hook_t *hook, gchar *buffer, size_t len)
-{
-  struct ssl_data *ssl = hook->data;
-  int r;
-  g_string_append_len (ssl->buffer, buffer, len);
-  do
-    {
-      r = gnutls_record_recv (ssl->session, buffer, len);
-      if (r > 0)
-        hc_conn_write (hook->peer->conn, buffer, r);
-    } while (r > 0);
-}
-
-static void
-ssl_server_error (net_hook_t *hook)
-{
-  g_message ("Error in POP3 client connection.");
-}
-
-net_hook_t *
-ssl_server_hook_new (net_hook_t *client_hook, char *server, char *port)
-{
-  net_hook_t *hook;
-  int fd;
-  hook = g_slice_new (net_hook_t);
-  hook->peer = client_hook;
-  hook->server = TRUE;
-  hook->connect = ssl_server_connect;
-  hook->close = ssl_server_close;
-  hook->read = ssl_server_read;
-  hook->data = ssl_data_new ();
-  hook->conn = hc_conn_new (nethook_event, hook);
-  fd = hc_tcp_connect (server, port);
-  hc_conn_set_driver_channel (hook->conn, fd);
-  return hook;
-}