sslproto.pxd 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. cdef enum SSLProtocolState:
  2. UNWRAPPED = 0
  3. DO_HANDSHAKE = 1
  4. WRAPPED = 2
  5. FLUSHING = 3
  6. SHUTDOWN = 4
  7. cdef enum AppProtocolState:
  8. # This tracks the state of app protocol (https://git.io/fj59P):
  9. #
  10. # INIT -cm-> CON_MADE [-dr*->] [-er-> EOF?] -cl-> CON_LOST
  11. #
  12. # * cm: connection_made()
  13. # * dr: data_received()
  14. # * er: eof_received()
  15. # * cl: connection_lost()
  16. STATE_INIT = 0
  17. STATE_CON_MADE = 1
  18. STATE_EOF = 2
  19. STATE_CON_LOST = 3
  20. cdef class _SSLProtocolTransport:
  21. cdef:
  22. Loop _loop
  23. SSLProtocol _ssl_protocol
  24. bint _closed
  25. object context
  26. cdef class SSLProtocol:
  27. cdef:
  28. bint _server_side
  29. str _server_hostname
  30. object _sslcontext
  31. object _extra
  32. object _write_backlog
  33. size_t _write_buffer_size
  34. object _waiter
  35. Loop _loop
  36. _SSLProtocolTransport _app_transport
  37. bint _app_transport_created
  38. object _transport
  39. object _ssl_handshake_timeout
  40. object _ssl_shutdown_timeout
  41. object _sslobj
  42. object _sslobj_read
  43. object _sslobj_write
  44. object _sslobj_pending
  45. object _incoming
  46. object _incoming_write
  47. object _outgoing
  48. object _outgoing_read
  49. char* _ssl_buffer
  50. size_t _ssl_buffer_len
  51. SSLProtocolState _state
  52. size_t _conn_lost
  53. AppProtocolState _app_state
  54. bint _ssl_writing_paused
  55. bint _app_reading_paused
  56. size_t _incoming_high_water
  57. size_t _incoming_low_water
  58. bint _ssl_reading_paused
  59. bint _app_writing_paused
  60. size_t _outgoing_high_water
  61. size_t _outgoing_low_water
  62. object _app_protocol
  63. bint _app_protocol_is_buffer
  64. object _app_protocol_get_buffer
  65. object _app_protocol_buffer_updated
  66. object _handshake_start_time
  67. object _handshake_timeout_handle
  68. object _shutdown_timeout_handle
  69. # Instead of doing python calls, c methods *_impl are called directly
  70. # from stream.pyx
  71. cdef inline get_buffer_impl(self, size_t n, char** buf, size_t* buf_size)
  72. cdef inline buffer_updated_impl(self, size_t nbytes)
  73. cdef inline _set_app_protocol(self, app_protocol)
  74. cdef inline _wakeup_waiter(self, exc=*)
  75. cdef inline _get_extra_info(self, name, default=*)
  76. cdef inline _set_state(self, SSLProtocolState new_state)
  77. # Handshake flow
  78. cdef inline _start_handshake(self)
  79. cdef inline _check_handshake_timeout(self)
  80. cdef inline _do_handshake(self)
  81. cdef inline _on_handshake_complete(self, handshake_exc)
  82. # Shutdown flow
  83. cdef inline _start_shutdown(self, object context=*)
  84. cdef inline _check_shutdown_timeout(self)
  85. cdef inline _do_read_into_void(self, object context)
  86. cdef inline _do_flush(self, object context=*)
  87. cdef inline _do_shutdown(self, object context=*)
  88. cdef inline _on_shutdown_complete(self, shutdown_exc)
  89. cdef inline _abort(self, exc)
  90. # Outgoing flow
  91. cdef inline _write_appdata(self, list_of_data, object context)
  92. cdef inline _do_write(self)
  93. cdef inline _process_outgoing(self)
  94. # Incoming flow
  95. cdef inline _do_read(self)
  96. cdef inline _do_read__buffered(self)
  97. cdef inline _do_read__copied(self)
  98. cdef inline _call_eof_received(self, object context=*)
  99. # Flow control for writes from APP socket
  100. cdef inline _control_app_writing(self, object context=*)
  101. cdef inline size_t _get_write_buffer_size(self)
  102. cdef inline _set_write_buffer_limits(self, high=*, low=*)
  103. # Flow control for reads to APP socket
  104. cdef inline _pause_reading(self)
  105. cdef inline _resume_reading(self, object context)
  106. # Flow control for reads from SSL socket
  107. cdef inline _control_ssl_reading(self)
  108. cdef inline _set_read_buffer_limits(self, high=*, low=*)
  109. cdef inline size_t _get_read_buffer_size(self)
  110. cdef inline _fatal_error(self, exc, message=*)