Beispiel #1
0
int
identd_plugin_init (hextor_plugin *plugin_handle, char **plugin_name,
                    char **plugin_desc, char **plugin_version, char *arg)
{
    ph = plugin_handle;
    *plugin_name = "";
    *plugin_desc = "";
    *plugin_version = "";


    responses = g_hash_table_new_full (NULL, NULL, NULL, g_free);
    hextor_hook_command (ph, "IDENTD", HEXTOR_PRI_NORM, identd_command_cb,
                         _("IDENTD <port> <username>"), NULL);

    identd_start_server ();

    return 1; /* This must always succeed for /identd to work */
}
Beispiel #2
0
static int
identd_command_cb (char *word[], char *word_eol[], void *userdata)
{
	g_return_val_if_fail (responses != NULL, HEXCHAT_EAT_ALL);

	if (!g_strcmp0 (word[2], "reload"))
	{
		if (service)
		{
			g_socket_service_stop (service);
			g_clear_object (&service);
		}

		identd_start_server ();

		if (service)
			return HEXCHAT_EAT_ALL;
	}

	if (service == NULL) /* If we are not running plugins can handle it */
		return HEXCHAT_EAT_HEXCHAT;

	if (word[2] && *word[2] && word[3] && *word[3])
	{
		guint64 port = g_ascii_strtoull (word[2], NULL, 0);

		if (port && port <= G_MAXUINT16)
		{
			g_hash_table_insert (responses, GINT_TO_POINTER (port), g_strdup (word[3]));
			/* Automatically remove entry after 30 seconds */
			hexchat_hook_timer (ph, 30000, identd_cleanup_response_cb, GINT_TO_POINTER (port));
		}
	}
	else
	{
		hexchat_command (ph, "HELP IDENTD");
	}

	return HEXCHAT_EAT_ALL;
}