|
| 1 | +%% same values as in rabbit_reader |
| 2 | +-define(NORMAL_TIMEOUT, 3_000). |
| 3 | +-define(CLOSING_TIMEOUT, 30_000). |
| 4 | +-define(SILENT_CLOSE_DELAY, 3_000). |
| 5 | + |
| 6 | +%% Allow for potentially large sets of tokens during the SASL exchange. |
| 7 | +%% https://docs.oasis-open.org/amqp/amqp-cbs/v1.0/csd01/amqp-cbs-v1.0-csd01.html#_Toc67999915 |
| 8 | +-define(INITIAL_MAX_FRAME_SIZE, 8192). |
| 9 | + |
| 10 | +-type protocol() :: amqp | sasl. |
| 11 | +-type channel_number() :: non_neg_integer(). |
| 12 | +-type callback() :: handshake | |
| 13 | + {frame_header, protocol()} | |
| 14 | + {frame_body, protocol(), DataOffset :: pos_integer(), channel_number()}. |
| 15 | + |
| 16 | +-record(v1_connection, |
| 17 | + {name :: binary(), |
| 18 | + container_id = none :: none | binary(), |
| 19 | + vhost = none :: none | rabbit_types:vhost(), |
| 20 | + %% server host |
| 21 | + host :: inet:ip_address() | inet:hostname(), |
| 22 | + %% client host |
| 23 | + peer_host :: inet:ip_address() | inet:hostname(), |
| 24 | + %% server port |
| 25 | + port :: inet:port_number(), |
| 26 | + %% client port |
| 27 | + peer_port :: inet:port_number(), |
| 28 | + connected_at :: integer(), |
| 29 | + user = unauthenticated :: unauthenticated | rabbit_types:user(), |
| 30 | + timeout = ?NORMAL_TIMEOUT :: non_neg_integer(), |
| 31 | + incoming_max_frame_size = ?INITIAL_MAX_FRAME_SIZE :: pos_integer(), |
| 32 | + outgoing_max_frame_size = ?INITIAL_MAX_FRAME_SIZE :: unlimited | pos_integer(), |
| 33 | + %% "Prior to any explicit negotiation, [...] the maximum channel number is 0." [2.4.1] |
| 34 | + channel_max = 0 :: non_neg_integer(), |
| 35 | + auth_mechanism = sasl_init_unprocessed :: sasl_init_unprocessed | {binary(), module()}, |
| 36 | + auth_state = unauthenticated :: term(), |
| 37 | + credential_timer :: undefined | reference(), |
| 38 | + properties :: undefined | {map, list(tuple())} |
| 39 | + }). |
| 40 | + |
| 41 | +-record(v1, |
| 42 | + {parent :: pid(), |
| 43 | + helper_sup :: pid(), |
| 44 | + writer = none :: none | pid(), |
| 45 | + heartbeater = none :: none | rabbit_heartbeat:heartbeaters(), |
| 46 | + session_sup = none :: none | pid(), |
| 47 | + websocket :: boolean(), |
| 48 | + sock :: none | rabbit_net:socket(), |
| 49 | + proxy_socket :: undefined | {rabbit_proxy_socket, any(), any()}, |
| 50 | + connection :: none | #v1_connection{}, |
| 51 | + connection_state :: waiting_amqp3100 | received_amqp3100 | waiting_sasl_init | |
| 52 | + securing | waiting_amqp0100 | waiting_open | running | |
| 53 | + closing | closed, |
| 54 | + callback :: callback(), |
| 55 | + recv_len = 8 :: non_neg_integer(), |
| 56 | + pending_recv :: boolean(), |
| 57 | + buf :: list(), |
| 58 | + buf_len :: non_neg_integer(), |
| 59 | + tracked_channels = maps:new() :: #{channel_number() => Session :: pid()}, |
| 60 | + stats_timer :: rabbit_event:state() |
| 61 | + }). |
| 62 | + |
| 63 | +-type state() :: #v1{}. |
0 commit comments