This commit is contained in:
Jan Vidar Krey 2012-04-19 23:17:39 +02:00
commit 55030935a7
16 changed files with 72 additions and 63 deletions

8
.gitignore vendored
View File

@ -7,3 +7,11 @@ uhub-admin
adcrush
uhub
revision.h*
build-stamp
debian/files
debian/uhub.debhelper.log
debian/uhub.postinst.debhelper
debian/uhub.postrm.debhelper
debian/uhub.prerm.debhelper
debian/uhub.substvars
uhub-passwd

View File

@ -355,7 +355,5 @@ dist-clean:
@rm -rf $(all_OBJECTS) *~ core
clean:
@rm -rf $(libuhub_OBJECTS) *~ core $(uhub_BINARY) $(admin_BINARY) $(autotest_BINARY) $(adcrush_BINARY) $(all_OBJECTS) $(all_plugins) autotest.c revision.h revision.h.tmp && \
@rm -rf $(libuhub_OBJECTS) *~ core $(uhub_BINARY) $(uhub-passwd_BINARY) $(admin_BINARY) $(autotest_BINARY) $(adcrush_BINARY) $(all_OBJECTS) $(all_plugins) autotest.c revision.h revision.h.tmp && \
echo $(MSG_CLEAN)

2
README
View File

@ -4,5 +4,5 @@ For the official documentation, bugs and other information, please visit:
http://www.uhub.org/
For a list of compatible ADC clients, see:
http://www.adcportal.com/wiki/index.php/ADC_Software_List#Client_Software
http://en.wikipedia.org/wiki/Advanced_Direct_Connect#Client_software

4
debian/changelog vendored
View File

@ -2,13 +2,13 @@ uhub (0.3.2-1) unstable; urgency=low
* Updated upstream version.
-- Jan Vidar Krey <janvidar@extatic.org> Mon 30 May 2010 18:00:00 +0200
-- Jan Vidar Krey <janvidar@extatic.org> Mon, 30 May 2010 18:00:00 +0200
uhub (0.3.1-1) unstable; urgency=low
* Updated version number.
-- Jan Vidar Krey <janvidar@extatic.org> Mon 04 Apr 2010 16:44:21 +0200
-- Jan Vidar Krey <janvidar@extatic.org> Mon, 04 Apr 2010 16:44:21 +0200
uhub (0.3.0-2) unstable; urgency=low

View File

@ -1,13 +1,13 @@
= Architecture of uHub =
uHub is single threaded and handles network and timer events using the
uHub is single-threaded and handles network and timer events using the
libevent library.
For each state there is a read event (and sometimes a write event) and timeout
event in case an expected read (or write) event does not occur.
== Protocol overview ==
uHub use "speak" the ADC protocol, which works in short as follows:
uHub "speaks" the ADC protocol, which works in short as follows:
(C = client, S = server aka uHub).
C: HSUP ADBASE

View File

@ -1,7 +1,7 @@
How to compile:
---------------
See the official compiling howto: http://www.extatic.org/uhub/compile.html
See the official compiling howto: http://www.uhub.org/compile.php
Prerequisites

View File

@ -31,7 +31,7 @@ The hub should send a packet containing the token back:
'IECH {token} {host:port}', aswell as the same message via TCP.
If the client receives the message via UDP, it should now be able to determine the type of NAT.
If the client receives the message via TCP only it knows it has a firewall blocking icomming communication.
If the client receives the message via TCP only it knows it has a firewall blocking incomming communication.
If the client does not receive the message, it should assume a firewall is blocking all UDP communication,
and resume in passive mode.

View File

@ -186,7 +186,10 @@ static enum command_parse_status command_extract_arguments(struct command_base*
if (!token || !*token)
{
status = (arg_code == '?' ? cmd_status_ok : cmd_status_missing_args);
if (arg_code == '?' || opt == 1)
status = cmd_status_ok;
else
status = cmd_status_missing_args;
break;
}
@ -284,7 +287,7 @@ static enum command_parse_status command_extract_arguments(struct command_base*
{
hub_free(data);
data = NULL;
return cmd_status_arg_number;
status = cmd_status_arg_number;
}
break;
@ -387,10 +390,13 @@ void command_get_syntax(struct command_handle* handler, struct cbuffer* buf)
{
for (n = 0; n < strlen(handler->args); n++)
{
if (n > 0 && !opt) cbuf_append(buf, " ");
if (n > 0)
cbuf_append(buf, " ");
if (opt)
cbuf_append(buf, "[");
switch (handler->args[n])
{
case '?': cbuf_append(buf, "["); opt = 1; continue;
case '?': opt = 1; continue;
case 'n': cbuf_append(buf, "<nick>"); break;
case 'u': cbuf_append(buf, "<user>"); break;
case 'i': cbuf_append(buf, "<cid>"); break;
@ -403,11 +409,10 @@ void command_get_syntax(struct command_handle* handler, struct cbuffer* buf)
case 'N': cbuf_append(buf, "<number>"); break;
}
if (opt)
{
opt++;
}
while (opt--)
cbuf_append(buf, "]");
opt = 0;
}
}
}
}
@ -858,7 +863,7 @@ void commands_builtin_add(struct command_base* cbase)
ADD_COMMAND("getip", 5, "u", auth_cred_operator, command_getip, "Show IP address for a user" );
ADD_COMMAND("help", 4, "?c",auth_cred_guest, command_help, "Show this help message." );
ADD_COMMAND("kick", 4, "u", auth_cred_operator, command_kick, "Kick a user" );
ADD_COMMAND("log", 3, "?m", auth_cred_operator, command_log, "Display log" ); // fail
ADD_COMMAND("log", 3, "?m",auth_cred_operator, command_log, "Display log" ); // fail
ADD_COMMAND("myip", 4, "", auth_cred_guest, command_myip, "Show your own IP." );
ADD_COMMAND("reload", 6, "", auth_cred_admin, command_reload, "Reload configuration files." );
ADD_COMMAND("shutdown", 8, "", auth_cred_admin, command_shutdown_hub, "Shutdown hub." );

View File

@ -83,7 +83,7 @@ struct hub_command
{
const char* message; /**<<< "The complete message." */
char* prefix; /**<<< "The prefix extracted from the message." */
struct linked_list* args; /**<<< "List of all parsed arguments from the message. Type depends on expectations." */
struct linked_list* args; /**<<< "List of arguments of type struct hub_command_arg_data. Parsed from message." */
enum command_parse_status status; /**<<< "Status of the hub_command." */
command_handler handler; /**<<< "The function handler to call in order to invoke this command." */
const struct hub_user* user; /**<<< "The user who invoked this command." */

View File

@ -54,26 +54,6 @@ static int plugin_command_dispatch(struct command_base* cbase, struct hub_user*
return 0;
}
struct plugin_callback_data* plugin_callback_data_create()
{
struct plugin_callback_data* data = (struct plugin_callback_data*) hub_malloc_zero(sizeof(struct plugin_callback_data));
LOG_PLUGIN("plugin_callback_data_create()");
data->commands = list_create();
return data;
}
void plugin_callback_data_destroy(struct plugin_callback_data* data)
{
LOG_PLUGIN("plugin_callback_data_destroy()");
if (data->commands)
{
uhub_assert(list_size(data->commands) == 0);
list_destroy(data->commands);
}
hub_free(data);
}
static struct hub_user* convert_user_type(struct plugin_user* user)
{
struct hub_user* huser = (struct hub_user*) user;
@ -229,3 +209,30 @@ void plugin_register_callback_functions(struct plugin_handle* handle)
void plugin_unregister_callback_functions(struct plugin_handle* handle)
{
}
struct plugin_callback_data* plugin_callback_data_create()
{
struct plugin_callback_data* data = (struct plugin_callback_data*) hub_malloc_zero(sizeof(struct plugin_callback_data));
LOG_PLUGIN("plugin_callback_data_create()");
data->commands = list_create();
return data;
}
void plugin_callback_data_destroy(struct plugin_handle* plugin, struct plugin_callback_data* data)
{
LOG_PLUGIN("plugin_callback_data_destroy()");
if (data->commands)
{
// delete commands not deleted by the plugin itself:
struct plugin_command_handle* cmd = list_get_first(data->commands);
while (cmd)
{
cbfunc_command_del(plugin, cmd);
list_remove(data->commands, cmd);
cmd = list_get_next(data->commands);
}
list_destroy(data->commands);
}
hub_free(data);
}

View File

@ -24,7 +24,7 @@ struct plugin_handle;
struct uhub_plugin;
extern struct plugin_callback_data* plugin_callback_data_create();
extern void plugin_callback_data_destroy(struct plugin_callback_data* data);
extern void plugin_callback_data_destroy(struct plugin_handle* plugin, struct plugin_callback_data* data);
extern void plugin_register_callback_functions(struct plugin_handle* plugin);
extern void plugin_unregister_callback_functions(struct plugin_handle* plugin);

View File

@ -76,7 +76,7 @@ void plugin_close(struct uhub_plugin* plugin)
struct plugin_hub_internals* internals = (struct plugin_hub_internals*) plugin->internals;
LOG_PLUGIN("plugin_close: \"%s\"", plugin->filename);
plugin_callback_data_destroy(internals->callback_data);
plugin_callback_data_destroy(plugin->handle, internals->callback_data);
hub_free(internals);
plugin->internals = NULL;
@ -162,8 +162,8 @@ struct plugin_handle* plugin_load(const char* filename, const char* config, stru
void plugin_unload(struct plugin_handle* plugin)
{
struct plugin_hub_internals* internals = get_internals(plugin);
plugin_unregister_callback_functions(plugin);
internals->unregister(plugin);
plugin_unregister_callback_functions(plugin);
plugin_close(plugin->handle);
hub_free(plugin);
}

View File

@ -114,13 +114,6 @@ int net_destroy()
return -1;
}
#ifdef USE_LIBEVENT
struct event_base* net_get_evbase()
{
return net_evbase;
}
#endif
static void net_error_out(int fd, const char* func)
{
int err = net_error();

View File

@ -51,8 +51,6 @@ extern int net_initialize();
*/
extern int net_destroy();
extern struct event_base* net_get_evbase();
/**
* @return the number of sockets currrently being monitored.
*/

View File

@ -55,7 +55,7 @@ int net_backend_poll_select(struct net_backend* data, int ms)
struct net_backend_select* backend = (struct net_backend_select*) data;
tval.tv_sec = ms / 1000;
tval.tv_usec = ((ms % 1000) * 1000); // FIXME: correct?
tval.tv_usec = (ms % 1000) * 1000;
FD_ZERO(&backend->rfds);
FD_ZERO(&backend->wfds);