Added simple plugin that blocks downloads for non-registered users (guests).
This commit is contained in:
parent
594801df46
commit
a43953bc0d
|
@ -76,6 +76,7 @@ add_library(mod_auth_simple MODULE ${PROJECT_SOURCE_DIR}/plugins/mod_auth_simple
|
|||
add_library(mod_chat_history MODULE ${PROJECT_SOURCE_DIR}/plugins/mod_chat_history.c )
|
||||
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)
|
||||
|
||||
if (SQLITE_SUPPORT)
|
||||
add_library(mod_auth_sqlite MODULE ${PROJECT_SOURCE_DIR}/plugins/mod_auth_sqlite.c)
|
||||
|
@ -101,6 +102,7 @@ set_target_properties(
|
|||
mod_auth_simple
|
||||
mod_chat_history
|
||||
mod_chat_only
|
||||
mod_no_guest_downloads
|
||||
mod_topic
|
||||
PROPERTIES PREFIX "")
|
||||
|
||||
|
@ -110,6 +112,7 @@ target_link_libraries(mod_example utils)
|
|||
target_link_libraries(mod_welcome utils)
|
||||
target_link_libraries(mod_auth_simple utils)
|
||||
target_link_libraries(mod_chat_history utils)
|
||||
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)
|
||||
|
@ -184,7 +187,7 @@ endif()
|
|||
|
||||
if (UNIX)
|
||||
install( TARGETS uhub RUNTIME DESTINATION bin )
|
||||
install( TARGETS mod_example mod_welcome mod_logging mod_auth_simple mod_auth_sqlite mod_chat_history mod_chat_only mod_topic DESTINATION /usr/lib/uhub/ OPTIONAL )
|
||||
install( TARGETS mod_example mod_welcome mod_logging mod_auth_simple mod_auth_sqlite mod_chat_history mod_chat_only mod_topic mod_no_guest_downloads DESTINATION /usr/lib/uhub/ OPTIONAL )
|
||||
install( FILES ${CMAKE_SOURCE_DIR}/doc/uhub.conf ${CMAKE_SOURCE_DIR}/doc/plugins.conf ${CMAKE_SOURCE_DIR}/doc/rules.txt ${CMAKE_SOURCE_DIR}/doc/motd.txt DESTINATION /etc/uhub OPTIONAL )
|
||||
|
||||
if (SQLITE_SUPPORT)
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* uhub - A tiny ADC p2p connection hub
|
||||
* Copyright (C) 2007-2012, 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 "util/memory.h"
|
||||
|
||||
static plugin_st on_search_result(struct plugin_handle* plugin, struct plugin_user* from, struct plugin_user* to, const char* search_data)
|
||||
{
|
||||
if (to->credentials >= auth_cred_user)
|
||||
return st_default;
|
||||
return st_deny;
|
||||
}
|
||||
|
||||
static plugin_st on_search(struct plugin_handle* plugin, struct plugin_user* user, const char* search_data)
|
||||
{
|
||||
// Registered users are allowed to search.
|
||||
if (user->credentials >= auth_cred_user)
|
||||
return st_default;
|
||||
return st_deny;
|
||||
}
|
||||
|
||||
static plugin_st on_p2p_connect(struct plugin_handle* plugin, struct plugin_user* from, struct plugin_user* to)
|
||||
{
|
||||
if (from->credentials >= auth_cred_user)
|
||||
return st_default;
|
||||
return st_deny;
|
||||
}
|
||||
|
||||
int plugin_register(struct plugin_handle* plugin, const char* config)
|
||||
{
|
||||
PLUGIN_INITIALIZE(plugin, "No guest downloading", "0.1", "This plug-in only allows registered users to search and initiate transfers.");
|
||||
plugin->ptr = NULL;
|
||||
plugin->funcs.on_search = on_search;
|
||||
plugin->funcs.on_search_result = on_search_result;
|
||||
plugin->funcs.on_p2p_connect = on_p2p_connect;
|
||||
// plugin->funcs.on_p2p_revconnect = on_p2p_connect;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int plugin_unregister(struct plugin_handle* plugin)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue