6 #include "proto_detect.h"
8 #define CONFFILE SYSCONFDIR "/improxy.conf"
10 void new_client (GServer* server, GConn* conn, gpointer data)
15 g_critical ("Server has received an error event.");
18 g_message ("Received connection from %s.", conn->hostname);
19 hook = proto_detect_new (conn);
20 gnet_conn_read (conn);
23 static gchar* configfile;
25 static GOptionEntry opt_entries[] =
27 { "config-file", 'c', 0, G_OPTION_ARG_FILENAME, &configfile,
28 "Configuration file location", "file" },
32 int main (int argc, char** argv)
35 GOptionContext* opt_ctx;
44 configfile = CONFFILE;
45 opt_ctx = g_option_context_new ("");
46 g_option_context_add_main_entries (opt_ctx, opt_entries, NULL);
47 if (!g_option_context_parse (opt_ctx, &argc, &argv, NULL))
49 g_log (NULL, G_LOG_LEVEL_WARNING | G_LOG_FLAG_FATAL,
50 "Could not parse command line options.");
52 g_option_context_free (opt_ctx);
54 keyfile = g_key_file_new ();
56 g_key_file_load_from_file (keyfile, configfile, G_KEY_FILE_NONE, NULL);
58 conf_address = g_key_file_get_string (keyfile, "global", "address", NULL);
59 port = g_key_file_get_integer (keyfile, "global", "port", NULL);
61 g_message ("Listen address is %s:%d.", conf_address, port);
63 inetaddr = gnet_inetaddr_new_nonblock (conf_address, port);
64 gnet_server_new (inetaddr, port, new_client, NULL);
66 g_main_loop_run (g_main_loop_new (g_main_context_default (), TRUE));