PADDING cells can't be sent immediately after a VERSIONS cell
When I send a VERSIONS cell and a PADDING cell in the same socket write, Tor 0.3.0.9 closes the connection:
Jul 15 19:55:43.000 [info] channel_register: Channel 0x7f848276e300 (global ID 207) in state opening (1) registered with no identity digest
Jul 15 19:55:43.000 [info] channel_tls_process_versions_cell: Negotiated version 3 with [scrubbed]:58001; Sending cells: VERSIONS CERTS AUTH_CHALLENGE NETINFO
Jul 15 19:55:43.000 [info] channel_tls_handle_cell: Received unexpected cell command 0 in chan state opening / conn state handshaking (Tor, v3 handshake); closing the connection.
Jul 15 19:55:43.000 [info] conn_close_if_marked: Conn (addr [scrubbed], fd 9, type OR, state 7) marked, but wants to flush 2033 bytes. (Marked at src/or/connection_or.c:1338)
Jul 15 19:55:43.000 [info] conn_close_if_marked: We stalled too much while trying to write 2033 bytes to address [scrubbed]. If this happens a lot, either something is wrong with your network connection, or something is wrong with theirs. (fd 9, type OR, state 7, marked at src/or/connection_or.c:1338).
It doesn't matter if I send a VPADDING cell before the padding cell.
But the tor spec says:
When this handshake is in use, the first cell must
be VERSIONS, VPADDING or AUTHORIZE, and no other cell type is allowed to
intervene besides those specified, except for PADDING and VPADDING cells.
https://gitweb.torproject.org/torspec.git/tree/tor-spec.txt#n482