+/*
+** Copyright (C) 2006 Thadeu Lima de Souza Cascardo <cascardo@minaslivre.org>
+**
+** 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 <glib.h>
#include <gnet.h>
#include <stdio.h>
+#include <unistd.h>
#include "log.h"
+#include "nethook.h"
+#include "proto_detect.h"
-#define CONFFILE "/etc/improxy.conf"
-
-void client_event (GConn* conn, GConnEvent* event, gpointer data)
-{
- GConn* server;
- server = (GConn*) data;
- switch (event->type)
- {
- case GNET_CONN_CONNECT:
- g_debug ("Connected to localhost:80.");
- gnet_conn_read (conn);
- break;
- case GNET_CONN_READ:
- if (server == NULL)
- {
- g_debug ("Establishing connection to localhost:80.");
- server = gnet_conn_new ("127.0.0.1", 80, client_event, (gpointer) conn);
- gnet_conn_connect (server);
- gnet_conn_set_callback (conn, client_event, (gpointer) server);
- }
- gnet_conn_write (server, event->buffer, event->length);
- gnet_conn_read (conn);
- break;
- case GNET_CONN_WRITE:
- break;
- case GNET_CONN_CLOSE:
- gnet_conn_unref (server);
- gnet_conn_unref (conn);
- break;
- default:
- g_warning ("Received an unexpected client event.");
- break;
- }
-}
+#define CONFFILE SYSCONFDIR "/improxy.conf"
void new_client (GServer* server, GConn* conn, gpointer data)
{
+ net_hook_t* hook;
if (conn == NULL)
{
g_critical ("Server has received an error event.");
return;
}
g_message ("Received connection from %s.", conn->hostname);
- gnet_conn_set_callback (conn, client_event, NULL);
+ hook = proto_detect_new (conn);
gnet_conn_read (conn);
}
gchar* conf_address;
gint port;
+ daemon (0, 0);
+
gnet_init ();
im_log_init ();