shitflow.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. // acetone, 2024
  2. // I hate copyright of any kind. This is a public domain.
  3. // Original source: https://notabug.org/acetone/shitflow
  4. /**********************************************************************************
  5. *** MINI INLINE DOCUMENTATION ***
  6. Dialog protocol: request-response.
  7. If there is no response to the request, the connection is closed by timeout.
  8. A fatal error message is transmitted outside of the sequential dialog.
  9. After sending, the sender closes the connection.
  10. If the message could not be read correctly, it is not a fatal error.
  11. The message_validation_error_no_action response is used so that the sender
  12. repeats the sending.
  13. In protocol terminology, the one who provides access to download files
  14. is the "publisher". The other party receiving is the "consumer".
  15. It is assumed that the implementation allows multiple consumers to connect.
  16. The transfer payload (file) is called the "point".
  17. The v0 protocol uses the following types of messaging objects:
  18. - message:
  19. - request:
  20. - handshake,
  21. - get_point_declaration_list,
  22. - get_chunk,
  23. - close_connection_on_success
  24. - response:
  25. - handshake,
  26. - point_does_not_exists,
  27. - chunk_does_not_exists,
  28. - message_validation_error_no_action,
  29. - point_declaration_list,
  30. - chunk
  31. - fatal_error:
  32. - reading_timeout,
  33. - other
  34. The v0 protocol uses the following types of data structures:
  35. - handshake
  36. - point_declaration
  37. - chunk
  38. Data structures have versions.
  39. This provides the potential for extending the protocol without major changes.
  40. *** Message scheme:
  41. +------------------------+
  42. | DESCRIPTION CRC32 | 4 bytes
  43. +------------------------+
  44. | DESCRIPTION SIZE | 2 bytes
  45. +------------------------+
  46. | DESCRIPTION | variable
  47. +------------------------+
  48. | PAYLOAD CRC32 | 4 bytes
  49. +------------------------+
  50. | PAYLOAD | variable
  51. +------------------------+
  52. The payload may contain a nested similar message.
  53. Description validation logic via CRC32 allows you to
  54. validate an incoming message without fully receiving it.
  55. If the description part are corrupted, further
  56. processing is interrupted.
  57. Description contains Message type and other base info.
  58. Any payload of variable and significant size is not included
  59. in the description. This is to ensure that the initial validation
  60. of the input data does not require the acquisition
  61. of a large amount of data.
  62. *** Handshake
  63. The consumer makes a request specifying the protocol version
  64. and all supported stucture versions to be used.
  65. The publisher responds with the protocol version and only one version
  66. for each structure it supports, as reported by the consumer.
  67. The most recent version that both parties support should be used.
  68. If an incompatibility occurs, the publisher sends a handshake message
  69. with an incompatibility flag.
  70. * Handshake request structure:
  71. +-------------------------------+
  72. | PROTOCOL VERSION | 1 byte
  73. +===============================+
  74. | SUPPORTED HANDSHAKE VER COUNT | 1 byte
  75. +-------------------------------+
  76. | SUPPORTED VERSIONS ARRAY | 1*count byte
  77. +===============================+
  78. | S. POINT DECLARATION V. COUNT | 1 byte
  79. +-------------------------------+
  80. | SUPPORTED VERSIONS ARRAY | 1*count byte
  81. +===============================+
  82. | SUPPORTED CHUNK VER COUNT | 1 byte
  83. +-------------------------------+
  84. | SUPPORTED VERSIONS ARRAY | 1*count byte
  85. +-------------------------------+
  86. * Handshake response structure:
  87. +-------------------------------+
  88. | INCOMPATIBILITY FLAG | 1 byte
  89. +-------------------------------+
  90. | PROTOCOL VERSION | 1 byte
  91. +-------------------------------+
  92. | HANDSHAKE VERSION | 1 byte
  93. +-------------------------------+
  94. | POINT DECLARATION VERSION | 1 byte
  95. +-------------------------------+
  96. | CHUNK VERSION | 1 byte
  97. +-------------------------------+
  98. **********************************************************************************/
  99. #pragma once
  100. namespace ShitFlow {
  101. } // namespace ShitFlow