| 1 | #pragma once |
| 2 | |
| 3 | /// @file |
| 4 | /// @brief Server ACL events. |
| 5 | |
| 6 | #include <string> |
| 7 | #include <vector> |
| 8 | |
| 9 | #if __has_include(<nlohmann/json_fwd.hpp>) |
| 10 | #include <nlohmann/json_fwd.hpp> |
| 11 | #else |
| 12 | #include <nlohmann/json.hpp> |
| 13 | #endif |
| 14 | |
| 15 | namespace mtx { |
| 16 | namespace events { |
| 17 | namespace state { |
| 18 | |
| 19 | //! Content for the `m.room.server_acl` event. |
| 20 | // |
| 21 | //! An event to indicate which servers are permitted to participate in the room. Server ACLs may |
| 22 | //! allow or deny groups of hosts. All servers participating in the room, including those that are |
| 23 | //! denied, are expected to uphold the server ACL. Servers that do not uphold the ACLs MUST be added |
| 24 | //! to the denied hosts list in order for the ACLs to remain effective. |
| 25 | struct ServerAcl |
| 26 | { |
| 27 | //! The server names to allow in the room, excluding any port information. Wildcards may be used |
| 28 | //! to cover a wider range of hosts, where * matches zero or more characters and ? matches |
| 29 | //! exactly one character. |
| 30 | //! |
| 31 | //! This defaults to an empty list when not provided, effectively disallowing every server. |
| 32 | std::vector<std::string> allow; |
| 33 | |
| 34 | //! The server names to disallow in the room, excluding any port information. Wildcards may be |
| 35 | //! used to cover a wider range of hosts, where * matches zero or more characters and ? matches |
| 36 | //! exactly one character. |
| 37 | //! |
| 38 | //! This defaults to an empty list when not provided. |
| 39 | std::vector<std::string> deny; |
| 40 | |
| 41 | //! True to allow server names that are IP address literals. False to deny. Defaults to true if |
| 42 | //! missing or otherwise not a boolean. |
| 43 | //! |
| 44 | //! This is strongly recommended to be set to false as servers running with IP literal names are |
| 45 | //! strongly discouraged in order to require legitimate homeservers to be backed by a valid |
| 46 | //! registered domain name. |
| 47 | bool allow_ip_literals = true; |
| 48 | |
| 49 | //! Deserialization method needed by @p nlohmann::json. |
| 50 | friend void from_json(const nlohmann::json &obj, ServerAcl &content); |
| 51 | |
| 52 | //! Serialization method needed by @p nlohmann::json. |
| 53 | friend void to_json(nlohmann::json &obj, const ServerAcl &content); |
| 54 | }; |
| 55 | |
| 56 | } // namespace state |
| 57 | } // namespace events |
| 58 | } // namespace mtx |