Guest User

Untitled

a guest
Oct 17th, 2020
30
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Table: `id`, `timestamp`, `server_id`, `invoker_database_id`, `invoker_name`, `action`, `property`, `value_old`, `value_new`
  2. class ServerEditActionLogger : public TypedActionLogger<std::string_view, std::string, std::string> {
  3. public:
  4. explicit ServerEditActionLogger(ActionLogger* impl, LogGroupSettings* group_settings);
  5.  
  6. bool setup(int, std::string &) override;
  7. void log_server_edit(
  8. ServerId /* server id */,
  9. const std::shared_ptr<ConnectedClient>& /* editor (may be null) */,
  10. const property::PropertyDescription& /* property */,
  11. const std::string& /* old value */,
  12. const std::string& /* new value */);
  13. };
  14.  
  15. enum struct ServerCreateReason {
  16. USER_ACTION,
  17. SNAPSHOT_DEPLOY,
  18. INITIAL_SERVER,
  19. MAX
  20. };
  21. constexpr static std::array<std::string_view, (int) ServerCreateReason::MAX> kServerCreateReasonName {
  22. "user-action",
  23. "snapshot-deploy",
  24. "initial-server"
  25. };
  26.  
  27. //Table: `id`, `timestamp`, `server_id`, `invoker_database_id`, `invoker_name`, `action`, `reason`
  28. class ServerActionLogger : public TypedActionLogger<std::string_view> {
  29. public:
  30. explicit ServerActionLogger(ActionLogger* impl, LogGroupSettings* group_settings);
  31.  
  32. bool setup(int, std::string &) override;
  33.  
  34. void log_server_create(
  35. ServerId /* server id */,
  36. const std::shared_ptr<ConnectedClient>& /* editor (may be null) */,
  37. ServerCreateReason /* create reason */);
  38.  
  39. void log_server_delete(
  40. ServerId /* server id */,
  41. const std::shared_ptr<ConnectedClient>& /* editor (may be null) */);
  42.  
  43. void log_server_start(
  44. ServerId /* server id */,
  45. const std::shared_ptr<ConnectedClient>& /* editor (may be null) */);
  46.  
  47. void log_server_stop(
  48. ServerId /* server id */,
  49. const std::shared_ptr<ConnectedClient>& /* editor (may be null) */);
  50. };
  51.  
  52. enum struct ChannelDeleteReason {
  53. PARENT_DELETED,
  54. USER_ACTION,
  55. SERVER_STOP,
  56. EMPTY,
  57. MAX
  58. };
  59. constexpr static std::array<std::string_view, (int) ChannelDeleteReason::MAX> kChannelDeleteReasonName {
  60. "parent-deleted",
  61. "user-action",
  62. "server-stop",
  63. "empty"
  64. };
  65.  
  66. enum struct ChannelType {
  67. TEMPORARY,
  68. SEMI_PERMANENT,
  69. PERMANENT,
  70. MAX
  71. };
  72. constexpr static std::array<std::string_view, (int) ChannelType::MAX> kChannelTypeName {
  73. "temporary",
  74. "semi-permanent",
  75. "permanent"
  76. };
  77.  
  78. //Table: `id`, `timestamp`, `server_id`, `invoker_database_id`, `invoker_name`, `action`, `property` (may be the delete reason), `value_old`, `value_new`
  79. class ChannelActionLogger : public TypedActionLogger<ChannelId, std::string_view, std::string, std::string> {
  80. public:
  81. explicit ChannelActionLogger(ActionLogger* impl, LogGroupSettings* group_settings);
  82.  
  83. bool setup(int, std::string &) override;
  84.  
  85. void log_channel_create(
  86. ServerId /* server id */,
  87. const std::shared_ptr<ConnectedClient>& /* editor (may be null) */,
  88. ChannelId /* channel id */,
  89. ChannelType /* type */);
  90.  
  91. void log_channel_move(
  92. ServerId /* server id */,
  93. const std::shared_ptr<ConnectedClient>& /* editor (may be null) */,
  94. ChannelId /* channel id */,
  95. ChannelId /* old parent channel */,
  96. ChannelId /* new parent channel */,
  97. ChannelId /* old channel order */,
  98. ChannelId /* new channel order */);
  99.  
  100. void log_channel_edit(
  101. ServerId /* server id */,
  102. const std::shared_ptr<ConnectedClient>& /* editor (may be null) */,
  103. ChannelId /* channel id */,
  104. const property::PropertyDescription& /* property */,
  105. const std::string& /* old value */,
  106. const std::string& /* new value */);
  107.  
  108. void log_channel_delete(
  109. ServerId /* server id */,
  110. const std::shared_ptr<ConnectedClient>& /* editor (may be null) */,
  111. ChannelId /* channel id */,
  112. ChannelDeleteReason /* reason */);
  113. };
  114.  
  115. enum struct PermissionTarget {
  116. SERVER_GROUP,
  117. CHANNEL_GROUP,
  118. CHANNEL,
  119. CLIENT,
  120. CLIENT_CHANNEL,
  121. PLAYLIST,
  122. PLAYLIST_CLIENT,
  123.  
  124. MAX
  125. };
  126. constexpr static std::array<std::string_view, (int) PermissionTarget::MAX> kPermissionTargetName {
  127. "server-group",
  128. "channel-group",
  129. "channel",
  130. "client",
  131. "client-channel",
  132. "playlist",
  133. "playlist-client"
  134. };
  135.  
  136. //Table: `id`, `timestamp`, `server_id`, `invoker_database_id`, `invoker_name`, `action`, `target`, `id1`, `id1_name`, `id2`, `id2_name`, `permission`, `old_value`, `old_negated`, `old_skipped`, `new_value`, `new_negated`, `new_skipped`
  137. class PermissionActionLogger : public TypedActionLogger<std::string_view, uint64_t, std::string, uint64_t, std::string, std::string, int32_t, bool, bool, int32_t, bool, bool> {
  138. public:
  139. explicit PermissionActionLogger(ActionLogger* impl, LogGroupSettings* group_settings);
  140.  
  141. bool setup(int, std::string &) override;
  142.  
  143. void log_permission_add_value(
  144. ServerId /* server id */,
  145. const std::shared_ptr<ConnectedClient>& /* editor (may be null) */,
  146. ts::server::log::PermissionTarget /* target */,
  147. uint64_t /* id1 */, const std::string& /* id1 name */,
  148. uint64_t /* id2 */, const std::string& /* id2 name */,
  149. const permission::PermissionTypeEntry& /* permission */,
  150. int32_t /* value */,
  151. bool /* negated */,
  152. bool /* skipped */);
  153.  
  154. void log_permission_add_grant(
  155. ServerId /* server id */,
  156. const std::shared_ptr<ConnectedClient>& /* editor (may be null) */,
  157. ts::server::log::PermissionTarget /* target */,
  158. uint64_t /* id1 */, const std::string& /* id1 name */,
  159. uint64_t /* id2 */, const std::string& /* id2 name */,
  160. const permission::PermissionTypeEntry& /* permission */,
  161. int32_t /* value */);
  162.  
  163. void log_permission_edit_value(
  164. ServerId /* server id */,
  165. const std::shared_ptr<ConnectedClient>& /* editor (may be null) */,
  166. ts::server::log::PermissionTarget /* target */,
  167. uint64_t /* id1 */, const std::string& /* id1 name */,
  168. uint64_t /* id2 */, const std::string& /* id2 name */,
  169. const permission::PermissionTypeEntry& /* permission */,
  170. int32_t /* old value */,
  171. bool /* old negated */,
  172. bool /* old skipped */,
  173. int32_t /* new value */,
  174. bool /* new negated */,
  175. bool /* new skipped */);
  176.  
  177. void log_permission_edit_grant(
  178. ServerId /* server id */,
  179. const std::shared_ptr<ConnectedClient>& /* editor (may be null) */,
  180. ts::server::log::PermissionTarget /* target */,
  181. uint64_t /* id1 */, const std::string& /* id1 name */,
  182. uint64_t /* id2 */, const std::string& /* id2 name */,
  183. const permission::PermissionTypeEntry& /* permission */,
  184. int32_t /* old value */,
  185. int32_t /* new value */);
  186.  
  187. void log_permission_remove_value(
  188. ServerId /* server id */,
  189. const std::shared_ptr<ConnectedClient>& /* editor (may be null) */,
  190. ts::server::log::PermissionTarget /* target */,
  191. uint64_t /* id1 */, const std::string& /* id1 name */,
  192. uint64_t /* id2 */, const std::string& /* id2 name */,
  193. const permission::PermissionTypeEntry& /* permission */,
  194. int32_t /* old value */,
  195. bool /* old negate */,
  196. bool /* old skip */);
  197.  
  198. void log_permission_remove_grant(
  199. ServerId /* server id */,
  200. const std::shared_ptr<ConnectedClient>& /* editor (may be null) */,
  201. ts::server::log::PermissionTarget /* target */,
  202. uint64_t /* id1 */, const std::string& /* id1 name */,
  203. uint64_t /* id2 */, const std::string& /* id2 name */,
  204. const permission::PermissionTypeEntry& /* permission */,
  205. int32_t /* old value */);
  206. };
  207.  
  208. enum struct GroupType {
  209. NORMAL,
  210. TEMPLATE,
  211. QUERY,
  212. MAX
  213. };
  214. constexpr static std::array<std::string_view, (int) GroupType::MAX> kGroupTypeName {
  215. "normal",
  216. "template",
  217. "query"
  218. };
  219.  
  220. enum struct GroupTarget {
  221. SERVER,
  222. CHANNEL,
  223. MAX
  224. };
  225. constexpr static std::array<std::string_view, (int) GroupTarget::MAX> kGroupTargetName {
  226. "server",
  227. "channel"
  228. };
  229.  
  230. //Table: `id`, `timestamp`, `server_id`, `invoker_database_id`, `invoker_name`, `action`, `type`, `target`, `group`, `group_name`, `source`, `source_name`
  231. class GroupActionLogger : public TypedActionLogger<std::string_view, std::string_view, uint64_t, std::string, uint64_t, std::string> {
  232. public:
  233. explicit GroupActionLogger(ActionLogger* impl, LogGroupSettings* group_settings);
  234.  
  235. bool setup(int, std::string &) override;
  236.  
  237. void log_group_create(
  238. ServerId /* server id */,
  239. const std::shared_ptr<ConnectedClient>& /* editor (may be null) */,
  240. GroupTarget /* target */,
  241. GroupType /* type */,
  242. uint64_t /* group */,
  243. const std::string& /* group name */,
  244. uint64_t /* source */,
  245. const std::string& /* source name */
  246. );
  247.  
  248. void log_group_rename(
  249. ServerId /* server id */,
  250. const std::shared_ptr<ConnectedClient>& /* editor (may be null) */,
  251. GroupTarget /* target */,
  252. GroupType /* type */,
  253. uint64_t /* group */,
  254. const std::string& /* target name */,
  255. const std::string& /* source name */
  256. );
  257.  
  258. void log_group_permission_copy(
  259. ServerId /* server id */,
  260. const std::shared_ptr<ConnectedClient>& /* editor (may be null) */,
  261. GroupTarget /* target */,
  262. GroupType /* type */,
  263. uint64_t /* target group */,
  264. const std::string& /* target group name */,
  265. uint64_t /* source */,
  266. const std::string& /* source name */
  267. );
  268.  
  269. void log_group_delete(
  270. ServerId /* server id */,
  271. const std::shared_ptr<ConnectedClient>& /* editor (may be null) */,
  272. GroupTarget /* target */,
  273. GroupType /* type */,
  274. uint64_t /* group */,
  275. const std::string& /* group name */
  276. );
  277. };
  278.  
  279.  
  280. //Table: `id`, `timestamp`, `server_id`, `invoker_database_id`, `invoker_name`, `action`, `target`, `group`, `group_name`, `client`, `client_name`
  281. class GroupAssignmentActionLogger : public TypedActionLogger<std::string_view, uint64_t, std::string, uint64_t, std::string> {
  282. public:
  283. explicit GroupAssignmentActionLogger(ActionLogger *impl, LogGroupSettings* group_settings);
  284.  
  285. bool setup(int, std::string &) override;
  286.  
  287. void log_group_assignment_add(
  288. ServerId /* server id */,
  289. const std::shared_ptr<ConnectedClient>& /* editor (may be null) */,
  290. GroupTarget /* target */,
  291. uint64_t /* group */,
  292. const std::string& /* group name */,
  293. uint64_t /* client */,
  294. const std::string& /* client name */
  295. );
  296.  
  297. void log_group_assignment_remove(
  298. ServerId /* server id */,
  299. const std::shared_ptr<ConnectedClient>& /* editor (may be null) */,
  300. GroupTarget /* target */,
  301. uint64_t /* group */,
  302. const std::string& /* group name */,
  303. uint64_t /* client */,
  304. const std::string& /* client name */
  305. );
  306. };
  307.  
  308. //Table: `id`, `timestamp`, `server_id`, `invoker_database_id`, `invoker_name`, `action`, `target_client`, `target_client_name`, `source_channel`, `source_channel_name`, `target_channel`, `target_channel_name`
  309. class ClientChannelActionLogger : public TypedActionLogger<uint64_t, std::string, uint64_t, std::string, uint64_t, std::string> {
  310. public:
  311. explicit ClientChannelActionLogger(ActionLogger *impl, LogGroupSettings* group_settings);
  312.  
  313. bool setup(int, std::string &) override;
  314.  
  315.  
  316. void log_client_join(
  317. ServerId /* server id */,
  318. const std::shared_ptr<ConnectedClient>& /* subject */,
  319. uint64_t /* target channel */,
  320. const std::string& /* target channel name */
  321. );
  322.  
  323. void log_client_move(
  324. ServerId /* server id */,
  325. const std::shared_ptr<ConnectedClient>& /* issuer (may be null) */,
  326. const std::shared_ptr<ConnectedClient>& /* subject */,
  327. uint64_t /* target channel */,
  328. const std::string& /* target channel name */,
  329. uint64_t /* source channel */,
  330. const std::string& /* source channel name */
  331. );
  332.  
  333. void log_client_kick(
  334. ServerId /* server id */,
  335. const std::shared_ptr<ConnectedClient>& /* issuer (may be null) */,
  336. const std::shared_ptr<ConnectedClient>& /* subject */,
  337. uint64_t /* target channel */,
  338. const std::string& /* target channel name */,
  339. uint64_t /* source channel */,
  340. const std::string& /* source channel name */
  341. );
  342.  
  343. void log_client_leave(
  344. ServerId /* server id */,
  345. const std::shared_ptr<ConnectedClient>& /* subject */,
  346. uint64_t /* source channel */,
  347. const std::string& /* source channel name */
  348. );
  349. };
  350.  
  351. //Table: `id`, `timestamp`, `server_id`, `invoker_database_id`, `invoker_name`, `action`, `target_client`, `target_client_name`, `property`, `old_value`, `new_value`
  352. class ClientEditActionLogger : public TypedActionLogger<uint64_t, std::string, std::string_view, std::string, std::string> {
  353. public:
  354. explicit ClientEditActionLogger(ActionLogger *impl, LogGroupSettings* group_settings);
  355.  
  356. bool setup(int, std::string &) override;
  357.  
  358. void log_client_edit(
  359. ServerId /* server id */,
  360. const std::shared_ptr<ConnectedClient>& /* issuer (may be null) */,
  361. const std::shared_ptr<ConnectedClient>& /* subject */,
  362. const property::PropertyDescription& /* property */,
  363. const std::string& /* old value */,
  364. const std::string& /* new value */
  365. );
  366. };
  367.  
  368. //Table: `id`, `timestamp`, `server_id`, `invoker_database_id`, `invoker_name`, `action`, `source_channel_id`, `source_path`, `target_channel_id`, `target_path`
  369. class FilesActionLogger : public TypedActionLogger<uint64_t, std::string, uint64_t, std::string> {
  370. public:
  371. explicit FilesActionLogger(ActionLogger *impl, LogGroupSettings* group_settings);
  372.  
  373. bool setup(int, std::string &) override;
  374.  
  375. void log_file_upload(
  376. ServerId /* server id */,
  377. const std::shared_ptr<ConnectedClient>& /* invoker */,
  378. uint64_t /* channel id */,
  379. const std::string& /* path */
  380. );
  381.  
  382. void log_file_download(
  383. ServerId /* server id */,
  384. const std::shared_ptr<ConnectedClient>& /* invoker */,
  385. uint64_t /* channel id */,
  386. const std::string& /* path */
  387. );
  388.  
  389. void log_file_rename(
  390. ServerId /* server id */,
  391. const std::shared_ptr<ConnectedClient>& /* invoker */,
  392. uint64_t /* source channel id */,
  393. const std::string& /* source name */,
  394. uint64_t /* target channel id */,
  395. const std::string& /* target name */
  396. );
  397.  
  398. void log_file_delete(
  399. ServerId /* server id */,
  400. const std::shared_ptr<ConnectedClient>& /* invoker */,
  401. uint64_t /* channel id */,
  402. const std::string& /* source name */
  403. );
  404.  
  405. void log_file_directory_create(
  406. ServerId /* server id */,
  407. const std::shared_ptr<ConnectedClient>& /* invoker */,
  408. uint64_t /* channel id */,
  409. const std::string& /* path */
  410. );
  411. };
  412.  
  413. //Table: `id`, `timestamp`, `server_id`, `invoker_database_id`, `invoker_name`, `action`, `message`
  414. class CustomLogger : public TypedActionLogger<std::string> {
  415. public:
  416. explicit CustomLogger(ActionLogger *impl, LogGroupSettings* group_settings);
  417.  
  418. bool setup(int, std::string &) override;
  419.  
  420.  
  421. void add_log_message(
  422. ServerId /* server id */,
  423. const std::shared_ptr<ConnectedClient>& /* issuer (may be null) */,
  424. const std::string& /* message */
  425. );
  426. };
  427.  
  428. enum struct QueryAuthenticateResult {
  429. SUCCESS,
  430. UNKNOWN_USER,
  431. INVALID_PASSWORD,
  432. MAX
  433. };
  434.  
  435. constexpr static std::array<std::string_view, (int) QueryAuthenticateResult::MAX> kQueryAuthenticateResultName {
  436. "success",
  437. "unknown-user",
  438. "invalid-password"
  439. };
  440.  
  441. //Table: `id`, `timestamp`, `server_id`, `invoker_database_id`, `invoker_name`, `action`, `ip`, `username`, `result`
  442. class QueryAuthenticateLogger : public TypedActionLogger<std::string, std::string, std::string_view> {
  443. public:
  444. explicit QueryAuthenticateLogger(ActionLogger *impl, LogGroupSettings* group_settings);
  445.  
  446. bool setup(int, std::string &) override;
  447.  
  448. void log_query_authenticate(
  449. ServerId /* server id */,
  450. const std::shared_ptr<QueryClient>& /* query */,
  451. const std::string& /* username (if empty he logs out) */,
  452. QueryAuthenticateResult /* result */
  453. );
  454. };
  455.  
  456. //Table: `id`, `timestamp`, `server_id`, `invoker_database_id`, `invoker_name`, `action`, `ip`, `username`, `source_server`
  457. class QueryServerLogger : public TypedActionLogger<std::string, std::string, bool> {
  458. public:
  459. explicit QueryServerLogger(ActionLogger *impl, LogGroupSettings* group_settings);
  460.  
  461. bool setup(int, std::string &) override;
  462.  
  463. void log_query_switch(
  464. const std::shared_ptr<QueryClient>& /* query */,
  465. const std::string& /* authenticated username */,
  466. ServerId /* source */,
  467. ServerId /* target */
  468. );
  469. };
RAW Paste Data