Compare commits

...

2 Commits

Author SHA1 Message Date
Jan Vidar Krey c7d40dc6e0 Add missing file (Stub) 2019-01-22 18:29:06 +01:00
Jan Vidar Krey 9ac1a378d0 WIP 2019-01-17 18:57:19 +01:00
4 changed files with 74 additions and 1 deletions

View File

@ -1,6 +1,6 @@
##
## Makefile for uhub
## Copyright (C) 2007-2013, Jan Vidar Krey <janvidar@extatic.org>
## Copyright (C) 2007-2019, Jan Vidar Krey <janvidar@extatic.org>
#
cmake_minimum_required (VERSION 2.8.2)
@ -120,6 +120,7 @@ add_library(mod_chat_only MODULE ${PROJECT_SOURCE_DIR}/plugins/mod_chat_only.c)
add_library(mod_topic MODULE ${PROJECT_SOURCE_DIR}/plugins/mod_topic.c)
add_library(mod_no_guest_downloads MODULE ${PROJECT_SOURCE_DIR}/plugins/mod_no_guest_downloads.c)
add_library(mod_auth_sqlite MODULE ${PROJECT_SOURCE_DIR}/plugins/mod_auth_sqlite.c)
add_library(mod_require_tls MODULE ${PROJECT_SOURCE_DIR}/plugins/mod_require_tls.c)
if(WIN32)
target_link_libraries(uhub ws2_32)
@ -139,6 +140,7 @@ set_target_properties(
mod_chat_only
mod_no_guest_downloads
mod_topic
mod_require_tls
PROPERTIES PREFIX "")
target_link_libraries(uhub ${CMAKE_DL_LIBS} adc network utils)
@ -154,6 +156,7 @@ target_link_libraries(mod_no_guest_downloads utils)
target_link_libraries(mod_chat_only utils)
target_link_libraries(mod_logging utils)
target_link_libraries(mod_topic utils)
target_link_libraries(mod_require_tls utils)
target_link_libraries(utils network)
target_link_libraries(mod_welcome network)
target_link_libraries(mod_logging network)

View File

@ -96,6 +96,29 @@ static int cbfunc_user_disconnect(struct plugin_handle* plugin, struct plugin_us
return 0;
}
static int cbfunc_user_redirect(struct plugin_handle* plugin, struct plugin_user* user, const char* address)
{
char* buffer = adc_msg_escape(address);
struct adc_message* command = adc_msg_construct(ADC_CMD_IQUI, strlen(buffer) + 10);
adc_msg_add_named_argument(command, ADC_QUI_FLAG_REDIRECT, buffer);
route_to_user(plugin_get_hub(plugin), convert_user_type(user), command);
adc_msg_free(command);
hub_free(buffer);
hub_disconnect_user(plugin_get_hub(plugin), convert_user_type(user), quit_disconnected);
return 0;
}
static int cbfunc_user_is_tls_connected(struct plugin_handle* plugin, struct plugin_user* user)
{
#ifdef SSL_SUPPORT
struct hub_user* u = convert_user_type(user);
return net_con_is_ssl(u->connection);
#else
return 0;
#endif
}
static int cbfunc_command_add(struct plugin_handle* plugin, struct plugin_command_handle* cmdh)
{
struct plugin_callback_data* data = get_callback_data(plugin);
@ -203,6 +226,8 @@ void plugin_register_callback_functions(struct plugin_handle* handle)
handle->hub.send_broadcast_message = cbfunc_send_broadcast;
handle->hub.send_status_message = cbfunc_send_status;
handle->hub.user_disconnect = cbfunc_user_disconnect;
handle->hub.user_redirect = cbfunc_user_redirect;
handle->hub.user_is_tls_connected = cbfunc_user_is_tls_connected;
handle->hub.command_add = cbfunc_command_add;
handle->hub.command_del = cbfunc_command_del;
handle->hub.command_arg_reset = cbfunc_command_arg_reset;

View File

@ -114,6 +114,8 @@ typedef int (*hfunc_send_message)(struct plugin_handle*, struct plugin_user* use
typedef int (*hfunc_send_broadcast_message)(struct plugin_handle*, const char* message);
typedef int (*hfunc_send_status)(struct plugin_handle*, struct plugin_user* to, int code, const char* message);
typedef int (*hfunc_user_disconnect)(struct plugin_handle*, struct plugin_user* user);
typedef int (*hfunc_user_redirect)(struct plugin_handle*, struct plugin_user* user, const char* address);
typedef int (*hfunc_user_is_tls_connected)(struct plugin_handle*, struct plugin_user* user);
typedef int (*hfunc_command_add)(struct plugin_handle*, struct plugin_command_handle*);
typedef int (*hfunc_command_del)(struct plugin_handle*, struct plugin_command_handle*);
@ -137,6 +139,8 @@ struct plugin_hub_funcs
hfunc_send_broadcast_message send_broadcast_message;
hfunc_send_status send_status_message;
hfunc_user_disconnect user_disconnect;
hfunc_user_redirect user_redirect;
hfunc_user_is_tls_connected user_is_tls_connected;
hfunc_command_add command_add;
hfunc_command_del command_del;
hfunc_command_arg_reset command_arg_reset;

View File

@ -0,0 +1,41 @@
/*
* uhub - A tiny ADC p2p connection hub
* Copyright (C) 2007-2018, Jan Vidar Krey
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*
*/
#include "plugin_api/handle.h"
#include "plugin_api/command_api.h"
#include "util/memory.h"
struct example_plugin_data
{
struct plugin_command_handle* redirect;
};
int plugin_register(struct plugin_handle* plugin, const char* config)
{
PLUGIN_INITIALIZE(plugin, "TLS redirect plugin", "1.0", "A simple redirect to TLS plug-in");
return 0;
}
int plugin_unregister(struct plugin_handle* plugin)
{
return 0;
}