Compare commits
3 Commits
acl/user_s
...
writev_sup
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d183c7b3dc | ||
|
|
be098144db | ||
|
|
71cdf158e4 |
3
BUGS
3
BUGS
@@ -1 +1,2 @@
|
||||
Bugs are tracked on: https://github.com/janvidar/uhub/issues
|
||||
Bugs are tracked on: http://bugs.extatic.org/
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ enable_language(C)
|
||||
|
||||
set (UHUB_VERSION_MAJOR 0)
|
||||
set (UHUB_VERSION_MINOR 5)
|
||||
set (UHUB_VERSION_PATCH 1)
|
||||
set (UHUB_VERSION_PATCH 0)
|
||||
|
||||
set (PROJECT_SOURCE_DIR "${CMAKE_SOURCE_DIR}/src")
|
||||
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake/Modules)
|
||||
@@ -26,7 +26,8 @@ find_package(Git)
|
||||
find_package(Sqlite3)
|
||||
|
||||
include(TestBigEndian)
|
||||
include(CheckSymbolExists)
|
||||
include(CheckSymbolExists)
|
||||
include(CheckFunctionExists)
|
||||
include(CheckIncludeFile)
|
||||
include(CheckTypeSize)
|
||||
|
||||
@@ -54,13 +55,10 @@ if (SSL_SUPPORT)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (NOT SQLITE3_FOUND)
|
||||
message(FATAL_ERROR "SQLite3 is not found!")
|
||||
endif()
|
||||
|
||||
if (SYSTEMD_SUPPORT)
|
||||
INCLUDE(FindPkgConfig)
|
||||
pkg_search_module(SD REQUIRED libsystemd)
|
||||
pkg_search_module(SD_DAEMON REQUIRED libsystemd-daemon)
|
||||
pkg_search_module(SD_JOURNAL REQUIRED libsystemd-journal)
|
||||
endif()
|
||||
|
||||
if (MSVC)
|
||||
@@ -72,9 +70,19 @@ check_include_file(sys/types.h HAVE_SYS_TYPES_H)
|
||||
if (HAVE_SYS_TYPES_H)
|
||||
set (CMAKE_EXTRA_INCLUDE_FILES ${CMAKE_EXTRA_INCLUDE_FILES} "sys/types.h")
|
||||
endif()
|
||||
check_type_size( ssize_t SSIZE_T )
|
||||
|
||||
check_include_file(sys/uio.h HAVE_SYS_UIO_H)
|
||||
if (HAVE_SYS_UIO_H)
|
||||
set (CMAKE_EXTRA_INCLUDE_FILES ${CMAKE_EXTRA_INCLUDE_FILES} "sys/uio.h")
|
||||
endif()
|
||||
|
||||
check_type_size(ssize_t SSIZE_T)
|
||||
check_symbol_exists(memmem string.h HAVE_MEMMEM)
|
||||
check_symbol_exists(strndup string.h HAVE_STRNDUP)
|
||||
check_function_exists(writev HAVE_FUNC_WRITEV)
|
||||
check_function_exists(pwritev HAVE_FUNC_PWRITEV)
|
||||
check_function_exists(readv HAVE_FUNC_WRITEV)
|
||||
check_function_exists(preadv HAVE_FUNC_PWRITEV)
|
||||
|
||||
include_directories("${PROJECT_SOURCE_DIR}")
|
||||
include_directories(${SQLITE3_INCLUDE_DIRS})
|
||||
@@ -107,7 +115,7 @@ add_dependencies(adc utils)
|
||||
add_dependencies(network utils)
|
||||
|
||||
add_executable(uhub ${PROJECT_SOURCE_DIR}/core/main.c ${uhub_SOURCES} )
|
||||
add_executable(autotest-bin ${CMAKE_SOURCE_DIR}/autotest/test.c ${uhub_SOURCES} )
|
||||
add_executable(test ${CMAKE_SOURCE_DIR}/autotest/test.c ${uhub_SOURCES} )
|
||||
add_executable(uhub-passwd ${PROJECT_SOURCE_DIR}/tools/uhub-passwd.c)
|
||||
|
||||
add_library(mod_example MODULE ${PROJECT_SOURCE_DIR}/plugins/mod_example.c)
|
||||
@@ -123,7 +131,7 @@ add_library(mod_auth_sqlite MODULE ${PROJECT_SOURCE_DIR}/plugins/mod_auth_sqlite
|
||||
|
||||
if(WIN32)
|
||||
target_link_libraries(uhub ws2_32)
|
||||
target_link_libraries(autotest-bin ws2_32)
|
||||
target_link_libraries(test ws2_32)
|
||||
target_link_libraries(mod_logging ws2_32)
|
||||
target_link_libraries(mod_welcome ws2_32)
|
||||
endif()
|
||||
@@ -143,7 +151,7 @@ set_target_properties(
|
||||
|
||||
target_link_libraries(uhub ${CMAKE_DL_LIBS} adc network utils)
|
||||
target_link_libraries(uhub-passwd ${SQLITE3_LIBRARIES} utils)
|
||||
target_link_libraries(autotest-bin ${CMAKE_DL_LIBS} adc network utils)
|
||||
target_link_libraries(test ${CMAKE_DL_LIBS} adc network utils)
|
||||
target_link_libraries(mod_example utils)
|
||||
target_link_libraries(mod_welcome utils)
|
||||
target_link_libraries(mod_auth_simple utils)
|
||||
@@ -164,7 +172,7 @@ if(UNIX)
|
||||
add_executable(uhub-admin ${PROJECT_SOURCE_DIR}/tools/admin.c)
|
||||
target_link_libraries(uhub-admin adcclient adc network utils pthread)
|
||||
target_link_libraries(uhub pthread)
|
||||
target_link_libraries(autotest-bin pthread)
|
||||
target_link_libraries(test pthread)
|
||||
|
||||
if (ADC_STRESS)
|
||||
add_executable(adcrush ${PROJECT_SOURCE_DIR}/tools/adcrush.c ${adcclient_SOURCES})
|
||||
@@ -203,7 +211,7 @@ endif()
|
||||
|
||||
if(SSL_SUPPORT)
|
||||
target_link_libraries(uhub ${SSL_LIBS})
|
||||
target_link_libraries(autotest-bin ${SSL_LIBS})
|
||||
target_link_libraries(test ${SSL_LIBS})
|
||||
if(UNIX)
|
||||
target_link_libraries(uhub-admin ${SSL_LIBS})
|
||||
endif()
|
||||
@@ -215,11 +223,14 @@ if(SSL_SUPPORT)
|
||||
endif()
|
||||
|
||||
if (SYSTEMD_SUPPORT)
|
||||
target_link_libraries(uhub ${SD_LIBRARIES})
|
||||
target_link_libraries(autotest-bin ${SD_LIBRARIES})
|
||||
target_link_libraries(uhub-passwd ${SD_LIBRARIES})
|
||||
target_link_libraries(uhub-admin ${SD_LIBRARIES})
|
||||
include_directories(${SD_INCLUDE_DIRS})
|
||||
target_link_libraries(uhub ${SD_DAEMON_LIBRARIES})
|
||||
target_link_libraries(uhub ${SD_JOURNAL_LIBRARIES})
|
||||
target_link_libraries(test ${SD_DAEMON_LIBRARIES})
|
||||
target_link_libraries(test ${SD_JOURNAL_LIBRARIES})
|
||||
target_link_libraries(uhub-passwd ${SD_JOURNAL_LIBRARIES})
|
||||
target_link_libraries(uhub-admin ${SD_JOURNAL_LIBRARIES})
|
||||
include_directories(${SD_DAEMON_INCLUDE_DIRS})
|
||||
include_directories(${SD_JOURNAL_INCLUDE_DIRS})
|
||||
add_definitions(-DSYSTEMD)
|
||||
endif()
|
||||
|
||||
|
||||
@@ -17,8 +17,6 @@ static int result = 0;
|
||||
|
||||
EXO_TEST(setup, {
|
||||
hub = hub_malloc_zero(sizeof(struct hub_info));
|
||||
hub->config = hub_malloc_zero(sizeof(struct hub_config));
|
||||
config_defaults(hub->config);
|
||||
cbase = command_initialize(hub);
|
||||
hub->commands = cbase;
|
||||
hub->users = uman_init();
|
||||
@@ -248,8 +246,6 @@ EXO_TEST(command_destroy, {
|
||||
EXO_TEST(cleanup, {
|
||||
uman_shutdown(hub->users);
|
||||
command_shutdown(hub->commands);
|
||||
free_config(hub->config);
|
||||
hub_free(hub->config);
|
||||
hub_free(hub);
|
||||
return 1;
|
||||
});
|
||||
|
||||
@@ -34,8 +34,8 @@ cmake ${CMAKEOPTS} \
|
||||
make VERBOSE=1
|
||||
|
||||
|
||||
make VERBOSE=1 autotest-bin
|
||||
./autotest-bin
|
||||
make VERBOSE=1 test
|
||||
./test
|
||||
|
||||
|
||||
sudo make install
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
Getting started guide
|
||||
---------------------
|
||||
|
||||
(This document is maintained at http://www.extatic.org/uhub/getstarted.html )
|
||||
|
||||
Unpack your binaries
|
||||
|
||||
Example:
|
||||
@@ -15,7 +17,6 @@ Create configuration files.
|
||||
If no configuration files are created, uhub will use the default parameters, so you can skip this step if you are in a hurry to see it run.
|
||||
|
||||
As root, or use sudo.
|
||||
|
||||
% mkdir /etc/uhub
|
||||
% cp doc/uhub.conf /etc/uhub
|
||||
% cp doc/users.conf /etc/uhub
|
||||
@@ -31,11 +32,8 @@ NOTE: It is important to use the "adc://" prefix, and the port number when using
|
||||
|
||||
If you modify the configuration files in /etc/uhub you will have to notify uhub by sending a HUP signal.
|
||||
|
||||
% ps aux | grep uhub
|
||||
% kill -HUP <pid of uhub>
|
||||
|
||||
Or, for the lazy people
|
||||
|
||||
% killall -HUP uhub
|
||||
|
||||
In order to run uhub as a daemon, start it with the -f switch which will make it fork into the background.
|
||||
@@ -43,9 +41,9 @@ In addition, use the -l to specify a log file instead of stdout. One can also sp
|
||||
if one wishes to run uhub as a specific user using the -u and -g switches.
|
||||
|
||||
Example:
|
||||
|
||||
% uhub -f -l mylog.txt -u nobody -g nogroup
|
||||
|
||||
|
||||
If you are planning to more than 1024 users on hub, you must increase the max number of file descriptors allowed.
|
||||
This limit needs to be higher than the configured max_users in uhub.conf.
|
||||
|
||||
@@ -54,14 +52,6 @@ In linux can add the following lines to /etc/security/limits.conf (allows for ~4
|
||||
* hard nofile 4096
|
||||
|
||||
Or, you can use (as root):
|
||||
|
||||
% ulimit -n 4096
|
||||
|
||||
You can interact with uhub in your hub main chat using the `!` prefix, followed by a command:
|
||||
|
||||
Example :
|
||||
|
||||
* to display help and the command you can use:
|
||||
!help
|
||||
|
||||
Your mileage may vary -- Good luck!
|
||||
|
||||
@@ -41,7 +41,7 @@ plugin /usr/lib/uhub/mod_logging.so "file=/var/log/uhub.log"
|
||||
#
|
||||
# Parameters:
|
||||
# motd: path/filename for the welcome message (message of the day)
|
||||
# rules: path/filename for the rules file
|
||||
# rules: path/filenam for the rules file
|
||||
#
|
||||
# NOTE: The files MUST exist, however if you do not wish to provide one then these parameters can be omitted.
|
||||
#
|
||||
@@ -69,3 +69,4 @@ plugin /usr/lib/uhub/mod_welcome.so "motd=/etc/uhub/motd.txt rules=/etc/uhub/rul
|
||||
# history_default: when !history is provided without arguments, then this default number of messages are returned.
|
||||
# history_connect: the number of chat history messages to send when users connect (0 = do not send any history)
|
||||
plugin /usr/lib/uhub/mod_chat_history.so "history_max=200 history_default=10 history_connect=5"
|
||||
|
||||
|
||||
@@ -39,4 +39,4 @@ is one of 'admin', 'super', 'op', 'user'
|
||||
This program was written by Jan Vidar Krey <janvidar@extatic.org>
|
||||
.SH "BUG REPORTS"
|
||||
If you find a bug in uhub please report it to
|
||||
.B https://github.com/janvidar/uhub/issues
|
||||
.B http://bugs.extatic.org/
|
||||
|
||||
@@ -69,4 +69,4 @@ To run uhub as a daemon, and log to a file:
|
||||
This program was written by Jan Vidar Krey <janvidar@extatic.org>
|
||||
.SH "BUG REPORTS"
|
||||
If you find a bug in uhub please report it to
|
||||
.B https://github.com/janvidar/uhub/issues
|
||||
.B http://bugs.extatic.org/
|
||||
|
||||
@@ -574,33 +574,6 @@ static int command_stats(struct command_base* cbase, struct hub_user* user, stru
|
||||
return command_status(cbase, user, cmd, buf);
|
||||
}
|
||||
|
||||
static int command_register_self(struct command_base* cbase, struct hub_user* user, struct hub_command* cmd)
|
||||
{
|
||||
if (user_is_registered(user))
|
||||
return command_status(cbase, user, cmd, cbuf_create_const("You are already registered!"));
|
||||
|
||||
struct hub_command_arg_data* arg = hub_command_arg_next(cmd, type_string);
|
||||
char* password = arg->data.string;
|
||||
|
||||
if (!*password || strlen(password) > MAX_PASS_LEN)
|
||||
return command_status(cbase, user, cmd, cbuf_create_const("Invalid password!"));
|
||||
|
||||
struct auth_info info;
|
||||
memset(&info, 0, sizeof(info));
|
||||
memcpy(&info.nickname, user->id.nick, MAX_NICK_LEN);
|
||||
memcpy(&info.password, password, MAX_PASS_LEN);
|
||||
info.credentials = auth_cred_user;
|
||||
|
||||
|
||||
if (acl_register_user(cbase->hub, &info))
|
||||
{
|
||||
return command_status(cbase, user, cmd, cbuf_create_const("You are now registered."));
|
||||
}
|
||||
|
||||
// NOTE: No good reason for this can be given here!
|
||||
return command_status(cbase, user, cmd, cbuf_create_const("Unable to register user."));
|
||||
}
|
||||
|
||||
static struct command_handle* add_builtin(struct command_base* cbase, const char* prefix, const char* args, enum auth_credentials cred, command_handler handler, const char* description)
|
||||
{
|
||||
struct command_handle* handle = (struct command_handle*) hub_malloc_zero(sizeof(struct command_handle));
|
||||
@@ -628,10 +601,6 @@ void commands_builtin_add(struct command_base* cbase)
|
||||
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." );
|
||||
|
||||
if (cbase->hub->config->register_self)
|
||||
ADD_COMMAND("register", 8, "p", auth_cred_guest, command_register_self, "Register yourself." );
|
||||
|
||||
ADD_COMMAND("stats", 5, "", auth_cred_super, command_stats, "Show hub statistics." );
|
||||
ADD_COMMAND("uptime", 6, "", auth_cred_guest, command_uptime, "Display hub uptime info." );
|
||||
ADD_COMMAND("version", 7, "", auth_cred_guest, command_version, "Show hub version info." );
|
||||
|
||||
@@ -111,7 +111,7 @@
|
||||
<option name="register_self" type="boolean" default="0">
|
||||
<short>Allow users to register themselves on the hub.</short>
|
||||
<description><![CDATA[
|
||||
If this is enabled guests can register their nickname on the hub using !register command.
|
||||
If this is enabled guests can register their nickname on the hub.
|
||||
Otherwise only operators can register users.
|
||||
]]></description>
|
||||
<since>0.4.0</since>
|
||||
|
||||
@@ -19,6 +19,23 @@
|
||||
|
||||
#include "uhub.h"
|
||||
|
||||
struct ioq_send
|
||||
{
|
||||
size_t size; /** Size of send queue (in bytes, not messages) */
|
||||
size_t offset; /** Queue byte offset in the first message. Should be 0 unless a partial write. */
|
||||
#ifdef SSL_SUPPORT
|
||||
size_t last_send; /** When using SSL, one have to send the exact same buffer and length if a write cannot complete. */
|
||||
#endif
|
||||
struct linked_list* queue; /** List of queued messages (struct adc_message) */
|
||||
};
|
||||
|
||||
struct ioq_recv
|
||||
{
|
||||
char* buf;
|
||||
size_t size;
|
||||
};
|
||||
|
||||
|
||||
#ifdef DEBUG_SENDQ
|
||||
static void debug_msg(const char* prefix, struct adc_message* msg)
|
||||
{
|
||||
@@ -143,10 +160,46 @@ static void ioq_send_remove(struct ioq_send* q, struct adc_message* msg)
|
||||
|
||||
int ioq_send_send(struct ioq_send* q, struct net_connection* con)
|
||||
{
|
||||
int ret;
|
||||
struct adc_message* msg = list_get_first(q->queue);
|
||||
if (!msg) return 0;
|
||||
uhub_assert(msg->cache && *msg->cache);
|
||||
int ret;
|
||||
struct adc_message* msg = list_get_first(q->queue);
|
||||
if (!msg) return 0;
|
||||
uhub_assert(msg->cache && *msg->cache);
|
||||
|
||||
#ifdef HAVE_FUNC_WRITEV
|
||||
#define MAX_IOVEC 32
|
||||
struct iovec vec[MAX_IOVEC];
|
||||
size_t n = 0;
|
||||
vec[0].iov_base = msg->cache + q->offset;
|
||||
vec[0].iov_len = msg->length - q->offset;
|
||||
|
||||
for (struct adc_message* tmp = (struct adc_message*) list_get_next(q->queue), n = 1; tmp && n < MAX_IOVEC; tmp = (struct adc_message*) list_get_next(q->queue), n++)
|
||||
{
|
||||
vec[n].iov_base = msg->cache;
|
||||
vec[n].iov_len = msg->length;
|
||||
}
|
||||
|
||||
ret = net_con_writev(con, &iovec, n);
|
||||
|
||||
if (ret > 0)
|
||||
{
|
||||
while (ret > 0)
|
||||
{
|
||||
if (ret >= (msg->length - q->offset))
|
||||
{
|
||||
ret -= (msg->length - q->offset);
|
||||
q->offset = 0;
|
||||
ioq_send_remove(q, msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
q->offset += ret;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return ret;
|
||||
#else
|
||||
ret = net_con_send(con, msg->cache + q->offset, msg->length - q->offset);
|
||||
|
||||
if (ret > 0)
|
||||
@@ -159,8 +212,10 @@ int ioq_send_send(struct ioq_send* q, struct net_connection* con)
|
||||
return 1;
|
||||
}
|
||||
return ret;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
int ioq_send_is_empty(struct ioq_send* q)
|
||||
{
|
||||
return (q->size - q->offset) == 0;
|
||||
|
||||
@@ -21,25 +21,8 @@
|
||||
#define HAVE_UHUB_IO_QUEUE_H
|
||||
|
||||
struct adc_message;
|
||||
struct linked_list;
|
||||
typedef int (*ioq_write)(void* desc, const void* buf, size_t len);
|
||||
typedef int (*ioq_read)(void* desc, void* buf, size_t len);
|
||||
|
||||
struct ioq_send
|
||||
{
|
||||
size_t size; /** Size of send queue (in bytes, not messages) */
|
||||
size_t offset; /** Queue byte offset in the first message. Should be 0 unless a partial write. */
|
||||
#ifdef SSL_SUPPORT
|
||||
size_t last_send; /** When using SSL, one have to send the exact same buffer and length if a write cannot complete. */
|
||||
#endif
|
||||
struct linked_list* queue; /** List of queued messages (struct adc_message) */
|
||||
};
|
||||
|
||||
struct ioq_recv
|
||||
{
|
||||
char* buf;
|
||||
size_t size;
|
||||
};
|
||||
struct ioq_send;
|
||||
struct ioq_recv;
|
||||
|
||||
/**
|
||||
* Create a send queue
|
||||
|
||||
@@ -102,6 +102,7 @@ struct plugin_handle* plugin_load(const char* filename, const char* config, stru
|
||||
int ret;
|
||||
struct plugin_handle* handle = (struct plugin_handle*) hub_malloc_zero(sizeof(struct plugin_handle));
|
||||
struct uhub_plugin* plugin = plugin_open(filename);
|
||||
struct plugin_hub_internals* internals = (struct plugin_hub_internals*) plugin->internals;
|
||||
|
||||
if (!plugin)
|
||||
return NULL;
|
||||
@@ -117,7 +118,6 @@ struct plugin_handle* plugin_load(const char* filename, const char* config, stru
|
||||
unregister_f = plugin_lookup_symbol(plugin, "plugin_unregister");
|
||||
|
||||
// register hub internals
|
||||
struct plugin_hub_internals* internals = (struct plugin_hub_internals*) plugin->internals;
|
||||
internals->unregister = unregister_f;
|
||||
internals->hub = hub;
|
||||
internals->callback_data = plugin_callback_data_create();
|
||||
|
||||
@@ -80,13 +80,13 @@ static int check_send_queue(struct hub_info* hub, struct hub_user* user, struct
|
||||
if (user_flag_get(user, flag_user_list))
|
||||
return 1;
|
||||
|
||||
if ((user->send_queue->size + msg->length) > get_max_send_queue(hub))
|
||||
if ((ioq_send_get_bytes(user->send_queue) + msg->length) > get_max_send_queue(hub))
|
||||
{
|
||||
LOG_WARN("send queue overflowed, message discarded.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (user->send_queue->size > get_max_send_queue_soft(hub))
|
||||
if (ioq_send_get_bytes(user->send_queue) > get_max_send_queue_soft(hub))
|
||||
{
|
||||
LOG_WARN("send queue soft overflowed.");
|
||||
return 0;
|
||||
|
||||
@@ -57,6 +57,48 @@ ssize_t net_con_send(struct net_connection* con, const void* buf, size_t len)
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef HAVE_FUNC_WRITEV
|
||||
ssize_t net_con_writev(struct net_connection* con, const struct iovec* iov, size_t iocnt)
|
||||
{
|
||||
int ret;
|
||||
#ifdef SSL_SUPPORT
|
||||
if (!con->ssl)
|
||||
{
|
||||
#endif
|
||||
ret = writev(con->sd, iovec, (int) iocnt);
|
||||
if (ret == -1)
|
||||
{
|
||||
if (is_blocked_or_interrupted())
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
#ifdef SSL_SUPPORT
|
||||
}
|
||||
else
|
||||
{
|
||||
ssize_t total = 0;
|
||||
ret = 0;
|
||||
while (iocnt--)
|
||||
{
|
||||
ret = net_ssl_send(con, buf, len);
|
||||
if (ret >= 0)
|
||||
total += ret;
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (total == 0 && !is_blocked_or_interrupted())
|
||||
return -1;
|
||||
|
||||
return total;
|
||||
}
|
||||
#endif /* SSL_SUPPORT */
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
ssize_t net_con_recv(struct net_connection* con, void* buf, size_t len)
|
||||
{
|
||||
int ret;
|
||||
|
||||
@@ -92,6 +92,11 @@ extern void net_con_close(struct net_connection* con);
|
||||
*/
|
||||
extern ssize_t net_con_send(struct net_connection* con, const void* buf, size_t len);
|
||||
|
||||
|
||||
#ifdef HAVE_FUNC_WRITEV
|
||||
extern ssize_t net_con_writev(struct net_connection* con, const struct iovec* iov, size_t iocnt);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Receive data
|
||||
*
|
||||
|
||||
@@ -91,9 +91,7 @@ int net_ssl_library_init()
|
||||
int net_ssl_library_shutdown()
|
||||
{
|
||||
ERR_clear_error();
|
||||
#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
||||
ERR_remove_state(0);
|
||||
#endif
|
||||
|
||||
ENGINE_cleanup();
|
||||
CONF_modules_unload(1);
|
||||
@@ -108,24 +106,16 @@ int net_ssl_library_shutdown()
|
||||
|
||||
static void add_io_stats(struct net_ssl_openssl* handle)
|
||||
{
|
||||
#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
||||
unsigned long num_read = handle->bio->num_read;
|
||||
unsigned long num_write = handle->bio->num_write;
|
||||
#else
|
||||
unsigned long num_read = BIO_number_read(handle->bio);
|
||||
unsigned long num_write = BIO_number_written(handle->bio);
|
||||
#endif
|
||||
|
||||
if (num_read > handle->bytes_rx)
|
||||
if (handle->bio->num_read > handle->bytes_rx)
|
||||
{
|
||||
net_stats_add_rx(num_read - handle->bytes_rx);
|
||||
handle->bytes_rx = num_read;
|
||||
net_stats_add_rx(handle->bio->num_read - handle->bytes_rx);
|
||||
handle->bytes_rx = handle->bio->num_read;
|
||||
}
|
||||
|
||||
if (num_write > handle->bytes_tx)
|
||||
if (handle->bio->num_write > handle->bytes_tx)
|
||||
{
|
||||
net_stats_add_tx(num_write - handle->bytes_tx);
|
||||
handle->bytes_tx = num_write;
|
||||
net_stats_add_tx(handle->bio->num_write - handle->bytes_tx);
|
||||
handle->bytes_tx = handle->bio->num_write;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,7 +127,6 @@ static const SSL_METHOD* get_ssl_method(const char* tls_version)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
||||
if (!strcmp(tls_version, "1.0"))
|
||||
return TLSv1_method();
|
||||
if (!strcmp(tls_version, "1.1"))
|
||||
@@ -147,10 +136,6 @@ static const SSL_METHOD* get_ssl_method(const char* tls_version)
|
||||
|
||||
LOG_ERROR("Unable to recognize tls_version.");
|
||||
return 0;
|
||||
#else
|
||||
LOG_WARN("tls_version is obsolete, and should not be used.");
|
||||
return TLS_method();
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -348,7 +333,7 @@ ssize_t net_ssl_send(struct net_connection* con, const void* buf, size_t len)
|
||||
{
|
||||
struct net_ssl_openssl* handle = get_handle(con);
|
||||
|
||||
LOG_TRACE("net_ssl_send(), state=%d", (int) handle->state);
|
||||
LOG_ERROR("net_ssl_send(), state=%d", (int) handle->state);
|
||||
|
||||
if (handle->state == tls_st_error)
|
||||
return -2;
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include "util/list.h"
|
||||
#include "util/cbuffer.h"
|
||||
|
||||
#define MAX_HISTORY_SIZE 614400
|
||||
#define MAX_HISTORY_SIZE 16384
|
||||
|
||||
struct chat_history_data
|
||||
{
|
||||
@@ -142,7 +142,7 @@ void user_login(struct plugin_handle* plugin, struct plugin_user* user)
|
||||
struct cbuffer* buf = NULL;
|
||||
struct linked_list* found = (struct linked_list*) list_create();
|
||||
|
||||
sql_execute(data, get_messages_callback, found, "SELECT from_nick,message, datetime(time, 'localtime') as time FROM chat_history ORDER BY time DESC LIMIT 0,%d;", (int) data->history_connect);
|
||||
sql_execute(data, get_messages_callback, found, "SELECT * FROM chat_history ORDER BY time DESC LIMIT 0,%d;", (int) data->history_connect);
|
||||
|
||||
if (data->history_connect > 0 && list_size(found) > 0)
|
||||
{
|
||||
@@ -180,7 +180,7 @@ static int command_history(struct plugin_handle* plugin, struct plugin_user* use
|
||||
else
|
||||
maxlines = data->history_default;
|
||||
|
||||
sql_execute(data, get_messages_callback, found, "SELECT from_nick,message, datetime(time, 'localtime') as time FROM chat_history ORDER BY time DESC LIMIT 0,%d;", maxlines);
|
||||
sql_execute(data, get_messages_callback, found, "SELECT * FROM chat_history ORDER BY time DESC LIMIT 0,%d;", maxlines);
|
||||
|
||||
size_t linecount = list_size(found);
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ static struct log_data* parse_config(const char* line, struct plugin_handle* plu
|
||||
else if (strcmp(cfg_settings_get_key(setting), "syslog") == 0)
|
||||
{
|
||||
int use_syslog = 0;
|
||||
if (string_to_boolean(cfg_settings_get_value(setting), &use_syslog))
|
||||
if (!string_to_boolean(cfg_settings_get_value(setting), &use_syslog))
|
||||
{
|
||||
data->logmode = (use_syslog) ? mode_syslog : mode_file;
|
||||
}
|
||||
|
||||
@@ -88,6 +88,11 @@
|
||||
#cmakedefine HAVE_STRNDUP
|
||||
#cmakedefine HAVE_MEMMEM
|
||||
|
||||
#cmakedefine HAVE_SYS_UIO_H
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#include <sys/uio.h>
|
||||
#endif
|
||||
|
||||
/* printf support for size_t and uint64_t */
|
||||
#if defined(WIN32)
|
||||
#define PRINTF_SIZE_T "%Iu"
|
||||
@@ -197,10 +202,6 @@
|
||||
#define CPUINFO "ARM"
|
||||
#endif
|
||||
|
||||
#if defined(__aarch64__)
|
||||
#define CPUINFO "AArch64"
|
||||
#endif
|
||||
|
||||
#if defined(__i386__) || defined(__i386) || defined(i386) || defined(_M_IX86) || defined(__X86__) || defined(_X86_) || defined(__I86__) || defined(__INTEL__) || defined(__THW_INTEL__)
|
||||
#define CPUINFO "i386"
|
||||
#endif
|
||||
|
||||
@@ -375,7 +375,7 @@ void main_usage(const char* binary)
|
||||
" 'filename' is a database file\n"
|
||||
" 'username' is a nickname (UTF-8, up to %i bytes)\n"
|
||||
" 'password' is a password (UTF-8, up to %i bytes)\n"
|
||||
" 'credentials' is one of 'bot', 'ubot', 'opbot', 'opubot', 'admin', 'super', 'op' or 'user'\n"
|
||||
" 'credentials' is one of 'admin', 'super', 'op', 'user'\n"
|
||||
"\n"
|
||||
, binary, MAX_NICK_LEN, MAX_PASS_LEN);
|
||||
}
|
||||
@@ -403,3 +403,5 @@ int main(int argc, char** argv)
|
||||
main_usage(argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#include "uhub.h"
|
||||
|
||||
#define CBUF_FLAG_CONST_BUFFER 0x01
|
||||
#define MAX_MSG_LEN 16384
|
||||
|
||||
struct cbuffer
|
||||
{
|
||||
@@ -87,19 +86,19 @@ void cbuf_append(struct cbuffer* buf, const char* msg)
|
||||
|
||||
void cbuf_append_format(struct cbuffer* buf, const char* format, ...)
|
||||
{
|
||||
static char tmp[MAX_MSG_LEN];
|
||||
static char tmp[1024];
|
||||
va_list args;
|
||||
int bytes;
|
||||
uhub_assert(buf->flags == 0);
|
||||
va_start(args, format);
|
||||
bytes = vsnprintf(tmp, sizeof(tmp), format, args);
|
||||
bytes = vsnprintf(tmp, 1024, format, args);
|
||||
va_end(args);
|
||||
cbuf_append_bytes(buf, tmp, bytes);
|
||||
}
|
||||
|
||||
void cbuf_append_strftime(struct cbuffer* buf, const char* format, const struct tm* tm)
|
||||
{
|
||||
static char tmp[MAX_MSG_LEN];
|
||||
static char tmp[1024];
|
||||
int bytes;
|
||||
uhub_assert(buf->flags == 0);
|
||||
bytes = strftime(tmp, sizeof(tmp), format, tm);
|
||||
|
||||
Reference in New Issue
Block a user