Misc plugin work

* Fix crash when unloading plugins.
* Fixed plugin loader and plugin unload handler.
* Added a new example plugin: mod_logging which logs users logging in and out of the hub to stdout.
This commit is contained in:
Jan Vidar Krey
2010-06-22 16:04:33 +02:00
parent ccaa4860b4
commit aa26052479
11 changed files with 265 additions and 29 deletions

View File

@@ -175,8 +175,10 @@ void net_on_accept(struct net_connection* con, int event, void *arg)
struct hub_info* hub = (struct hub_info*) arg;
struct hub_probe* probe = 0;
struct ip_addr_encap ipaddr;
const char* addr;
int server_fd = net_con_get_sd(con);
#ifdef PLUGIN_SUPPORT
plugin_st status;
#endif
for (;;)
{
@@ -194,19 +196,18 @@ void net_on_accept(struct net_connection* con, int event, void *arg)
}
}
addr = ip_convert_to_string(&ipaddr);
/* FIXME: Should have a plugin log this */
LOG_TRACE("Got connection from %s", addr);
/* FIXME: A plugin should perform this check: is IP banned? */
if (acl_is_ip_banned(hub->acl, addr))
#ifdef PLUGIN_SUPPORT
status = plugin_check_ip_early(hub, &ipaddr);
if (status == st_deny)
{
LOG_INFO("Denied [%s] (IP banned)", addr);
plugin_log_connection_denied(hub, &ipaddr);
net_close(fd);
continue;
}
plugin_log_connection_accepted(hub, &ipaddr);
#endif
probe = probe_create(hub, fd, &ipaddr);
if (!probe)
{