├── .circleci └── config.yml ├── .gitattributes ├── .githooks └── license-maintainer │ ├── cpp │ └── LICENSE.AGPL3 │ ├── license.pm │ └── pre-commit ├── .gitignore ├── .idea ├── codeStyles │ └── codeStyleConfig.xml ├── discord.xml ├── encodings.xml ├── inspectionProfiles │ └── Project_Default.xml ├── markdown-exported-files.xml ├── markdown-navigator.xml ├── misc.xml ├── modules.xml ├── shiro.iml └── vcs.xml ├── CMakeLists.txt ├── LICENSE.txt ├── README.md ├── bors.toml ├── cmake ├── FindHinnantDate.cmake └── FindTcmalloc.cmake ├── docker ├── ci │ └── Dockerfile └── prod │ └── Dockerfile ├── external ├── generate_ssl_certificate.sh ├── shiro.nginxconf ├── sqlpp11-connector-mysql.patch └── sqlpp11.patch ├── resources ├── api.toml ├── bancho.toml ├── bot.toml ├── database.toml ├── direct.toml ├── geolite2_city.mmdb ├── ipc.toml ├── ripple_migrations.sql └── score_submission.toml ├── src ├── beatmaps │ ├── beatmap.cc │ ├── beatmap.hh │ ├── beatmap_helper.cc │ ├── beatmap_helper.hh │ └── beatmap_ranked_status.hh ├── bot │ ├── bot.cc │ └── bot.hh ├── channels │ ├── channel_manager.cc │ ├── channel_manager.hh │ ├── console_osu_bridge.cc │ └── console_osu_bridge.hh ├── commands │ ├── public │ │ ├── help_command.cc │ │ ├── help_command.hh │ │ ├── localclear_command.cc │ │ ├── localclear_command.hh │ │ ├── roll_command.cc │ │ └── roll_command.hh │ └── staff │ │ ├── announce_command.cc │ │ ├── announce_command.hh │ │ ├── ban_command.cc │ │ ├── ban_command.hh │ │ ├── clear_command.cc │ │ ├── clear_command.hh │ │ ├── clients_command.cc │ │ ├── clients_command.hh │ │ ├── kick_command.cc │ │ ├── kick_command.hh │ │ ├── recalculate_ranks.cc │ │ ├── recalculate_ranks.hh │ │ ├── restart_command.cc │ │ ├── restart_command.hh │ │ ├── restrict_command.cc │ │ ├── restrict_command.hh │ │ ├── rtx_command.cc │ │ ├── rtx_command.hh │ │ ├── silence_command.cc │ │ └── silence_command.hh ├── config │ ├── api_file.cc │ ├── api_file.hh │ ├── bancho_file.cc │ ├── bancho_file.hh │ ├── bot_file.cc │ ├── bot_file.hh │ ├── cli_args.cc │ ├── cli_args.hh │ ├── db_file.cc │ ├── db_file.hh │ ├── direct_file.cc │ ├── direct_file.hh │ ├── ipc_file.cc │ ├── ipc_file.hh │ ├── score_submission_file.cc │ └── score_submission_file.hh ├── database │ ├── database.cc │ ├── database.hh │ └── tables │ │ ├── beatmap_table.hh │ │ ├── channel_table.hh │ │ ├── common_tables.hh │ │ ├── punishments_table.hh │ │ ├── relationship_table.hh │ │ ├── roles_table.hh │ │ ├── score_table.hh │ │ └── user_table.hh ├── direct │ ├── direct_provider.cc │ ├── direct_provider.hh │ └── providers │ │ ├── beatconnect.cc │ │ ├── beatconnect.hh │ │ ├── emulation.cc │ │ └── emulation.hh ├── geoloc │ ├── country_ids.cc │ ├── country_ids.hh │ ├── geoloc.cc │ ├── geoloc.hh │ ├── location_info.hh │ ├── maxmind_resolver.cc │ └── maxmind_resolver.hh ├── handlers │ ├── chat │ │ ├── join_channel_handler.cc │ │ ├── join_channel_handler.hh │ │ ├── leave_channel_handler.cc │ │ ├── leave_channel_handler.hh │ │ ├── private_chat_handler.cc │ │ ├── private_chat_handler.hh │ │ ├── public_chat_handler.cc │ │ └── public_chat_handler.hh │ ├── friends │ │ ├── friend_add_handler.cc │ │ ├── friend_add_handler.hh │ │ ├── friend_remove_handler.cc │ │ └── friend_remove_handler.hh │ ├── invite_handler.cc │ ├── invite_handler.hh │ ├── login_handler.cc │ ├── login_handler.hh │ ├── logout_handler.cc │ ├── logout_handler.hh │ ├── multiplayer │ │ ├── lobby │ │ │ ├── lobby_join_handler.cc │ │ │ ├── lobby_join_handler.hh │ │ │ ├── lobby_leave_handler.cc │ │ │ └── lobby_leave_handler.hh │ │ ├── match │ │ │ ├── match_complete_handler.cc │ │ │ ├── match_complete_handler.hh │ │ │ ├── match_load_handler.cc │ │ │ ├── match_load_handler.hh │ │ │ ├── match_score_update_handler.cc │ │ │ ├── match_score_update_handler.hh │ │ │ ├── match_skip_request_handler.cc │ │ │ ├── match_skip_request_handler.hh │ │ │ ├── match_start_handler.cc │ │ │ └── match_start_handler.hh │ │ └── room │ │ │ ├── room_beatmap_handler.cc │ │ │ ├── room_beatmap_handler.hh │ │ │ ├── room_change_host_handler.cc │ │ │ ├── room_change_host_handler.hh │ │ │ ├── room_change_mods_handler.cc │ │ │ ├── room_change_mods_handler.hh │ │ │ ├── room_change_password_handler.cc │ │ │ ├── room_change_password_handler.hh │ │ │ ├── room_change_settings_handler.cc │ │ │ ├── room_change_settings_handler.hh │ │ │ ├── room_change_slot_handler.cc │ │ │ ├── room_change_slot_handler.hh │ │ │ ├── room_change_team_handler.cc │ │ │ ├── room_change_team_handler.hh │ │ │ ├── room_create_handler.cc │ │ │ ├── room_create_handler.hh │ │ │ ├── room_join_handler.cc │ │ │ ├── room_join_handler.hh │ │ │ ├── room_leave_handler.cc │ │ │ ├── room_leave_handler.hh │ │ │ ├── room_lock_slot_handler.cc │ │ │ ├── room_lock_slot_handler.hh │ │ │ ├── room_ready_handler.cc │ │ │ └── room_ready_handler.hh │ ├── ping_handler.cc │ ├── ping_handler.hh │ ├── presence │ │ ├── user_presence_request_all_handler.cc │ │ ├── user_presence_request_all_handler.hh │ │ ├── user_presence_request_handler.cc │ │ ├── user_presence_request_handler.hh │ │ ├── user_stats_request_handler.cc │ │ └── user_stats_request_handler.hh │ ├── request_status_update_handler.cc │ ├── request_status_update_handler.hh │ ├── spectating │ │ ├── cant_spectate_handler.cc │ │ ├── cant_spectate_handler.hh │ │ ├── spectator_frames_handler.cc │ │ ├── spectator_frames_handler.hh │ │ ├── start_spectating_handler.cc │ │ ├── start_spectating_handler.hh │ │ ├── stop_spectating_handler.cc │ │ └── stop_spectating_handler.hh │ ├── user_status_handler.cc │ └── user_status_handler.hh ├── io │ ├── layouts │ │ ├── channel │ │ │ ├── channel.cc │ │ │ └── channel.hh │ │ ├── message │ │ │ ├── message.cc │ │ │ └── message.hh │ │ ├── multiplayer │ │ │ ├── multiplayer_join.cc │ │ │ ├── multiplayer_join.hh │ │ │ ├── multiplayer_match.cc │ │ │ └── multiplayer_match.hh │ │ ├── packets.hh │ │ ├── replay │ │ │ ├── replay_frame.cc │ │ │ ├── replay_frame.hh │ │ │ ├── score_frame.cc │ │ │ ├── score_frame.hh │ │ │ ├── spectate_frames.cc │ │ │ └── spectate_frames.hh │ │ ├── serializable.cc │ │ ├── serializable.hh │ │ └── user │ │ │ ├── user_presence.cc │ │ │ ├── user_presence.hh │ │ │ ├── user_quit.cc │ │ │ ├── user_quit.hh │ │ │ ├── user_stats.cc │ │ │ ├── user_stats.hh │ │ │ ├── user_status.cc │ │ │ └── user_status.hh │ ├── osu_buffer.cc │ ├── osu_buffer.hh │ ├── osu_packet.cc │ ├── osu_packet.hh │ ├── osu_reader.cc │ ├── osu_reader.hh │ ├── osu_writer.cc │ ├── osu_writer.hh │ ├── queue.cc │ └── queue.hh ├── logger │ ├── logger.cc │ ├── logger.hh │ ├── route_logger.cc │ ├── route_logger.hh │ ├── sentry_logger.cc │ └── sentry_logger.hh ├── main.cc ├── multiplayer │ ├── lobby_manager.cc │ ├── lobby_manager.hh │ ├── match_manager.cc │ └── match_manager.hh ├── native │ ├── linux │ │ ├── process_info_linux.cc │ │ ├── signal_handler_linux.cc │ │ ├── system_info_linux.cc │ │ └── system_statistics_linux.cc │ ├── mac │ │ ├── process_info_mac.cc │ │ ├── signal_handler_mac.cc │ │ ├── system_info_mac.cc │ │ └── system_statistics_mac.cc │ ├── process_info.hh │ ├── signal_handler.hh │ ├── system_info.hh │ ├── system_statistics.hh │ └── win │ │ ├── process_info_windows.cc │ │ ├── signal_handler_windows.cc │ │ ├── system_info_windows.cc │ │ └── system_statistics_windows.cc ├── permissions │ ├── permissions.hh │ ├── role.cc │ ├── role.hh │ ├── role_manager.cc │ └── role_manager.hh ├── pp │ ├── pp_recalculator.cc │ ├── pp_recalculator.hh │ ├── pp_score_metric.cc │ ├── pp_score_metric.hh │ └── wrapper │ │ ├── oppai_wrapper.cc │ │ └── oppai_wrapper.hh ├── ranking │ ├── ranking_helper.cc │ └── ranking_helper.hh ├── redis │ ├── redis.cc │ └── redis.hh ├── replays │ ├── replay.cc │ ├── replay.hh │ ├── replay_manager.cc │ └── replay_manager.hh ├── routes │ ├── impl │ │ ├── api │ │ │ ├── ci_trigger_route.cc │ │ │ └── ci_trigger_route.hh │ │ ├── direct │ │ │ ├── download_route.cc │ │ │ ├── download_route.hh │ │ │ ├── search_route.cc │ │ │ └── search_route.hh │ │ ├── root_route.cc │ │ ├── root_route.hh │ │ └── web │ │ │ ├── bancho_connect_route.cc │ │ │ ├── bancho_connect_route.hh │ │ │ ├── get_replay_route.cc │ │ │ ├── get_replay_route.hh │ │ │ ├── get_scores_route.cc │ │ │ ├── get_scores_route.hh │ │ │ ├── lastfm_route.cc │ │ │ ├── lastfm_route.hh │ │ │ ├── submit_score_route.cc │ │ │ └── submit_score_route.hh │ ├── packet_router.cc │ ├── packet_router.hh │ ├── routes.cc │ └── routes.hh ├── scores │ ├── score.cc │ ├── score.hh │ ├── score_helper.cc │ ├── score_helper.hh │ ├── table_display.cc │ └── table_display.hh ├── shiro.cc ├── shiro.hh ├── spectating │ ├── spectator_manager.cc │ └── spectator_manager.hh ├── thirdparty │ ├── algorithm │ │ ├── blake.hh │ │ ├── blake2.hh │ │ ├── detail │ │ │ ├── blake2_provider.hh │ │ │ ├── blake_provider.hh │ │ │ ├── constants │ │ │ │ ├── blake2_constants.hh │ │ │ │ ├── blake_constants.hh │ │ │ │ ├── groestl_constants.hh │ │ │ │ ├── jh_constants.hh │ │ │ │ ├── kupyna_constants.hh │ │ │ │ ├── md5_constants.hh │ │ │ │ ├── sha1_constants.hh │ │ │ │ ├── sha2_constants.hh │ │ │ │ ├── sha3_constants.hh │ │ │ │ ├── skein_constants.hh │ │ │ │ ├── streebog_constants.hh │ │ │ │ └── whirlpool_constants.hh │ │ │ ├── groestl_provider.hh │ │ │ ├── jh_provider.hh │ │ │ ├── k12m14_provider.hh │ │ │ ├── kmac_provider.hh │ │ │ ├── kupyna_provider.hh │ │ │ ├── md5_provider.hh │ │ │ ├── sha1_provider.hh │ │ │ ├── sha2_provider.hh │ │ │ ├── sha3_provider.hh │ │ │ ├── shake_provider.hh │ │ │ ├── skein_provider.hh │ │ │ ├── sm3_provider.hh │ │ │ ├── streebog_provider.hh │ │ │ └── whirlpool_provider.hh │ │ ├── groestl.hh │ │ ├── jh.hh │ │ ├── k12m14.hh │ │ ├── kmac.hh │ │ ├── kupyna.hh │ │ ├── md5.hh │ │ ├── mixin │ │ │ ├── blake2_mixin.hh │ │ │ ├── blake_mixin.hh │ │ │ ├── cshake_mixin.hh │ │ │ ├── k12m14_mixin.hh │ │ │ ├── kmac_mixin.hh │ │ │ ├── null_mixin.hh │ │ │ └── skein_mixin.hh │ │ ├── sha1.hh │ │ ├── sha2.hh │ │ ├── sha3.hh │ │ ├── shake.hh │ │ ├── skein.hh │ │ ├── sm3.hh │ │ ├── streebog.hh │ │ └── whirlpool.hh │ ├── cache │ │ ├── cache.hh │ │ ├── cache_policy.hh │ │ ├── fifo_cache_policy.hh │ │ ├── lfu_cache_policy.hh │ │ └── lru_cache_policy.hh │ ├── cli11.hh │ ├── cppcrypto │ │ ├── alignedarray.hh │ │ ├── block_cipher.cc │ │ ├── block_cipher.hh │ │ ├── cbc.cc │ │ ├── cbc.hh │ │ ├── cpuinfo.cc │ │ ├── cpuinfo.hh │ │ ├── portability.hh │ │ ├── rijndael-impl.hh │ │ ├── rijndael.cc │ │ └── rijndael.hh │ ├── cpptoml.hh │ ├── crow.hh │ ├── detail │ │ ├── absorb_data.hh │ │ ├── functions.hh │ │ ├── stream_width_fixer.hh │ │ ├── traits.hh │ │ └── validate_hash_size.hh │ ├── digestpp.hh │ ├── enum.hh │ ├── enum_macros.hh │ ├── hasher.hh │ ├── json.hh │ ├── loguru.cc │ ├── loguru.hh │ ├── multipartparser.cc │ ├── multipartparser.hh │ ├── oppai.hh │ ├── sentry │ │ ├── crow.cc │ │ ├── crow.hh │ │ ├── crow_config.hh │ │ ├── crow_utilities.cc │ │ ├── crow_utilities.hh │ │ └── curl_wrapper.hh │ ├── taskscheduler.cc │ ├── taskscheduler.hh │ └── uuid.hh ├── users │ ├── user.cc │ ├── user.hh │ ├── user_activity.cc │ ├── user_activity.hh │ ├── user_manager.cc │ ├── user_manager.hh │ ├── user_punishments.cc │ ├── user_punishments.hh │ ├── user_timeout.cc │ └── user_timeout.hh ├── utils │ ├── bot_utils.cc │ ├── bot_utils.hh │ ├── client_side_flags.hh │ ├── crypto.cc │ ├── crypto.hh │ ├── curler.cc │ ├── curler.hh │ ├── escaper.cc │ ├── escaper.hh │ ├── filesystem.hh │ ├── leb128.cc │ ├── leb128.hh │ ├── login_responses.hh │ ├── match_team_type.hh │ ├── mods.hh │ ├── multipart_parser.cc │ ├── multipart_parser.hh │ ├── osu_client.cc │ ├── osu_client.hh │ ├── osu_permissions.hh │ ├── osu_string.cc │ ├── osu_string.hh │ ├── play_mode.cc │ ├── play_mode.hh │ ├── punishment_type.hh │ ├── slot_status.hh │ ├── string_utils.cc │ ├── string_utils.hh │ ├── time_utils.cc │ ├── time_utils.hh │ └── vector_utils.hh └── views │ ├── index_page.hh │ ├── index_view.cc │ └── index_view.hh └── windows_setup_build.bat /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | jobs: 3 | build: 4 | working_directory: ~/shiro 5 | docker: 6 | - image: marc3842h/shiro:ci 7 | branches: 8 | only: 9 | - staging 10 | - trying 11 | - master 12 | steps: 13 | - checkout 14 | - run: 15 | name: Generate CMake file 16 | command: | 17 | cmake . 18 | - run: 19 | name: Build 20 | command: | 21 | make -j2 22 | - store_artifacts: 23 | path: ~/shiro/bin/shiro 24 | destination: shiro 25 | - deploy: 26 | name: Deploy to development server 27 | command: | 28 | if [ "${CIRCLE_BRANCH}" == "master" ]; then 29 | curl -X POST \ 30 | -H "User-Agent: CircleCI $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME" \ 31 | -F "token=$SHIRO_DEPLOY_TOKEN" \ 32 | -F "commit=$CIRCLE_SHA1" \ 33 | -F "file=@$HOME/shiro/bin/shiro" \ 34 | https://example.com/api/ci_trigger 35 | fi 36 | -------------------------------------------------------------------------------- /.githooks/license-maintainer/cpp/LICENSE.AGPL3: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | -------------------------------------------------------------------------------- /.idea/codeStyles/codeStyleConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /.idea/discord.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.idea/markdown-exported-files.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 12 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/shiro.iml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /bors.toml: -------------------------------------------------------------------------------- 1 | # Bors configuration file for Shiro 2 | timeout_sec = 900 3 | delete_merged_branches = true 4 | status = [ "ci/circleci" ] 5 | block_labels = [ 6 | "status: blocked", 7 | "status: do not merge" 8 | ] 9 | -------------------------------------------------------------------------------- /cmake/FindTcmalloc.cmake: -------------------------------------------------------------------------------- 1 | # - Find Tcmalloc 2 | # Find the native Tcmalloc library 3 | # 4 | # Tcmalloc_LIBRARIES - List of libraries when using Tcmalloc. 5 | # Tcmalloc_FOUND - True if Tcmalloc found. 6 | 7 | if (USE_TCMALLOC) 8 | set(Tcmalloc_NAMES tcmalloc) 9 | else () 10 | set(Tcmalloc_NAMES tcmalloc_minimal tcmalloc) 11 | endif () 12 | 13 | find_library(Tcmalloc_LIBRARY NO_DEFAULT_PATH 14 | NAMES ${Tcmalloc_NAMES} 15 | PATHS ${HT_DEPENDENCY_LIB_DIR} /lib /usr/lib /usr/local/lib /opt/local/lib 16 | ) 17 | 18 | if (Tcmalloc_LIBRARY) 19 | set(Tcmalloc_FOUND TRUE) 20 | set( Tcmalloc_LIBRARIES ${Tcmalloc_LIBRARY} ) 21 | else () 22 | set(Tcmalloc_FOUND FALSE) 23 | set( Tcmalloc_LIBRARIES ) 24 | endif () 25 | 26 | if (Tcmalloc_FOUND) 27 | message(STATUS "Found Tcmalloc: ${Tcmalloc_LIBRARY}") 28 | else () 29 | message(STATUS "Not Found Tcmalloc: ${Tcmalloc_LIBRARY}") 30 | if (Tcmalloc_FIND_REQUIRED) 31 | message(STATUS "Looked for Tcmalloc libraries named ${Tcmalloc_NAMES}.") 32 | message(FATAL_ERROR "Could NOT find Tcmalloc library") 33 | endif () 34 | endif () 35 | 36 | mark_as_advanced( 37 | Tcmalloc_LIBRARY 38 | ) 39 | -------------------------------------------------------------------------------- /docker/prod/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:rolling 2 | 3 | 4 | -------------------------------------------------------------------------------- /external/generate_ssl_certificate.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Asks for server name 4 | read -p "What's the name of your server? \n" server_name 5 | # Checks if input is blank, if so, set server name to "Shiro" 6 | server_name=${server_name=Shiro} 7 | 8 | # Asks for country code 9 | read -p "What is the country code of the country are you based in? (i.e DE = Germany) \n" country_name 10 | # Again, checks if input is blank, if not, sets the country code to GB. 11 | country_name=${country_name=GB} 12 | 13 | # Creates the necessary args needed 14 | args="/CN=*.ppy.sh/O=$server_name/C=$country_name" 15 | # Creates the SSL certificate using the args we created 16 | openssl req -subj $args -new -newkey rsa:4096 -sha256 -days 36500 -nodes -x509 -keyout key.pem -out cert.pem 17 | # Convert it to .crt 18 | openssl x509 -outform der -in cert.pem -out cert.crt 19 | printf "Your SSL Certificates have been generated, it's a good idea to move them to a seperate directory now." 20 | -------------------------------------------------------------------------------- /external/sqlpp11.patch: -------------------------------------------------------------------------------- 1 | From e8b96e6be49ab36c39503cdfffe5d3a5127e7db6 Mon Sep 17 00:00:00 2001 2 | From: F1ssi0N 3 | Date: Mon, 8 Oct 2018 21:55:12 +0100 4 | Subject: [PATCH] Fix compilation errors 5 | 6 | --- 7 | include/sqlpp11/char_sequence.h | 8 ++++---- 8 | 1 file changed, 4 insertions(+), 4 deletions(-) 9 | 10 | diff --git a/include/sqlpp11/char_sequence.h b/include/sqlpp11/char_sequence.h 11 | index 57595258..1470bff2 100644 12 | --- a/include/sqlpp11/char_sequence.h 13 | +++ b/include/sqlpp11/char_sequence.h 14 | @@ -54,18 +54,18 @@ namespace sqlpp 15 | } 16 | }; 17 | 18 | - template 19 | + template 20 | struct make_char_sequence_impl; 21 | 22 | - template 23 | + template 24 | struct make_char_sequence_impl> 25 | { 26 | using type = char_sequence; 27 | }; 28 | 29 | - template 30 | + template 31 | using make_char_sequence = 32 | - typename make_char_sequence_impl>::type; 33 | + typename make_char_sequence_impl>::type; 34 | } // namespace sqlpp 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /resources/api.toml: -------------------------------------------------------------------------------- 1 | # API configuration file for shiro 2 | 3 | [deploy] 4 | enabled = false 5 | token = "" 6 | command = "systemctl restart shiro" 7 | -------------------------------------------------------------------------------- /resources/bancho.toml: -------------------------------------------------------------------------------- 1 | # Bancho configuration file for Shiro 2 | 3 | [server] 4 | host = "127.0.0.1" 5 | port = 8080 6 | # Amount of concurrent connections the server accepts. 7 | # Set this higher if you have more players, however also results in more RAM being used. 8 | concurrency = 64 9 | 10 | [permissions] 11 | # Allow users with no roles / permissions to have supporer in-game? 12 | default_supporter = true 13 | 14 | [api] 15 | key = "osu!Bancho token" 16 | 17 | [motd] 18 | alert = "Welcome to Shiro" 19 | # The image needs to be on the host "i.ppy.sh" 20 | title_image = "https://i.ppy.sh/motd.png" 21 | title_url = "https://shiro.host" 22 | 23 | [integrations] 24 | sentry = true 25 | -------------------------------------------------------------------------------- /resources/bot.toml: -------------------------------------------------------------------------------- 1 | # Bot configuration file for shiro 2 | 3 | [bot] 4 | name = "Shiro" 5 | -------------------------------------------------------------------------------- /resources/database.toml: -------------------------------------------------------------------------------- 1 | # Database configuration file for shiro 2 | 3 | [database] 4 | address = "127.0.0.1" 5 | port = 3306 6 | database = "shiro" 7 | username = "root" 8 | password = "hunter2" 9 | 10 | [redis] 11 | address = "127.0.0.1" 12 | port = 6379 13 | password = "" 14 | -------------------------------------------------------------------------------- /resources/direct.toml: -------------------------------------------------------------------------------- 1 | # Direct configuration file for Shiro 2 | 3 | [direct] 4 | # Should direct be enabled? 5 | # Players still need the direct permission in order to use it 6 | enabled = true 7 | # Which provider implementation should Shiro use? 8 | # provider 0 = Contact local Shirogane over a Shared Memory Region 9 | # provider 1 = Emulate a client request to direct via another Bancho server 10 | # provider 2 = Use the Beatconnect API (recommended) 11 | provider = 1 12 | 13 | # This section is only active if provider is set to 0 14 | [shirogane] 15 | shm = 195934910 16 | 17 | # This section is only active if provider is set to 1 18 | [emulate] 19 | base_url = "https://shiro.host" 20 | mirror_url = "https://mirror.shiro.host" 21 | 22 | # This section is only active if provider is set to 2 23 | [beatconnect] 24 | api_key = "Beatconnect API key" 25 | -------------------------------------------------------------------------------- /resources/geolite2_city.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mellowagain/shiro/9bf68f77e55febf358dbfe48fea038029397c91f/resources/geolite2_city.mmdb -------------------------------------------------------------------------------- /resources/ipc.toml: -------------------------------------------------------------------------------- 1 | # Interprocess Communication configuration file for Shiro 2 | 3 | [meta] 4 | # Urls defined here need to have a trailing slash (/) at the end. 5 | backend_url = "https://c.shiro.host/" 6 | frontend_url = "https://shiro.host/" 7 | # The url defined below should take you directly to the beatmap page if the beatmap id or the 8 | # beatmap set id is appended right after it's trailing slash (/) at the end. 9 | beatmap_url = "https://osu.ppy.sh/b/" 10 | -------------------------------------------------------------------------------- /src/beatmaps/beatmap_helper.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_BEATMAP_HELPER_HH 20 | #define SHIRO_BEATMAP_HELPER_HH 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #include "beatmap_ranked_status.hh" 27 | 28 | namespace shiro::beatmaps::helper { 29 | 30 | void init(); 31 | 32 | int32_t fix_beatmap_status(int32_t status_code); 33 | 34 | bool has_leaderboard(int32_t status_code); 35 | 36 | bool awards_pp(int32_t status_code); 37 | 38 | std::optional get_location(int32_t beatmap_id, bool download = true); 39 | 40 | } 41 | 42 | #endif //SHIRO_BEATMAP_HELPER_HH 43 | -------------------------------------------------------------------------------- /src/beatmaps/beatmap_ranked_status.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_BEATMAP_RANKED_STATUS_HH 20 | #define SHIRO_BEATMAP_RANKED_STATUS_HH 21 | 22 | #include 23 | 24 | namespace shiro::beatmaps { 25 | 26 | enum class status : int32_t { 27 | unknown = -2, 28 | unsubmitted = -1, 29 | latest_pending = 0, 30 | needs_update = 1, 31 | ranked = 2, 32 | approved = 3, 33 | qualified = 4, 34 | loved = 5 35 | 36 | }; 37 | 38 | } 39 | 40 | #endif // SHIRO_BEATMAP_RANKED_STATUS_HH 41 | -------------------------------------------------------------------------------- /src/bot/bot.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_BOT_HH 20 | #define SHIRO_BOT_HH 21 | 22 | #include 23 | #include 24 | 25 | #include "../users/user.hh" 26 | 27 | namespace shiro::bot { 28 | 29 | extern std::shared_ptr bot_user; 30 | 31 | void init(); 32 | 33 | void init_commands(); 34 | 35 | bool handle(const std::string &command, std::deque &args, std::shared_ptr user, std::string channel); 36 | 37 | } 38 | 39 | #endif //SHIRO_BOT_HH 40 | -------------------------------------------------------------------------------- /src/channels/console_osu_bridge.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_CONSOLE_OSU_BRIDGE_HH 20 | #define SHIRO_CONSOLE_OSU_BRIDGE_HH 21 | 22 | #include "../thirdparty/loguru.hh" 23 | 24 | namespace shiro::channels::bridge { 25 | 26 | void install(); 27 | 28 | void callback(void *user_data, const loguru::Message &message); 29 | 30 | uint8_t get_permission(loguru::Verbosity verbosity); 31 | 32 | } 33 | 34 | #endif //SHIRO_CONSOLE_OSU_BRIDGE_HH 35 | -------------------------------------------------------------------------------- /src/commands/public/help_command.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_HELP_COMMAND_HH 20 | #define SHIRO_HELP_COMMAND_HH 21 | 22 | #include 23 | #include 24 | 25 | #include "../../users/user.hh" 26 | 27 | namespace shiro::commands { 28 | 29 | bool help(std::deque &args, std::shared_ptr user, std::string channel); 30 | 31 | } 32 | 33 | #endif //SHIRO_HELP_COMMAND_HH 34 | -------------------------------------------------------------------------------- /src/commands/public/localclear_command.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include "../../users/user_manager.hh" 20 | #include "../../utils/bot_utils.hh" 21 | #include "localclear_command.hh" 22 | 23 | bool shiro::commands::localclear(std::deque &args, std::shared_ptr user, std::string channel) { 24 | io::osu_writer writer; 25 | 26 | users::manager::iterate([&writer](std::shared_ptr online_user) { 27 | writer.user_silenced(online_user->user_id); 28 | }); 29 | 30 | user->queue.enqueue(writer); 31 | 32 | utils::bot::respond("You have cleared your local chat.", std::move(user), std::move(channel), true); 33 | return true; 34 | } 35 | -------------------------------------------------------------------------------- /src/commands/public/localclear_command.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_LOCALCLEAR_COMMAND_HH 20 | #define SHIRO_LOCALCLEAR_COMMAND_HH 21 | 22 | #include 23 | #include 24 | 25 | #include "../../users/user.hh" 26 | 27 | namespace shiro::commands { 28 | 29 | bool localclear(std::deque &args, std::shared_ptr user, std::string channel); 30 | 31 | } 32 | 33 | #endif //SHIRO_LOCALCLEAR_COMMAND_HH 34 | -------------------------------------------------------------------------------- /src/commands/public/roll_command.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_ROLL_COMMAND_HH 20 | #define SHIRO_ROLL_COMMAND_HH 21 | 22 | #include 23 | #include 24 | 25 | #include "../../users/user.hh" 26 | 27 | namespace shiro::commands { 28 | 29 | bool roll(std::deque &args, std::shared_ptr user, std::string channel); 30 | 31 | } 32 | 33 | 34 | #endif //SHIRO_ROLL_COMMAND_HH 35 | -------------------------------------------------------------------------------- /src/commands/staff/announce_command.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_ANNOUNCE_COMMAND_HH 20 | #define SHIRO_ANNOUNCE_COMMAND_HH 21 | 22 | #include 23 | #include 24 | 25 | #include "../../users/user.hh" 26 | 27 | namespace shiro::commands { 28 | 29 | bool announce(std::deque &args, std::shared_ptr user, std::string channel); 30 | 31 | } 32 | 33 | #endif //SHIRO_ANNOUNCE_COMMAND_HH 34 | -------------------------------------------------------------------------------- /src/commands/staff/ban_command.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_BAN_COMMAND_HH 20 | #define SHIRO_BAN_COMMAND_HH 21 | 22 | #include 23 | #include 24 | 25 | #include "../../users/user.hh" 26 | 27 | namespace shiro::commands { 28 | 29 | bool ban(std::deque &args, std::shared_ptr user, std::string channel); 30 | 31 | } 32 | 33 | #endif //SHIRO_BAN_COMMAND_HH 34 | -------------------------------------------------------------------------------- /src/commands/staff/clear_command.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_CLEAR_COMMAND_HH 20 | #define SHIRO_CLEAR_COMMAND_HH 21 | 22 | #include 23 | #include 24 | 25 | #include "../../users/user.hh" 26 | 27 | namespace shiro::commands { 28 | 29 | bool clear(std::deque &args, std::shared_ptr user, std::string channel); 30 | 31 | } 32 | 33 | #endif //SHIRO_CLEAR_COMMAND_HH 34 | -------------------------------------------------------------------------------- /src/commands/staff/clients_command.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_CLIENTS_COMMAND_HH 20 | #define SHIRO_CLIENTS_COMMAND_HH 21 | 22 | #include 23 | #include 24 | 25 | #include "../../users/user.hh" 26 | 27 | namespace shiro::commands { 28 | 29 | bool clients(std::deque &args, std::shared_ptr user, std::string channel); 30 | 31 | } 32 | 33 | #endif //SHIRO_CLIENTS_COMMAND_HH 34 | -------------------------------------------------------------------------------- /src/commands/staff/kick_command.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_KICK_COMMAND_HH 20 | #define SHIRO_KICK_COMMAND_HH 21 | 22 | #include 23 | #include 24 | 25 | #include "../../users/user.hh" 26 | 27 | namespace shiro::commands { 28 | 29 | bool kick(std::deque &args, std::shared_ptr user, std::string channel); 30 | 31 | } 32 | 33 | #endif //SHIRO_KICK_COMMAND_HH 34 | -------------------------------------------------------------------------------- /src/commands/staff/recalculate_ranks.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_RECALCULATE_RANKS_HH 20 | #define SHIRO_RECALCULATE_RANKS_HH 21 | 22 | #include 23 | #include 24 | 25 | #include "../../users/user.hh" 26 | 27 | namespace shiro::commands { 28 | 29 | bool recalculate(std::deque &args, std::shared_ptr user, std::string channel); 30 | 31 | } 32 | 33 | #endif //SHIRO_RECALCULATE_RANKS_HH 34 | -------------------------------------------------------------------------------- /src/commands/staff/restart_command.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_RESTART_COMMAND_HH 20 | #define SHIRO_RESTART_COMMAND_HH 21 | 22 | #include 23 | #include 24 | 25 | #include "../../users/user.hh" 26 | 27 | namespace shiro::commands { 28 | 29 | bool restart(std::deque &args, std::shared_ptr user, std::string channel); 30 | 31 | } 32 | 33 | #endif //SHIRO_RESTART_COMMAND_HH 34 | -------------------------------------------------------------------------------- /src/commands/staff/restrict_command.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_RESTRICT_COMMAND_HH 20 | #define SHIRO_RESTRICT_COMMAND_HH 21 | 22 | #include 23 | #include 24 | 25 | #include "../../users/user.hh" 26 | 27 | namespace shiro::commands { 28 | 29 | bool restrict(std::deque &args, std::shared_ptr user, std::string channel); 30 | 31 | } 32 | 33 | #endif //SHIRO_RESTRICT_COMMAND_HH 34 | -------------------------------------------------------------------------------- /src/commands/staff/rtx_command.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_RTX_COMMAND_HH 20 | #define SHIRO_RTX_COMMAND_HH 21 | 22 | #include 23 | #include 24 | 25 | #include "../../users/user.hh" 26 | 27 | namespace shiro::commands { 28 | 29 | bool rtx(std::deque &args, std::shared_ptr user, std::string channel); 30 | 31 | } 32 | 33 | #endif //SHIRO_RTX_COMMAND_HH 34 | -------------------------------------------------------------------------------- /src/commands/staff/silence_command.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_SILENCE_COMMAND_HH 20 | #define SHIRO_SILENCE_COMMAND_HH 21 | 22 | #include 23 | #include 24 | 25 | #include "../../users/user.hh" 26 | 27 | namespace shiro::commands { 28 | 29 | bool silence(std::deque &args, std::shared_ptr user, std::string channel); 30 | 31 | } 32 | 33 | #endif //SHIRO_SILENCE_COMMAND_HH 34 | -------------------------------------------------------------------------------- /src/config/api_file.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_API_FILE_HH 20 | #define SHIRO_API_FILE_HH 21 | 22 | #include 23 | #include 24 | 25 | namespace shiro::config::api { 26 | 27 | extern bool deploy_enabled; 28 | extern std::string deploy_key; 29 | extern std::string deploy_command; 30 | 31 | void parse(); 32 | 33 | } 34 | 35 | #endif //SHIRO_API_FILE_HH 36 | -------------------------------------------------------------------------------- /src/config/bancho_file.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_BANCHO_FILE_HH 20 | #define SHIRO_BANCHO_FILE_HH 21 | 22 | #include 23 | 24 | namespace shiro::config::bancho { 25 | 26 | extern std::string host; 27 | extern uint16_t port; 28 | extern uint16_t concurrency; 29 | 30 | extern bool default_supporter; 31 | 32 | extern std::string api_key; 33 | 34 | extern std::string alert; 35 | extern std::string title_image; 36 | extern std::string title_url; 37 | 38 | extern bool sentry_integration; 39 | 40 | void parse(); 41 | 42 | } 43 | 44 | #endif //SHIRO_BANCHO_FILE_HH 45 | -------------------------------------------------------------------------------- /src/config/bot_file.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_BOT_FILE_HH 20 | #define SHIRO_BOT_FILE_HH 21 | 22 | #include 23 | 24 | namespace shiro::config::bot { 25 | 26 | extern std::string name; 27 | 28 | void parse(); 29 | 30 | } 31 | 32 | #endif //SHIRO_BOT_FILE_HH 33 | -------------------------------------------------------------------------------- /src/config/cli_args.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include "../thirdparty/loguru.hh" 20 | #include "cli_args.hh" 21 | 22 | static int args_count = 0; 23 | static char **args_vector {}; 24 | 25 | CLI::App shiro::config::cli::cli_app = CLI::App("C++ osu!Bancho re-implementation", "shiro"); 26 | 27 | void shiro::config::cli::parse(int argc, char **argv) { 28 | args_count = argc; 29 | args_vector = argv; 30 | 31 | try { 32 | cli_app.parse(argc, argv); 33 | } catch (const CLI::ParseError &ex) { 34 | ABORT_F("Unable to parse command line arguments: %s.", ex.what()); 35 | } 36 | } 37 | 38 | std::tuple shiro::config::cli::get_args() { 39 | return std::make_tuple(args_count, args_vector); 40 | } 41 | -------------------------------------------------------------------------------- /src/config/cli_args.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_CLI_ARGS_HH 20 | #define SHIRO_CLI_ARGS_HH 21 | 22 | #include 23 | 24 | #include "../thirdparty/cli11.hh" 25 | 26 | namespace shiro::config::cli { 27 | 28 | extern CLI::App cli_app; 29 | 30 | void parse(int argc, char **argv); 31 | 32 | std::tuple get_args(); 33 | 34 | } 35 | 36 | #endif //SHIRO_CLI_ARGS_HH 37 | -------------------------------------------------------------------------------- /src/config/db_file.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_DB_FILE_HH 20 | #define SHIRO_DB_FILE_HH 21 | 22 | #include 23 | 24 | namespace shiro::config::database { 25 | 26 | extern std::string address; 27 | extern uint32_t port; 28 | extern std::string database; 29 | extern std::string username; 30 | extern std::string password; 31 | 32 | extern std::string redis_address; 33 | extern uint32_t redis_port; 34 | extern std::string redis_password; 35 | 36 | void parse(); 37 | 38 | } 39 | 40 | #endif //SHIRO_DB_FILE_HH 41 | -------------------------------------------------------------------------------- /src/config/direct_file.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_DIRECT_FILE_HH 20 | #define SHIRO_DIRECT_FILE_HH 21 | 22 | #include 23 | #include 24 | 25 | namespace shiro::config::direct { 26 | 27 | extern bool enabled; 28 | extern int32_t provider; 29 | 30 | // Provider 0: Shirogane 31 | extern uint64_t shm; 32 | 33 | // Provider 1: Emulation 34 | extern std::string base_url; 35 | extern std::string mirror_url; 36 | 37 | // Provider 2: Beatconnect 38 | extern std::string api_key; 39 | 40 | void parse(); 41 | 42 | } 43 | 44 | #endif //SHIRO_DIRECT_FILE_HH 45 | -------------------------------------------------------------------------------- /src/config/ipc_file.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_IPC_FILE_HH 20 | #define SHIRO_IPC_FILE_HH 21 | 22 | #include 23 | 24 | namespace shiro::config::ipc { 25 | 26 | extern std::string backend_url; 27 | extern std::string frontend_url; 28 | extern std::string beatmap_url; 29 | 30 | void parse(); 31 | 32 | } 33 | 34 | #endif //SHIRO_IPC_FILE_HH 35 | -------------------------------------------------------------------------------- /src/direct/providers/emulation.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_EMULATION_HH 20 | #define SHIRO_EMULATION_HH 21 | 22 | #include "../direct_provider.hh" 23 | 24 | namespace shiro::direct { 25 | 26 | class emulation : public direct_provider { 27 | public: 28 | std::tuple search(std::unordered_map parameters) override; 29 | std::tuple download(int32_t beatmap_id, bool no_video) override; 30 | 31 | const std::string name() const override; 32 | 33 | }; 34 | 35 | } 36 | 37 | #endif //SHIRO_EMULATION_HH 38 | -------------------------------------------------------------------------------- /src/geoloc/country_ids.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_COUNTRY_IDS_HH 20 | #define SHIRO_COUNTRY_IDS_HH 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #include "../thirdparty/enum.hh" 27 | 28 | namespace shiro::geoloc { 29 | 30 | extern std::unordered_map country_ids; 31 | 32 | uint8_t get_country_id(const std::string &country_code); 33 | std::string get_country_name(uint8_t country_id); 34 | 35 | } 36 | 37 | #endif //SHIRO_COUNTRY_IDS_HH 38 | -------------------------------------------------------------------------------- /src/geoloc/geoloc.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_GEOLOC_HH 20 | #define SHIRO_GEOLOC_HH 21 | 22 | #include 23 | #include 24 | 25 | #include "location_info.hh" 26 | 27 | namespace shiro::geoloc { 28 | 29 | extern std::string localhost_ip; 30 | 31 | void init(); 32 | 33 | std::optional get_location(std::string ip_address); 34 | 35 | } 36 | 37 | #endif //SHIRO_GEOLOC_HH 38 | -------------------------------------------------------------------------------- /src/geoloc/location_info.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_LOCATION_INFO_HH 20 | #define SHIRO_LOCATION_INFO_HH 21 | 22 | #include 23 | #include 24 | 25 | #include "country_ids.hh" 26 | 27 | namespace shiro::geoloc { 28 | 29 | class location_info { 30 | public: 31 | uint8_t country = 0; 32 | float latitude = 0.0f; 33 | float longitude = 0.0f; 34 | 35 | explicit location_info(uint8_t country, float latitude, float longitude) 36 | : country(country) 37 | , latitude(latitude) 38 | , longitude(longitude) { 39 | // Initializer in initializer list 40 | } 41 | 42 | }; 43 | 44 | } 45 | 46 | #endif // SHIRO_LOCATION_INFO_HH 47 | -------------------------------------------------------------------------------- /src/geoloc/maxmind_resolver.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_MAXMIND_RESOLVER_HH 20 | #define SHIRO_MAXMIND_RESOLVER_HH 21 | 22 | #include 23 | #include 24 | 25 | namespace shiro::geoloc::maxmind { 26 | 27 | void init(); 28 | 29 | void destroy(); 30 | 31 | std::tuple locate(const std::string &ip_address); 32 | 33 | } 34 | 35 | #endif //SHIRO_MAXMIND_RESOLVER_HH 36 | -------------------------------------------------------------------------------- /src/handlers/chat/join_channel_handler.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_JOIN_CHANNEL_HANDLER_HH 20 | #define SHIRO_JOIN_CHANNEL_HANDLER_HH 21 | 22 | #include "../../io/osu_packet.hh" 23 | #include "../../io/osu_writer.hh" 24 | #include "../../users/user.hh" 25 | 26 | namespace shiro::handler::chat::join { 27 | 28 | void handle(io::osu_packet &in, io::osu_writer &out, std::shared_ptr user); 29 | 30 | } 31 | 32 | #endif //SHIRO_JOIN_CHANNEL_HANDLER_HH 33 | -------------------------------------------------------------------------------- /src/handlers/chat/leave_channel_handler.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_LEAVE_CHANNEL_HANDLER_HH 20 | #define SHIRO_LEAVE_CHANNEL_HANDLER_HH 21 | 22 | #include "../../io/osu_packet.hh" 23 | #include "../../io/osu_writer.hh" 24 | #include "../../users/user.hh" 25 | 26 | namespace shiro::handler::chat::leave { 27 | 28 | void handle(io::osu_packet &in, io::osu_writer &out, std::shared_ptr user); 29 | 30 | } 31 | 32 | #endif //SHIRO_LEAVE_CHANNEL_HANDLER_HH 33 | -------------------------------------------------------------------------------- /src/handlers/chat/private_chat_handler.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_PRIVATE_CHAT_HANDLER_HH 20 | #define SHIRO_PRIVATE_CHAT_HANDLER_HH 21 | 22 | #include "../../io/osu_packet.hh" 23 | #include "../../io/osu_writer.hh" 24 | #include "../../users/user.hh" 25 | 26 | namespace shiro::handler::chat { 27 | 28 | void handle_private(io::osu_packet &in, io::osu_writer &out, std::shared_ptr user); 29 | 30 | } 31 | 32 | #endif //SHIRO_PRIVATE_CHAT_HANDLER_HH 33 | -------------------------------------------------------------------------------- /src/handlers/chat/public_chat_handler.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_PUBLIC_CHAT_HANDLER_HH 20 | #define SHIRO_PUBLIC_CHAT_HANDLER_HH 21 | 22 | #include "../../io/osu_packet.hh" 23 | #include "../../io/osu_writer.hh" 24 | #include "../../users/user.hh" 25 | 26 | namespace shiro::handler::chat { 27 | 28 | void handle_public(io::osu_packet &in, io::osu_writer &out, std::shared_ptr user); 29 | 30 | } 31 | 32 | #endif //SHIRO_PUBLIC_CHAT_HANDLER_HH 33 | -------------------------------------------------------------------------------- /src/handlers/friends/friend_add_handler.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_FRIEND_ADD_HANDLER_HH 20 | #define SHIRO_FRIEND_ADD_HANDLER_HH 21 | 22 | #include "../../io/osu_packet.hh" 23 | #include "../../io/osu_writer.hh" 24 | #include "../../users/user.hh" 25 | 26 | namespace shiro::handler::friends::add { 27 | 28 | void handle(io::osu_packet &in, io::osu_writer &out, std::shared_ptr user); 29 | 30 | } 31 | 32 | #endif //SHIRO_FRIEND_ADD_HANDLER_HH 33 | -------------------------------------------------------------------------------- /src/handlers/friends/friend_remove_handler.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_FRIEND_REMOVE_HANDLER_HH 20 | #define SHIRO_FRIEND_REMOVE_HANDLER_HH 21 | 22 | #include "../../io/osu_packet.hh" 23 | #include "../../io/osu_writer.hh" 24 | #include "../../users/user.hh" 25 | 26 | namespace shiro::handler::friends::remove { 27 | 28 | void handle(io::osu_packet &in, io::osu_writer &out, std::shared_ptr user); 29 | 30 | } 31 | 32 | #endif //SHIRO_FRIEND_REMOVE_HANDLER_HH 33 | -------------------------------------------------------------------------------- /src/handlers/invite_handler.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_INVITE_HANDLER_HH 20 | #define SHIRO_INVITE_HANDLER_HH 21 | 22 | #include "../io/osu_packet.hh" 23 | #include "../io/osu_writer.hh" 24 | #include "../users/user.hh" 25 | 26 | namespace shiro::handler::invite { 27 | 28 | void handle(io::osu_packet &in, io::osu_writer &out, std::shared_ptr user); 29 | 30 | } 31 | 32 | #endif //SHIRO_INVITE_HANDLER_HH 33 | -------------------------------------------------------------------------------- /src/handlers/login_handler.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_LOGIN_HANDLER_HH 20 | #define SHIRO_LOGIN_HANDLER_HH 21 | 22 | #include "../thirdparty/crow.hh" 23 | 24 | namespace shiro::handler::login { 25 | 26 | void handle(const crow::request &request, crow::response &response); 27 | 28 | } 29 | 30 | #endif //SHIRO_LOGIN_HANDLER_HH 31 | -------------------------------------------------------------------------------- /src/handlers/logout_handler.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_LOGOUT_HANDLER_HH 20 | #define SHIRO_LOGOUT_HANDLER_HH 21 | 22 | #include "../io/osu_packet.hh" 23 | #include "../io/osu_writer.hh" 24 | #include "../users/user.hh" 25 | 26 | namespace shiro::handler::logout { 27 | 28 | void handle(io::osu_packet &in, io::osu_writer &out, std::shared_ptr user); 29 | 30 | } 31 | 32 | #endif //SHIRO_LOGOUT_HANDLER_HH 33 | -------------------------------------------------------------------------------- /src/handlers/multiplayer/lobby/lobby_join_handler.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include "../../../multiplayer/lobby_manager.hh" 20 | #include "../../../multiplayer/match_manager.hh" 21 | #include "lobby_join_handler.hh" 22 | 23 | void shiro::handler::multiplayer::lobby::join::handle(shiro::io::osu_packet &in, shiro::io::osu_writer &out, std::shared_ptr user) { 24 | if (shiro::multiplayer::lobby_manager::in_lobby(user)) 25 | return; 26 | 27 | shiro::multiplayer::lobby_manager::add_user(user); 28 | 29 | shiro::multiplayer::match_manager::iterate([&out, user](io::layouts::multiplayer_match &match) -> bool { 30 | out.match_new(match, match.host_id != user->user_id); 31 | return false; 32 | }); 33 | } 34 | -------------------------------------------------------------------------------- /src/handlers/multiplayer/lobby/lobby_join_handler.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_LOBBY_JOIN_HANDLER_HH 20 | #define SHIRO_LOBBY_JOIN_HANDLER_HH 21 | 22 | #include "../../../io/osu_packet.hh" 23 | #include "../../../io/osu_writer.hh" 24 | #include "../../../users/user.hh" 25 | 26 | namespace shiro::handler::multiplayer::lobby::join { 27 | 28 | void handle(io::osu_packet &in, io::osu_writer &out, std::shared_ptr user); 29 | 30 | } 31 | 32 | #endif //SHIRO_LOBBY_JOIN_HANDLER_HH 33 | -------------------------------------------------------------------------------- /src/handlers/multiplayer/lobby/lobby_leave_handler.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include "../../../multiplayer/lobby_manager.hh" 20 | #include "lobby_leave_handler.hh" 21 | 22 | void shiro::handler::multiplayer::lobby::leave::handle(shiro::io::osu_packet &in, shiro::io::osu_writer &out, std::shared_ptr user) { 23 | if (!shiro::multiplayer::lobby_manager::in_lobby(user)) 24 | return; 25 | 26 | shiro::multiplayer::lobby_manager::remove_user(user); 27 | } 28 | -------------------------------------------------------------------------------- /src/handlers/multiplayer/lobby/lobby_leave_handler.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_LOBBY_LEAVE_HANDLER_HH 20 | #define SHIRO_LOBBY_LEAVE_HANDLER_HH 21 | 22 | #include "../../../io/osu_packet.hh" 23 | #include "../../../io/osu_writer.hh" 24 | #include "../../../users/user.hh" 25 | 26 | namespace shiro::handler::multiplayer::lobby::leave { 27 | 28 | void handle(io::osu_packet &in, io::osu_writer &out, std::shared_ptr user); 29 | 30 | } 31 | 32 | #endif //SHIRO_LOBBY_LEAVE_HANDLER_HH 33 | -------------------------------------------------------------------------------- /src/handlers/multiplayer/match/match_complete_handler.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_MATCH_COMPLETE_HANDLER_HH 20 | #define SHIRO_MATCH_COMPLETE_HANDLER_HH 21 | 22 | #include "../../../io/osu_packet.hh" 23 | #include "../../../io/osu_writer.hh" 24 | #include "../../../users/user.hh" 25 | 26 | namespace shiro::handler::multiplayer::match::complete { 27 | 28 | void handle(io::osu_packet &in, io::osu_writer &out, std::shared_ptr user); 29 | 30 | } 31 | 32 | #endif //SHIRO_MATCH_COMPLETE_HANDLER_HH 33 | -------------------------------------------------------------------------------- /src/handlers/multiplayer/match/match_load_handler.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_MATCH_LOAD_HANDLER_HH 20 | #define SHIRO_MATCH_LOAD_HANDLER_HH 21 | 22 | #include "../../../io/osu_packet.hh" 23 | #include "../../../io/osu_writer.hh" 24 | #include "../../../users/user.hh" 25 | 26 | namespace shiro::handler::multiplayer::match::load { 27 | 28 | void handle(io::osu_packet &in, io::osu_writer &out, std::shared_ptr user); 29 | 30 | } 31 | 32 | #endif //SHIRO_MATCH_LOAD_HANDLER_HH 33 | -------------------------------------------------------------------------------- /src/handlers/multiplayer/match/match_score_update_handler.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_MATCH_SCORE_UPDATE_HANDLER_HH 20 | #define SHIRO_MATCH_SCORE_UPDATE_HANDLER_HH 21 | 22 | #include "../../../io/osu_packet.hh" 23 | #include "../../../io/osu_writer.hh" 24 | #include "../../../users/user.hh" 25 | 26 | namespace shiro::handler::multiplayer::match::score_update { 27 | 28 | void handle(io::osu_packet &in, io::osu_writer &out, std::shared_ptr user); 29 | 30 | } 31 | 32 | #endif //SHIRO_MATCH_SCORE_UPDATE_HANDLER_HH 33 | -------------------------------------------------------------------------------- /src/handlers/multiplayer/match/match_skip_request_handler.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_MATCH_SKIP_REQUEST_HANDLER_HH 20 | #define SHIRO_MATCH_SKIP_REQUEST_HANDLER_HH 21 | 22 | #include "../../../io/osu_packet.hh" 23 | #include "../../../io/osu_writer.hh" 24 | #include "../../../users/user.hh" 25 | 26 | namespace shiro::handler::multiplayer::match::skip_request { 27 | 28 | void handle(io::osu_packet &in, io::osu_writer &out, std::shared_ptr user); 29 | 30 | } 31 | 32 | #endif //SHIRO_MATCH_SKIP_REQUEST_HANDLER_HH 33 | -------------------------------------------------------------------------------- /src/handlers/multiplayer/match/match_start_handler.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_MATCH_START_HANDLER_HH 20 | #define SHIRO_MATCH_START_HANDLER_HH 21 | 22 | #include "../../../io/osu_packet.hh" 23 | #include "../../../io/osu_writer.hh" 24 | #include "../../../users/user.hh" 25 | 26 | namespace shiro::handler::multiplayer::match::start { 27 | 28 | void handle(io::osu_packet &in, io::osu_writer &out, std::shared_ptr user); 29 | 30 | } 31 | 32 | #endif //SHIRO_MATCH_START_HANDLER_HH 33 | -------------------------------------------------------------------------------- /src/handlers/multiplayer/room/room_beatmap_handler.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_ROOM_BEATMAP_HANDLER_HH 20 | #define SHIRO_ROOM_BEATMAP_HANDLER_HH 21 | 22 | #include "../../../io/osu_packet.hh" 23 | #include "../../../io/osu_writer.hh" 24 | #include "../../../users/user.hh" 25 | 26 | namespace shiro::handler::multiplayer::room::beatmap { 27 | 28 | void handle_has_beatmap(io::osu_packet &in, io::osu_writer &out, std::shared_ptr user); 29 | 30 | void handle_no_beatmap(io::osu_packet &in, io::osu_writer &out, std::shared_ptr user); 31 | 32 | } 33 | 34 | #endif //SHIRO_ROOM_BEATMAP_HANDLER_HH 35 | -------------------------------------------------------------------------------- /src/handlers/multiplayer/room/room_change_host_handler.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_ROOM_CHANGE_HOST_HANDLER_HH 20 | #define SHIRO_ROOM_CHANGE_HOST_HANDLER_HH 21 | 22 | #include "../../../io/osu_packet.hh" 23 | #include "../../../io/osu_writer.hh" 24 | #include "../../../users/user.hh" 25 | 26 | namespace shiro::handler::multiplayer::room::change_host { 27 | 28 | void handle(io::osu_packet &in, io::osu_writer &out, std::shared_ptr user); 29 | 30 | } 31 | 32 | #endif //SHIRO_ROOM_CHANGE_HOST_HANDLER_HH 33 | -------------------------------------------------------------------------------- /src/handlers/multiplayer/room/room_change_mods_handler.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_ROOM_CHANGE_MODS_HANDLER_HH 20 | #define SHIRO_ROOM_CHANGE_MODS_HANDLER_HH 21 | 22 | #include "../../../io/osu_packet.hh" 23 | #include "../../../io/osu_writer.hh" 24 | #include "../../../users/user.hh" 25 | 26 | namespace shiro::handler::multiplayer::room::change_mods { 27 | 28 | void handle(io::osu_packet &in, io::osu_writer &out, std::shared_ptr user); 29 | 30 | } 31 | 32 | #endif //SHIRO_ROOM_CHANGE_MODS_HANDLER_HH 33 | -------------------------------------------------------------------------------- /src/handlers/multiplayer/room/room_change_password_handler.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_ROOM_CHANGE_PASSWORD_HANDLER_HH 20 | #define SHIRO_ROOM_CHANGE_PASSWORD_HANDLER_HH 21 | 22 | #include "../../../io/osu_packet.hh" 23 | #include "../../../io/osu_writer.hh" 24 | #include "../../../users/user.hh" 25 | 26 | namespace shiro::handler::multiplayer::room::change_password { 27 | 28 | void handle(io::osu_packet &in, io::osu_writer &out, std::shared_ptr user); 29 | 30 | } 31 | 32 | #endif //SHIRO_ROOM_CHANGE_PASSWORD_HANDLER_HH 33 | -------------------------------------------------------------------------------- /src/handlers/multiplayer/room/room_change_settings_handler.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_ROOM_CHANGE_SETTINGS_HANDLER_HH 20 | #define SHIRO_ROOM_CHANGE_SETTINGS_HANDLER_HH 21 | 22 | #include "../../../io/osu_packet.hh" 23 | #include "../../../io/osu_writer.hh" 24 | #include "../../../users/user.hh" 25 | 26 | namespace shiro::handler::multiplayer::room::change_settings { 27 | 28 | void handle(io::osu_packet &in, io::osu_writer &out, std::shared_ptr user); 29 | 30 | } 31 | 32 | #endif //SHIRO_ROOM_CHANGE_SETTINGS_HANDLER_HH 33 | -------------------------------------------------------------------------------- /src/handlers/multiplayer/room/room_change_slot_handler.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_ROOM_CHANGE_SLOT_HANDLER_HH 20 | #define SHIRO_ROOM_CHANGE_SLOT_HANDLER_HH 21 | 22 | #include "../../../io/osu_packet.hh" 23 | #include "../../../io/osu_writer.hh" 24 | #include "../../../users/user.hh" 25 | 26 | namespace shiro::handler::multiplayer::room::change_slot { 27 | 28 | void handle(io::osu_packet &in, io::osu_writer &out, std::shared_ptr user); 29 | 30 | } 31 | 32 | #endif //SHIRO_ROOM_CHANGE_SLOT_HANDLER_HH 33 | -------------------------------------------------------------------------------- /src/handlers/multiplayer/room/room_change_team_handler.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_ROOM_CHANGE_TEAM_HANDLER_HH 20 | #define SHIRO_ROOM_CHANGE_TEAM_HANDLER_HH 21 | 22 | #include "../../../io/osu_packet.hh" 23 | #include "../../../io/osu_writer.hh" 24 | #include "../../../users/user.hh" 25 | 26 | namespace shiro::handler::multiplayer::room::change_team { 27 | 28 | void handle(io::osu_packet &in, io::osu_writer &out, std::shared_ptr user); 29 | 30 | } 31 | 32 | #endif //SHIRO_ROOM_CHANGE_TEAM_HANDLER_HH 33 | -------------------------------------------------------------------------------- /src/handlers/multiplayer/room/room_create_handler.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_ROOM_CREATE_HANDLER_HH 20 | #define SHIRO_ROOM_CREATE_HANDLER_HH 21 | 22 | #include "../../../io/osu_packet.hh" 23 | #include "../../../io/osu_writer.hh" 24 | #include "../../../users/user.hh" 25 | 26 | namespace shiro::handler::multiplayer::room::create { 27 | 28 | void handle(io::osu_packet &in, io::osu_writer &out, std::shared_ptr user); 29 | 30 | } 31 | 32 | #endif //SHIRO_ROOM_CREATE_HANDLER_HH 33 | -------------------------------------------------------------------------------- /src/handlers/multiplayer/room/room_join_handler.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_ROOM_JOIN_HANDLER_HH 20 | #define SHIRO_ROOM_JOIN_HANDLER_HH 21 | 22 | #include "../../../io/osu_packet.hh" 23 | #include "../../../io/osu_writer.hh" 24 | #include "../../../users/user.hh" 25 | 26 | namespace shiro::handler::multiplayer::room::join { 27 | 28 | void handle(io::osu_packet &in, io::osu_writer &out, std::shared_ptr user); 29 | 30 | } 31 | 32 | #endif //SHIRO_ROOM_JOIN_HANDLER_HH 33 | -------------------------------------------------------------------------------- /src/handlers/multiplayer/room/room_leave_handler.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include "../../../multiplayer/match_manager.hh" 20 | #include "room_leave_handler.hh" 21 | 22 | void shiro::handler::multiplayer::room::leave::handle(shiro::io::osu_packet &in, shiro::io::osu_writer &out, std::shared_ptr user) { 23 | shiro::multiplayer::match_manager::leave_match(std::move(user)); 24 | 25 | out.channel_revoked("#multiplayer"); 26 | } 27 | -------------------------------------------------------------------------------- /src/handlers/multiplayer/room/room_leave_handler.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_ROOM_LEAVE_HANDLER_HH 20 | #define SHIRO_ROOM_LEAVE_HANDLER_HH 21 | 22 | #include "../../../io/osu_packet.hh" 23 | #include "../../../io/osu_writer.hh" 24 | #include "../../../users/user.hh" 25 | 26 | namespace shiro::handler::multiplayer::room::leave { 27 | 28 | void handle(io::osu_packet &in, io::osu_writer &out, std::shared_ptr user); 29 | 30 | } 31 | 32 | #endif //SHIRO_ROOM_LEAVE_HANDLER_HH 33 | -------------------------------------------------------------------------------- /src/handlers/multiplayer/room/room_lock_slot_handler.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_ROOM_LOCK_SLOT_HANDLER_HH 20 | #define SHIRO_ROOM_LOCK_SLOT_HANDLER_HH 21 | 22 | #include "../../../io/osu_packet.hh" 23 | #include "../../../io/osu_writer.hh" 24 | #include "../../../users/user.hh" 25 | 26 | namespace shiro::handler::multiplayer::room::lock_slot { 27 | 28 | void handle(io::osu_packet &in, io::osu_writer &out, std::shared_ptr user); 29 | 30 | } 31 | 32 | #endif //SHIRO_ROOM_LOCK_SLOT_HANDLER_HH 33 | -------------------------------------------------------------------------------- /src/handlers/multiplayer/room/room_ready_handler.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_ROOM_READY_HANDLER_HH 20 | #define SHIRO_ROOM_READY_HANDLER_HH 21 | 22 | #include "../../../io/osu_packet.hh" 23 | #include "../../../io/osu_writer.hh" 24 | #include "../../../users/user.hh" 25 | 26 | namespace shiro::handler::multiplayer::room::ready { 27 | 28 | void handle_ready(io::osu_packet &in, io::osu_writer &out, std::shared_ptr user); 29 | 30 | void handle_unready(io::osu_packet &in, io::osu_writer &out, std::shared_ptr user); 31 | 32 | } 33 | 34 | #endif //SHIRO_ROOM_READY_HANDLER_HH 35 | -------------------------------------------------------------------------------- /src/handlers/ping_handler.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include 20 | 21 | #include "../spectating/spectator_manager.hh" 22 | #include "ping_handler.hh" 23 | 24 | void shiro::handler::ping::handle(shiro::io::osu_packet &in, shiro::io::osu_writer &out, std::shared_ptr user) { 25 | if (!spectating::manager::is_spectating(user)) 26 | return; 27 | 28 | std::shared_ptr host = spectating::manager::get_host(user); 29 | 30 | if (host == nullptr) 31 | return; 32 | 33 | out.user_presence(host->presence); 34 | out.user_stats(host->stats); 35 | } 36 | -------------------------------------------------------------------------------- /src/handlers/ping_handler.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_PING_HANDLER_HH 20 | #define SHIRO_PING_HANDLER_HH 21 | 22 | #include "../io/osu_packet.hh" 23 | #include "../io/osu_writer.hh" 24 | #include "../users/user.hh" 25 | 26 | namespace shiro::handler::ping { 27 | 28 | void handle(io::osu_packet &in, io::osu_writer &out, std::shared_ptr user); 29 | 30 | } 31 | 32 | #endif //SHIRO_PING_HANDLER_HH 33 | -------------------------------------------------------------------------------- /src/handlers/presence/user_presence_request_all_handler.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include "../../users/user_manager.hh" 20 | #include "user_presence_request_all_handler.hh" 21 | 22 | void shiro::handler::presence::request_all::handle(shiro::io::osu_packet &in, shiro::io::osu_writer &out, std::shared_ptr user) { 23 | users::manager::iterate([&out](std::shared_ptr online_user) { 24 | if (online_user->hidden) 25 | return; 26 | 27 | if (online_user->user_id != -1) 28 | out.user_stats(online_user->stats); 29 | 30 | out.user_presence(online_user->presence); 31 | }); 32 | } 33 | -------------------------------------------------------------------------------- /src/handlers/presence/user_presence_request_all_handler.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_USER_PRESENCE_REQUEST_ALL_HANDLER_HH 20 | #define SHIRO_USER_PRESENCE_REQUEST_ALL_HANDLER_HH 21 | 22 | #include "../../io/osu_packet.hh" 23 | #include "../../io/osu_writer.hh" 24 | #include "../../users/user.hh" 25 | 26 | namespace shiro::handler::presence::request_all { 27 | 28 | void handle(io::osu_packet &in, io::osu_writer &out, std::shared_ptr user); 29 | 30 | } 31 | 32 | #endif //SHIRO_USER_PRESENCE_REQUEST_ALL_HANDLER_HH 33 | -------------------------------------------------------------------------------- /src/handlers/presence/user_presence_request_handler.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_USER_PRESENCE_REQUEST_HANDLER_HH 20 | #define SHIRO_USER_PRESENCE_REQUEST_HANDLER_HH 21 | 22 | #include "../../io/osu_packet.hh" 23 | #include "../../io/osu_writer.hh" 24 | #include "../../users/user.hh" 25 | 26 | namespace shiro::handler::presence::request { 27 | 28 | void handle(io::osu_packet &in, io::osu_writer &out, std::shared_ptr user); 29 | 30 | } 31 | 32 | #endif //SHIRO_USER_PRESENCE_REQUEST_HANDLER_HH 33 | -------------------------------------------------------------------------------- /src/handlers/presence/user_stats_request_handler.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_USER_STATS_REQUEST_HANDLER_HH 20 | #define SHIRO_USER_STATS_REQUEST_HANDLER_HH 21 | 22 | #include "../../io/osu_packet.hh" 23 | #include "../../io/osu_writer.hh" 24 | #include "../../users/user.hh" 25 | 26 | namespace shiro::handler::stats::request_all { 27 | 28 | void handle(io::osu_packet &in, io::osu_writer &out, std::shared_ptr user); 29 | 30 | } 31 | 32 | #endif //SHIRO_USER_STATS_REQUEST_HANDLER_HH 33 | -------------------------------------------------------------------------------- /src/handlers/request_status_update_handler.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include "request_status_update_handler.hh" 20 | 21 | void shiro::handler::request_status_update::handle(shiro::io::osu_packet &in, shiro::io::osu_writer &out, std::shared_ptr user) { 22 | user->update(); 23 | user->refresh_stats(); 24 | } 25 | -------------------------------------------------------------------------------- /src/handlers/request_status_update_handler.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_REQUEST_STATUS_UPDATE_HANDLER_HH 20 | #define SHIRO_REQUEST_STATUS_UPDATE_HANDLER_HH 21 | 22 | #include "../io/osu_packet.hh" 23 | #include "../io/osu_writer.hh" 24 | #include "../users/user.hh" 25 | 26 | namespace shiro::handler::request_status_update { 27 | 28 | void handle(io::osu_packet &in, io::osu_writer &out, std::shared_ptr user); 29 | 30 | } 31 | 32 | #endif //SHIRO_REQUEST_STATUS_UPDATE_HANDLER_HH 33 | -------------------------------------------------------------------------------- /src/handlers/spectating/cant_spectate_handler.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_CANT_SPECTATE_HANDLER_HH 20 | #define SHIRO_CANT_SPECTATE_HANDLER_HH 21 | 22 | #include "../../io/osu_packet.hh" 23 | #include "../../io/osu_writer.hh" 24 | #include "../../users/user.hh" 25 | 26 | namespace shiro::handler::spectating::cant_spectate { 27 | 28 | void handle(io::osu_packet &in, io::osu_writer &out, std::shared_ptr user); 29 | 30 | } 31 | 32 | #endif //SHIRO_CANT_SPECTATE_HANDLER_HH 33 | -------------------------------------------------------------------------------- /src/handlers/spectating/spectator_frames_handler.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_SPECTATOR_FRAMES_HANDLER_HH 20 | #define SHIRO_SPECTATOR_FRAMES_HANDLER_HH 21 | 22 | #include "../../io/osu_packet.hh" 23 | #include "../../io/osu_writer.hh" 24 | #include "../../users/user.hh" 25 | 26 | namespace shiro::handler::spectating::frames { 27 | 28 | void handle(io::osu_packet &in, io::osu_writer &out, std::shared_ptr user); 29 | 30 | } 31 | 32 | #endif //SHIRO_SPECTATOR_FRAMES_HANDLER_HH 33 | -------------------------------------------------------------------------------- /src/handlers/spectating/start_spectating_handler.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_START_SPECTATING_HANDLER_HH 20 | #define SHIRO_START_SPECTATING_HANDLER_HH 21 | 22 | #include "../../io/osu_packet.hh" 23 | #include "../../io/osu_writer.hh" 24 | #include "../../users/user.hh" 25 | 26 | namespace shiro::handler::spectating::start { 27 | 28 | void handle(io::osu_packet &in, io::osu_writer &out, std::shared_ptr user); 29 | 30 | } 31 | 32 | #endif //SHIRO_START_SPECTATING_HANDLER_HH 33 | -------------------------------------------------------------------------------- /src/handlers/spectating/stop_spectating_handler.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_STOP_SPECTATING_HANDLER_HH 20 | #define SHIRO_STOP_SPECTATING_HANDLER_HH 21 | 22 | #include "../../io/osu_packet.hh" 23 | #include "../../io/osu_writer.hh" 24 | #include "../../users/user.hh" 25 | 26 | namespace shiro::handler::spectating::stop { 27 | 28 | void handle(io::osu_packet &in, io::osu_writer &out, std::shared_ptr user); 29 | 30 | } 31 | 32 | #endif //SHIRO_STOP_SPECTATING_HANDLER_HH 33 | -------------------------------------------------------------------------------- /src/handlers/user_status_handler.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_USER_STATUS_HANDLER_HH 20 | #define SHIRO_USER_STATUS_HANDLER_HH 21 | 22 | #include "../io/osu_packet.hh" 23 | #include "../io/osu_writer.hh" 24 | #include "../users/user.hh" 25 | 26 | namespace shiro::handler::user_status { 27 | 28 | void handle(io::osu_packet &in, io::osu_writer &out, std::shared_ptr user); 29 | 30 | } 31 | 32 | #endif //SHIRO_USER_STATUS_HANDLER_HH 33 | -------------------------------------------------------------------------------- /src/io/layouts/multiplayer/multiplayer_join.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include "multiplayer_join.hh" 20 | 21 | shiro::io::buffer shiro::io::layouts::multiplayer_join::marshal() { 22 | io::buffer buf; 23 | 24 | buf.write(this->match_id); 25 | buf.write_string(this->password); 26 | 27 | return buf; 28 | } 29 | 30 | void shiro::io::layouts::multiplayer_join::unmarshal(shiro::io::buffer &buffer) { 31 | this->match_id = buffer.read(); 32 | this->password = buffer.read_string(); 33 | } 34 | 35 | int32_t shiro::io::layouts::multiplayer_join::get_size() { 36 | return this->marshal().get_size(); 37 | } 38 | -------------------------------------------------------------------------------- /src/io/layouts/multiplayer/multiplayer_join.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_MULTIPLAYER_JOIN_HH 20 | #define SHIRO_MULTIPLAYER_JOIN_HH 21 | 22 | #include "../serializable.hh" 23 | 24 | namespace shiro::io::layouts { 25 | 26 | class multiplayer_join : public serializable { 27 | public: 28 | int32_t match_id; 29 | std::string password; 30 | 31 | buffer marshal() override; 32 | void unmarshal(shiro::io::buffer &buffer) override; 33 | 34 | int32_t get_size() override; 35 | 36 | }; 37 | 38 | } 39 | 40 | #endif //SHIRO_MULTIPLAYER_JOIN_HH 41 | -------------------------------------------------------------------------------- /src/io/layouts/replay/replay_frame.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_REPLAY_FRAME_HH 20 | #define SHIRO_REPLAY_FRAME_HH 21 | 22 | #include "../serializable.hh" 23 | 24 | namespace shiro::io::layouts { 25 | 26 | class replay_frame : public serializable { 27 | public: 28 | virtual ~replay_frame() = default; 29 | 30 | uint8_t button_state = 0; 31 | uint8_t button_type = 0; 32 | 33 | float mouse_x = 0.0f; 34 | float mouse_y = 0.0f; 35 | 36 | int32_t time = 0; 37 | 38 | buffer marshal() override; 39 | void unmarshal(shiro::io::buffer &buffer) override; 40 | 41 | int32_t get_size() override; 42 | }; 43 | 44 | } 45 | 46 | #endif //SHIRO_REPLAY_FRAME_HH 47 | -------------------------------------------------------------------------------- /src/io/layouts/user/user_quit.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include "user_quit.hh" 20 | 21 | shiro::io::buffer shiro::io::layouts::user_quit::marshal() { 22 | io::buffer buf; 23 | 24 | buf.write(this->user_id); 25 | buf.write(this->state); 26 | 27 | return buf; 28 | } 29 | 30 | void shiro::io::layouts::user_quit::unmarshal(shiro::io::buffer &buffer) { 31 | this->user_id = buffer.read(); 32 | this->state = buffer.read(); 33 | } 34 | 35 | int32_t shiro::io::layouts::user_quit::get_size() { 36 | return 4 + 1; 37 | } 38 | -------------------------------------------------------------------------------- /src/io/layouts/user/user_quit.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_USER_QUIT_HH 20 | #define SHIRO_USER_QUIT_HH 21 | 22 | #include "../serializable.hh" 23 | 24 | namespace shiro::io::layouts { 25 | 26 | class user_quit : public serializable { 27 | public: 28 | int32_t user_id = 0; 29 | uint8_t state = 0; 30 | 31 | buffer marshal() override; 32 | void unmarshal(shiro::io::buffer &buffer) override; 33 | 34 | int32_t get_size() override; 35 | 36 | }; 37 | 38 | } 39 | 40 | #endif //SHIRO_USER_QUIT_HH 41 | -------------------------------------------------------------------------------- /src/io/layouts/user/user_status.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include "user_status.hh" 20 | 21 | shiro::io::buffer shiro::io::layouts::user_status::marshal() { 22 | buffer buf; 23 | 24 | return buf; 25 | } 26 | 27 | void shiro::io::layouts::user_status::unmarshal(shiro::io::buffer &data) { 28 | this->activity = data.read(); 29 | this->activity_desc = data.read_string(); 30 | 31 | this->beatmap_checksum = data.read_string(); 32 | 33 | this->current_mods = data.read(); 34 | this->play_mode = data.read(); 35 | 36 | this->beatmap_id = data.read(); 37 | } 38 | 39 | int32_t shiro::io::layouts::user_status::get_size() { 40 | return (int32_t) this->marshal().get_size(); 41 | } 42 | -------------------------------------------------------------------------------- /src/io/layouts/user/user_status.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_USER_STATUS_HH 20 | #define SHIRO_USER_STATUS_HH 21 | 22 | #include "../serializable.hh" 23 | 24 | namespace shiro::io::layouts { 25 | 26 | class user_status : public serializable { 27 | public: 28 | uint8_t activity = 0; 29 | std::string activity_desc = ""; 30 | 31 | std::string beatmap_checksum = ""; 32 | 33 | uint32_t current_mods = 0; 34 | uint8_t play_mode = 0; 35 | 36 | int32_t beatmap_id = 0; 37 | 38 | buffer marshal() override; 39 | void unmarshal(shiro::io::buffer &buffer) override; 40 | 41 | int32_t get_size() override; 42 | 43 | }; 44 | 45 | } 46 | 47 | #endif //SHIRO_USER_STATUS_HH 48 | -------------------------------------------------------------------------------- /src/io/osu_packet.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include "osu_packet.hh" 20 | 21 | shiro::io::osu_packet::osu_packet(buffer &data) { 22 | this->id = (packet_id)data.read(); 23 | data.read(); 24 | 25 | int data_size = data.read(); 26 | 27 | for (int i = 0; i < data_size; i++) { 28 | this->data.write(static_cast(data.read())); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/io/osu_packet.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_OSU_PACKET_HH 20 | #define SHIRO_OSU_PACKET_HH 21 | 22 | #include "layouts/packets.hh" 23 | #include "osu_buffer.hh" 24 | 25 | namespace shiro::io { 26 | 27 | class osu_packet { 28 | public: 29 | packet_id id; 30 | buffer data; 31 | 32 | explicit osu_packet(buffer &data); 33 | 34 | template 35 | l unmarshal() { 36 | l result; 37 | result.unmarshal(this->data); 38 | 39 | return result; 40 | } 41 | 42 | }; 43 | 44 | } 45 | 46 | #endif //SHIRO_OSU_PACKET_HH 47 | -------------------------------------------------------------------------------- /src/io/osu_reader.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include "osu_reader.hh" 20 | 21 | shiro::io::osu_reader::osu_reader(std::string data) { 22 | this->data = buffer(data); 23 | } 24 | 25 | std::vector &shiro::io::osu_reader::parse() { 26 | while (this->data.can_read(7)) { 27 | this->packets.emplace_back(osu_packet(this->data)); 28 | } 29 | 30 | return this->packets; 31 | } 32 | -------------------------------------------------------------------------------- /src/io/osu_reader.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_OSU_READER_HH 20 | #define SHIRO_OSU_READER_HH 21 | 22 | #include "osu_buffer.hh" 23 | #include "osu_packet.hh" 24 | 25 | namespace shiro::io { 26 | 27 | class osu_reader { 28 | private: 29 | buffer data; 30 | std::vector packets; 31 | 32 | public: 33 | osu_reader() = default; 34 | explicit osu_reader(std::string data); 35 | 36 | std::vector &parse(); 37 | 38 | }; 39 | 40 | } 41 | 42 | #endif //SHIRO_OSU_READER_HH 43 | -------------------------------------------------------------------------------- /src/logger/logger.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_LOGGER_HH 20 | #define SHIRO_LOGGER_HH 21 | 22 | namespace shiro::logging { 23 | 24 | void init(int argc, char **argv); 25 | 26 | } 27 | 28 | #endif //SHIRO_LOGGER_HH 29 | -------------------------------------------------------------------------------- /src/logger/route_logger.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_ROUTE_LOGGER_HH 20 | #define SHIRO_ROUTE_LOGGER_HH 21 | 22 | #include "../thirdparty/crow.hh" 23 | 24 | namespace shiro::logging { 25 | 26 | class route_logger : public crow::ILogHandler { 27 | public: 28 | virtual ~route_logger() = default; 29 | void log(std::string message, crow::LogLevel level) override; 30 | 31 | }; 32 | 33 | } 34 | 35 | #endif //SHIRO_ROUTE_LOGGER_HH 36 | -------------------------------------------------------------------------------- /src/main.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include 20 | 21 | #include "shiro.hh" 22 | 23 | int main(int argc, char **argv) { 24 | std::atexit(shiro::destroy); 25 | return shiro::init(argc, argv); 26 | } 27 | -------------------------------------------------------------------------------- /src/multiplayer/lobby_manager.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_LOBBY_MANAGER_HH 20 | #define SHIRO_LOBBY_MANAGER_HH 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #include "../users/user.hh" 27 | 28 | namespace shiro::multiplayer::lobby_manager { 29 | 30 | extern std::vector> users; 31 | extern std::shared_timed_mutex mutex; 32 | 33 | void add_user(std::shared_ptr user); 34 | 35 | void remove_user(std::shared_ptr user); 36 | 37 | bool in_lobby(std::shared_ptr user); 38 | 39 | void iterate(const std::function)> &callback); 40 | 41 | } 42 | 43 | #endif //SHIRO_LOBBY_MANAGER_HH 44 | -------------------------------------------------------------------------------- /src/native/linux/process_info_linux.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #if defined(__linux__) 20 | 21 | #include 22 | #include 23 | 24 | #include "../../utils/filesystem.hh" 25 | #include "../process_info.hh" 26 | 27 | int32_t shiro::native::process_info::get_pid() { 28 | return getpid(); 29 | } 30 | 31 | std::string shiro::native::process_info::get_executable_location() { 32 | return fs::read_symlink("/proc/self/exe").u8string(); 33 | } 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /src/native/mac/signal_handler_mac.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include "../signal_handler.hh" 20 | 21 | #if defined(__APPLE__) 22 | #include "../linux/signal_handler_linux.cc" 23 | #endif 24 | -------------------------------------------------------------------------------- /src/native/process_info.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_PROCESS_INFO_HH 20 | #define SHIRO_PROCESS_INFO_HH 21 | 22 | #include 23 | #include 24 | 25 | namespace shiro::native::process_info { 26 | 27 | int32_t get_pid(); 28 | 29 | std::string get_executable_location(); 30 | 31 | } 32 | 33 | #endif // SHIRO_PROCESS_INFO_HH 34 | -------------------------------------------------------------------------------- /src/native/signal_handler.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_SIGNAL_HANDLER_HH 20 | #define SHIRO_SIGNAL_HANDLER_HH 21 | 22 | namespace shiro::native::signal_handler { 23 | 24 | void install(); 25 | 26 | } 27 | 28 | #endif // SHIRO_SIGNAL_HANDLER_HH 29 | -------------------------------------------------------------------------------- /src/native/system_info.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_SYSTEM_INFO_HH 20 | #define SHIRO_SYSTEM_INFO_HH 21 | 22 | #include 23 | 24 | namespace shiro::native::system_info { 25 | 26 | std::string get_architecture(); 27 | 28 | std::string get_host_name(); 29 | 30 | std::string get_hw_model(); 31 | 32 | std::string get_os_version(); 33 | 34 | std::string get_os_build(); 35 | 36 | } 37 | 38 | #endif // SHIRO_SYSTEM_INFO_HH 39 | -------------------------------------------------------------------------------- /src/permissions/role.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include 20 | 21 | #include "role.hh" 22 | 23 | shiro::permissions::role::role(uint32_t id, std::string name, uint64_t permissions, uint8_t color) 24 | : id(id) 25 | , name(std::move(name)) 26 | , permissions(permissions) 27 | , color(color) { 28 | // Initialized in initializer list 29 | } 30 | -------------------------------------------------------------------------------- /src/permissions/role.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_ROLE_HH 20 | #define SHIRO_ROLE_HH 21 | 22 | #include 23 | #include 24 | 25 | namespace shiro::permissions { 26 | 27 | class role { 28 | public: 29 | uint32_t id = 0; 30 | std::string name = ""; 31 | uint64_t permissions = 0; 32 | uint8_t color = 0; 33 | 34 | role(uint32_t id, std::string name, uint64_t permissions, uint8_t color); 35 | 36 | }; 37 | 38 | } 39 | 40 | #endif //SHIRO_ROLE_HH 41 | -------------------------------------------------------------------------------- /src/permissions/role_manager.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_ROLE_MANAGER_HH 20 | #define SHIRO_ROLE_MANAGER_HH 21 | 22 | #include 23 | #include 24 | 25 | #include "../users/user.hh" 26 | #include "permissions.hh" 27 | #include "role.hh" 28 | 29 | namespace shiro::roles::manager { 30 | 31 | extern std::vector roles; 32 | 33 | void init(); 34 | 35 | bool has_permission(std::shared_ptr user, permissions::perms permissions); 36 | 37 | uint8_t get_chat_color(uint32_t roles); 38 | 39 | } 40 | 41 | #endif //SHIRO_ROLE_MANAGER_HH 42 | -------------------------------------------------------------------------------- /src/pp/pp_score_metric.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_PP_SCORE_METRIC_HH 20 | #define SHIRO_PP_SCORE_METRIC_HH 21 | 22 | #include "../beatmaps/beatmap.hh" 23 | #include "../scores/score.hh" 24 | 25 | namespace shiro::pp { 26 | 27 | float calculate(beatmaps::beatmap beatmap, scores::score score); 28 | 29 | float calculate_std(beatmaps::beatmap beatmap, scores::score score); 30 | 31 | float calculate_taiko(beatmaps::beatmap beatmap, scores::score score); 32 | 33 | float calculate_mania(beatmaps::beatmap beatmap, scores::score score); 34 | 35 | float calculate_ctb(beatmaps::beatmap beatmap, scores::score score); 36 | 37 | } 38 | 39 | #endif //SHIRO_PP_SCORE_METRIC_HH 40 | -------------------------------------------------------------------------------- /src/pp/wrapper/oppai_wrapper.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_OPPAI_WRAPPER_HH 20 | #define SHIRO_OPPAI_WRAPPER_HH 21 | 22 | #include "../../thirdparty/oppai.hh" 23 | #include "../../beatmaps/beatmap.hh" 24 | #include "../../scores/score.hh" 25 | 26 | namespace shiro::pp { 27 | 28 | class oppai_wrapper { 29 | private: 30 | ezpp_t ez = nullptr; 31 | 32 | public: 33 | oppai_wrapper(beatmaps::beatmap beatmap, scores::score score); 34 | ~oppai_wrapper(); 35 | 36 | float calculate(); 37 | 38 | }; 39 | 40 | } 41 | 42 | #endif //SHIRO_OPPAI_WRAPPER_HH 43 | -------------------------------------------------------------------------------- /src/ranking/ranking_helper.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_RANKING_HELPER_HH 20 | #define SHIRO_RANKING_HELPER_HH 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #include "../users/user.hh" 27 | #include "../utils/play_mode.hh" 28 | 29 | namespace shiro::ranking::helper { 30 | 31 | int32_t get_leaderboard_position(uint8_t mode, std::string username); 32 | 33 | std::string get_leaderboard_user(uint8_t mode, int32_t pos); 34 | 35 | int16_t get_pp_for_user(uint8_t mode, std::string username); 36 | 37 | void recalculate_ranks(const utils::play_mode &mode); 38 | 39 | } 40 | 41 | #endif //SHIRO_RANKING_HELPER_HH 42 | -------------------------------------------------------------------------------- /src/replays/replay_manager.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_REPLAY_MANAGER_HH 20 | #define SHIRO_REPLAY_MANAGER_HH 21 | 22 | #include 23 | 24 | #include "../beatmaps/beatmap.hh" 25 | #include "../scores/score.hh" 26 | 27 | namespace shiro::replays { 28 | 29 | void init(); 30 | 31 | void save_replay(const scores::score &s, const beatmaps::beatmap &beatmap, int32_t game_version, std::string replay); 32 | 33 | std::string calculate_diagram(const scores::score &s, std::string replay); 34 | 35 | std::string get_replay(const scores::score &s); 36 | 37 | bool has_replay(const scores::score &s); 38 | 39 | } 40 | 41 | #endif //SHIRO_REPLAY_MANAGER_HH 42 | -------------------------------------------------------------------------------- /src/routes/impl/api/ci_trigger_route.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_CI_TRIGGER_ROUTE_HH 20 | #define SHIRO_CI_TRIGGER_ROUTE_HH 21 | 22 | #include "../../../thirdparty/crow.hh" 23 | 24 | namespace shiro::routes::api::ci_trigger { 25 | 26 | void handle(const crow::request &request, crow::response &response); 27 | 28 | } 29 | 30 | #endif //SHIRO_CI_TRIGGER_ROUTE_HH 31 | -------------------------------------------------------------------------------- /src/routes/impl/direct/download_route.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_DOWNLOAD_ROUTE_HH 20 | #define SHIRO_DOWNLOAD_ROUTE_HH 21 | 22 | #include 23 | 24 | #include "../../../thirdparty/crow.hh" 25 | 26 | namespace shiro::routes::direct::download { 27 | 28 | void handle(const crow::request &request, crow::response &response, std::string args); 29 | 30 | } 31 | 32 | #endif //SHIRO_DOWNLOAD_ROUTE_HH 33 | -------------------------------------------------------------------------------- /src/routes/impl/direct/search_route.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_SEARCH_ROUTE_HH 20 | #define SHIRO_SEARCH_ROUTE_HH 21 | 22 | #include "../../../thirdparty/crow.hh" 23 | 24 | namespace shiro::routes::direct::search { 25 | 26 | void handle(const crow::request &request, crow::response &response); 27 | 28 | } 29 | 30 | #endif //SHIRO_SEARCH_ROUTE_HH 31 | -------------------------------------------------------------------------------- /src/routes/impl/root_route.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_ROOT_ROUTE_HH 20 | #define SHIRO_ROOT_ROUTE_HH 21 | 22 | #include "../../thirdparty/crow.hh" 23 | 24 | namespace shiro::routes::root { 25 | 26 | void handle(const crow::request &request, crow::response &response); 27 | 28 | } 29 | 30 | #endif //SHIRO_ROOT_ROUTE_HH 31 | -------------------------------------------------------------------------------- /src/routes/impl/web/bancho_connect_route.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_BANCHO_CONNECT_ROUTE_HH 20 | #define SHIRO_BANCHO_CONNECT_ROUTE_HH 21 | 22 | #include "../../../thirdparty/crow.hh" 23 | 24 | namespace shiro::routes::web::bancho_connect { 25 | 26 | void handle(const crow::request &request, crow::response &response); 27 | 28 | } 29 | 30 | #endif //SHIRO_BANCHO_CONNECT_ROUTE_HH 31 | -------------------------------------------------------------------------------- /src/routes/impl/web/get_replay_route.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_GET_REPLAY_ROUTE_HH 20 | #define SHIRO_GET_REPLAY_ROUTE_HH 21 | 22 | #include "../../../thirdparty/crow.hh" 23 | 24 | namespace shiro::routes::web::get_replay { 25 | 26 | void handle(const crow::request &request, crow::response &response); 27 | 28 | } 29 | 30 | #endif //SHIRO_GET_REPLAY_ROUTE_HH 31 | -------------------------------------------------------------------------------- /src/routes/impl/web/get_scores_route.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_GET_SCORES_ROUTE_HH 20 | #define SHIRO_GET_SCORES_ROUTE_HH 21 | 22 | #include "../../../thirdparty/crow.hh" 23 | 24 | namespace shiro::routes::web::get_scores { 25 | 26 | void handle(const crow::request &request, crow::response &response); 27 | 28 | } 29 | 30 | #endif //SHIRO_GET_SCORES_ROUTE_HH 31 | -------------------------------------------------------------------------------- /src/routes/impl/web/lastfm_route.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_LASTFM_ROUTE_HH 20 | #define SHIRO_LASTFM_ROUTE_HH 21 | 22 | #include "../../../thirdparty/crow.hh" 23 | 24 | namespace shiro::routes::web::lastfm { 25 | 26 | void handle(const crow::request &request, crow::response &response); 27 | 28 | } 29 | 30 | #endif //SHIRO_LASTFM_ROUTE_HH 31 | -------------------------------------------------------------------------------- /src/routes/impl/web/submit_score_route.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_SUBMIT_SCORE_ROUTE_HH 20 | #define SHIRO_SUBMIT_SCORE_ROUTE_HH 21 | 22 | #include "../../../thirdparty/crow.hh" 23 | 24 | namespace shiro::routes::web::submit_score { 25 | 26 | void handle(const crow::request &request, crow::response &response); 27 | 28 | } 29 | 30 | #endif //SHIRO_SUBMIT_SCORE_ROUTE_HH 31 | -------------------------------------------------------------------------------- /src/routes/packet_router.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_PACKET_ROUTER_HH 20 | #define SHIRO_PACKET_ROUTER_HH 21 | 22 | #include "../io/layouts/packets.hh" 23 | #include "../io/osu_packet.hh" 24 | #include "../io/osu_writer.hh" 25 | #include "../users/user.hh" 26 | 27 | namespace shiro::routes { 28 | 29 | void route(io::packet_id packet_id, io::osu_packet &in, io::osu_writer &out, std::shared_ptr user); 30 | 31 | } 32 | 33 | #endif //SHIRO_PACKET_ROUTER_HH 34 | -------------------------------------------------------------------------------- /src/shiro.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_SHIRO_HH 20 | #define SHIRO_SHIRO_HH 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #include "database/database.hh" 28 | #include "redis/redis.hh" 29 | #include "thirdparty/taskscheduler.hh" 30 | 31 | namespace shiro { 32 | 33 | extern std::shared_ptr db_connection; 34 | extern std::shared_ptr redis_connection; 35 | 36 | using namespace std::chrono_literals; 37 | extern tsc::TaskScheduler scheduler; 38 | 39 | extern std::time_t start_time; 40 | extern std::string commit; 41 | 42 | int init(int argc, char **argv); 43 | 44 | void destroy(); 45 | 46 | } 47 | 48 | #endif //SHIRO_SHIRO_HH 49 | -------------------------------------------------------------------------------- /src/thirdparty/algorithm/blake.hh: -------------------------------------------------------------------------------- 1 | /* 2 | This code is written by kerukuro and released into public domain. 3 | */ 4 | 5 | #ifndef DIGESTPP_ALGORITHM_BLAKE_HH 6 | #define DIGESTPP_ALGORITHM_BLAKE_HH 7 | 8 | #include "../hasher.hh" 9 | #include "detail/blake_provider.hh" 10 | #include "mixin/blake_mixin.hh" 11 | 12 | namespace digestpp 13 | { 14 | 15 | /** 16 | * @brief BLAKE hash function (SHA-3 finalist) 17 | * 18 | * @hash 19 | * 20 | * @outputsize 224 / 256 / 384 / 512 bits 21 | * 22 | * @defaultsize none 23 | * 24 | * @throw std::runtime_error if the requested digest size is not supported 25 | * 26 | * @mixinparams salt 27 | * 28 | * @mixin{mixin::blake_mixin} 29 | * 30 | * @par Example:\n 31 | * @code // Output a 256-bit BLAKE digest of a string 32 | * digestpp::blake hasher(256); 33 | * hasher.absorb("The quick brown fox jumps over the lazy dog"); 34 | * std::cout << hasher.hexdigest() << '\n'; 35 | * @endcode 36 | * 37 | * @par Example output:\n 38 | * @code 7576698ee9cad30173080678e5965916adbb11cb5245d386bf1ffda1cb26c9d7 39 | * @endcode 40 | * 41 | * @sa hasher, mixin::blake_mixin 42 | */ 43 | typedef hasher blake; 44 | 45 | } // namespace digestpp 46 | 47 | #endif // DIGESTPP_ALGORITHM_BLAKE_HH 48 | 49 | -------------------------------------------------------------------------------- /src/thirdparty/algorithm/detail/constants/sha1_constants.hh: -------------------------------------------------------------------------------- 1 | /* 2 | This code is written by kerukuro and released into public domain. 3 | */ 4 | 5 | #ifndef DIGESTPP_PROVIDERS_SHA1_CONSTANTS_HH 6 | #define DIGESTPP_PROVIDERS_SHA1_CONSTANTS_HH 7 | 8 | namespace digestpp 9 | { 10 | 11 | namespace detail 12 | { 13 | 14 | template 15 | struct sha1_constants 16 | { 17 | const static uint32_t K[4]; 18 | }; 19 | 20 | template 21 | const uint32_t sha1_constants::K[4] = { 22 | 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6 23 | }; 24 | 25 | } // namespace detail 26 | 27 | } // namespace digestpp 28 | 29 | #endif 30 | 31 | -------------------------------------------------------------------------------- /src/thirdparty/algorithm/detail/constants/sha3_constants.hh: -------------------------------------------------------------------------------- 1 | /* 2 | This code is written by kerukuro and released into public domain. 3 | */ 4 | 5 | #ifndef DIGESTPP_PROVIDERS_SHA3_CONSTANTS_HH 6 | #define DIGESTPP_PROVIDERS_SHA3_CONSTANTS_HH 7 | 8 | namespace digestpp 9 | { 10 | 11 | namespace detail 12 | { 13 | 14 | template 15 | struct sha3_constants 16 | { 17 | const static uint64_t RC[24]; 18 | }; 19 | 20 | template 21 | const uint64_t sha3_constants::RC[24] = { 22 | 0x0000000000000001ull, 0x0000000000008082ull, 0x800000000000808Aull, 0x8000000080008000ull, 23 | 0x000000000000808Bull, 0x0000000080000001ull, 0x8000000080008081ull, 0x8000000000008009ull, 24 | 0x000000000000008Aull, 0x0000000000000088ull, 0x0000000080008009ull, 0x000000008000000Aull, 25 | 0x000000008000808Bull, 0x800000000000008Bull, 0x8000000000008089ull, 0x8000000000008003ull, 26 | 0x8000000000008002ull, 0x8000000000000080ull, 0x000000000000800Aull, 0x800000008000000Aull, 27 | 0x8000000080008081ull, 0x8000000000008080ull, 0x0000000080000001ull, 0x8000000080008008ull 28 | }; 29 | 30 | 31 | } // namespace detail 32 | 33 | } // namespace digestpp 34 | 35 | #endif // DIGESTPP_PROVIDERS_SHA3_CONSTANTS_HH 36 | 37 | 38 | -------------------------------------------------------------------------------- /src/thirdparty/algorithm/groestl.hh: -------------------------------------------------------------------------------- 1 | /* 2 | This code is written by kerukuro and released into public domain. 3 | */ 4 | 5 | #ifndef DIGESTPP_ALGORITHM_GROESTL_HH 6 | #define DIGESTPP_ALGORITHM_GROESTL_HH 7 | 8 | #include "../hasher.hh" 9 | #include "detail/groestl_provider.hh" 10 | 11 | namespace digestpp 12 | { 13 | 14 | /** 15 | * @brief Grøstl hash function 16 | * 17 | * @hash 18 | * 19 | * @outputsize 8 - 512 bits 20 | * 21 | * @defaultsize none 22 | * 23 | * @throw std::runtime_error if the requested digest size is not divisible by 8 (full bytes), 24 | * or is not within the supported range 25 | * 26 | * @par Example:\n 27 | * @code // Output a 256-bit Grøstl digest of a string 28 | * digestpp::groestl hasher(256); 29 | * hasher.absorb("The quick brown fox jumps over the lazy dog"); 30 | * std::cout << hasher.hexdigest() << '\n'; 31 | * @endcode 32 | * 33 | * @par Example output:\n 34 | * @code 8c7ad62eb26a21297bc39c2d7293b4bd4d3399fa8afab29e970471739e28b301 35 | * @endcode 36 | * 37 | * @sa hasher 38 | */ 39 | typedef hasher groestl; 40 | 41 | } // namespace digestpp 42 | 43 | #endif // DIGESTPP_ALGORITHM_GROESTL_HH 44 | 45 | -------------------------------------------------------------------------------- /src/thirdparty/algorithm/jh.hh: -------------------------------------------------------------------------------- 1 | /* 2 | This code is written by kerukuro and released into public domain. 3 | */ 4 | 5 | #ifndef DIGESTPP_ALGORITHM_JG_HH 6 | #define DIGESTPP_ALGORITHM_JG_HH 7 | 8 | #include "../hasher.hh" 9 | #include "detail/jh_provider.hh" 10 | 11 | namespace digestpp 12 | { 13 | 14 | /** 15 | * @brief JH hash function 16 | * 17 | * @hash 18 | * 19 | * @outputsize 8 - 512 bits 20 | * 21 | * @defaultsize none 22 | * 23 | * @throw std::runtime_error if the requested digest size is not divisible by 8 (full bytes), 24 | * or is not within the supported range 25 | * 26 | * @par Example:\n 27 | * @code // Output a 256-bit JH digest of a string 28 | * digestpp::jh hasher(256); 29 | * hasher.absorb("The quick brown fox jumps over the lazy dog"); 30 | * std::cout << hasher.hexdigest() << '\n'; 31 | * @endcode 32 | * 33 | * @par Example output:\n 34 | * @code 6a049fed5fc6874acfdc4a08b568a4f8cbac27de933496f031015b38961608a0 35 | * @endcode 36 | * 37 | * @sa hasher 38 | */ 39 | typedef hasher jh; 40 | 41 | } // namespace digestpp 42 | 43 | #endif // DIGESTPP_ALGORITHM_JG_HH 44 | 45 | -------------------------------------------------------------------------------- /src/thirdparty/algorithm/kupyna.hh: -------------------------------------------------------------------------------- 1 | /* 2 | This code is written by kerukuro and released into public domain. 3 | */ 4 | 5 | #ifndef DIGESTPP_ALGORITHM_KUPYNA_HH 6 | #define DIGESTPP_ALGORITHM_KUPYNA_HH 7 | 8 | #include "../hasher.hh" 9 | #include "detail/kupyna_provider.hh" 10 | 11 | namespace digestpp 12 | { 13 | 14 | /** 15 | * @brief Kupyna hash function 16 | * 17 | * @hash 18 | * 19 | * @outputsize 256 / 512 bits 20 | * 21 | * @defaultsize none 22 | * 23 | * @throw std::runtime_error if the requested digest size is not supported 24 | * 25 | * @par Example:\n 26 | * @code // Output a 256-bit Kupyna digest of a string 27 | * digestpp::kupyna hasher(256); 28 | * hasher.absorb("The quick brown fox jumps over the lazy dog"); 29 | * std::cout << hasher.hexdigest() << '\n'; 30 | * @endcode 31 | * 32 | * @par Example output:\n 33 | * @code 996899f2d7422ceaf552475036b2dc120607eff538abf2b8dff471a98a4740c6 34 | * @endcode 35 | * 36 | * @sa hasher 37 | */ 38 | 39 | typedef hasher kupyna; 40 | 41 | } // namespace digestpp 42 | 43 | #endif // DIGESTPP_ALGORITHM_KUPYNA_HH 44 | 45 | -------------------------------------------------------------------------------- /src/thirdparty/algorithm/md5.hh: -------------------------------------------------------------------------------- 1 | /* 2 | This code is written by kerukuro and released into public domain. 3 | */ 4 | 5 | #ifndef DIGESTPP_ALGORITHM_MD5_HH 6 | #define DIGESTPP_ALGORITHM_MD5_HH 7 | 8 | #include "../hasher.hh" 9 | #include "detail/md5_provider.hh" 10 | 11 | namespace digestpp 12 | { 13 | 14 | /** 15 | * @brief MD5 hash function 16 | * 17 | * Note that MD5 hash function is considered insecure and is not recommended for new applications. 18 | * 19 | * @hash 20 | * 21 | * @outputsize 128 bits 22 | * 23 | * @defaultsize 128 bits 24 | * 25 | * @par Example:\n 26 | * @code // Output an MD5 digest of a string 27 | * digestpp::md5 hasher; 28 | * hasher.absorb("The quick brown fox jumps over the lazy dog"); 29 | * std::cout << hasher.hexdigest() << '\n'; 30 | * @endcode 31 | * 32 | * @par Example output:\n 33 | * @code 9e107d9d372bb6826bd81d3542a419d6 34 | * @endcode 35 | * 36 | * @sa hasher 37 | */ 38 | typedef hasher md5; 39 | 40 | } // namespace digestpp 41 | 42 | #endif 43 | 44 | -------------------------------------------------------------------------------- /src/thirdparty/algorithm/mixin/null_mixin.hh: -------------------------------------------------------------------------------- 1 | /* 2 | This code is written by kerukuro and released into public domain. 3 | */ 4 | 5 | #ifndef DIGESTPP_MIXINS_NULL_HH 6 | #define DIGESTPP_MIXINS_NULL_HH 7 | 8 | namespace digestpp 9 | { 10 | namespace mixin 11 | { 12 | 13 | /** 14 | * \brief Empty mixin that does not have any additional fuctions. 15 | * \sa hasher 16 | */ 17 | template 18 | struct null_mixin 19 | { 20 | }; 21 | 22 | } // namespace mixin 23 | } // namespace digestpp 24 | 25 | #endif // DIGESTPP_MIXINS_NULL_HH 26 | 27 | -------------------------------------------------------------------------------- /src/thirdparty/algorithm/sha1.hh: -------------------------------------------------------------------------------- 1 | /* 2 | This code is written by kerukuro and released into public domain. 3 | */ 4 | 5 | #ifndef DIGESTPP_ALGORITHM_SHA1_HH 6 | #define DIGESTPP_ALGORITHM_SHA1_HH 7 | 8 | #include "../hasher.hh" 9 | #include "detail/sha1_provider.hh" 10 | 11 | namespace digestpp 12 | { 13 | 14 | /** 15 | * @brief SHA-1 hash function 16 | * 17 | * Note that SHA-1 hash function is considered insecure and is not recommended for new applications. 18 | * 19 | * @hash 20 | * 21 | * @outputsize 160 bits 22 | * 23 | * @defaultsize 160 bits 24 | * 25 | * @par Example:\n 26 | * @code // Output a SHA1 digest of a string 27 | * digestpp::sha1 hasher; 28 | * hasher.absorb("The quick brown fox jumps over the lazy dog"); 29 | * std::cout << hasher.hexdigest() << '\n'; 30 | * @endcode 31 | * 32 | * @par Example output:\n 33 | * @code 2fd4e1c67a2d28fced849ee1bb76e7391b93eb12 34 | * @endcode 35 | * 36 | * @sa hasher 37 | */ 38 | typedef hasher sha1; 39 | 40 | } // namespace digestpp 41 | 42 | #endif 43 | 44 | -------------------------------------------------------------------------------- /src/thirdparty/algorithm/sha3.hh: -------------------------------------------------------------------------------- 1 | /* 2 | This code is written by kerukuro and released into public domain. 3 | */ 4 | 5 | #ifndef DIGESTPP_ALGORITHM_SHA3_HH 6 | #define DIGESTPP_ALGORITHM_SHA3_HH 7 | 8 | #include "../hasher.hh" 9 | #include "detail/sha3_provider.hh" 10 | 11 | namespace digestpp 12 | { 13 | 14 | /** 15 | * @brief SHA-3 hash function 16 | * 17 | * @hash 18 | * 19 | * @outputsize 224 / 256 / 384 / 512 bits 20 | * 21 | * @defaultsize none 22 | * 23 | * @throw std::runtime_error if the requested digest size is not supported 24 | * 25 | * @par Example:\n 26 | * @code // Output a 256-bit SHA-3 digest of a string 27 | * digestpp::sha3 hasher(256); 28 | * hasher.absorb("The quick brown fox jumps over the lazy dog"); 29 | * std::cout << hasher.hexdigest() << '\n'; 30 | * @endcode 31 | * 32 | * @par Example output:\n 33 | * @code 69070dda01975c8c120c3aada1b282394e7f032fa9cf32f4cb2259a0897dfc04 34 | * @endcode 35 | * 36 | * @sa hasher 37 | */ 38 | typedef hasher sha3; 39 | 40 | } // namespace digestpp 41 | 42 | #endif // DIGESTPP_ALGORITHM_SHA3_HH 43 | 44 | 45 | -------------------------------------------------------------------------------- /src/thirdparty/algorithm/sm3.hh: -------------------------------------------------------------------------------- 1 | /* 2 | This code is written by kerukuro and released into public domain. 3 | */ 4 | 5 | #ifndef DIGESTPP_ALGORITHM_SM3_HH 6 | #define DIGESTPP_ALGORITHM_SM3_HH 7 | 8 | #include "../hasher.hh" 9 | #include "detail/sm3_provider.hh" 10 | 11 | namespace digestpp 12 | { 13 | 14 | /** 15 | * @brief SM3 hash function 16 | * 17 | * @hash 18 | * 19 | * @outputsize 256 bits 20 | * 21 | * @defaultsize 256 bits 22 | * 23 | * @par Example:\n 24 | * @code // Output a SM3 digest of a string 25 | * digestpp::sm3 hasher; 26 | * hasher.absorb("The quick brown fox jumps over the lazy dog"); 27 | * std::cout << hasher.hexdigest() << '\n'; 28 | * @endcode 29 | * 30 | * @par Example output:\n 31 | * @code 5fdfe814b8573ca021983970fc79b2218c9570369b4859684e2e4c3fc76cb8ea 32 | * @endcode 33 | * 34 | * @sa hasher 35 | */ 36 | typedef hasher sm3; 37 | 38 | } // namespace digestpp 39 | 40 | #endif 41 | 42 | -------------------------------------------------------------------------------- /src/thirdparty/algorithm/streebog.hh: -------------------------------------------------------------------------------- 1 | /* 2 | This code is written by kerukuro and released into public domain. 3 | */ 4 | 5 | #ifndef DIGESTPP_ALGORITHM_STREEBOG_HH 6 | #define DIGESTPP_ALGORITHM_STREEBOG_HH 7 | 8 | #include "../hasher.hh" 9 | #include "detail/streebog_provider.hh" 10 | 11 | namespace digestpp 12 | { 13 | 14 | /** @brief Streebog hash function 15 | * 16 | * @hash 17 | * 18 | * @outputsize 256 / 512 bits 19 | * 20 | * @defaultsize none 21 | * 22 | * @throw std::runtime_error if the requested digest size is not supported 23 | * 24 | * @par Example:\n 25 | * @code // Output a 256-bit Streebog digest of a string 26 | * digestpp::streebog hasher(256); 27 | * hasher.absorb("The quick brown fox jumps over the lazy dog"); 28 | * std::cout << hasher.hexdigest() << '\n'; 29 | * @endcode 30 | * 31 | * @par Example output:\n 32 | * @code 3e7dea7f2384b6c5a3d0e24aaa29c05e89ddd762145030ec22c71a6db8b2c1f4 33 | * @endcode 34 | * 35 | * @sa hasher 36 | */ 37 | typedef hasher streebog; 38 | 39 | } // namespace digestpp 40 | 41 | #endif // DIGESTPP_ALGORITHM_STREEBOG_HH 42 | 43 | -------------------------------------------------------------------------------- /src/thirdparty/algorithm/whirlpool.hh: -------------------------------------------------------------------------------- 1 | /* 2 | This code is written by kerukuro and released into public domain. 3 | */ 4 | 5 | #ifndef DIGESTPP_ALGORITHM_WHIRLPOOL_HH 6 | #define DIGESTPP_ALGORITHM_WHIRLPOOL_HH 7 | 8 | #include "../hasher.hh" 9 | #include "detail/whirlpool_provider.hh" 10 | 11 | namespace digestpp 12 | { 13 | 14 | /** 15 | * @brief Whirlpool hash function 16 | * 17 | * @hash 18 | * 19 | * @outputsize 512 bits 20 | * 21 | * @defaultsize 512 bits 22 | * 23 | * @par Example:\n 24 | * @code // Output a Whirlpool digest of a string 25 | * digestpp::whirlpool hasher; 26 | * hasher.absorb("The quick brown fox jumps over the lazy dog"); 27 | * std::cout << hasher.hexdigest() << '\n'; 28 | * @endcode 29 | * 30 | * @par Example output:\n 31 | * @code b97de512e91e3828b40d2b0fdce9ceb3c4a71f9bea8d88e75c4fa854df36725fd2b52eb6544edcacd6f8beddfea403cb55ae31f03ad62a5ef54e42ee82c3fb35 32 | * @endcode 33 | * 34 | * @sa hasher 35 | */ 36 | typedef hasher whirlpool; 37 | 38 | } // namespace digestpp 39 | 40 | #endif // DIGESTPP_ALGORITHM_WHIRLPOOL_HH 41 | 42 | -------------------------------------------------------------------------------- /src/thirdparty/cache/fifo_cache_policy.hh: -------------------------------------------------------------------------------- 1 | #ifndef SHIRO_FIFO_CACHE_POLICY_HH 2 | #define SHIRO_FIFO_CACHE_POLICY_HH 3 | 4 | #include "cache_policy.hh" 5 | #include 6 | 7 | namespace caches 8 | { 9 | template class FIFOCachePolicy : public ICachePolicy 10 | { 11 | public: 12 | FIFOCachePolicy() = default; 13 | ~FIFOCachePolicy() = default; 14 | 15 | void Insert(const Key &key) override 16 | { 17 | fifo_queue.emplace_front(key); 18 | } 19 | // handle request to the key-element in a cache 20 | void Touch(const Key &key) override 21 | { 22 | // nothing to do here in the FIFO strategy 23 | } 24 | // handle element deletion from a cache 25 | void Erase(const Key &key) override 26 | { 27 | fifo_queue.pop_back(); 28 | } 29 | 30 | // return a key of a replacement candidate 31 | const Key &ReplCandidate() const override 32 | { 33 | return fifo_queue.back(); 34 | } 35 | 36 | private: 37 | std::list fifo_queue; 38 | }; 39 | } // namespace caches 40 | 41 | #endif // SHIRO_FIFO_CACHE_POLICY_HH 42 | -------------------------------------------------------------------------------- /src/thirdparty/cache/lru_cache_policy.hh: -------------------------------------------------------------------------------- 1 | #ifndef SHIRO_LRU_CACHE_POLICY_HH 2 | #define SHIRO_LRU_CACHE_POLICY_HH 3 | 4 | #include "cache_policy.hh" 5 | #include 6 | #include 7 | 8 | namespace caches 9 | { 10 | template class LRUCachePolicy : public ICachePolicy 11 | { 12 | public: 13 | using lru_iterator = typename std::list::iterator; 14 | 15 | LRUCachePolicy() = default; 16 | ~LRUCachePolicy() = default; 17 | 18 | void Insert(const Key &key) override 19 | { 20 | lru_queue.emplace_front(key); 21 | key_finder[key] = lru_queue.begin(); 22 | } 23 | 24 | void Touch(const Key &key) override 25 | { 26 | // move the touched element at the beginning of the lru_queue 27 | lru_queue.splice(lru_queue.begin(), lru_queue, key_finder[key]); 28 | } 29 | 30 | void Erase(const Key &) override 31 | { 32 | // remove the least recently used element 33 | key_finder.erase(lru_queue.back()); 34 | lru_queue.pop_back(); 35 | } 36 | 37 | // return a key of a displacement candidate 38 | const Key &ReplCandidate() const override 39 | { 40 | return lru_queue.back(); 41 | } 42 | 43 | private: 44 | std::list lru_queue; 45 | std::unordered_map key_finder; 46 | }; 47 | } // namespace caches 48 | 49 | #endif // SHIRO_LRU_CACHE_POLICY_HH 50 | -------------------------------------------------------------------------------- /src/thirdparty/cppcrypto/block_cipher.cc: -------------------------------------------------------------------------------- 1 | /* 2 | This code is written by kerukuro for cppcrypto library (http://cppcrypto.sourceforge.net/) 3 | and released into public domain. 4 | */ 5 | 6 | #include "block_cipher.hh" 7 | 8 | namespace cppcrypto { 9 | block_cipher::~block_cipher() { 10 | } 11 | 12 | void block_cipher::encrypt_blocks(const unsigned char *in, unsigned char *out, size_t n) { 13 | size_t bs = blocksize(); 14 | for (size_t i = 0; i < n; i++) { 15 | encrypt_block(in, out); 16 | in += bs; 17 | out += bs; 18 | } 19 | } 20 | 21 | void block_cipher::decrypt_blocks(const unsigned char *in, unsigned char *out, size_t n) { 22 | size_t bs = blocksize(); 23 | for (size_t i = 0; i < n; i++) { 24 | decrypt_block(in, out); 25 | in += bs; 26 | out += bs; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/thirdparty/cppcrypto/block_cipher.hh: -------------------------------------------------------------------------------- 1 | /* 2 | This code is written by kerukuro for cppcrypto library (http://cppcrypto.sourceforge.net/) 3 | and released into public domain. 4 | */ 5 | 6 | #ifndef CPPCRYPTO_BLOCK_CIPHER_H 7 | #define CPPCRYPTO_BLOCK_CIPHER_H 8 | 9 | #include 10 | #include 11 | 12 | namespace cppcrypto { 13 | 14 | class block_cipher { 15 | public: 16 | enum direction { encryption, decryption }; 17 | 18 | block_cipher() { 19 | } 20 | virtual ~block_cipher(); 21 | 22 | virtual size_t blocksize() const = 0; 23 | virtual size_t keysize() const = 0; 24 | virtual block_cipher *clone() const = 0; 25 | virtual void clear() = 0; 26 | 27 | virtual bool init(const unsigned char *key, block_cipher::direction direction) = 0; 28 | virtual void encrypt_block(const unsigned char *in, unsigned char *out) = 0; 29 | virtual void decrypt_block(const unsigned char *in, unsigned char *out) = 0; 30 | 31 | virtual void encrypt_blocks(const unsigned char *in, unsigned char *out, size_t n); 32 | virtual void decrypt_blocks(const unsigned char *in, unsigned char *out, size_t n); 33 | 34 | private: 35 | block_cipher(const block_cipher &) = delete; 36 | void operator=(const block_cipher &) = delete; 37 | }; 38 | } 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /src/thirdparty/cppcrypto/cpuinfo.hh: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | This code is released under Simplified BSD License (see license.txt). 3 | ******************************************************************************/ 4 | #ifndef CPPCRYPTO_CPUINFO_H 5 | #define CPPCRYPTO_CPUINFO_H 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | namespace cppcrypto 13 | { 14 | 15 | class cpu_info 16 | { 17 | class cpu_info_impl; 18 | public: 19 | static bool sse2() { return impl_.edx1_[26]; } 20 | static bool sse41() { return impl_.ecx1_[19]; } 21 | static bool avx() { return impl_.ecx1_[28]; } 22 | static bool avx2() { return impl_.ebx7_[5]; } 23 | static bool bmi2() { return impl_.ebx7_[8]; } 24 | static bool ssse3() { return impl_.ecx1_[9]; } 25 | static bool aesni() { return impl_.ecx1_[25]; } 26 | static bool mmx() { return impl_.edx1_[23]; } 27 | 28 | 29 | 30 | private: 31 | class cpu_info_impl 32 | { 33 | public: 34 | cpu_info_impl(); 35 | 36 | std::bitset<32> ecx1_; 37 | std::bitset<32> edx1_; 38 | std::bitset<32> ebx7_; 39 | std::bitset<32> ecx7_; 40 | std::bitset<32> ecx81_; 41 | std::bitset<32> edx81_; 42 | 43 | }; 44 | 45 | static const cpu_info_impl impl_; 46 | }; 47 | 48 | } 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /src/thirdparty/detail/absorb_data.hh: -------------------------------------------------------------------------------- 1 | /* 2 | This code is written by kerukuro and released into public domain. 3 | */ 4 | 5 | #ifndef DIGESTPP_DETAIL_ABSORB_DATA_HH 6 | #define DIGESTPP_DETAIL_ABSORB_DATA_HH 7 | 8 | namespace digestpp 9 | { 10 | 11 | namespace detail 12 | { 13 | 14 | // Accumulate data and call the transformation function for full blocks. 15 | template 16 | inline void absorb_bytes(const unsigned char* data, size_t len, size_t bs, size_t bschk, 17 | unsigned char* m, size_t& pos, T& total, TF transform) 18 | { 19 | if (pos && pos + len >= bschk) 20 | { 21 | memcpy(m + pos, data, bs - pos); 22 | transform(m, 1); 23 | len -= bs - pos; 24 | data += bs - pos; 25 | total += bs * 8; 26 | pos = 0; 27 | } 28 | if (len >= bschk) 29 | { 30 | size_t blocks = (len + bs - bschk) / bs; 31 | size_t bytes = blocks * bs; 32 | transform(data, blocks); 33 | len -= bytes; 34 | data += bytes; 35 | total += (bytes)* 8; 36 | } 37 | memcpy(m + pos, data, len); 38 | pos += len; 39 | } 40 | 41 | 42 | } // namespace detail 43 | 44 | } // namespace digestpp 45 | 46 | #endif // DIGESTPP_DETAIL_ABSORB_DATA_HH 47 | 48 | -------------------------------------------------------------------------------- /src/thirdparty/detail/stream_width_fixer.hh: -------------------------------------------------------------------------------- 1 | /* 2 | This code is written by kerukuro and released into public domain. 3 | */ 4 | 5 | #ifndef DIGESTPP_DETAIL_WIDTH_FIXER_HH 6 | #define DIGESTPP_DETAIL_WIDTH_FIXER_HH 7 | 8 | namespace digestpp 9 | { 10 | namespace detail 11 | { 12 | 13 | template 14 | struct stream_width_fixer 15 | { 16 | stream_width_fixer(T value) : v(value) {} 17 | T v; 18 | }; 19 | 20 | template 21 | std::ostream& operator<<(std::ostream& ostr, const stream_width_fixer& value) 22 | { 23 | return ostr << std::setw(N) << value.v; 24 | } 25 | 26 | 27 | } // namespace detail 28 | } // namespace digestpp 29 | 30 | #endif // DIGESTPP_DETAIL_WIDTH_FIXER_HH 31 | 32 | -------------------------------------------------------------------------------- /src/thirdparty/detail/traits.hh: -------------------------------------------------------------------------------- 1 | /* 2 | This code is written by kerukuro and released into public domain. 3 | */ 4 | 5 | #ifndef DIGESTPP_DETAIL_TRAITS_HH 6 | #define DIGESTPP_DETAIL_TRAITS_HH 7 | 8 | namespace digestpp 9 | { 10 | namespace detail 11 | { 12 | 13 | template 14 | struct is_xof 15 | { 16 | static const bool value = T::is_xof; 17 | }; 18 | 19 | template 20 | struct is_byte 21 | { 22 | static const bool value = std::is_same::value || 23 | std::is_same::value || 24 | std::is_same::value; 25 | }; 26 | 27 | } // namespace detail 28 | } // namespace digestpp 29 | 30 | #endif // DIGESTPP_DETAIL_TRAITS_HH 31 | 32 | -------------------------------------------------------------------------------- /src/thirdparty/detail/validate_hash_size.hh: -------------------------------------------------------------------------------- 1 | /* 2 | This code is written by kerukuro and released into public domain. 3 | */ 4 | 5 | #ifndef DIGESTPP_DETAIL_VALIDATE_HASH_SIZE_HH 6 | #define DIGESTPP_DETAIL_VALIDATE_HASH_SIZE_HH 7 | 8 | namespace digestpp 9 | { 10 | namespace detail 11 | { 12 | 13 | // Validate that variable hash is within the list of allowed sizes 14 | inline void validate_hash_size(size_t hs, std::initializer_list set) 15 | { 16 | if (!hs) 17 | throw std::runtime_error("hash size can't be zero"); 18 | 19 | if (std::find(set.begin(), set.end(), hs)) 20 | return; 21 | 22 | throw std::runtime_error("invalid hash size"); 23 | } 24 | 25 | // Validate variable hash size up to max bits 26 | inline void validate_hash_size(size_t hs, size_t max) 27 | { 28 | if (!hs) 29 | throw std::runtime_error("hash size can't be zero"); 30 | 31 | if (hs % 8) 32 | throw std::runtime_error("non-byte hash sizes are not supported"); 33 | 34 | if (hs > max) 35 | throw std::runtime_error("invalid hash size"); 36 | } 37 | 38 | } // namespace detail 39 | } // namespace digestpp 40 | 41 | #endif // DIGESTPP_DETAIL_VALIDATE_HASH_SIZE_HH 42 | 43 | -------------------------------------------------------------------------------- /src/thirdparty/digestpp.hh: -------------------------------------------------------------------------------- 1 | /* 2 | This code is written by kerukuro and released into public domain. 3 | */ 4 | 5 | #include "hasher.hh" 6 | #include "algorithm/sha2.hh" 7 | #include "algorithm/sha3.hh" 8 | #include "algorithm/shake.hh" 9 | #include "algorithm/skein.hh" 10 | #include "algorithm/blake.hh" 11 | #include "algorithm/blake2.hh" 12 | #include "algorithm/groestl.hh" 13 | #include "algorithm/jh.hh" 14 | #include "algorithm/md5.hh" 15 | #include "algorithm/sha1.hh" 16 | #include "algorithm/sm3.hh" 17 | #include "algorithm/streebog.hh" 18 | #include "algorithm/whirlpool.hh" 19 | #include "algorithm/k12m14.hh" 20 | #include "algorithm/kupyna.hh" 21 | #include "algorithm/kmac.hh" 22 | -------------------------------------------------------------------------------- /src/users/user_activity.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_USER_ACTIVITY_HH 20 | #define SHIRO_USER_ACTIVITY_HH 21 | 22 | #include "../utils/play_mode.hh" 23 | 24 | namespace shiro::users::activity { 25 | 26 | void init(); 27 | 28 | // A user is inactive if they haven't submitted a score in over 90 days 29 | bool is_inactive(int32_t id, const utils::play_mode &mode); 30 | 31 | } 32 | 33 | #endif //SHIRO_USER_ACTIVITY_HH 34 | -------------------------------------------------------------------------------- /src/users/user_timeout.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_USER_TIMEOUT_HH 20 | #define SHIRO_USER_TIMEOUT_HH 21 | 22 | namespace shiro::users::timeout { 23 | 24 | void init(); 25 | 26 | } 27 | 28 | #endif //SHIRO_USER_TIMEOUT_HH 29 | -------------------------------------------------------------------------------- /src/utils/bot_utils.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_BOT_UTILS_HH 20 | #define SHIRO_BOT_UTILS_HH 21 | 22 | #include 23 | 24 | #include "../users/user.hh" 25 | 26 | namespace shiro::utils::bot { 27 | 28 | void handle(io::layouts::message message, std::shared_ptr user); 29 | 30 | void respond(std::string message, std::shared_ptr user, std::string channel, bool only_user = false); 31 | 32 | } 33 | 34 | #endif //SHIRO_BOT_UTILS_HH 35 | -------------------------------------------------------------------------------- /src/utils/escaper.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include 20 | #include 21 | 22 | #include "escaper.hh" 23 | 24 | std::string shiro::utils::escaper::make_safe(std::string input) { 25 | std::transform(input.begin(), input.end(), input.begin(), ::tolower); 26 | 27 | input.erase(std::remove_if(input.begin(), input.end(), [](char c) { 28 | return !std::isalnum(c) && !std::isspace(c); 29 | }), input.end()); 30 | 31 | std::replace(input.begin(), input.end(), ' ', '_'); 32 | return input; 33 | } 34 | -------------------------------------------------------------------------------- /src/utils/escaper.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_ESCAPER_HH 20 | #define SHIRO_ESCAPER_HH 21 | 22 | #include 23 | 24 | namespace shiro::utils::escaper { 25 | 26 | std::string make_safe(std::string input); 27 | 28 | } 29 | 30 | #endif //SHIRO_ESCAPER_HH 31 | -------------------------------------------------------------------------------- /src/utils/filesystem.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_FILESYSTEM_UTILS 20 | #define SHIRO_FILESYSTEM_UTILS 21 | 22 | #include 23 | 24 | // Being so close to C++20, almost all major compilers support C++17 filesystem now 25 | namespace fs = std::filesystem; 26 | 27 | namespace shiro::utils::filesystem { 28 | 29 | // Fix for MSVC's stl preferring wchar_t over char 30 | inline constexpr char preferred_separator = (char) fs::path::preferred_separator; 31 | 32 | inline std::string combine(const std::string &a, const std::string &b) { 33 | return a + preferred_separator + b; 34 | } 35 | 36 | } 37 | 38 | #endif //SHIRO_FILESYSTEM_UTILS 39 | -------------------------------------------------------------------------------- /src/utils/leb128.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_LEB128_HH 20 | #define SHIRO_LEB128_HH 21 | 22 | #include 23 | 24 | #include "../io/osu_buffer.hh" 25 | 26 | namespace shiro::utils::leb128 { 27 | 28 | uint64_t read_leb128(io::buffer &buffer); 29 | 30 | void write_leb128(io::buffer &buffer, uint64_t value); 31 | 32 | } 33 | 34 | #endif //SHIRO_LEB128_HH 35 | -------------------------------------------------------------------------------- /src/utils/login_responses.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_LOGIN_RESPONSES_HH 20 | #define SHIRO_LOGIN_RESPONSES_HH 21 | 22 | #include 23 | 24 | namespace shiro::utils { 25 | 26 | enum class login_responses : int32_t { 27 | invalid_credentials = -1, 28 | outdated_client = -2, 29 | user_banned = -3, 30 | multiaccount_detected = -4, 31 | server_error = -5, 32 | cutting_edge_multiplayer = -6, 33 | account_password_reset = -7, 34 | verification_required = -8 35 | }; 36 | 37 | } 38 | 39 | #endif // SHIRO_LOGIN_RESPONSES_HH 40 | -------------------------------------------------------------------------------- /src/utils/match_team_type.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_MATCH_TEAM_TYPE_HH 20 | #define SHIRO_MATCH_TEAM_TYPE_HH 21 | 22 | #include 23 | 24 | namespace shiro::utils { 25 | 26 | enum class match_team_type : uint8_t { 27 | head_to_head = 0, 28 | tag_coop = 1, 29 | team_vs = 2, 30 | tag_team_vs = 3 31 | 32 | }; 33 | 34 | inline bool is_team(uint8_t type) { 35 | return type == (uint8_t) match_team_type::team_vs || type == (uint8_t) match_team_type::tag_team_vs; 36 | } 37 | 38 | } 39 | 40 | #endif // SHIRO_MATCH_TEAM_TYPE_HH 41 | -------------------------------------------------------------------------------- /src/utils/osu_permissions.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_OSU_PERMISSIONS_HH 20 | #define SHIRO_OSU_PERMISSIONS_HH 21 | 22 | #include 23 | 24 | namespace shiro::utils { 25 | 26 | enum class osu_permissions : uint8_t { 27 | none = 0 << 0, // Light yellow 28 | normal = 1 << 0, // Light yellow 29 | bat = 1 << 1, // Red 30 | supporter = 1 << 2, // Yellow 31 | friend_ = 1 << 3, // Light blue 32 | peppy = 1 << 4, // Blue 33 | tournament = 1 << 5 // This bit will never be sent by us in user presence 34 | }; 35 | 36 | } 37 | 38 | #endif // SHIRO_OSU_PERMISSIONS_HH 39 | -------------------------------------------------------------------------------- /src/utils/osu_string.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include "../io/osu_buffer.hh" 20 | #include "leb128.hh" 21 | #include "osu_string.hh" 22 | 23 | std::string shiro::utils::osu_string(std::string value, bool nullable) { 24 | io::buffer buffer; 25 | 26 | if (value.empty()) { 27 | if (nullable) { 28 | buffer.write(0); 29 | } else { 30 | buffer.write(11); 31 | buffer.write(0); 32 | } 33 | } else { 34 | buffer.write(11); 35 | utils::leb128::write_leb128(buffer, value.size()); 36 | buffer.write_string(value); 37 | } 38 | 39 | return buffer.serialize(); 40 | } 41 | -------------------------------------------------------------------------------- /src/utils/osu_string.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_OSU_STRING_HH 20 | #define SHIRO_OSU_STRING_HH 21 | 22 | #include 23 | 24 | namespace shiro::utils { 25 | 26 | std::string osu_string(std::string value, bool nullable = false); 27 | 28 | } 29 | 30 | #endif //SHIRO_OSU_STRING_HH 31 | -------------------------------------------------------------------------------- /src/utils/play_mode.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include "play_mode.hh" 20 | 21 | std::string shiro::utils::play_mode_to_string(shiro::utils::play_mode mode, bool long_name) { 22 | switch (mode) { 23 | case play_mode::taiko: 24 | return long_name ? "osu!taiko" : "taiko"; 25 | case play_mode::fruits: 26 | return long_name ? "osu!catch" : "ctb"; 27 | case play_mode::mania: 28 | return long_name ? "osu!mania" : "mania"; 29 | case play_mode::standard: 30 | default: 31 | return long_name ? "osu!" : "std"; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/utils/play_mode.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_PLAY_MODE_HH 20 | #define SHIRO_PLAY_MODE_HH 21 | 22 | #include 23 | #include 24 | 25 | namespace shiro::utils { 26 | 27 | enum class play_mode : uint8_t { 28 | standard = 0, 29 | taiko = 1, 30 | fruits = 2, 31 | mania = 3 32 | 33 | }; 34 | 35 | std::string play_mode_to_string(play_mode mode, bool long_name = true); 36 | 37 | } 38 | 39 | #endif //SHIRO_PLAY_MODE_HH 40 | -------------------------------------------------------------------------------- /src/utils/punishment_type.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_PUNISHMENT_TYPE_HH 20 | #define SHIRO_PUNISHMENT_TYPE_HH 21 | 22 | #include 23 | 24 | namespace shiro::utils { 25 | 26 | enum class punishment_type : uint16_t { 27 | kick = 0, 28 | silence = 1, 29 | restrict = 2, 30 | ban = 3 31 | }; 32 | 33 | } 34 | 35 | #endif // SHIRO_PUNISHMENT_TYPE_HH 36 | -------------------------------------------------------------------------------- /src/utils/string_utils.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include 20 | 21 | #include "string_utils.hh" 22 | 23 | bool shiro::utils::strings::to_bool(std::string src) { 24 | try { 25 | return boost::lexical_cast(src); 26 | } catch (const boost::bad_lexical_cast &ex) { 27 | std::transform(src.begin(), src.end(), src.begin(), ::tolower); 28 | return src == "true"; 29 | } 30 | } 31 | 32 | std::string shiro::utils::strings::to_string(bool src) { 33 | return src ? "true" : "false"; 34 | } 35 | -------------------------------------------------------------------------------- /src/utils/string_utils.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_STRING_UTILS_HH 20 | #define SHIRO_STRING_UTILS_HH 21 | 22 | #include 23 | #include 24 | 25 | namespace shiro::utils::strings { 26 | 27 | bool to_bool(std::string src); 28 | 29 | std::string to_string(bool src); 30 | 31 | } 32 | 33 | #endif //SHIRO_STRING_UTILS_HH 34 | -------------------------------------------------------------------------------- /src/utils/time_utils.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_TIME_UTILS_HH 20 | #define SHIRO_TIME_UTILS_HH 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | namespace shiro::utils::time { 28 | 29 | extern int64_t unix_epoch_ticks; 30 | 31 | extern std::unordered_map duration_mapping; 32 | 33 | int64_t get_current_time_ticks(); 34 | 35 | // Returns seconds of the parsed time string, e.g input: "15min" returns 900 (seconds) 36 | std::optional parse_time_string(const std::string &input); 37 | 38 | } 39 | 40 | #endif //SHIRO_TIME_UTILS_HH 41 | -------------------------------------------------------------------------------- /src/views/index_view.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * shiro - High performance, high quality osu!Bancho C++ re-implementation 3 | * Copyright (C) 2018-2020 Marc3842h, czapek 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SHIRO_INDEX_VIEW_HH 20 | #define SHIRO_INDEX_VIEW_HH 21 | 22 | #include 23 | 24 | namespace shiro::views::index { 25 | 26 | void replace_hash(std::string &view); 27 | 28 | void replace_time(std::string &view); 29 | 30 | std::string get_view(); 31 | 32 | } 33 | 34 | #endif //SHIRO_INDEX_VIEW_HH 35 | --------------------------------------------------------------------------------