├── opt └── llhttp-v6.0.5.tgz ├── deps ├── spdlog │ ├── include │ │ └── spdlog │ │ │ ├── fmt │ │ │ ├── bundled │ │ │ │ ├── locale.h │ │ │ │ └── fmt.license.rst │ │ │ ├── chrono.h │ │ │ ├── ranges.h │ │ │ ├── xchar.h │ │ │ ├── ostr.h │ │ │ ├── compile.h │ │ │ ├── std.h │ │ │ └── fmt.h │ │ │ ├── details │ │ │ ├── windows_include.h │ │ │ ├── console_globals.h │ │ │ ├── periodic_worker-inl.h │ │ │ ├── synchronous_factory.h │ │ │ ├── log_msg_buffer.h │ │ │ ├── null_mutex.h │ │ │ ├── log_msg-inl.h │ │ │ ├── log_msg.h │ │ │ └── backtracer.h │ │ │ ├── version.h │ │ │ ├── fwd.h │ │ │ ├── formatter.h │ │ │ ├── sinks │ │ │ ├── sink-inl.h │ │ │ ├── sink.h │ │ │ ├── basic_file_sink-inl.h │ │ │ ├── stdout_color_sinks-inl.h │ │ │ ├── null_sink.h │ │ │ └── ostream_sink.h │ │ │ └── cfg │ │ │ ├── helpers.h │ │ │ ├── env.h │ │ │ └── argv.h │ ├── src │ │ ├── cfg.cpp │ │ ├── async.cpp │ │ ├── file_sinks.cpp │ │ └── spdlog.cpp │ └── LICENSE ├── asio │ ├── asio │ │ ├── unyield.hpp │ │ ├── yield.hpp │ │ ├── ts │ │ │ ├── io_context.hpp │ │ │ ├── buffer.hpp │ │ │ ├── net.hpp │ │ │ ├── timer.hpp │ │ │ ├── socket.hpp │ │ │ ├── executor.hpp │ │ │ └── internet.hpp │ │ ├── io_service_strand.hpp │ │ ├── buffered_stream_fwd.hpp │ │ ├── version.hpp │ │ ├── buffered_read_stream_fwd.hpp │ │ ├── buffered_write_stream_fwd.hpp │ │ ├── signal_set.hpp │ │ ├── detail │ │ │ ├── limits.hpp │ │ │ ├── cstddef.hpp │ │ │ ├── date_time_fwd.hpp │ │ │ ├── dependent_type.hpp │ │ │ ├── win_iocp_thread_info.hpp │ │ │ ├── impl │ │ │ │ ├── thread_context.ipp │ │ │ │ ├── posix_mutex.ipp │ │ │ │ ├── posix_tss_ptr.ipp │ │ │ │ └── win_tss_ptr.ipp │ │ │ ├── assert.hpp │ │ │ ├── operation.hpp │ │ │ ├── array_fwd.hpp │ │ │ ├── array.hpp │ │ │ ├── noncopyable.hpp │ │ │ ├── fd_set_adapter.hpp │ │ │ ├── null_fenced_block.hpp │ │ │ ├── scheduler_thread_info.hpp │ │ │ ├── resolve_op.hpp │ │ │ ├── signal_init.hpp │ │ │ ├── exception.hpp │ │ │ ├── functional.hpp │ │ │ ├── wait_op.hpp │ │ │ ├── future.hpp │ │ │ ├── timer_scheduler.hpp │ │ │ ├── regex_fwd.hpp │ │ │ ├── null_mutex.hpp │ │ │ ├── scheduler_task.hpp │ │ │ ├── signal_op.hpp │ │ │ ├── timer_scheduler_fwd.hpp │ │ │ ├── mutex.hpp │ │ │ ├── null_static_mutex.hpp │ │ │ ├── event.hpp │ │ │ ├── signal_blocker.hpp │ │ │ ├── null_global.hpp │ │ │ ├── global.hpp │ │ │ ├── handler_cont_helpers.hpp │ │ │ ├── null_tss_ptr.hpp │ │ │ ├── select_interrupter.hpp │ │ │ ├── source_location.hpp │ │ │ ├── solaris_fenced_block.hpp │ │ │ ├── macos_fenced_block.hpp │ │ │ ├── std_fenced_block.hpp │ │ │ ├── thread_context.hpp │ │ │ ├── null_thread.hpp │ │ │ ├── std_mutex.hpp │ │ │ ├── string_view.hpp │ │ │ ├── local_free_on_block_exit.hpp │ │ │ ├── keyword_tss_ptr.hpp │ │ │ ├── non_const_lvalue.hpp │ │ │ └── posix_static_mutex.hpp │ │ ├── static_thread_pool.hpp │ │ ├── ssl.hpp │ │ ├── streambuf.hpp │ │ ├── io_service.hpp │ │ ├── ssl │ │ │ ├── impl │ │ │ │ └── src.hpp │ │ │ ├── detail │ │ │ │ ├── openssl_types.hpp │ │ │ │ └── verify_callback.hpp │ │ │ └── stream_base.hpp │ │ ├── impl │ │ │ ├── system_context.hpp │ │ │ ├── executor.ipp │ │ │ ├── multiple_exceptions.ipp │ │ │ └── serial_port_base.hpp │ │ ├── associator.hpp │ │ ├── stream_file.hpp │ │ ├── basic_streambuf_fwd.hpp │ │ ├── readable_pipe.hpp │ │ ├── writable_pipe.hpp │ │ ├── experimental │ │ │ ├── append.hpp │ │ │ ├── prepend.hpp │ │ │ ├── as_tuple.hpp │ │ │ ├── deferred.hpp │ │ │ └── detail │ │ │ │ └── has_signature.hpp │ │ ├── random_access_file.hpp │ │ ├── serial_port.hpp │ │ ├── posix │ │ │ ├── descriptor.hpp │ │ │ └── stream_descriptor.hpp │ │ ├── execution │ │ │ ├── impl │ │ │ │ ├── bad_executor.ipp │ │ │ │ └── receiver_invocation_error.ipp │ │ │ ├── bad_executor.hpp │ │ │ └── receiver_invocation_error.hpp │ │ ├── windows │ │ │ ├── stream_handle.hpp │ │ │ ├── object_handle.hpp │ │ │ ├── random_access_handle.hpp │ │ │ └── overlapped_handle.hpp │ │ ├── ip │ │ │ ├── host_name.hpp │ │ │ ├── resolver_query_base.hpp │ │ │ └── impl │ │ │ │ ├── basic_endpoint.hpp │ │ │ │ ├── host_name.ipp │ │ │ │ ├── network_v6.hpp │ │ │ │ └── network_v4.hpp │ │ ├── deadline_timer.hpp │ │ ├── steady_timer.hpp │ │ ├── system_timer.hpp │ │ ├── is_executor.hpp │ │ ├── is_contiguous_iterator.hpp │ │ ├── high_resolution_timer.hpp │ │ ├── wait_traits.hpp │ │ └── handler_continuation_hook.hpp │ └── LICENSE_1_0.txt └── fmt │ ├── src │ └── format.cc │ └── LICENSE.rst ├── include ├── websocket │ └── wsock_router.hpp ├── http │ ├── http_context.hpp │ ├── http_client.hpp │ └── http_server.hpp ├── kcp │ └── kcp_message.hpp ├── pipe │ └── pipe_proto.hpp ├── tls_context.hpp ├── utils │ └── string_thief.hpp ├── knet_factory.hpp └── knet_handler.hpp ├── .gitmodules ├── samples ├── webclient.cpp ├── test_url.cpp ├── wsclient1.cpp ├── wsserver.cpp ├── wssserver.cpp ├── udpclient.cpp ├── webserver.cpp ├── wsclient.cpp ├── kcpserver.cpp ├── wssclient.cpp ├── kcpclient.cpp ├── unbind_pipe_server.cpp ├── mt_server.h ├── logger.cpp ├── unbind_pipe_client.cpp └── pipe_server.cpp ├── .github └── workflows │ └── c-cpp.yml ├── .gitignore └── kcp └── CMakeLists.txt /opt/llhttp-v6.0.5.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cageq/knet/HEAD/opt/llhttp-v6.0.5.tgz -------------------------------------------------------------------------------- /deps/spdlog/include/spdlog/fmt/bundled/locale.h: -------------------------------------------------------------------------------- 1 | #include "xchar.h" 2 | #warning fmt/locale.h is deprecated, include fmt/format.h or fmt/xchar.h instead 3 | -------------------------------------------------------------------------------- /deps/spdlog/include/spdlog/details/windows_include.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef NOMINMAX 4 | # define NOMINMAX // prevent windows redefining min/max 5 | #endif 6 | 7 | #ifndef WIN32_LEAN_AND_MEAN 8 | # define WIN32_LEAN_AND_MEAN 9 | #endif 10 | 11 | #include 12 | -------------------------------------------------------------------------------- /include/websocket/wsock_router.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "http/http_connection.hpp" 3 | 4 | using namespace knet::http; 5 | namespace knet { 6 | namespace websocket { 7 | 8 | 9 | class WSockRouter{ 10 | 11 | 12 | public: 13 | 14 | 15 | 16 | 17 | 18 | 19 | }; 20 | 21 | 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /deps/spdlog/src/cfg.cpp: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #ifndef SPDLOG_COMPILED_LIB 5 | # error Please define SPDLOG_COMPILED_LIB to compile this file. 6 | #endif 7 | 8 | #include 9 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "opt/asio"] 2 | path = opt/asio 3 | url = https://github.com/chriskohlhoff/asio.git 4 | [submodule "opt/fmt"] 5 | path = opt/fmt 6 | url = https://github.com/fmtlib/fmt.git 7 | [submodule "opt/klog"] 8 | path = opt/klog 9 | url = https://github.com/cageq/klog 10 | [submodule "opt/spdlog"] 11 | path = opt/spdlog 12 | url = https://github.com/gabime/spdlog.git 13 | -------------------------------------------------------------------------------- /samples/webclient.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "knet.hpp" 4 | 5 | #include "http/http_client.hpp" 6 | 7 | using namespace knet::http; 8 | 9 | 10 | int main(int argc, char* argv[]) { 11 | HttpClient httpClient; 12 | 13 | httpClient.get("http://127.0.0.1/index"); 14 | 15 | while (1) { 16 | std::this_thread::sleep_for(std::chrono::seconds(1)); 17 | } 18 | return 0; 19 | } -------------------------------------------------------------------------------- /deps/spdlog/include/spdlog/version.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #define SPDLOG_VER_MAJOR 1 7 | #define SPDLOG_VER_MINOR 12 8 | #define SPDLOG_VER_PATCH 0 9 | 10 | #define SPDLOG_VERSION (SPDLOG_VER_MAJOR * 10000 + SPDLOG_VER_MINOR * 100 + SPDLOG_VER_PATCH) 11 | -------------------------------------------------------------------------------- /deps/spdlog/include/spdlog/fwd.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | namespace spdlog { 7 | class logger; 8 | class formatter; 9 | 10 | namespace sinks { 11 | class sink; 12 | } 13 | 14 | namespace level { 15 | enum level_enum : int; 16 | } 17 | 18 | } // namespace spdlog 19 | -------------------------------------------------------------------------------- /deps/spdlog/src/async.cpp: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #ifndef SPDLOG_COMPILED_LIB 5 | # error Please define SPDLOG_COMPILED_LIB to compile this file. 6 | #endif 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | -------------------------------------------------------------------------------- /deps/asio/asio/unyield.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // unyield.hpp 3 | // ~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifdef reenter 12 | # undef reenter 13 | #endif 14 | 15 | #ifdef yield 16 | # undef yield 17 | #endif 18 | 19 | #ifdef fork 20 | # undef fork 21 | #endif 22 | -------------------------------------------------------------------------------- /.github/workflows/c-cpp.yml: -------------------------------------------------------------------------------- 1 | name: C/C++ CI 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | build: 11 | 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - uses: actions/checkout@v2 16 | 17 | - name: Setup C++ environment 18 | uses: kurocha/setup-cpp@v1 19 | - name: Init Submodules 20 | run: git submodule init && git submodule update --recursive && git submodule sync 21 | - name: Build 22 | run: ./build.sh 23 | 24 | -------------------------------------------------------------------------------- /deps/spdlog/include/spdlog/formatter.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | namespace spdlog { 10 | 11 | class formatter 12 | { 13 | public: 14 | virtual ~formatter() = default; 15 | virtual void format(const details::log_msg &msg, memory_buf_t &dest) = 0; 16 | virtual std::unique_ptr clone() const = 0; 17 | }; 18 | } // namespace spdlog 19 | -------------------------------------------------------------------------------- /deps/asio/asio/yield.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // yield.hpp 3 | // ~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #include "coroutine.hpp" 12 | 13 | #ifndef reenter 14 | # define reenter(c) ASIO_CORO_REENTER(c) 15 | #endif 16 | 17 | #ifndef yield 18 | # define yield ASIO_CORO_YIELD 19 | #endif 20 | 21 | #ifndef fork 22 | # define fork ASIO_CORO_FORK 23 | #endif 24 | -------------------------------------------------------------------------------- /samples/test_url.cpp: -------------------------------------------------------------------------------- 1 | #include "utils/knet_url.hpp" 2 | 3 | #include 4 | 5 | 6 | 7 | using namespace knet::utils; 8 | 9 | 10 | 11 | int main(int argc, char * argv[]){ 12 | 13 | 14 | 15 | KNetUrl urlInfo; 16 | auto info = urlInfo.parse("tcp://127.0.0.1:8999?delay=0&sendsize=180000&recvsize=33333"); 17 | 18 | std::cout << urlInfo.dump() << std::endl ; 19 | std::cout << urlInfo.encode() << std::endl; 20 | 21 | info = urlInfo.parse("tcp://127.0.0.1:8999"); 22 | 23 | std::cout << urlInfo.dump() << std::endl ; 24 | std::cout << urlInfo.encode() << std::endl; 25 | }; 26 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | 34 | CMakeFiles 35 | cmake_install.cmake 36 | CMakeCache.txt 37 | env.cmake 38 | Makefile 39 | .DS_Store 40 | build 41 | opt/asio-1.18.0 42 | opt/fmt-7.0.3 43 | bin 44 | 45 | *.swp 46 | .vscode 47 | *.log 48 | -------------------------------------------------------------------------------- /deps/asio/asio/ts/io_context.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // ts/io_context.hpp 3 | // ~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_TS_IO_CONTEXT_HPP 12 | #define ASIO_TS_IO_CONTEXT_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/io_context.hpp" 19 | 20 | #endif // ASIO_TS_IO_CONTEXT_HPP 21 | -------------------------------------------------------------------------------- /deps/spdlog/include/spdlog/fmt/chrono.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(c) 2016 Gabi Melman. 3 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 4 | // 5 | 6 | #pragma once 7 | // 8 | // include bundled or external copy of fmtlib's chrono support 9 | // 10 | 11 | #if !defined(SPDLOG_USE_STD_FORMAT) 12 | # if !defined(SPDLOG_FMT_EXTERNAL) 13 | # ifdef SPDLOG_HEADER_ONLY 14 | # ifndef FMT_HEADER_ONLY 15 | # define FMT_HEADER_ONLY 16 | # endif 17 | # endif 18 | # include 19 | # else 20 | # include 21 | # endif 22 | #endif 23 | -------------------------------------------------------------------------------- /deps/spdlog/include/spdlog/fmt/ranges.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(c) 2016 Gabi Melman. 3 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 4 | // 5 | 6 | #pragma once 7 | // 8 | // include bundled or external copy of fmtlib's ranges support 9 | // 10 | 11 | #if !defined(SPDLOG_USE_STD_FORMAT) 12 | # if !defined(SPDLOG_FMT_EXTERNAL) 13 | # ifdef SPDLOG_HEADER_ONLY 14 | # ifndef FMT_HEADER_ONLY 15 | # define FMT_HEADER_ONLY 16 | # endif 17 | # endif 18 | # include 19 | # else 20 | # include 21 | # endif 22 | #endif 23 | -------------------------------------------------------------------------------- /deps/spdlog/include/spdlog/fmt/xchar.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(c) 2016 Gabi Melman. 3 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 4 | // 5 | 6 | #pragma once 7 | // 8 | // include bundled or external copy of fmtlib's xchar support 9 | // 10 | 11 | #if !defined(SPDLOG_USE_STD_FORMAT) 12 | # if !defined(SPDLOG_FMT_EXTERNAL) 13 | # ifdef SPDLOG_HEADER_ONLY 14 | # ifndef FMT_HEADER_ONLY 15 | # define FMT_HEADER_ONLY 16 | # endif 17 | # endif 18 | # include 19 | # else 20 | # include 21 | # endif 22 | #endif 23 | -------------------------------------------------------------------------------- /deps/spdlog/include/spdlog/fmt/ostr.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(c) 2016 Gabi Melman. 3 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 4 | // 5 | 6 | #pragma once 7 | // 8 | // include bundled or external copy of fmtlib's ostream support 9 | // 10 | 11 | #if !defined(SPDLOG_USE_STD_FORMAT) 12 | # if !defined(SPDLOG_FMT_EXTERNAL) 13 | # ifdef SPDLOG_HEADER_ONLY 14 | # ifndef FMT_HEADER_ONLY 15 | # define FMT_HEADER_ONLY 16 | # endif 17 | # endif 18 | # include 19 | # else 20 | # include 21 | # endif 22 | #endif 23 | -------------------------------------------------------------------------------- /deps/spdlog/include/spdlog/fmt/compile.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(c) 2016 Gabi Melman. 3 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 4 | // 5 | 6 | #pragma once 7 | // 8 | // include bundled or external copy of fmtlib's compile-time support 9 | // 10 | 11 | #if !defined(SPDLOG_USE_STD_FORMAT) 12 | # if !defined(SPDLOG_FMT_EXTERNAL) 13 | # ifdef SPDLOG_HEADER_ONLY 14 | # ifndef FMT_HEADER_ONLY 15 | # define FMT_HEADER_ONLY 16 | # endif 17 | # endif 18 | # include 19 | # else 20 | # include 21 | # endif 22 | #endif 23 | -------------------------------------------------------------------------------- /deps/asio/asio/io_service_strand.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // io_service_strand.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_IO_SERVICE_STRAND_HPP 12 | #define ASIO_IO_SERVICE_STRAND_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/io_context_strand.hpp" 19 | 20 | #endif // ASIO_IO_SERVICE_STRAND_HPP 21 | -------------------------------------------------------------------------------- /deps/spdlog/include/spdlog/fmt/std.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(c) 2016 Gabi Melman. 3 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 4 | // 5 | 6 | #pragma once 7 | // 8 | // include bundled or external copy of fmtlib's std support (for formatting e.g. std::filesystem::path, std::thread::id, std::monostate, 9 | // std::variant, ...) 10 | // 11 | 12 | #if !defined(SPDLOG_USE_STD_FORMAT) 13 | # if !defined(SPDLOG_FMT_EXTERNAL) 14 | # ifdef SPDLOG_HEADER_ONLY 15 | # ifndef FMT_HEADER_ONLY 16 | # define FMT_HEADER_ONLY 17 | # endif 18 | # endif 19 | # include 20 | # else 21 | # include 22 | # endif 23 | #endif 24 | -------------------------------------------------------------------------------- /deps/asio/asio/ts/buffer.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // ts/buffer.hpp 3 | // ~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_TS_BUFFER_HPP 12 | #define ASIO_TS_BUFFER_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/buffer.hpp" 19 | #include "asio/completion_condition.hpp" 20 | #include "asio/read.hpp" 21 | #include "asio/write.hpp" 22 | #include "asio/read_until.hpp" 23 | 24 | #endif // ASIO_TS_BUFFER_HPP 25 | -------------------------------------------------------------------------------- /deps/asio/asio/buffered_stream_fwd.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // buffered_stream_fwd.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_BUFFERED_STREAM_FWD_HPP 12 | #define ASIO_BUFFERED_STREAM_FWD_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | namespace asio { 19 | 20 | template 21 | class buffered_stream; 22 | 23 | } // namespace asio 24 | 25 | #endif // ASIO_BUFFERED_STREAM_FWD_HPP 26 | -------------------------------------------------------------------------------- /deps/asio/asio/version.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // version.hpp 3 | // ~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_VERSION_HPP 12 | #define ASIO_VERSION_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | // ASIO_VERSION % 100 is the sub-minor version 19 | // ASIO_VERSION / 100 % 1000 is the minor version 20 | // ASIO_VERSION / 100000 is the major version 21 | #define ASIO_VERSION 102801 // 1.28.1 22 | 23 | #endif // ASIO_VERSION_HPP 24 | -------------------------------------------------------------------------------- /deps/asio/asio/buffered_read_stream_fwd.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // buffered_read_stream_fwd.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_BUFFERED_READ_STREAM_FWD_HPP 12 | #define ASIO_BUFFERED_READ_STREAM_FWD_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | namespace asio { 19 | 20 | template 21 | class buffered_read_stream; 22 | 23 | } // namespace asio 24 | 25 | #endif // ASIO_BUFFERED_READ_STREAM_FWD_HPP 26 | -------------------------------------------------------------------------------- /include/http/http_context.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "http_request.hpp" 4 | #include "http_response.hpp" 5 | 6 | namespace knet 7 | { 8 | namespace http 9 | { 10 | 11 | class HttpContext 12 | { 13 | public: 14 | HttpRequest request; 15 | HttpResponse response; 16 | 17 | int32_t write(const std::string & msg){ 18 | return response.write(msg); 19 | } 20 | 21 | }; 22 | 23 | 24 | using HttpContextPtr = std::shared_ptr; 25 | 26 | using HttpRequestHandler = std::function ; 27 | using HttpContextHandler = std::function ; 28 | 29 | } 30 | 31 | } -------------------------------------------------------------------------------- /deps/asio/asio/buffered_write_stream_fwd.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // buffered_write_stream_fwd.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_BUFFERED_WRITE_STREAM_FWD_HPP 12 | #define ASIO_BUFFERED_WRITE_STREAM_FWD_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | namespace asio { 19 | 20 | template 21 | class buffered_write_stream; 22 | 23 | } // namespace asio 24 | 25 | #endif // ASIO_BUFFERED_WRITE_STREAM_FWD_HPP 26 | -------------------------------------------------------------------------------- /deps/spdlog/include/spdlog/details/console_globals.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | namespace spdlog { 10 | namespace details { 11 | 12 | struct console_mutex 13 | { 14 | using mutex_t = std::mutex; 15 | static mutex_t &mutex() 16 | { 17 | static mutex_t s_mutex; 18 | return s_mutex; 19 | } 20 | }; 21 | 22 | struct console_nullmutex 23 | { 24 | using mutex_t = null_mutex; 25 | static mutex_t &mutex() 26 | { 27 | static mutex_t s_mutex; 28 | return s_mutex; 29 | } 30 | }; 31 | } // namespace details 32 | } // namespace spdlog 33 | -------------------------------------------------------------------------------- /deps/spdlog/include/spdlog/details/periodic_worker-inl.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #ifndef SPDLOG_HEADER_ONLY 7 | # include 8 | #endif 9 | 10 | namespace spdlog { 11 | namespace details { 12 | 13 | // stop the worker thread and join it 14 | SPDLOG_INLINE periodic_worker::~periodic_worker() 15 | { 16 | if (worker_thread_.joinable()) 17 | { 18 | { 19 | std::lock_guard lock(mutex_); 20 | active_ = false; 21 | } 22 | cv_.notify_one(); 23 | worker_thread_.join(); 24 | } 25 | } 26 | 27 | } // namespace details 28 | } // namespace spdlog 29 | -------------------------------------------------------------------------------- /deps/asio/asio/ts/net.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // ts/net.hpp 3 | // ~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_TS_NET_HPP 12 | #define ASIO_TS_NET_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/ts/netfwd.hpp" 19 | #include "asio/ts/executor.hpp" 20 | #include "asio/ts/io_context.hpp" 21 | #include "asio/ts/timer.hpp" 22 | #include "asio/ts/buffer.hpp" 23 | #include "asio/ts/socket.hpp" 24 | #include "asio/ts/internet.hpp" 25 | 26 | #endif // ASIO_TS_NET_HPP 27 | -------------------------------------------------------------------------------- /deps/asio/asio/ts/timer.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // ts/timer.hpp 3 | // ~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_TS_TIMER_HPP 12 | #define ASIO_TS_TIMER_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/chrono.hpp" 19 | 20 | #include "asio/wait_traits.hpp" 21 | #include "asio/basic_waitable_timer.hpp" 22 | #include "asio/system_timer.hpp" 23 | #include "asio/steady_timer.hpp" 24 | #include "asio/high_resolution_timer.hpp" 25 | 26 | #endif // ASIO_TS_TIMER_HPP 27 | -------------------------------------------------------------------------------- /deps/asio/asio/signal_set.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // signal_set.hpp 3 | // ~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_SIGNAL_SET_HPP 12 | #define ASIO_SIGNAL_SET_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | #include "asio/basic_signal_set.hpp" 20 | 21 | namespace asio { 22 | 23 | /// Typedef for the typical usage of a signal set. 24 | typedef basic_signal_set<> signal_set; 25 | 26 | } // namespace asio 27 | 28 | #endif // ASIO_SIGNAL_SET_HPP 29 | -------------------------------------------------------------------------------- /deps/asio/asio/detail/limits.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // detail/limits.hpp 3 | // ~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2011 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_DETAIL_LIMITS_HPP 12 | #define ASIO_DETAIL_LIMITS_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | 20 | #if defined(ASIO_HAS_BOOST_LIMITS) 21 | # include 22 | #else // defined(ASIO_HAS_BOOST_LIMITS) 23 | # include 24 | #endif // defined(ASIO_HAS_BOOST_LIMITS) 25 | 26 | #endif // ASIO_DETAIL_LIMITS_HPP 27 | -------------------------------------------------------------------------------- /kcp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | CMAKE_MINIMUM_REQUIRED(VERSION 2.6) 2 | 3 | project(kcp LANGUAGES C) 4 | 5 | include(CTest) 6 | include(GNUInstallDirs) 7 | 8 | add_library(kcp STATIC ikcp.c) 9 | 10 | install(FILES ikcp.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) 11 | 12 | install(TARGETS kcp 13 | EXPORT kcp-targets 14 | ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} 15 | INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} 16 | ) 17 | 18 | install(EXPORT kcp-targets 19 | FILE kcp-config.cmake 20 | NAMESPACE kcp:: 21 | DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/kcp 22 | ) 23 | 24 | if (BUILD_TESTING) 25 | enable_language(CXX) 26 | 27 | add_executable(kcp_test test.cpp) 28 | if(MSVC AND NOT (MSVC_VERSION LESS 1900)) 29 | target_compile_options(kcp_test PRIVATE /utf-8) 30 | endif() 31 | endif () 32 | -------------------------------------------------------------------------------- /samples/wsclient1.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "knet.hpp" 3 | 4 | #include "websocket/wsock_connection.hpp" 5 | #include 6 | 7 | using namespace knet::tcp; 8 | using namespace knet::websocket; 9 | 10 | 11 | int main(int argc, char** argv) 12 | { 13 | knet_dlog("init client "); 14 | Connector connector; 15 | connector.start(); 16 | 17 | for (int i = 0; i < 1; i++) 18 | { 19 | //connector.add_wsconnection("127.0.0.1", 5020); 20 | //connector.add_wsconnection("127.0.0.1", 3000); 21 | connector.add_wsconnection("echo.websocket.org", 80,"/echo"); 22 | //connector.add_connection("10.246.34.55", 8855); 23 | } 24 | 25 | char c = getchar(); 26 | while (c) 27 | { 28 | if (c == 'q') 29 | { 30 | break; 31 | } 32 | c = getchar() ; 33 | } 34 | 35 | return 0; 36 | } 37 | 38 | -------------------------------------------------------------------------------- /samples/wsserver.cpp: -------------------------------------------------------------------------------- 1 | #include "websocket/wsock_server.hpp" 2 | 3 | 4 | 5 | using namespace knet::websocket; 6 | 7 | int main(int argc, char** argv) 8 | { 9 | 10 | knet_add_console_sink(); 11 | 12 | knet_dlog("init websocket server "); 13 | WSockServer<> wsServer; 14 | 15 | WSockHandler wsHandler; 16 | wsHandler.message = [](std::shared_ptr conn, const std::string & msg ){ 17 | 18 | knet_wlog("on websocket message {}", msg); 19 | conn->send_text("hello client",OpCode::TEXT_FRAME,false); 20 | return true; 21 | }; 22 | wsServer.register_router("/echo", wsHandler); 23 | 24 | wsServer.start(8888, "0.0.0.0"); 25 | 26 | char c = getchar(); 27 | while (c) 28 | { 29 | if (c == 'q') 30 | { 31 | break; 32 | } 33 | c = getchar() ; 34 | } 35 | 36 | return 0; 37 | 38 | } 39 | -------------------------------------------------------------------------------- /deps/spdlog/include/spdlog/sinks/sink-inl.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #ifndef SPDLOG_HEADER_ONLY 7 | # include 8 | #endif 9 | 10 | #include 11 | 12 | SPDLOG_INLINE bool spdlog::sinks::sink::should_log(spdlog::level::level_enum msg_level) const 13 | { 14 | return msg_level >= level_.load(std::memory_order_relaxed); 15 | } 16 | 17 | SPDLOG_INLINE void spdlog::sinks::sink::set_level(level::level_enum log_level) 18 | { 19 | level_.store(log_level, std::memory_order_relaxed); 20 | } 21 | 22 | SPDLOG_INLINE spdlog::level::level_enum spdlog::sinks::sink::level() const 23 | { 24 | return static_cast(level_.load(std::memory_order_relaxed)); 25 | } 26 | -------------------------------------------------------------------------------- /deps/spdlog/include/spdlog/cfg/helpers.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | namespace spdlog { 10 | namespace cfg { 11 | namespace helpers { 12 | // 13 | // Init levels from given string 14 | // 15 | // Examples: 16 | // 17 | // set global level to debug: "debug" 18 | // turn off all logging except for logger1: "off,logger1=debug" 19 | // turn off all logging except for logger1 and logger2: "off,logger1=debug,logger2=info" 20 | // 21 | SPDLOG_API void load_levels(const std::string &txt); 22 | } // namespace helpers 23 | 24 | } // namespace cfg 25 | } // namespace spdlog 26 | 27 | #ifdef SPDLOG_HEADER_ONLY 28 | # include "helpers-inl.h" 29 | #endif // SPDLOG_HEADER_ONLY 30 | -------------------------------------------------------------------------------- /deps/asio/asio/detail/cstddef.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // detail/cstddef.hpp 3 | // ~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_DETAIL_CSTDDEF_HPP 12 | #define ASIO_DETAIL_CSTDDEF_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | #include 20 | 21 | namespace asio { 22 | 23 | #if defined(ASIO_HAS_NULLPTR) 24 | using std::nullptr_t; 25 | #else // defined(ASIO_HAS_NULLPTR) 26 | struct nullptr_t {}; 27 | #endif // defined(ASIO_HAS_NULLPTR) 28 | 29 | } // namespace asio 30 | 31 | #endif // ASIO_DETAIL_CSTDDEF_HPP 32 | -------------------------------------------------------------------------------- /deps/spdlog/include/spdlog/details/synchronous_factory.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #include "registry.h" 7 | 8 | namespace spdlog { 9 | 10 | // Default logger factory- creates synchronous loggers 11 | class logger; 12 | 13 | struct synchronous_factory 14 | { 15 | template 16 | static std::shared_ptr create(std::string logger_name, SinkArgs &&...args) 17 | { 18 | auto sink = std::make_shared(std::forward(args)...); 19 | auto new_logger = std::make_shared(std::move(logger_name), std::move(sink)); 20 | details::registry::instance().initialize_logger(new_logger); 21 | return new_logger; 22 | } 23 | }; 24 | } // namespace spdlog 25 | -------------------------------------------------------------------------------- /deps/spdlog/src/file_sinks.cpp: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #ifndef SPDLOG_COMPILED_LIB 5 | # error Please define SPDLOG_COMPILED_LIB to compile this file. 6 | #endif 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | 15 | template class SPDLOG_API spdlog::sinks::basic_file_sink; 16 | template class SPDLOG_API spdlog::sinks::basic_file_sink; 17 | 18 | #include 19 | template class SPDLOG_API spdlog::sinks::rotating_file_sink; 20 | template class SPDLOG_API spdlog::sinks::rotating_file_sink; 21 | -------------------------------------------------------------------------------- /deps/asio/asio/static_thread_pool.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // static_thread_pool.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_STATIC_THREAD_POOL_HPP 12 | #define ASIO_STATIC_THREAD_POOL_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | #include "asio/thread_pool.hpp" 20 | 21 | #include "asio/detail/push_options.hpp" 22 | 23 | namespace asio { 24 | 25 | typedef thread_pool static_thread_pool; 26 | 27 | } // namespace asio 28 | 29 | #include "asio/detail/pop_options.hpp" 30 | 31 | #endif // ASIO_STATIC_THREAD_POOL_HPP 32 | -------------------------------------------------------------------------------- /deps/asio/asio/ssl.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // ssl.hpp 3 | // ~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_SSL_HPP 12 | #define ASIO_SSL_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/ssl/context.hpp" 19 | #include "asio/ssl/context_base.hpp" 20 | #include "asio/ssl/error.hpp" 21 | #include "asio/ssl/rfc2818_verification.hpp" 22 | #include "asio/ssl/host_name_verification.hpp" 23 | #include "asio/ssl/stream.hpp" 24 | #include "asio/ssl/stream_base.hpp" 25 | #include "asio/ssl/verify_context.hpp" 26 | #include "asio/ssl/verify_mode.hpp" 27 | 28 | #endif // ASIO_SSL_HPP 29 | -------------------------------------------------------------------------------- /deps/asio/asio/streambuf.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // streambuf.hpp 3 | // ~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_STREAMBUF_HPP 12 | #define ASIO_STREAMBUF_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | 20 | #if !defined(ASIO_NO_IOSTREAM) 21 | 22 | #include "asio/basic_streambuf.hpp" 23 | 24 | namespace asio { 25 | 26 | /// Typedef for the typical usage of basic_streambuf. 27 | typedef basic_streambuf<> streambuf; 28 | 29 | } // namespace asio 30 | 31 | #endif // !defined(ASIO_NO_IOSTREAM) 32 | 33 | #endif // ASIO_STREAMBUF_HPP 34 | -------------------------------------------------------------------------------- /deps/asio/asio/ts/socket.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // ts/socket.hpp 3 | // ~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_TS_SOCKET_HPP 12 | #define ASIO_TS_SOCKET_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/socket_base.hpp" 19 | #include "asio/basic_socket.hpp" 20 | #include "asio/basic_datagram_socket.hpp" 21 | #include "asio/basic_stream_socket.hpp" 22 | #include "asio/basic_socket_acceptor.hpp" 23 | #include "asio/basic_socket_streambuf.hpp" 24 | #include "asio/basic_socket_iostream.hpp" 25 | #include "asio/connect.hpp" 26 | 27 | #endif // ASIO_TS_SOCKET_HPP 28 | -------------------------------------------------------------------------------- /deps/asio/asio/io_service.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // io_service.hpp 3 | // ~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_IO_SERVICE_HPP 12 | #define ASIO_IO_SERVICE_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/io_context.hpp" 19 | 20 | #include "asio/detail/push_options.hpp" 21 | 22 | namespace asio { 23 | 24 | #if !defined(ASIO_NO_DEPRECATED) 25 | /// Typedef for backwards compatibility. 26 | typedef io_context io_service; 27 | #endif // !defined(ASIO_NO_DEPRECATED) 28 | 29 | } // namespace asio 30 | 31 | #include "asio/detail/pop_options.hpp" 32 | 33 | #endif // ASIO_IO_SERVICE_HPP 34 | -------------------------------------------------------------------------------- /deps/asio/asio/detail/date_time_fwd.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // detail/date_time_fwd.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_DETAIL_DATE_TIME_FWD_HPP 12 | #define ASIO_DETAIL_DATE_TIME_FWD_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | 20 | namespace boost { 21 | namespace date_time { 22 | 23 | template 24 | class base_time; 25 | 26 | } // namespace date_time 27 | namespace posix_time { 28 | 29 | class ptime; 30 | 31 | } // namespace posix_time 32 | } // namespace boost 33 | 34 | #endif // ASIO_DETAIL_DATE_TIME_FWD_HPP 35 | -------------------------------------------------------------------------------- /deps/asio/asio/ssl/impl/src.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // impl/ssl/src.hpp 3 | // ~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_SSL_IMPL_SRC_HPP 12 | #define ASIO_SSL_IMPL_SRC_HPP 13 | 14 | #define ASIO_SOURCE 15 | 16 | #include "asio/detail/config.hpp" 17 | 18 | #if defined(ASIO_HEADER_ONLY) 19 | # error Do not compile Asio library source with ASIO_HEADER_ONLY defined 20 | #endif 21 | 22 | #include "asio/ssl/impl/context.ipp" 23 | #include "asio/ssl/impl/error.ipp" 24 | #include "asio/ssl/detail/impl/engine.ipp" 25 | #include "asio/ssl/detail/impl/openssl_init.ipp" 26 | #include "asio/ssl/impl/host_name_verification.ipp" 27 | #include "asio/ssl/impl/rfc2818_verification.ipp" 28 | 29 | #endif // ASIO_SSL_IMPL_SRC_HPP 30 | -------------------------------------------------------------------------------- /deps/asio/asio/impl/system_context.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // impl/system_context.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_IMPL_SYSTEM_CONTEXT_HPP 12 | #define ASIO_IMPL_SYSTEM_CONTEXT_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/system_executor.hpp" 19 | 20 | #include "asio/detail/push_options.hpp" 21 | 22 | namespace asio { 23 | 24 | inline system_context::executor_type 25 | system_context::get_executor() ASIO_NOEXCEPT 26 | { 27 | return system_executor(); 28 | } 29 | 30 | } // namespace asio 31 | 32 | #include "asio/detail/pop_options.hpp" 33 | 34 | #endif // ASIO_IMPL_SYSTEM_CONTEXT_HPP 35 | -------------------------------------------------------------------------------- /samples/wssserver.cpp: -------------------------------------------------------------------------------- 1 | #include "websocket/wsock_ssl_server.hpp" 2 | 3 | 4 | 5 | using namespace knet::websocket; 6 | 7 | int main(int argc, char** argv) 8 | { 9 | 10 | knet_add_console_sink(); 11 | 12 | knet_dlog("init websocket server "); 13 | WSockSslServer<> wsServer; 14 | 15 | WSockHandler wsHandler; 16 | wsHandler.message = [](std::shared_ptr conn, const std::string_view & msg){ 17 | 18 | knet_wlog("on websocket message: {}", msg); 19 | conn->send_text("hello client",OpCode::TEXT_FRAME,false); 20 | }; 21 | wsServer.register_router("/echo", wsHandler); 22 | 23 | //wsServer.init_ssl("cert/server.pem", "cert/dh2048.pem"); 24 | wsServer.init_ssl("ca/kstar.pem", "cert/dh2048.pem","Hello123"); 25 | 26 | wsServer.start(9000,"0.0.0.0"); 27 | 28 | char c = getchar(); 29 | while (c) 30 | { 31 | if (c == 'q') 32 | { 33 | break; 34 | } 35 | c = getchar() ; 36 | } 37 | 38 | return 0; 39 | 40 | } 41 | -------------------------------------------------------------------------------- /deps/asio/asio/associator.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // associator.hpp 3 | // ~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_ASSOCIATOR_HPP 12 | #define ASIO_ASSOCIATOR_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | 20 | #include "asio/detail/push_options.hpp" 21 | 22 | namespace asio { 23 | 24 | /// Used to generically specialise associators for a type. 25 | template