Compare commits
68 Commits
Author | SHA1 | Date |
---|---|---|
Jeffrey Paul | fdc1ccc68e | |
Jeffrey Paul | 0875ba15f5 | |
Jan Vidar Krey | 35d8088b44 | |
Jan Vidar Krey | cff10910ad | |
Jan Vidar Krey | 78a7039240 | |
Jan Vidar Krey | 0ae96b0da8 | |
Jan Vidar Krey | 022a9895ec | |
Jan Vidar Krey | 891adb84fb | |
Jan Vidar Krey | 9762b9389d | |
Jan Vidar Krey | 076e75897b | |
Jan Vidar Krey | bc8974b9a3 | |
Boris Pek | 1eb00ac04a | |
Boris Pek | cf3a6e06df | |
Boris Pek | cb04255006 | |
Jan Vidar Krey | 2a57dc859d | |
Jan Vidar Krey | 212064c166 | |
Jan Vidar Krey | 56426f7b2a | |
Jan Vidar Krey | 00bd8ba24d | |
Jan Vidar Krey | 46906a9a9c | |
Denys Smirnov | 566cd9a9db | |
Boris Pek | b27c44e633 | |
Boris Pek | d25fead3a8 | |
Boris Pek | ef83b31cec | |
Boris Pek | be1ad4f475 | |
Boris Pek | 3435d53478 | |
Felix Brucker | 9038f56efe | |
Jan Vidar Krey | de01486c0f | |
Jan Vidar Krey | c383a53105 | |
Kcchouette | f0b67ea4cd | |
Kcchouette | ac96ace7df | |
Kcchouette | 7970f80114 | |
Kcchouette | 62216a7afe | |
Felix Brucker | 99711a5c6e | |
Felix Brucker | e43aea35cc | |
makefu | d54d723c59 | |
Jan Vidar Krey | c813231c8d | |
Kcchouette | debbca572f | |
Jan Vidar Krey | a8ee6e7f60 | |
Jan Vidar Krey | f0e9b2ffd9 | |
Jan Vidar Krey | ba19048ebc | |
Jan Vidar Krey | fd05f13fe4 | |
Jan Vidar Krey | 11538d6909 | |
Yorhel | 90d05c9a19 | |
Jan Vidar Krey | ed5a59b16c | |
CoiLock | 70f2a43f67 | |
Jan Vidar Krey | dc80644471 | |
Jan Vidar Krey | 889807da1b | |
Jan Vidar Krey | 5151badbeb | |
mimicmod | 96cc46117f | |
Michal Micka | 5e63ab2ccd | |
Francisco Blas (klondike) Izquierdo Riera | 32b7e68f00 | |
Francisco Blas (klondike) Izquierdo Riera | 5c5918a89d | |
Francisco Blas (klondike) Izquierdo Riera | 3f2641595b | |
Jan Vidar Krey | 0e27e4219d | |
Jan Vidar Krey | e32bb3ff7a | |
mimicmod | 32c65ada49 | |
mimicmod | 77704f6e67 | |
mimicmod | 77323fa98d | |
mimicmod | 7840e09884 | |
Michal Micka | 6ad5efea6d | |
Francisco Blas (klondike) Izquierdo Riera | 076daec846 | |
Francisco Blas (klondike) Izquierdo Riera | 223e01937e | |
klondike | 19068de088 | |
klondike | c15f201d70 | |
klondike | 7bda215ad4 | |
klondike | d86ef503b3 | |
Francisco Blas (klondike) Izquierdo Riera | 7865277324 | |
Francisco Blas (klondike) Izquierdo Riera | 8a7e892aeb |
|
@ -0,0 +1,17 @@
|
|||
kind: pipeline
|
||||
name: default
|
||||
|
||||
steps:
|
||||
- name: docker
|
||||
image: plugins/docker
|
||||
network_mode: bridge
|
||||
settings:
|
||||
repo: sneak/uhub
|
||||
username:
|
||||
from_secret: docker_username
|
||||
password:
|
||||
from_secret: docker_password
|
||||
tags:
|
||||
- ${DRONE_BRANCH//\//-}-${DRONE_COMMIT_SHA:0:8}
|
||||
- ${DRONE_COMMIT_SHA}
|
||||
- ${DRONE_BRANCH/\//-}
|
|
@ -21,5 +21,3 @@ debian/uhub.postrm.debhelper
|
|||
debian/uhub.prerm.debhelper
|
||||
debian/uhub.substvars
|
||||
uhub-passwd
|
||||
src/version.h
|
||||
src/system.h
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
[submodule "thirdparty/sqlite"]
|
||||
path = thirdparty/sqlite
|
||||
url = git://github.com/janvidar/sqlite.git
|
||||
url = https://github.com/janvidar/sqlite.git
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
language: cpp
|
||||
dist: xenial
|
||||
compiler:
|
||||
- gcc
|
||||
- clang
|
||||
|
@ -9,3 +10,5 @@ install:
|
|||
- autotest/travis/install-build-depends.sh
|
||||
script:
|
||||
- autotest/travis/build-and-test.sh
|
||||
dist: xenial
|
||||
|
||||
|
|
3
BUGS
3
BUGS
|
@ -1,2 +1 @@
|
|||
Bugs are tracked on: http://bugs.extatic.org/
|
||||
|
||||
Bugs are tracked on: https://github.com/janvidar/uhub/issues
|
||||
|
|
|
@ -10,7 +10,7 @@ enable_language(C)
|
|||
|
||||
set (UHUB_VERSION_MAJOR 0)
|
||||
set (UHUB_VERSION_MINOR 5)
|
||||
set (UHUB_VERSION_PATCH 0)
|
||||
set (UHUB_VERSION_PATCH 1)
|
||||
|
||||
set (PROJECT_SOURCE_DIR "${CMAKE_SOURCE_DIR}/src")
|
||||
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake/Modules)
|
||||
|
@ -54,10 +54,13 @@ 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_DAEMON REQUIRED libsystemd-daemon)
|
||||
pkg_search_module(SD_JOURNAL REQUIRED libsystemd-journal)
|
||||
pkg_search_module(SD REQUIRED libsystemd)
|
||||
endif()
|
||||
|
||||
if (MSVC)
|
||||
|
@ -74,6 +77,7 @@ check_symbol_exists(memmem string.h HAVE_MEMMEM)
|
|||
check_symbol_exists(strndup string.h HAVE_STRNDUP)
|
||||
|
||||
include_directories("${PROJECT_SOURCE_DIR}")
|
||||
include_directories("${PROJECT_BINARY_DIR}")
|
||||
include_directories(${SQLITE3_INCLUDE_DIRS})
|
||||
link_directories(${SQLITE3_LIBRARY_DIRS})
|
||||
|
||||
|
@ -104,7 +108,7 @@ add_dependencies(adc utils)
|
|||
add_dependencies(network utils)
|
||||
|
||||
add_executable(uhub ${PROJECT_SOURCE_DIR}/core/main.c ${uhub_SOURCES} )
|
||||
add_executable(test ${CMAKE_SOURCE_DIR}/autotest/test.c ${uhub_SOURCES} )
|
||||
add_executable(autotest-bin ${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)
|
||||
|
@ -118,13 +122,6 @@ 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)
|
||||
|
||||
if(WIN32)
|
||||
target_link_libraries(uhub ws2_32)
|
||||
target_link_libraries(test ws2_32)
|
||||
target_link_libraries(mod_logging ws2_32)
|
||||
target_link_libraries(mod_welcome ws2_32)
|
||||
endif()
|
||||
|
||||
set_target_properties(
|
||||
mod_example
|
||||
mod_welcome
|
||||
|
@ -140,28 +137,32 @@ set_target_properties(
|
|||
|
||||
target_link_libraries(uhub ${CMAKE_DL_LIBS} adc network utils)
|
||||
target_link_libraries(uhub-passwd ${SQLITE3_LIBRARIES} utils)
|
||||
target_link_libraries(test ${CMAKE_DL_LIBS} adc network utils)
|
||||
target_link_libraries(autotest-bin ${CMAKE_DL_LIBS} adc network utils)
|
||||
target_link_libraries(mod_example utils)
|
||||
target_link_libraries(mod_welcome utils)
|
||||
target_link_libraries(mod_welcome network utils)
|
||||
target_link_libraries(mod_auth_simple utils)
|
||||
target_link_libraries(mod_auth_sqlite ${SQLITE3_LIBRARIES} utils)
|
||||
target_link_libraries(mod_chat_history utils)
|
||||
target_link_libraries(mod_chat_history_sqlite ${SQLITE3_LIBRARIES} 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_logging network utils)
|
||||
target_link_libraries(mod_topic utils)
|
||||
target_link_libraries(utils network)
|
||||
target_link_libraries(mod_welcome network)
|
||||
target_link_libraries(mod_logging network)
|
||||
|
||||
if(WIN32)
|
||||
target_link_libraries(uhub ws2_32)
|
||||
target_link_libraries(autotest-bin ws2_32)
|
||||
target_link_libraries(mod_logging ws2_32)
|
||||
target_link_libraries(mod_welcome ws2_32)
|
||||
endif()
|
||||
|
||||
if(UNIX)
|
||||
add_library(adcclient STATIC ${adcclient_SOURCES})
|
||||
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(test pthread)
|
||||
target_link_libraries(autotest-bin pthread)
|
||||
|
||||
if (ADC_STRESS)
|
||||
add_executable(adcrush ${PROJECT_SOURCE_DIR}/tools/adcrush.c ${adcclient_SOURCES})
|
||||
|
@ -200,7 +201,7 @@ endif()
|
|||
|
||||
if(SSL_SUPPORT)
|
||||
target_link_libraries(uhub ${SSL_LIBS})
|
||||
target_link_libraries(test ${SSL_LIBS})
|
||||
target_link_libraries(autotest-bin ${SSL_LIBS})
|
||||
if(UNIX)
|
||||
target_link_libraries(uhub-admin ${SSL_LIBS})
|
||||
endif()
|
||||
|
@ -212,19 +213,16 @@ if(SSL_SUPPORT)
|
|||
endif()
|
||||
|
||||
if (SYSTEMD_SUPPORT)
|
||||
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})
|
||||
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})
|
||||
add_definitions(-DSYSTEMD)
|
||||
endif()
|
||||
|
||||
configure_file ("${PROJECT_SOURCE_DIR}/version.h.in" "${PROJECT_SOURCE_DIR}/version.h")
|
||||
configure_file ("${PROJECT_SOURCE_DIR}/system.h.in" "${PROJECT_SOURCE_DIR}/system.h")
|
||||
configure_file ("${PROJECT_SOURCE_DIR}/version.h.in" "${PROJECT_BINARY_DIR}/version.h")
|
||||
configure_file ("${PROJECT_SOURCE_DIR}/system.h.in" "${PROJECT_BINARY_DIR}/system.h")
|
||||
|
||||
# mark_as_advanced(FORCE CMAKE_BUILD_TYPE)
|
||||
# if (RELEASE)
|
||||
|
|
|
@ -47,8 +47,8 @@
|
|||
- marked plugin callbacks that are not called yet
|
||||
- add on_change_nick() to struct plugin_funcs
|
||||
- minimal changes
|
||||
- Updated init script in debian package.
|
||||
- Updated list of man pages in debian package.
|
||||
- Updated init script in Debian package.
|
||||
- Updated list of man pages in Debian package.
|
||||
- Added man page for uhub-passwd.
|
||||
- Merge branch 'master' of https://github.com/Tilka/uhub
|
||||
- Fix issue with QUI messages being allowed through the hub
|
||||
|
@ -78,7 +78,7 @@
|
|||
- minimal documentation fixes
|
||||
- update client software link
|
||||
- update compile howto link
|
||||
- fix debian changelog
|
||||
- fix Debian changelog
|
||||
- Fix bug #158 - Added plugin for setting topic (hub description).
|
||||
- Command arguments handling + cleanups
|
||||
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
FROM alpine:latest as builder
|
||||
RUN apk update && apk upgrade && apk add --no-cache bash util-linux cmake make gcc git sqlite-dev openssl-dev git build-base
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
RUN cmake . && make
|
||||
RUN sed -i 's/\/usr\/lib\/uhub\//\/libs\//g' ./doc/*.conf && \
|
||||
sed -i 's/\/usr\/lib\/uhub\//\/libs\//g' ./doc/rules.txt && \
|
||||
sed -i 's/\/etc\/uhub\//\/conf\//g' ./doc/*.conf && \
|
||||
sed -i 's/\/etc\/uhub\//\/conf\//g' ./doc/rules.txt && \
|
||||
echo 'Welcome to uHub' > ./doc/motd.txt
|
||||
|
||||
FROM alpine:latest
|
||||
RUN apk update && apk upgrade && apk add --no-cache bash util-linux openssl-dev sqlite-dev
|
||||
WORKDIR /app
|
||||
COPY --from=builder /app/uhub .
|
||||
COPY --from=builder /app/doc/plugins.conf /app/doc/uhub.conf /app/doc/users.conf /app/doc/rules.txt /app/doc/motd.txt /conf/
|
||||
COPY --from=builder /app/*.so /libs/
|
||||
ENTRYPOINT ["./uhub"]
|
||||
CMD ["-c","/conf/uhub.conf"]
|
|
@ -1,8 +1,13 @@
|
|||
# uhub
|
||||
|
||||
Welcome and thanks for downloading uHub, a high performance ADC p2p hub.
|
||||
|
||||
For the official documentation, bugs and other information, please visit:
|
||||
http://www.uhub.org/
|
||||
https://www.uhub.org/
|
||||
|
||||
For a list of compatible ADC clients, see:
|
||||
http://en.wikipedia.org/wiki/Advanced_Direct_Connect#Client_software
|
||||
https://en.wikipedia.org/wiki/Comparison_of_ADC_software#Client_software
|
||||
|
||||
# on dockerhub
|
||||
|
||||
* https://hub.docker.com/r/sneak/uhub
|
|
@ -78,7 +78,7 @@ Description: a high performance hub for the ADC peer-to-peer network
|
|||
Its low memory footprint allows it to handle several thousand users
|
||||
on high-end servers, or a small private hub on embedded hardware.
|
||||
.
|
||||
Homepage: http://www.extatic.org/uhub/
|
||||
Homepage: https://www.uhub.org/
|
||||
EOF
|
||||
cd ..
|
||||
|
||||
|
|
|
@ -706,6 +706,34 @@ int main(int argc, char** argv)
|
|||
exotic_add_test(&handle, &exotic_test_utf8_valid_10, "utf8_valid_10");
|
||||
exotic_add_test(&handle, &exotic_test_utf8_valid_11, "utf8_valid_11");
|
||||
exotic_add_test(&handle, &exotic_test_utf8_valid_12, "utf8_valid_12");
|
||||
exotic_add_test(&handle, &exotic_test_utf8_valid_13, "utf8_valid_13");
|
||||
exotic_add_test(&handle, &exotic_test_utf8_valid_14, "utf8_valid_14");
|
||||
exotic_add_test(&handle, &exotic_test_utf8_valid_15, "utf8_valid_15");
|
||||
exotic_add_test(&handle, &exotic_test_utf8_valid_16, "utf8_valid_16");
|
||||
exotic_add_test(&handle, &exotic_test_utf8_valid_17, "utf8_valid_17");
|
||||
exotic_add_test(&handle, &exotic_test_utf8_valid_18, "utf8_valid_18");
|
||||
exotic_add_test(&handle, &exotic_test_utf8_valid_19, "utf8_valid_19");
|
||||
exotic_add_test(&handle, &exotic_test_utf8_valid_20, "utf8_valid_20");
|
||||
exotic_add_test(&handle, &exotic_test_utf8_valid_21, "utf8_valid_21");
|
||||
exotic_add_test(&handle, &exotic_test_utf8_valid_22, "utf8_valid_22");
|
||||
exotic_add_test(&handle, &exotic_test_utf8_valid_23, "utf8_valid_23");
|
||||
exotic_add_test(&handle, &exotic_test_utf8_valid_24, "utf8_valid_24");
|
||||
exotic_add_test(&handle, &exotic_test_utf8_valid_25, "utf8_valid_25");
|
||||
exotic_add_test(&handle, &exotic_test_utf8_valid_26, "utf8_valid_26");
|
||||
exotic_add_test(&handle, &exotic_test_utf8_valid_27, "utf8_valid_27");
|
||||
exotic_add_test(&handle, &exotic_test_utf8_valid_28, "utf8_valid_28");
|
||||
exotic_add_test(&handle, &exotic_test_utf8_valid_29, "utf8_valid_29");
|
||||
exotic_add_test(&handle, &exotic_test_utf8_valid_30, "utf8_valid_30");
|
||||
exotic_add_test(&handle, &exotic_test_utf8_valid_31, "utf8_valid_31");
|
||||
exotic_add_test(&handle, &exotic_test_utf8_valid_32, "utf8_valid_32");
|
||||
exotic_add_test(&handle, &exotic_test_utf8_valid_33, "utf8_valid_33");
|
||||
exotic_add_test(&handle, &exotic_test_utf8_valid_34, "utf8_valid_34");
|
||||
exotic_add_test(&handle, &exotic_test_utf8_valid_35, "utf8_valid_35");
|
||||
exotic_add_test(&handle, &exotic_test_utf8_valid_36, "utf8_valid_36");
|
||||
exotic_add_test(&handle, &exotic_test_utf8_valid_37, "utf8_valid_37");
|
||||
exotic_add_test(&handle, &exotic_test_utf8_valid_38, "utf8_valid_38");
|
||||
exotic_add_test(&handle, &exotic_test_utf8_valid_39, "utf8_valid_39");
|
||||
exotic_add_test(&handle, &exotic_test_utf8_valid_40, "utf8_valid_40");
|
||||
exotic_add_test(&handle, &exotic_test_rbtree_create_destroy, "rbtree_create_destroy");
|
||||
exotic_add_test(&handle, &exotic_test_rbtree_create_1, "rbtree_create_1");
|
||||
exotic_add_test(&handle, &exotic_test_rbtree_size_0, "rbtree_size_0");
|
||||
|
|
|
@ -107,6 +107,7 @@ static const char test_utf_seq_6[] = { 0xE2, 0x82, 0xAC, 0x00}; // valid
|
|||
static const char test_utf_seq_7[] = { 0xC2, 0x32, 0x00}; // invalid
|
||||
static const char test_utf_seq_8[] = { 0xE2, 0x82, 0x32, 0x00}; // invalid
|
||||
static const char test_utf_seq_9[] = { 0xE2, 0x32, 0x82, 0x00}; // invalid
|
||||
static const char test_utf_seq_10[] = { 0xF0, 0x9F, 0x98, 0x81, 0x00}; // valid
|
||||
|
||||
EXO_TEST(utf8_valid_4, { return is_valid_utf8(test_utf_seq_1); });
|
||||
EXO_TEST(utf8_valid_5, { return !is_valid_utf8(test_utf_seq_2); });
|
||||
|
@ -117,5 +118,61 @@ EXO_TEST(utf8_valid_9, { return is_valid_utf8(test_utf_seq_6); });
|
|||
EXO_TEST(utf8_valid_10, { return !is_valid_utf8(test_utf_seq_7); });
|
||||
EXO_TEST(utf8_valid_11, { return !is_valid_utf8(test_utf_seq_8); });
|
||||
EXO_TEST(utf8_valid_12, { return !is_valid_utf8(test_utf_seq_9); });
|
||||
EXO_TEST(utf8_valid_13, { return is_valid_utf8(test_utf_seq_10); });
|
||||
|
||||
// Limits of utf-8
|
||||
static const char test_utf_seq_11[] = { 0x7F, 0x00 }; // valid last 7-bit character
|
||||
static const char test_utf_seq_12[] = { 0x80, 0x00 }; // invalid truncated string
|
||||
static const char test_utf_seq_13[] = { 0xBF, 0x00 }; // invalid truncated string
|
||||
static const char test_utf_seq_14[] = { 0xC0, 0x80, 0x00 }; // invalid out of 2 bytes range
|
||||
static const char test_utf_seq_15[] = { 0xC1, 0x7F, 0x00 }; // invalid out of 2 bytes range
|
||||
static const char test_utf_seq_16[] = { 0xC2, 0x00 }; // invalid truncated string
|
||||
static const char test_utf_seq_17[] = { 0xC2, 0x80, 0x00 }; // valid
|
||||
static const char test_utf_seq_18[] = { 0xDF, 0xBF, 0x00 }; // valid
|
||||
static const char test_utf_seq_19[] = { 0xE0, 0x80, 0x80, 0x00 }; // invalid out of 3 bytes range
|
||||
static const char test_utf_seq_20[] = { 0xE0, 0x9F, 0xBF, 0x00 }; // invalid out of 3 bytes range
|
||||
static const char test_utf_seq_21[] = { 0xE0, 0x00 }; // invalid truncated string
|
||||
static const char test_utf_seq_22[] = { 0xE0, 0xA0, 0x00 }; // invalid truncated string
|
||||
static const char test_utf_seq_23[] = { 0xE0, 0xA0, 0x80, 0x00 }; // valid
|
||||
static const char test_utf_seq_24[] = { 0xEC, 0x9F, 0xBF, 0x00 }; // valid
|
||||
static const char test_utf_seq_25[] = { 0xED, 0xA0, 0x80, 0x00 }; // invalid surrogate
|
||||
static const char test_utf_seq_26[] = { 0xED, 0xBF, 0xBF, 0x00 }; // invalid surrogate
|
||||
static const char test_utf_seq_27[] = { 0xEF, 0x80, 0x80, 0x00 }; // valid
|
||||
static const char test_utf_seq_28[] = { 0xEF, 0xBF, 0xBF, 0x00 }; // valid
|
||||
static const char test_utf_seq_29[] = { 0xF0, 0x80, 0x80, 0x80, 0x00 }; // invalid out of 4 bytes range
|
||||
static const char test_utf_seq_30[] = { 0xF0, 0x8F, 0xBF, 0xBF, 0x00 }; // invalid out of 4 bytes range
|
||||
static const char test_utf_seq_31[] = { 0xF0, 0x00 }; // invalid truncated string
|
||||
static const char test_utf_seq_32[] = { 0xF0, 0x90, 0x00 }; // invalid truncated string
|
||||
static const char test_utf_seq_33[] = { 0xF0, 0x90, 0x80, 0x00 }; // invalid truncated string
|
||||
static const char test_utf_seq_34[] = { 0xF0, 0x90, 0x80, 0x80, 0x00 }; // valid
|
||||
static const char test_utf_seq_35[] = { 0xF4, 0x8F, 0xBF, 0xBF, 0x00 }; // valid
|
||||
static const char test_utf_seq_36[] = { 0xF4, 0x90, 0x80, 0x80, 0x00 }; // invalid out of 4 bytes range
|
||||
static const char test_utf_seq_37[] = { 0xFF, 0xBF, 0xBF, 0xBF, 0x00 }; // invalid out of 4 bytes range
|
||||
|
||||
EXO_TEST(utf8_valid_14, { return is_valid_utf8(test_utf_seq_11); });
|
||||
EXO_TEST(utf8_valid_15, { return !is_valid_utf8(test_utf_seq_12); });
|
||||
EXO_TEST(utf8_valid_16, { return !is_valid_utf8(test_utf_seq_13); });
|
||||
EXO_TEST(utf8_valid_17, { return !is_valid_utf8(test_utf_seq_14); });
|
||||
EXO_TEST(utf8_valid_18, { return !is_valid_utf8(test_utf_seq_15); });
|
||||
EXO_TEST(utf8_valid_19, { return !is_valid_utf8(test_utf_seq_16); });
|
||||
EXO_TEST(utf8_valid_20, { return is_valid_utf8(test_utf_seq_17); });
|
||||
EXO_TEST(utf8_valid_21, { return is_valid_utf8(test_utf_seq_18); });
|
||||
EXO_TEST(utf8_valid_22, { return !is_valid_utf8(test_utf_seq_19); });
|
||||
EXO_TEST(utf8_valid_23, { return !is_valid_utf8(test_utf_seq_20); });
|
||||
EXO_TEST(utf8_valid_24, { return !is_valid_utf8(test_utf_seq_21); });
|
||||
EXO_TEST(utf8_valid_25, { return !is_valid_utf8(test_utf_seq_22); });
|
||||
EXO_TEST(utf8_valid_26, { return is_valid_utf8(test_utf_seq_23); });
|
||||
EXO_TEST(utf8_valid_27, { return is_valid_utf8(test_utf_seq_24); });
|
||||
EXO_TEST(utf8_valid_28, { return !is_valid_utf8(test_utf_seq_25); });
|
||||
EXO_TEST(utf8_valid_29, { return !is_valid_utf8(test_utf_seq_26); });
|
||||
EXO_TEST(utf8_valid_30, { return is_valid_utf8(test_utf_seq_27); });
|
||||
EXO_TEST(utf8_valid_31, { return is_valid_utf8(test_utf_seq_28); });
|
||||
EXO_TEST(utf8_valid_32, { return !is_valid_utf8(test_utf_seq_29); });
|
||||
EXO_TEST(utf8_valid_33, { return !is_valid_utf8(test_utf_seq_30); });
|
||||
EXO_TEST(utf8_valid_34, { return !is_valid_utf8(test_utf_seq_31); });
|
||||
EXO_TEST(utf8_valid_35, { return !is_valid_utf8(test_utf_seq_32); });
|
||||
EXO_TEST(utf8_valid_36, { return !is_valid_utf8(test_utf_seq_33); });
|
||||
EXO_TEST(utf8_valid_37, { return is_valid_utf8(test_utf_seq_34); });
|
||||
EXO_TEST(utf8_valid_38, { return is_valid_utf8(test_utf_seq_35); });
|
||||
EXO_TEST(utf8_valid_39, { return !is_valid_utf8(test_utf_seq_36); });
|
||||
EXO_TEST(utf8_valid_40, { return !is_valid_utf8(test_utf_seq_37); });
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -x
|
||||
set -e
|
||||
|
||||
export CFLAGS="$(dpkg-buildflags --get CFLAGS) $(dpkg-buildflags --get CPPFLAGS)"
|
||||
export LDFLAGS="$(dpkg-buildflags --get LDFLAGS) -Wl,--as-needed"
|
||||
|
@ -33,6 +34,10 @@ cmake ${CMAKEOPTS} \
|
|||
make VERBOSE=1
|
||||
|
||||
|
||||
make VERBOSE=1 autotest-bin
|
||||
./autotest-bin
|
||||
|
||||
|
||||
sudo make install
|
||||
du -shc /etc/uhub/ /usr/bin/uhub* /usr/lib/uhub/
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
# SQLITE3_FOUND True if sqlite3 got found
|
||||
# SQLITE3_INCLUDEDIR Location of sqlite3 headers
|
||||
# SQLITE3_LIBRARIES List of libaries to use sqlite3
|
||||
# SQLITE3_LIBRARIES List of libraries to use sqlite3
|
||||
# SQLITE3_DEFINITIONS Definitions to compile sqlite3
|
||||
#
|
||||
# Copyright (c) 2007 Juha Tuomala <tuju@iki.fi>
|
||||
|
|
|
@ -20,5 +20,5 @@ Description: High performance ADC p2p hub
|
|||
- Advanced access control support
|
||||
- Easy configuration
|
||||
.
|
||||
Homepage: http://www.uhub.org/
|
||||
Homepage: https://www.uhub.org/
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ 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/>.
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
On Debian GNU/Linux systems, the complete text of the GNU General Public
|
||||
License can be found in `/usr/share/common-licenses/GPL'.
|
||||
|
|
|
@ -67,7 +67,7 @@ Accepting new users
|
|||
| | |
|
||||
| V |
|
||||
| --------------------- ---------------------
|
||||
| | Send password | ------> | Reveive and check |
|
||||
| | Send password | ------> | Receive and check |
|
||||
| | request, if needed| | password. |
|
||||
| --------------------- ---------------------
|
||||
| |
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
How to compile:
|
||||
---------------
|
||||
|
||||
See the official compiling howto: http://www.uhub.org/compile.php
|
||||
See the official compiling howto: https://www.uhub.org/compile.php
|
||||
|
||||
Prerequisites
|
||||
|
||||
|
@ -12,7 +12,7 @@ Before you try to compile µHub, please make sure the following prerequisites ar
|
|||
* openssl > 0.9.8 (or use "make USE_SSL=NO")
|
||||
* sqlite > 3.x
|
||||
|
||||
or read http://www.uhub.org/compile.php for more info.
|
||||
or read https://www.uhub.org/compile.php for more info.
|
||||
|
||||
|
||||
Linux, Mac OSX, FreeBSD, NetBSD and OpenBSD
|
||||
|
|
|
@ -28,10 +28,10 @@ The UDP packet SHOULD be echoed by the hub.
|
|||
This UDP packet should contain simply 'HECH {cid} {token}' (Hub echo).
|
||||
|
||||
The hub should send a packet containing the token back:
|
||||
'IECH {token} {host:port}', aswell as the same message via TCP.
|
||||
'IECH {token} {host:port}', as well 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 incomming communication.
|
||||
If the client receives the message via TCP only it knows it has a firewall blocking incoming communication.
|
||||
If the client does not receive the message, it should assume a firewall is blocking all UDP communication,
|
||||
and resume in passive mode.
|
||||
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
Getting started guide
|
||||
---------------------
|
||||
|
||||
(This document is maintained at http://www.extatic.org/uhub/getstarted.html )
|
||||
|
||||
Unpack your binaries
|
||||
|
||||
Example:
|
||||
|
@ -17,6 +15,7 @@ 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
|
||||
|
@ -32,8 +31,11 @@ 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.
|
||||
|
@ -41,17 +43,25 @@ 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
|
||||
|
||||
% 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.
|
||||
|
||||
In linux can add the following lines to /etc/security/limits.conf (allows for ~4000 users)
|
||||
In Linux can add the following lines to /etc/security/limits.conf (allows for ~4000 users)
|
||||
* soft nofile 4096
|
||||
* 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!
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# chkconfig: - 91 35
|
||||
# description: Starts and stops the Uhub ( http://www.uhub.org ) daemons on RHEL\CentOS \
|
||||
# description: Starts and stops the Uhub ( https://www.uhub.org ) daemons on RHEL\CentOS \
|
||||
# used to provide p2p network services.
|
||||
#
|
||||
# pidfile: /var/run/uhub.pid
|
||||
|
|
|
@ -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/filenam for the rules file
|
||||
# rules: path/filename 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,4 +69,3 @@ 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 http://bugs.extatic.org/
|
||||
.B https://github.com/janvidar/uhub/issues
|
||||
|
|
|
@ -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 http://bugs.extatic.org/
|
||||
.B https://github.com/janvidar/uhub/issues
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
# You should normally place this file in /etc/uhub/uhub.conf
|
||||
# and customize some of the settings below.
|
||||
#
|
||||
# This file is read only to the uhub deamon, and if you
|
||||
# This file is read only to the uhub daemon, and if you
|
||||
# make changes to it while uhub is running you can send a
|
||||
# HUP signal to it ( $ killall -HUP uhub ), to reparse configuration (only on UNIX).
|
||||
# All configuration directives: http://www.uhub.org/config.php
|
||||
# All configuration directives: https://www.uhub.org/config.php
|
||||
|
||||
# Bind to this port and address
|
||||
# server_bind_addr=any means listen to "::" if IPv6 is supported
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
inherit eutils
|
||||
|
||||
if [ "$PV" != "9999" ]; then
|
||||
SRC_URI="http://www.extatic.org/downloads/uhub/${P}-src.tar.bz2"
|
||||
SRC_URI="https://www.extatic.org/downloads/uhub/${P}-src.tar.bz2"
|
||||
KEYWORDS="~amd64 ~x86"
|
||||
else
|
||||
inherit git
|
||||
|
@ -16,7 +16,7 @@ fi
|
|||
EAPI="2"
|
||||
|
||||
DESCRIPTION="High performance ADC hub"
|
||||
HOMEPAGE="http://www.uhub.org/"
|
||||
HOMEPAGE="https://www.uhub.org/"
|
||||
|
||||
LICENSE="GPL-3"
|
||||
SLOT="0"
|
||||
|
|
|
@ -5,7 +5,7 @@ Release: 2
|
|||
License: GPLv3
|
||||
Group: Networking/File transfer
|
||||
Source: uhub-%{version}.tar.gz
|
||||
URL: http://www.uhub.org
|
||||
URL: https://www.uhub.org
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
|
||||
|
||||
BuildRequires: sqlite-devel
|
||||
|
@ -80,7 +80,7 @@ rm -rf $RPM_BUILD_ROOT
|
|||
if [ $1 -gt 1 ] ; then
|
||||
/etc/rc.d/init.d/uhub restart >/dev/null || :
|
||||
fi
|
||||
# need more informations about add services and users in system
|
||||
# need more information about add services and users in system
|
||||
/usr/sbin/adduser -M -d /tmp -G nobody -s /sbin/nologin -c 'The Uhub ADC p2p hub Daemon' uhub >/dev/null 2>&1 ||:
|
||||
# write SSL create
|
||||
echo "PLS see /usr/share/doc/uhub/"
|
||||
|
|
|
@ -8,7 +8,7 @@ start on filesystem or runlevel [2345]
|
|||
stop on runlevel [!2345]
|
||||
|
||||
# Allow the service to respawn, but if its happening too often
|
||||
# (10 times in 5 seconds) theres a problem and we should stop trying.
|
||||
# (10 times in 5 seconds) there's a problem and we should stop trying.
|
||||
respawn
|
||||
respawn limit 10 5
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -118,8 +118,8 @@ typedef uint32_t fourcc_t;
|
|||
#define ADC_INF_FLAG_SUPPORT "SU" /* support (extensions, feature cast) */
|
||||
#define ADC_INF_FLAG_SHARED_SIZE "SS" /* size of total files shared in bytes */
|
||||
#define ADC_INF_FLAG_SHARED_FILES "SF" /* number of files shared */
|
||||
#define ADC_INF_FLAG_UPLOAD_SPEED "US" /* maximum upload speed acheived in bytes/sec */
|
||||
#define ADC_INF_FLAG_DOWNLOAD_SPEED "DS" /* maximum download speed acheived in bytes/sec */
|
||||
#define ADC_INF_FLAG_UPLOAD_SPEED "US" /* maximum upload speed achieved in bytes/sec */
|
||||
#define ADC_INF_FLAG_DOWNLOAD_SPEED "DS" /* maximum download speed achieved in bytes/sec */
|
||||
#define ADC_INF_FLAG_UPLOAD_SLOTS "SL" /* maximum upload slots (concurrent uploads) */
|
||||
#define ADC_INF_FLAG_AUTO_SLOTS "AS" /* automatic slot if upload speed is less than this in bytes/sec */
|
||||
#define ADC_INF_FLAG_AUTO_SLOTS_MAX "AM" /* maximum number of automatic slots */
|
||||
|
@ -134,7 +134,7 @@ typedef uint32_t fourcc_t;
|
|||
#define ADC_MSG_FLAG_PRIVATE "PM" /* message is a private message */
|
||||
|
||||
#define ADC_SCH_FLAG_INCLUDE "AN" /* include given search term */
|
||||
#define ADC_SCH_FLAG_EXCLUDE "NO" /* exclude given serach term */
|
||||
#define ADC_SCH_FLAG_EXCLUDE "NO" /* exclude given search term */
|
||||
#define ADC_SCH_FLAG_FILE_EXTENSION "EX" /* search only for files with the given file extension */
|
||||
#define ADC_SCH_FLAG_FILE_TYPE "TY" /* search only for files with this file type (separate type) */
|
||||
#define ADC_SCH_FLAG_LESS_THAN "LE" /* search for files with this size or less */
|
||||
|
@ -156,9 +156,10 @@ typedef uint32_t fourcc_t;
|
|||
#define ADC_SUP_FLAG_ADD "AD"
|
||||
#define ADC_SUP_FLAG_REMOVE "RM"
|
||||
|
||||
#define ADC_CLIENT_TYPE_BOT "1"
|
||||
#define ADC_CLIENT_TYPE_REGISTERED_USER "2"
|
||||
#define ADC_CLIENT_TYPE_OPERATOR "4"
|
||||
#define ADC_CLIENT_TYPE_BOT "1"
|
||||
#define ADC_CLIENT_TYPE_REGISTERED_USER "2"
|
||||
#define ADC_CLIENT_TYPE_OPERATOR "4"
|
||||
#define ADC_CLIENT_TYPE_HUBBOT "5" /* 1 + 4 */
|
||||
#define ADC_CLIENT_TYPE_SUPER_USER "12" /* 8 + 4 */
|
||||
#define ADC_CLIENT_TYPE_ADMIN "20" /* 16 + 4 = hub owner */
|
||||
#define ADC_CLIENT_TYPE_HUB "32" /* the hub itself */
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -24,7 +24,6 @@
|
|||
uhub_assert(X); \
|
||||
uhub_assert(X->cache); \
|
||||
uhub_assert(X->capacity); \
|
||||
uhub_assert(X->length); \
|
||||
uhub_assert(X->length <= X->capacity); \
|
||||
uhub_assert(X->references > 0); \
|
||||
uhub_assert(X->length == strlen(X->cache));
|
||||
|
@ -311,7 +310,7 @@ struct adc_message* adc_msg_parse_verify(struct hub_user* u, const char* line, s
|
|||
if (!command)
|
||||
return 0;
|
||||
|
||||
if (command->source && (!u || command->source != u->id.sid))
|
||||
if (command->source && (!u || (command->source != u->id.sid && !auth_cred_is_unrestricted(u->credentials))))
|
||||
{
|
||||
LOG_DEBUG("Command does not match user's SID (command->source=%d, user->id.sid=%d)", command->source, (u ? u->id.sid : 0));
|
||||
adc_msg_free(command);
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -51,7 +51,7 @@ enum msg_status_level
|
|||
extern struct adc_message* adc_msg_incref(struct adc_message* msg);
|
||||
|
||||
/**
|
||||
* Decrease the reference counter, and free the memory when apropriate.
|
||||
* Decrease the reference counter, and free the memory when appropriate.
|
||||
*/
|
||||
extern void adc_msg_free(struct adc_message* msg);
|
||||
|
||||
|
@ -159,7 +159,7 @@ extern char* adc_msg_get_argument(struct adc_message* cmd, int offset);
|
|||
*
|
||||
* @arg prefix a 2 character argument prefix
|
||||
* @arg string must be escaped (see adc_msg_escape).
|
||||
* @return 0 if successful, or -1 if an error occured.
|
||||
* @return 0 if successful, or -1 if an error occurred.
|
||||
*/
|
||||
extern int adc_msg_replace_named_argument(struct adc_message* cmd, const char prefix[2], const char* string);
|
||||
|
||||
|
@ -167,7 +167,7 @@ extern int adc_msg_replace_named_argument(struct adc_message* cmd, const char pr
|
|||
* Append an argument
|
||||
*
|
||||
* @arg string must be escaped (see adc_msg_escape).
|
||||
* @return 0 if successful, or -1 if an error occured (out of memory).
|
||||
* @return 0 if successful, or -1 if an error occurred (out of memory).
|
||||
*/
|
||||
extern int adc_msg_add_argument(struct adc_message* cmd, const char* string);
|
||||
|
||||
|
@ -176,7 +176,7 @@ extern int adc_msg_add_argument(struct adc_message* cmd, const char* string);
|
|||
*
|
||||
* @arg prefix a 2 character argument prefix
|
||||
* @arg string must be escaped (see adc_msg_escape).
|
||||
* @return 0 if successful, or -1 if an error occured (out of memory).
|
||||
* @return 0 if successful, or -1 if an error occurred (out of memory).
|
||||
*/
|
||||
extern int adc_msg_add_named_argument(struct adc_message* cmd, const char prefix[2], const char* string);
|
||||
|
||||
|
@ -186,7 +186,7 @@ extern int adc_msg_add_named_argument(struct adc_message* cmd, const char prefix
|
|||
*
|
||||
* @arg prefix a 2 character argument prefix
|
||||
* @arg string must NOT be escaped
|
||||
* @return 0 if successful, or -1 if an error occured (out of memory).
|
||||
* @return 0 if successful, or -1 if an error occurred (out of memory).
|
||||
*/
|
||||
extern int adc_msg_add_named_argument_string(struct adc_message* cmd, const char prefix[2], const char* string);
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -170,6 +170,9 @@ static int acl_parse_line(char* line, int line_count, void* ptr_data)
|
|||
LOG_DEBUG("acl_parse_line: '%s'", line);
|
||||
|
||||
ACL_ADD_USER("bot", handle->users, auth_cred_bot);
|
||||
ACL_ADD_USER("ubot", handle->users, auth_cred_ubot);
|
||||
ACL_ADD_USER("opbot", handle->users, auth_cred_opbot);
|
||||
ACL_ADD_USER("opubot", handle->users, auth_cred_opubot);
|
||||
ACL_ADD_USER("user_admin", handle->users, auth_cred_admin);
|
||||
ACL_ADD_USER("user_super", handle->users, auth_cred_super);
|
||||
ACL_ADD_USER("user_op", handle->users, auth_cred_operator);
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -30,7 +30,7 @@ struct command_base;
|
|||
*
|
||||
* @param cbase Command base pointer.
|
||||
* @param user User who invoked the command.
|
||||
* @param message The message that is to be interpreted as a command (including the invokation prefix '!' or '+')
|
||||
* @param message The message that is to be interpreted as a command (including the invocation prefix '!' or '+')
|
||||
*
|
||||
* @return a hub_command that must be freed with command_free(). @See struct hub_command.
|
||||
*/
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ class Option(object):
|
|||
|
||||
class SourceGenerator(object):
|
||||
def __init__(self, filename, cppStyle = True):
|
||||
print "Generating %s..." % filename
|
||||
print ("Generating %s..." % filename)
|
||||
self.f = open(filename, 'w');
|
||||
|
||||
def write_header(self, Comment = True):
|
||||
|
|
|
@ -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.
|
||||
If this is enabled guests can register their nickname on the hub using !register command.
|
||||
Otherwise only operators can register users.
|
||||
]]></description>
|
||||
<since>0.4.0</since>
|
||||
|
@ -170,7 +170,7 @@
|
|||
<check min="1024" max="1048576" />
|
||||
<short>Max read buffer before parse, per user</short>
|
||||
<description><![CDATA[
|
||||
Maximum receive buffer allowed before commands are procesed. If a single ADC message exceeds this limit, it will be discarded by the hub. Use with caution.
|
||||
Maximum receive buffer allowed before commands are processed. If a single ADC message exceeds this limit, it will be discarded by the hub. Use with caution.
|
||||
]]></description>
|
||||
<since>0.1.3</since>
|
||||
</option>
|
||||
|
@ -567,7 +567,7 @@
|
|||
</option>
|
||||
|
||||
<option name="msg_inf_error_nick_taken" type="message" default="Nickname is already in use">
|
||||
<description><![CDATA[This message will be sent to clients if their provided nickname is alredy in use on the hub.]]></description>
|
||||
<description><![CDATA[This message will be sent to clients if their provided nickname is already in use on the hub.]]></description>
|
||||
<since>0.2.0</since>
|
||||
</option>
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -23,7 +23,7 @@ struct hub_info* g_hub = 0;
|
|||
|
||||
/* FIXME: Flood control should be done in a plugin! */
|
||||
#define CHECK_FLOOD(TYPE, WARN) \
|
||||
if (flood_control_check(&u->flood_ ## TYPE , hub->config->flood_ctl_ ## TYPE, hub->config->flood_ctl_interval, net_get_time())) \
|
||||
if (flood_control_check(&u->flood_ ## TYPE , hub->config->flood_ctl_ ## TYPE, hub->config->flood_ctl_interval, net_get_time()) && !auth_cred_is_unrestricted(u->credentials)) \
|
||||
{ \
|
||||
if (WARN) \
|
||||
{ \
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -88,7 +88,7 @@ static int check_hash_tiger(const char* cid, const char* pid)
|
|||
|
||||
|
||||
/*
|
||||
* FIXME: Only works for tiger hash. If a client doesnt support tiger we cannot let it in!
|
||||
* FIXME: Only works for tiger hash. If a client doesn't support tiger we cannot let it in!
|
||||
*/
|
||||
static int check_cid(struct hub_info* hub, struct hub_user* user, struct adc_message* cmd)
|
||||
{
|
||||
|
@ -337,9 +337,19 @@ static int check_logged_in(struct hub_info* hub, struct hub_user* user, struct a
|
|||
{
|
||||
if (lookup1 == lookup2)
|
||||
{
|
||||
LOG_DEBUG("check_logged_in: exact same user is logged in: %s", user->id.nick);
|
||||
hub_disconnect_user(hub, lookup1, quit_ghost_timeout);
|
||||
return 0;
|
||||
if (user_flag_get(lookup1, flag_choke))
|
||||
{
|
||||
LOG_DEBUG("check_logged_in: exact same user is already logged in, but likely ghost: %s", user->id.nick);
|
||||
|
||||
// Old user unable to swallow data.
|
||||
// Disconnect the existing user, and allow new user to enter.
|
||||
hub_disconnect_user(hub, lookup1, quit_ghost_timeout);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_DEBUG("check_logged_in: exact same user is already logged in: %s", user->id.nick);
|
||||
return status_msg_inf_error_cid_taken;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -571,6 +581,10 @@ static int set_credentials(struct hub_info* hub, struct hub_user* user, struct a
|
|||
adc_msg_add_argument(cmd, ADC_INF_FLAG_CLIENT_TYPE ADC_CLIENT_TYPE_BOT);
|
||||
break;
|
||||
|
||||
case auth_cred_ubot:
|
||||
adc_msg_add_argument(cmd, ADC_INF_FLAG_CLIENT_TYPE ADC_CLIENT_TYPE_BOT);
|
||||
break;
|
||||
|
||||
case auth_cred_guest:
|
||||
/* Nothing to be added to the info message */
|
||||
break;
|
||||
|
@ -583,6 +597,14 @@ static int set_credentials(struct hub_info* hub, struct hub_user* user, struct a
|
|||
adc_msg_add_argument(cmd, ADC_INF_FLAG_CLIENT_TYPE ADC_CLIENT_TYPE_OPERATOR);
|
||||
break;
|
||||
|
||||
case auth_cred_opbot:
|
||||
adc_msg_add_argument(cmd, ADC_INF_FLAG_CLIENT_TYPE ADC_CLIENT_TYPE_HUBBOT);
|
||||
break;
|
||||
|
||||
case auth_cred_opubot:
|
||||
adc_msg_add_argument(cmd, ADC_INF_FLAG_CLIENT_TYPE ADC_CLIENT_TYPE_HUBBOT);
|
||||
break;
|
||||
|
||||
case auth_cred_super:
|
||||
adc_msg_add_argument(cmd, ADC_INF_FLAG_CLIENT_TYPE ADC_CLIENT_TYPE_SUPER_USER);
|
||||
break;
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -151,7 +151,7 @@ int main_loop()
|
|||
setup_signal_handlers(hub);
|
||||
#ifdef SYSTEMD
|
||||
/* Notify the service manager that this daemon has
|
||||
* been successfully initalized and shall enter the
|
||||
* been successfully initialized and shall enter the
|
||||
* main loop.
|
||||
*/
|
||||
sd_notifyf(0, "READY=1\n"
|
||||
|
@ -471,7 +471,7 @@ int main(int argc, char** argv)
|
|||
}
|
||||
else if (ret == 0)
|
||||
{
|
||||
/* child process - detatch from TTY */
|
||||
/* child process - detach from TTY */
|
||||
fclose(stdin);
|
||||
fclose(stdout);
|
||||
fclose(stderr);
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -137,6 +137,12 @@ void net_event(struct net_connection* con, int event, void *arg)
|
|||
LOG_TRACE("net_event() : fd=%d, ev=%d, arg=%p", con->sd, (int) event, arg);
|
||||
#endif
|
||||
|
||||
if (event == NET_EVENT_ERROR)
|
||||
{
|
||||
hub_disconnect_user(user->hub, user, quit_socket_error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (event == NET_EVENT_TIMEOUT)
|
||||
{
|
||||
if (user_is_connecting(user))
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -102,7 +102,6 @@ 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;
|
||||
|
@ -118,6 +117,7 @@ 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();
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -90,11 +90,14 @@ static void probe_net_event(struct net_connection* con, int events, void *arg)
|
|||
if (probe->hub->config->tls_enable)
|
||||
{
|
||||
LOG_TRACE("Probed TLS %d.%d connection", (int) probe_recvbuf[9], (int) probe_recvbuf[10]);
|
||||
if (user_create(probe->hub, probe->connection, &probe->addr))
|
||||
if (net_con_ssl_handshake(con, net_con_ssl_mode_server, probe->hub->ctx) < 0)
|
||||
{
|
||||
LOG_TRACE("TLS handshake negotiation failed.");
|
||||
}
|
||||
else if (user_create(probe->hub, probe->connection, &probe->addr))
|
||||
{
|
||||
probe->connection = 0;
|
||||
}
|
||||
net_con_ssl_handshake(con, net_con_ssl_mode_server, probe->hub->ctx);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -82,16 +82,19 @@ static int check_send_queue(struct hub_info* hub, struct hub_user* user, struct
|
|||
|
||||
if ((user->send_queue->size + msg->length) > get_max_send_queue(hub))
|
||||
{
|
||||
user_flag_set(user, flag_choke);
|
||||
LOG_WARN("send queue overflowed, message discarded.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (user->send_queue->size > get_max_send_queue_soft(hub))
|
||||
{
|
||||
user_flag_set(user, flag_choke);
|
||||
LOG_WARN("send queue soft overflowed.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
user_flag_unset(user, flag_choke);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -68,7 +68,7 @@ enum user_quit_reason
|
|||
quit_timeout = 4, /** User timed out (no data for a while) */
|
||||
quit_send_queue = 5, /** User's send queue was overflowed */
|
||||
quit_memory_error = 6, /** Not enough memory available */
|
||||
quit_socket_error = 7, /** A socket error occured */
|
||||
quit_socket_error = 7, /** A socket error occurred */
|
||||
quit_protocol_error = 8, /** Fatal protocol error */
|
||||
quit_logon_error = 9, /** Unable to login (wrong password, CID/PID, etc) */
|
||||
quit_update_error = 10, /** Update error. INF update changed share/slot info and no longer satisfies the hub limits. */
|
||||
|
@ -76,7 +76,7 @@ enum user_quit_reason
|
|||
quit_ghost_timeout = 12, /** The user is a ghost, and trying to login from another connection */
|
||||
};
|
||||
|
||||
/** Returns an apropriate string for the given quit reason */
|
||||
/** Returns an appropriate string for the given quit reason */
|
||||
extern const char* user_get_quit_reason_string(enum user_quit_reason);
|
||||
|
||||
struct hub_user_info
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -42,7 +42,7 @@ extern struct hub_user_manager* uman_init();
|
|||
* Shuts down the user manager.
|
||||
* All users will be disconnected and deleted as part of this.
|
||||
*
|
||||
* @return 0 on success, or -1 in an error occured (invalid pointer).
|
||||
* @return 0 on success, or -1 in an error occurred (invalid pointer).
|
||||
*/
|
||||
extern int uman_shutdown(struct hub_user_manager* users);
|
||||
|
||||
|
@ -106,7 +106,7 @@ extern struct hub_user* uman_get_user_by_nick(struct hub_user_manager* users, co
|
|||
*
|
||||
* @param[out] target the list of users matching the address
|
||||
* @param range the IP range of users to match
|
||||
* @return The number of users matching the addressess, or -1 on error (mask is wrong).
|
||||
* @return The number of users matching the addresses, or -1 on error (mask is wrong).
|
||||
*/
|
||||
extern size_t uman_get_user_by_addr(struct hub_user_manager* users, struct linked_list* target, struct ip_range* range);
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -88,7 +88,7 @@ extern void net_con_close(struct net_connection* con);
|
|||
*
|
||||
* @return returns the number of bytes sent.
|
||||
* 0 if no data is sent, and this function should be called again (EWOULDBLOCK/EINTR)
|
||||
* <0 if an error occured, the negative number contains the error code.
|
||||
* <0 if an error occurred, the negative number contains the error code.
|
||||
*/
|
||||
extern ssize_t net_con_send(struct net_connection* con, const void* buf, size_t len);
|
||||
|
||||
|
@ -97,7 +97,7 @@ extern ssize_t net_con_send(struct net_connection* con, const void* buf, size_t
|
|||
*
|
||||
* @return returns the number of bytes sent.
|
||||
* 0 if no data is sent, and this function should be called again (EWOULDBLOCK/EINTR)
|
||||
* <0 if an error occured, the negative number contains the error code.
|
||||
* <0 if an error occurred, the negative number contains the error code.
|
||||
*/
|
||||
extern ssize_t net_con_recv(struct net_connection* con, void* buf, size_t len);
|
||||
|
||||
|
@ -109,7 +109,7 @@ extern ssize_t net_con_recv(struct net_connection* con, void* buf, size_t len);
|
|||
extern ssize_t net_con_peek(struct net_connection* con, void* buf, size_t len);
|
||||
|
||||
/**
|
||||
* Set timeout for connetion.
|
||||
* Set timeout for connection.
|
||||
*
|
||||
* @param seconds the number of seconds into the future.
|
||||
*/
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -92,7 +92,7 @@ extern int ip_is_valid_ipv6(const char* address);
|
|||
*
|
||||
* @param text_addr is an ipaddress either ipv6 or ipv4.
|
||||
* Special magic addresses called "any" and "loopback" exist,
|
||||
* and will work accross IPv6/IPv4.
|
||||
* and will work across IPv6/IPv4.
|
||||
* @param port Fill the struct sockaddr* with the given port, can safely be ignored.
|
||||
*/
|
||||
extern int ip_convert_address(const char* text_address, int port, struct sockaddr* addr, socklen_t* addr_len);
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* uhub - A tiny ADC p2p connection hub
|
||||
* Copyright (C) 2007-2014, Jan Vidar Krey
|
||||
* Copyright (C) 2007-2019, 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
|
||||
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -805,4 +805,22 @@ void net_stats_add_close()
|
|||
stats.closed++;
|
||||
}
|
||||
|
||||
void net_stats_tls_add_accept()
|
||||
{
|
||||
stats.tls_accept++;
|
||||
}
|
||||
|
||||
void net_stats_tls_add_connect()
|
||||
{
|
||||
stats.tls_connect++;
|
||||
}
|
||||
|
||||
void net_stats_tls_add_error()
|
||||
{
|
||||
stats.tls_error++;
|
||||
}
|
||||
|
||||
void net_stats_tls_add_close()
|
||||
{
|
||||
stats.tls_close++;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* uhub - A tiny ADC p2p connection hub
|
||||
* Copyright (C) 2007-2014, Jan Vidar Krey
|
||||
* Copyright (C) 2007-2019, 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
|
||||
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -28,6 +28,10 @@ struct net_statistics
|
|||
size_t accept;
|
||||
size_t closed;
|
||||
size_t errors;
|
||||
size_t tls_accept;
|
||||
size_t tls_connect;
|
||||
size_t tls_error;
|
||||
size_t tls_close;
|
||||
};
|
||||
|
||||
struct net_socket_t;
|
||||
|
@ -53,7 +57,7 @@ extern int net_initialize();
|
|||
extern int net_destroy();
|
||||
|
||||
/**
|
||||
* @return the number of sockets currrently being monitored.
|
||||
* @return the number of sockets currently being monitored.
|
||||
*/
|
||||
extern int net_monitor_count();
|
||||
|
||||
|
@ -63,7 +67,7 @@ extern int net_monitor_count();
|
|||
extern int net_monitor_capacity();
|
||||
|
||||
/**
|
||||
* @return the last error code occured.
|
||||
* @return the last error code occurred.
|
||||
*
|
||||
* NOTE: On Windows this is the last error code from the socket library, but
|
||||
* on UNIX this is the errno variable that can be overwritten by any
|
||||
|
@ -247,9 +251,14 @@ extern void net_stats_report();
|
|||
extern void net_stats_reset();
|
||||
extern void net_stats_add_tx(size_t bytes);
|
||||
extern void net_stats_add_rx(size_t bytes);
|
||||
extern void net_stats_tls_add_accept();
|
||||
extern void net_stats_tls_add_connect();
|
||||
extern void net_stats_tls_add_error();
|
||||
extern void net_stats_tls_add_close();
|
||||
extern void net_stats_add_accept();
|
||||
extern void net_stats_add_error();
|
||||
extern void net_stats_add_close();
|
||||
extern void net_stats_add_connect();
|
||||
extern int net_stats_timeout();
|
||||
extern void net_stats_get(struct net_statistics** intermediate, struct net_statistics** total);
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* uhub - A tiny ADC p2p connection hub
|
||||
* Copyright (C) 2007-2014, Jan Vidar Krey
|
||||
* Copyright (C) 2007-2019, 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
|
||||
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -27,6 +27,10 @@
|
|||
|
||||
void net_stats_add_tx(size_t bytes);
|
||||
void net_stats_add_rx(size_t bytes);
|
||||
void net_stats_tls_add_accept();
|
||||
void net_stats_tls_add_errors();
|
||||
void net_stats_tls_add_accept();
|
||||
|
||||
|
||||
struct net_ssl_openssl
|
||||
{
|
||||
|
@ -91,7 +95,9 @@ 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);
|
||||
|
@ -106,36 +112,115 @@ int net_ssl_library_shutdown()
|
|||
|
||||
static void add_io_stats(struct net_ssl_openssl* handle)
|
||||
{
|
||||
if (handle->bio->num_read > handle->bytes_rx)
|
||||
#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)
|
||||
{
|
||||
net_stats_add_rx(handle->bio->num_read - handle->bytes_rx);
|
||||
handle->bytes_rx = handle->bio->num_read;
|
||||
net_stats_add_rx(num_read - handle->bytes_rx);
|
||||
handle->bytes_rx = num_read;
|
||||
}
|
||||
|
||||
if (handle->bio->num_write > handle->bytes_tx)
|
||||
if (num_write > handle->bytes_tx)
|
||||
{
|
||||
net_stats_add_tx(handle->bio->num_write - handle->bytes_tx);
|
||||
handle->bytes_tx = handle->bio->num_write;
|
||||
net_stats_add_tx(num_write - handle->bytes_tx);
|
||||
handle->bytes_tx = num_write;
|
||||
}
|
||||
}
|
||||
|
||||
static const SSL_METHOD* get_ssl_method(const char* tls_version)
|
||||
static const SSL_METHOD* get_ssl_method(const char* tls_version, long* flags)
|
||||
{
|
||||
if (!flags)
|
||||
{
|
||||
LOG_ERROR("flags is null");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!tls_version || !*tls_version)
|
||||
{
|
||||
LOG_ERROR("tls_version is not set.");
|
||||
return 0;
|
||||
LOG_ERROR("tls_version is not set.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!strcmp(tls_version, "1.0"))
|
||||
return TLSv1_method();
|
||||
if (!strcmp(tls_version, "1.1"))
|
||||
return TLSv1_1_method();
|
||||
if (!strcmp(tls_version, "1.2"))
|
||||
return TLSv1_2_method();
|
||||
*flags = 0;
|
||||
*flags |= SSL_OP_NO_SSLv2;
|
||||
*flags |= SSL_OP_NO_SSLv3;
|
||||
|
||||
LOG_ERROR("Unable to recognize tls_version.");
|
||||
return 0;
|
||||
if (!strcmp(tls_version, "1.0"))
|
||||
{
|
||||
#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
||||
return TLSv1_method();
|
||||
#endif
|
||||
}
|
||||
else if (!strcmp(tls_version, "1.1"))
|
||||
{
|
||||
#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
||||
return TLSv1_1_method();
|
||||
#else
|
||||
*flags |= SSL_OP_NO_TLSv1;
|
||||
#endif
|
||||
}
|
||||
else if (!strcmp(tls_version, "1.2"))
|
||||
{
|
||||
#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
||||
return TLSv1_2_method();
|
||||
#else
|
||||
*flags |= SSL_OP_NO_TLSv1;
|
||||
*flags |= SSL_OP_NO_TLSv1_1;
|
||||
#endif
|
||||
}
|
||||
else if (!strcmp(tls_version, "1.3"))
|
||||
{
|
||||
#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
||||
LOG_ERROR("TLS 1.3 is not supported by this version of OpenSSL");
|
||||
return 0;
|
||||
#else
|
||||
*flags |= SSL_OP_NO_TLSv1;
|
||||
*flags |= SSL_OP_NO_TLSv1_1;
|
||||
*flags |= SSL_OP_NO_TLSv1_2;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_ERROR("Unable to recognize tls_version: %s", tls_version);
|
||||
return 0;
|
||||
}
|
||||
#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
||||
// never gets here!
|
||||
#else
|
||||
return TLS_method();
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* List of supported protocols for ALPN.
|
||||
* We only support "adc" protocol.
|
||||
*/
|
||||
unsigned char alpn_protocols[] = {
|
||||
3, 'a', 'd', 'c',
|
||||
};
|
||||
|
||||
/**
|
||||
* Callback for the server to select a protocol from the list
|
||||
* sent by the client via ALPN.
|
||||
*/
|
||||
static int alpn_server_select_protocol(SSL *ssl, const unsigned char **out, unsigned char *outlen,
|
||||
const unsigned char *in, unsigned int inlen, void *arg)
|
||||
{
|
||||
int res = SSL_select_next_proto((unsigned char **)out, outlen,
|
||||
alpn_protocols, sizeof(alpn_protocols), in, inlen);
|
||||
if (res == OPENSSL_NPN_NO_OVERLAP)
|
||||
{
|
||||
// set default protocol
|
||||
*out = alpn_protocols;
|
||||
*outlen = 1+alpn_protocols[0];
|
||||
}
|
||||
return SSL_TLSEXT_ERR_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -144,7 +229,8 @@ static const SSL_METHOD* get_ssl_method(const char* tls_version)
|
|||
struct ssl_context_handle* net_ssl_context_create(const char* tls_version, const char* tls_ciphersuite)
|
||||
{
|
||||
struct net_context_openssl* ctx = (struct net_context_openssl*) hub_malloc_zero(sizeof(struct net_context_openssl));
|
||||
const SSL_METHOD* ssl_method = get_ssl_method(tls_version);
|
||||
long flags = 0;
|
||||
const SSL_METHOD* ssl_method = get_ssl_method(tls_version, &flags);
|
||||
|
||||
if (!ssl_method)
|
||||
{
|
||||
|
@ -154,23 +240,18 @@ struct ssl_context_handle* net_ssl_context_create(const char* tls_version, const
|
|||
|
||||
ctx->ssl = SSL_CTX_new(ssl_method);
|
||||
|
||||
/* Disable SSLv2 */
|
||||
SSL_CTX_set_options(ctx->ssl, SSL_OP_NO_SSLv2);
|
||||
|
||||
// #ifdef SSL_OP_NO_SSLv3
|
||||
/* Disable SSLv3 */
|
||||
SSL_CTX_set_options(ctx->ssl, SSL_OP_NO_SSLv3);
|
||||
// #endif
|
||||
|
||||
// FIXME: Why did we need this again?
|
||||
SSL_CTX_set_quiet_shutdown(ctx->ssl, 1);
|
||||
|
||||
#ifdef SSL_OP_NO_COMPRESSION
|
||||
/* Disable compression */
|
||||
LOG_TRACE("Disabling SSL compression."); /* "CRIME" attack */
|
||||
SSL_CTX_set_options(ctx->ssl, SSL_OP_NO_COMPRESSION);
|
||||
flags |= SSL_OP_NO_COMPRESSION;
|
||||
#endif
|
||||
|
||||
// Set flags
|
||||
SSL_CTX_set_options(ctx->ssl, flags);
|
||||
|
||||
/* Set preferred cipher suite */
|
||||
if (SSL_CTX_set_cipher_list(ctx->ssl, tls_ciphersuite) != 1)
|
||||
{
|
||||
|
@ -180,6 +261,8 @@ struct ssl_context_handle* net_ssl_context_create(const char* tls_version, const
|
|||
return 0;
|
||||
}
|
||||
|
||||
SSL_CTX_set_alpn_select_cb(ctx->ssl, alpn_server_select_protocol, NULL);
|
||||
|
||||
return (struct ssl_context_handle*) ctx;
|
||||
}
|
||||
|
||||
|
@ -250,13 +333,16 @@ static int handle_openssl_error(struct net_connection* con, int ret, int read)
|
|||
|
||||
case SSL_ERROR_SSL:
|
||||
net_ssl_set_state(handle, tls_st_error);
|
||||
net_stats_tls_add_error();
|
||||
return -2;
|
||||
|
||||
case SSL_ERROR_SYSCALL:
|
||||
net_ssl_set_state(handle, tls_st_error);
|
||||
net_stats_tls_add_error();
|
||||
return -2;
|
||||
}
|
||||
|
||||
net_stats_tls_add_error();
|
||||
return -2;
|
||||
}
|
||||
|
||||
|
@ -272,6 +358,7 @@ ssize_t net_con_ssl_accept(struct net_connection* con)
|
|||
{
|
||||
net_con_update(con, NET_EVENT_READ);
|
||||
net_ssl_set_state(handle, tls_st_connected);
|
||||
net_stats_tls_add_accept();
|
||||
return ret;
|
||||
}
|
||||
return handle_openssl_error(con, ret, tls_st_accepting);
|
||||
|
@ -290,11 +377,14 @@ ssize_t net_con_ssl_connect(struct net_connection* con)
|
|||
{
|
||||
net_con_update(con, NET_EVENT_READ);
|
||||
net_ssl_set_state(handle, tls_st_connected);
|
||||
net_stats_tls_add_connect();
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = handle_openssl_error(con, ret, tls_st_connecting);
|
||||
LOG_ERROR("net_con_ssl_connect: ret=%d", ret);
|
||||
|
||||
if (ret != 0)
|
||||
LOG_ERROR("net_con_ssl_connect: ret=%d", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -333,7 +423,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_ERROR("net_ssl_send(), state=%d", (int) handle->state);
|
||||
LOG_TRACE("net_ssl_send(), state=%d", (int) handle->state);
|
||||
|
||||
if (handle->state == tls_st_error)
|
||||
return -2;
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along wtimeout_evtith this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along wtimeout_evtith this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -35,6 +35,16 @@ struct plugin_command
|
|||
struct linked_list* args;
|
||||
};
|
||||
|
||||
enum plugin_command_arg_type
|
||||
{
|
||||
plugin_cmd_arg_type_integer,
|
||||
plugin_cmd_arg_type_string,
|
||||
plugin_cmd_arg_type_user,
|
||||
plugin_cmd_arg_type_address,
|
||||
plugin_cmd_arg_type_range,
|
||||
plugin_cmd_arg_type_credentials,
|
||||
};
|
||||
|
||||
struct plugin_command_arg_data
|
||||
{
|
||||
enum plugin_command_arg_type type;
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -28,6 +28,7 @@
|
|||
#include "util/credentials.h"
|
||||
#include "network/ipcalc.h"
|
||||
#include "plugin_api/types.h"
|
||||
#include "plugin_api/command_api.h"
|
||||
|
||||
typedef void (*on_connection_accepted_t)(struct plugin_handle*, struct ip_addr_encap*);
|
||||
typedef void (*on_connection_refused_t)(struct plugin_handle*, struct ip_addr_encap*);
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -93,15 +93,6 @@ struct ban_info
|
|||
time_t expiry; /* Time when the ban record expires */
|
||||
};
|
||||
|
||||
enum plugin_command_arg_type
|
||||
{
|
||||
plugin_cmd_arg_type_integer,
|
||||
plugin_cmd_arg_type_string,
|
||||
plugin_cmd_arg_type_user,
|
||||
plugin_cmd_arg_type_address,
|
||||
plugin_cmd_arg_type_range,
|
||||
plugin_cmd_arg_type_credentials,
|
||||
};
|
||||
|
||||
|
||||
#endif /* HAVE_UHUB_PLUGIN_TYPES_H */
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
|||
#include "util/list.h"
|
||||
#include "util/cbuffer.h"
|
||||
|
||||
#define MAX_HISTORY_SIZE 16384
|
||||
#define MAX_HISTORY_SIZE 614400
|
||||
|
||||
struct chat_history_data
|
||||
{
|
||||
|
@ -49,7 +49,7 @@ static int null_callback(void* ptr, int argc, char **argv, char **colName) { ret
|
|||
|
||||
static const char* sql_escape_string(const char* str)
|
||||
{
|
||||
static char out[1024];
|
||||
static char out[MAX_HISTORY_SIZE];
|
||||
size_t i = 0;
|
||||
size_t n = 0;
|
||||
for (; n < strlen(str); n++)
|
||||
|
@ -65,7 +65,7 @@ static const char* sql_escape_string(const char* str)
|
|||
static int sql_execute(struct chat_history_data* sql, int (*callback)(void* ptr, int argc, char **argv, char **colName), void* ptr, const char* sql_fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
char query[1024];
|
||||
char query[MAX_HISTORY_SIZE];
|
||||
char* errMsg;
|
||||
int rc;
|
||||
|
||||
|
@ -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 chat_history ORDER BY time DESC LIMIT 0,%d;", (int) data->history_connect);
|
||||
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);
|
||||
|
||||
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 chat_history ORDER BY time DESC LIMIT 0,%d;", maxlines);
|
||||
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);
|
||||
|
||||
size_t linecount = list_size(found);
|
||||
|
||||
|
@ -226,6 +226,8 @@ static int command_historycleanup(struct plugin_handle* plugin, struct plugin_us
|
|||
plugin->hub.send_message(plugin, user, cbuf_get(buf));
|
||||
cbuf_destroy(buf);
|
||||
|
||||
sql_execute(data, null_callback, NULL, "VACUUM;");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue