root@server.milter:~# journalctl -u spamurai_milter --since "2025-06-22 21:50" | grep e208edf4
Jun 22 22:00:02 DEBUG:purepythonmilter.server.milterserver:e208edf4[1410568]: MTA connected. peername=('10.0.0.1', 58604) <StreamReader transport=<_SelectorSocketTransport fd=25 read=polling write=<idle, bufsize=0>>> <StreamWriter transport=<_SelectorSocketTransport fd=25 read=polling write=<idle, bufsize=0>> reader=<StreamReader transport=<_SelectorSocketTransport fd=25 read=polling write=<idle, bufsize=0>>>>
[...]
Jun 22 22:00:02 DEBUG:purepythonmilter.protocol.commands:e208edf4[1410568]: MTA: milter_protocol_version=0x000006 action_flags=0x0001ff protocol_flags=0x1fffff
[...]
Jun 22 22:00:02 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: Setting queue item done_event
Jun 22 22:00:02 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: commands_consumer: going to read the queue last_macro_command=None
[...]
Jun 22 22:00:03 DEBUG:purepythonmilter.protocol.packet:e208edf4[1410568]: MTA sent packet claiming payload_length=198 byte(s).
Jun 22 22:00:03 DEBUG:purepythonmilter.server.connectionhandler:e208edf4[1410568]: command_class=<class 'purepythonmilter.protocol.commands.DefineMacro'> command_data=b'Cj\x00server.mail\x00{daemon_name}\x00server.mail\x00{daemon_addr}\x00XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX\x00v\x00Postfix 3.7.11\x00_\x00server.client [XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX]\x00'
Jun 22 22:00:03 DEBUG:purepythonmilter.protocol.commands:e208edf4[1410568]: decoding DefineMacro self.data_raw.hex()='436a00736d74702d332d313030302e6d61696c2e696e666f6d616e69616b2e6368007b6461656d6f6e5f6e616d657d00736d74702d332d313030302e6d61696c2e696e666f6d616e69616b2e6368007b6461656d6f6e5f616464727d00323030313a313630303a303a616161613a3a313a36007600506f737466697820332e372e3131005f006f642d3066373239362e696e666f6d616e69616b2e6368205b323030313a313630303a31333a3130323a663831363a336566663a666561323a316332615d00'
Jun 22 22:00:03 DEBUG:purepythonmilter.protocol.commands:e208edf4[1410568]: Decoded macros: {'j': 'server.mail', '{daemon_name}': 'server.mail', '{daemon_addr}': 'XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX', 'v': 'Postfix 3.7.11', '_': 'server.client [XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX]'}
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: queue_command: command=DefineMacro(data_raw=b'Cj\x00server.mail\x00{daemon_name}\x00server.mail\x00{daemon_addr}\x00XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX\x00v\x00Postfix 3.7.11\x00_\x00server.client [XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX]\x00', stage=<MacroStage.CONNECT: 0>, macros={'j': 'server.mail', '{daemon_name}': 'server.mail', '{daemon_addr}': 'XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX', 'v': 'Postfix 3.7.11', '_': 'server.client [XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX]'})
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: incoming_command_queue size=1
Jun 22 22:00:03 DEBUG:purepythonmilter.protocol.packet:e208edf4[1410568]: MTA sent packet claiming payload_length=65 byte(s).
Jun 22 22:00:03 DEBUG:purepythonmilter.server.connectionhandler:e208edf4[1410568]: command_class=<class 'purepythonmilter.protocol.commands.Connect'> command_data=b'server.client\x006\xb1"XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX\x00'
Jun 22 22:00:03 DEBUG:purepythonmilter.protocol.commands:e208edf4[1410568]: Decoded socket data family_bin=b'6'
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: queue_command: command=Connect(data_raw=b'server.client\x006\xb1"XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX\x00', connection_info_args=ConnectionInfoArgsIPv6(hostname='server.client', addr=IPv6Address('XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX'), port=45346), macros={})
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: incoming_command_queue size=2
Jun 22 22:00:03 DEBUG:purepythonmilter.protocol.packet:e208edf4[1410568]: MTA sent packet claiming payload_length=2 byte(s).
Jun 22 22:00:03 DEBUG:purepythonmilter.server.connectionhandler:e208edf4[1410568]: command_class=<class 'purepythonmilter.protocol.commands.DefineMacro'> command_data=b'H'
Jun 22 22:00:03 DEBUG:purepythonmilter.protocol.commands:e208edf4[1410568]: decoding DefineMacro self.data_raw.hex()='48'
Jun 22 22:00:03 DEBUG:purepythonmilter.protocol.commands:e208edf4[1410568]: No macros in DefineMacro for stage=<MacroStage.HELO: 1>
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: queue_command: command=DefineMacro(data_raw=b'H', stage=<MacroStage.HELO: 1>, macros={})
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: incoming_command_queue size=3
Jun 22 22:00:03 DEBUG:purepythonmilter.protocol.packet:e208edf4[1410568]: MTA sent packet claiming payload_length=11 byte(s).
Jun 22 22:00:03 DEBUG:purepythonmilter.server.connectionhandler:e208edf4[1410568]: command_class=<class 'purepythonmilter.protocol.commands.Helo'> command_data=b'localhost\x00'
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: queue_command: command=Helo(data_raw=b'localhost\x00', hostname='localhost', macros={})
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: incoming_command_queue size=4
Jun 22 22:00:03 DEBUG:purepythonmilter.protocol.packet:e208edf4[1410568]: MTA sent packet claiming payload_length=221 byte(s).
Jun 22 22:00:03 DEBUG:purepythonmilter.server.connectionhandler:e208edf4[1410568]: command_class=<class 'purepythonmilter.protocol.commands.DefineMacro'> command_data=b'M_\x00server.client [XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX]\x00{mail_addr}\x00user@server.client\x00{client_addr}\x00IPv6:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX\x00{client_name}\x00server.client\x00{dkim_sign}\x001\x00'
Jun 22 22:00:03 DEBUG:purepythonmilter.protocol.commands:e208edf4[1410568]: decoding DefineMacro self.data_raw.hex()='4d5f006f642d3066373239362e696e666f6d616e69616b2e6368205b323030313a313630303a31333a3130323a663831363a336566663a666561323a316332615d007b6d61696c5f616464727d00756964323734373730406f642d3066373239362e696e666f6d616e69616b2e6368007b636c69656e745f616464727d00495076363a323030313a313630303a31333a3130323a663831363a336566663a666561323a31633261007b636c69656e745f6e616d657d006f642d3066373239362e696e666f6d616e69616b2e6368007b646b696d5f7369676e7d003100'
Jun 22 22:00:03 DEBUG:purepythonmilter.protocol.commands:e208edf4[1410568]: Decoded macros: {'_': 'server.client [XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX]', '{mail_addr}': 'user@server.client', '{client_addr}': 'IPv6:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX', '{client_name}': 'server.client', '{dkim_sign}': '1'}
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: queue_command: command=DefineMacro(data_raw=b'M_\x00server.client [XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX]\x00{mail_addr}\x00user@server.client\x00{client_addr}\x00IPv6:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX\x00{client_name}\x00server.client\x00{dkim_sign}\x001\x00', stage=<MacroStage.MAIL_FROM: 2>, macros={'_': 'server.client [XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX]', '{mail_addr}': 'user@server.client', '{client_addr}': 'IPv6:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX', '{client_name}': 'server.client', '{dkim_sign}': '1'})
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: incoming_command_queue size=5
Jun 22 22:00:03 DEBUG:purepythonmilter.protocol.packet:e208edf4[1410568]: MTA sent packet claiming payload_length=37 byte(s).
Jun 22 22:00:03 DEBUG:purepythonmilter.server.connectionhandler:e208edf4[1410568]: command_class=<class 'purepythonmilter.protocol.commands.MailFrom'> command_data=b'<user@server.client>\x00'
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: queue_command: command=MailFrom(data_raw=b'<user@server.client>\x00', address='user@server.client', esmtp_args={}, macros={})
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: incoming_command_queue size=6
Jun 22 22:00:03 DEBUG:purepythonmilter.protocol.packet:e208edf4[1410568]: MTA sent packet claiming payload_length=100 byte(s).
Jun 22 22:00:03 DEBUG:purepythonmilter.server.connectionhandler:e208edf4[1410568]: command_class=<class 'purepythonmilter.protocol.commands.DefineMacro'> command_data=b'R{rcpt_addr}\x00user@server.client\x00{rcpt_host}\x00server.client\x00{rcpt_mailer}\x00roundrobin2\x00'
Jun 22 22:00:03 DEBUG:purepythonmilter.protocol.commands:e208edf4[1410568]: decoding DefineMacro self.data_raw.hex()='527b726370745f616464727d00756964323734373730406d61696c2e696e666f6d616e69616b2e6368007b726370745f686f73747d006d61696c2e696e666f6d616e69616b2e6368007b726370745f6d61696c65727d00726f756e64726f62696e3200'
Jun 22 22:00:03 DEBUG:purepythonmilter.protocol.commands:e208edf4[1410568]: Decoded macros: {'{rcpt_addr}': 'user@server.client', '{rcpt_host}': 'server.client', '{rcpt_mailer}': 'roundrobin2'}
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: queue_command: command=DefineMacro(data_raw=b'R{rcpt_addr}\x00user@server.client\x00{rcpt_host}\x00server.client\x00{rcpt_mailer}\x00roundrobin2\x00', stage=<MacroStage.RCPT_TO: 3>, macros={'{rcpt_addr}': 'user@server.client', '{rcpt_host}': 'server.client', '{rcpt_mailer}': 'roundrobin2'})
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: incoming_command_queue size=7
Jun 22 22:00:03 DEBUG:purepythonmilter.protocol.packet:e208edf4[1410568]: MTA sent packet claiming payload_length=13 byte(s).
Jun 22 22:00:03 DEBUG:purepythonmilter.server.connectionhandler:e208edf4[1410568]: command_class=<class 'purepythonmilter.protocol.commands.RcptTo'> command_data=b'<user>\x00'
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: queue_command: command=RcptTo(data_raw=b'<user>\x00', address='user', esmtp_args={}, macros={})
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: incoming_command_queue size=8
Jun 22 22:00:03 DEBUG:purepythonmilter.protocol.packet:e208edf4[1410568]: MTA sent packet claiming payload_length=19 byte(s).
Jun 22 22:00:03 DEBUG:purepythonmilter.server.connectionhandler:e208edf4[1410568]: command_class=<class 'purepythonmilter.protocol.commands.DefineMacro'> command_data=b'Ti\x004bQMWQ6wT5z7fg\x00'
Jun 22 22:00:03 DEBUG:purepythonmilter.protocol.commands:e208edf4[1410568]: decoding DefineMacro self.data_raw.hex()='5469003462514d5751367754357a37666700'
Jun 22 22:00:03 DEBUG:purepythonmilter.protocol.commands:e208edf4[1410568]: Decoded macros: {'i': '4bQMWQ6wT5z7fg'}
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: queue_command: command=DefineMacro(data_raw=b'Ti\x004bQMWQ6wT5z7fg\x00', stage=<MacroStage.DATA: 4>, macros={'i': '4bQMWQ6wT5z7fg'})
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: incoming_command_queue size=9
Jun 22 22:00:03 DEBUG:purepythonmilter.protocol.packet:e208edf4[1410568]: MTA sent packet claiming payload_length=1 byte(s).
Jun 22 22:00:03 DEBUG:purepythonmilter.server.connectionhandler:e208edf4[1410568]: command_class=<class 'purepythonmilter.protocol.commands.Data'> command_data=b''
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: queue_command: command=Data(data_raw=b'', macros={})
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: incoming_command_queue size=10
Jun 22 22:00:03 DEBUG:purepythonmilter.server.connectionhandler:e208edf4[1410568]: No payload from packet (yet)
Jun 22 22:00:03 DEBUG:purepythonmilter.server.connectionhandler:e208edf4[1410568]: request to read 65540 bytes
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: commands_consumer: got queue_item=QueueEntry(command=DefineMacro(data_raw=b'Cj\x00server.mail\x00{daemon_name}\x00server.mail\x00{daemon_addr}\x00XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX\x00v\x00Postfix 3.7.11\x00_\x00server.client [XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX]\x00', stage=<MacroStage.CONNECT: 0>, macros={'j': 'server.mail', '{daemon_name}': 'server.mail', '{daemon_addr}': 'XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX', 'v': 'Postfix 3.7.11', '_': 'server.client [XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX]'}), done_event=<asyncio.locks.Event object at 0x7f50bb539e50 [unset]>)
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: on_define_macro command.macros={'j': 'server.mail', '{daemon_name}': 'server.mail', '{daemon_addr}': 'XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX', 'v': 'Postfix 3.7.11', '_': 'server.client [XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX]'}
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: Setting queue item done_event
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: commands_consumer: going to read the queue last_macro_command=None
Jun 22 22:00:03 DEBUG:purepythonmilter.server.connectionhandler:e208edf4[1410568]: got len(packet)=15 bytes [packet=b'\x00\x00\x00\x01A\x00\x00\x00\x01A\x00\x00\x00\x01Q']
Jun 22 22:00:03 DEBUG:purepythonmilter.protocol.packet:e208edf4[1410568]: MTA sent packet claiming payload_length=1 byte(s).
Jun 22 22:00:03 DEBUG:purepythonmilter.server.connectionhandler:e208edf4[1410568]: command_class=<class 'purepythonmilter.protocol.commands.Abort'> command_data=b''
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: queue_command: command=Abort(data_raw=b'')
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: incoming_command_queue size=10
Jun 22 22:00:03 DEBUG:purepythonmilter.protocol.packet:e208edf4[1410568]: MTA sent packet claiming payload_length=1 byte(s).
Jun 22 22:00:03 DEBUG:purepythonmilter.server.connectionhandler:e208edf4[1410568]: command_class=<class 'purepythonmilter.protocol.commands.Abort'> command_data=b''
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: queue_command: command=Abort(data_raw=b'')
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: incoming_command_queue size=11
Jun 22 22:00:03 DEBUG:purepythonmilter.protocol.packet:e208edf4[1410568]: MTA sent packet claiming payload_length=1 byte(s).
Jun 22 22:00:03 DEBUG:purepythonmilter.server.connectionhandler:e208edf4[1410568]: command_class=<class 'purepythonmilter.protocol.commands.Quit'> command_data=b''
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: queue_command: command=Quit(data_raw=b'')
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: incoming_command_queue size=12
Jun 22 22:00:03 DEBUG:purepythonmilter.server.connectionhandler:e208edf4[1410568]: No payload from packet (yet)
Jun 22 22:00:03 DEBUG:purepythonmilter.server.connectionhandler:e208edf4[1410568]: request to read 65540 bytes
Jun 22 22:00:03 DEBUG:purepythonmilter.server.connectionhandler:e208edf4[1410568]: Milter-MTA connection closed
Jun 22 22:00:03 DEBUG:purepythonmilter.server.connectionhandler:e208edf4[1410568]: close_bottom_up
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: close_bottom_up
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: _stop_commands_consumer [task=commands_consumer_task-e208edf4, exception=None, cancelled=False]
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: commands_consumer: got queue_item=QueueEntry(command=Connect(data_raw=b'server.client\x006\xb1"XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX\x00', connection_info_args=ConnectionInfoArgsIPv6(hostname='server.client', addr=IPv6Address('XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX'), port=45346), macros={}), done_event=<asyncio.locks.Event object at 0x7f50bb53aa10 [unset]>)
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: handle_command_in_app command=Connect(data_raw=b'server.client\x006\xb1"XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX\x00', connection_info_args=ConnectionInfoArgsIPv6(hostname='server.client', addr=IPv6Address('XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX'), port=45346), macros={'j': 'server.mail', '{daemon_name}': 'server.mail', '{daemon_addr}': 'XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX', 'v': 'Postfix 3.7.11', '_': 'server.client [XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX]'})
Jun 22 22:00:03 INFO:milter:e208edf4[1410568]: new connection: client_addr=XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX, server_name=server.mail, server_addr=XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX, server_version='Postfix 3.7.11', source='server.client [XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX]'
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: Setting queue item done_event
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: commands_consumer: going to read the queue last_macro_command=None
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: commands_consumer: got queue_item=QueueEntry(command=DefineMacro(data_raw=b'H', stage=<MacroStage.HELO: 1>, macros={}), done_event=<asyncio.locks.Event object at 0x7f50bb538a50 [unset]>)
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: on_define_macro command.macros={}
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: Setting queue item done_event
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: commands_consumer: going to read the queue last_macro_command=None
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: commands_consumer: got queue_item=QueueEntry(command=Helo(data_raw=b'localhost\x00', hostname='localhost', macros={}), done_event=<asyncio.locks.Event object at 0x7f50bb5388d0 [unset]>)
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: handle_command_in_app command=Helo(data_raw=b'localhost\x00', hostname='localhost', macros={})
Jun 22 22:00:03 INFO:milter:e208edf4[1410568]: helo=localhost
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: Setting queue item done_event
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: commands_consumer: going to read the queue last_macro_command=None
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: commands_consumer: got queue_item=QueueEntry(command=DefineMacro(data_raw=b'M_\x00server.client [XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX]\x00{mail_addr}\x00user@server.client\x00{client_addr}\x00IPv6:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX\x00{client_name}\x00server.client\x00{dkim_sign}\x001\x00', stage=<MacroStage.MAIL_FROM: 2>, macros={'_': 'server.client [XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX]', '{mail_addr}': 'user@server.client', '{client_addr}': 'IPv6:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX', '{client_name}': 'server.client', '{dkim_sign}': '1'}), done_event=<asyncio.locks.Event object at 0x7f50bb53bb50 [unset]>)
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: on_define_macro command.macros={'_': 'server.client [XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX]', '{mail_addr}': 'user@server.client', '{client_addr}': 'IPv6:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX', '{client_name}': 'server.client', '{dkim_sign}': '1'}
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: Setting queue item done_event
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: commands_consumer: going to read the queue last_macro_command=None
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: commands_consumer: got queue_item=QueueEntry(command=MailFrom(data_raw=b'<user@server.client>\x00', address='user@server.client', esmtp_args={}, macros={}), done_event=<asyncio.locks.Event object at 0x7f50bb5394d0 [unset]>)
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: handle_command_in_app command=MailFrom(data_raw=b'<user@server.client>\x00', address='user@server.client', esmtp_args={}, macros={'_': 'server.client [XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX]', '{mail_addr}': 'user@server.client', '{client_addr}': 'IPv6:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX', '{client_name}': 'server.client', '{dkim_sign}': '1'})
Jun 22 22:00:03 INFO:milter:e208edf4[1410568]: env_from=user@server.client
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: Setting queue item done_event
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: commands_consumer: going to read the queue last_macro_command=None
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: commands_consumer: got queue_item=QueueEntry(command=DefineMacro(data_raw=b'R{rcpt_addr}\x00user@server.client\x00{rcpt_host}\x00server.client\x00{rcpt_mailer}\x00roundrobin2\x00', stage=<MacroStage.RCPT_TO: 3>, macros={'{rcpt_addr}': 'user@server.client', '{rcpt_host}': 'server.client', '{rcpt_mailer}': 'roundrobin2'}), done_event=<asyncio.locks.Event object at 0x7f50bb53b610 [unset]>)
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: on_define_macro command.macros={'{rcpt_addr}': 'user@server.client', '{rcpt_host}': 'server.client', '{rcpt_mailer}': 'roundrobin2'}
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: Setting queue item done_event
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: commands_consumer: going to read the queue last_macro_command=None
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: commands_consumer: got queue_item=QueueEntry(command=RcptTo(data_raw=b'<user>\x00', address='user', esmtp_args={}, macros={}), done_event=<asyncio.locks.Event object at 0x7f50bb538210 [unset]>)
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: handle_command_in_app command=RcptTo(data_raw=b'<user>\x00', address='user', esmtp_args={}, macros={'{rcpt_addr}': 'user@server.client', '{rcpt_host}': 'server.client', '{rcpt_mailer}': 'roundrobin2'})
Jun 22 22:00:03 INFO:milter:e208edf4[1410568]: rcpt=user
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: Setting queue item done_event
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: commands_consumer: going to read the queue last_macro_command=None
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: commands_consumer: got queue_item=QueueEntry(command=DefineMacro(data_raw=b'Ti\x004bQMWQ6wT5z7fg\x00', stage=<MacroStage.DATA: 4>, macros={'i': '4bQMWQ6wT5z7fg'}), done_event=<asyncio.locks.Event object at 0x7f50bb53b750 [unset]>)
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: on_define_macro command.macros={'i': '4bQMWQ6wT5z7fg'}
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: Setting queue item done_event
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: commands_consumer: going to read the queue last_macro_command=None
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: commands_consumer: got queue_item=QueueEntry(command=Data(data_raw=b'', macros={}), done_event=<asyncio.locks.Event object at 0x7f50bb53b390 [unset]>)
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: handle_command_in_app command=Data(data_raw=b'', macros={'i': '4bQMWQ6wT5z7fg'})
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: Setting queue item done_event
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: commands_consumer: going to read the queue last_macro_command=None
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: commands_consumer: got queue_item=QueueEntry(command=Abort(data_raw=b''), done_event=<asyncio.locks.Event object at 0x7f50bb55edd0 [unset]>)
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: Reset Session
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: handle_command_in_app command=Abort(data_raw=b'')
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: Setting queue item done_event
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: commands_consumer: going to read the queue last_macro_command=None
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: commands_consumer: got queue_item=QueueEntry(command=Abort(data_raw=b''), done_event=<asyncio.locks.Event object at 0x7f50bb55e3d0 [unset]>)
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: Reset Session
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: handle_command_in_app command=Abort(data_raw=b'')
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: Setting queue item done_event
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: commands_consumer: going to read the queue last_macro_command=None
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: commands_consumer: got queue_item=QueueEntry(command=Quit(data_raw=b''), done_event=<asyncio.locks.Event object at 0x7f50bb566c90 [unset]>)
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: handle_command_in_app command=Quit(data_raw=b'')
Jun 22 22:00:03 INFO:milter:e208edf4[1410568]: connection closed
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: Setting queue item done_event
Jun 22 22:00:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: commands_consumer: going to read the queue last_macro_command=None
Jun 22 22:00:33 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: timeout reading the command queue
Jun 22 22:00:33 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: commands_consumer: going to read the queue last_macro_command=None
Jun 22 22:01:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: timeout reading the command queue
Jun 22 22:01:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: commands_consumer: going to read the queue last_macro_command=None
Jun 22 22:01:33 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: timeout reading the command queue
Jun 22 22:01:33 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: commands_consumer: going to read the queue last_macro_command=None
Jun 22 22:02:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: timeout reading the command queue
Jun 22 22:02:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: commands_consumer: going to read the queue last_macro_command=None
Jun 22 22:02:33 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: timeout reading the command queue
Jun 22 22:02:33 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: commands_consumer: going to read the queue last_macro_command=None
Jun 22 22:03:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: timeout reading the command queue
Jun 22 22:03:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: commands_consumer: going to read the queue last_macro_command=None
Jun 22 22:03:33 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: timeout reading the command queue
Jun 22 22:03:33 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: commands_consumer: going to read the queue last_macro_command=None
Jun 22 22:04:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: timeout reading the command queue
Jun 22 22:04:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: commands_consumer: going to read the queue last_macro_command=None
Jun 22 22:04:33 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: timeout reading the command queue
Jun 22 22:04:33 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: commands_consumer: going to read the queue last_macro_command=None
Jun 22 22:05:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: timeout reading the command queue
Jun 22 22:05:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: commands_consumer: going to read the queue last_macro_command=None
Jun 22 22:05:33 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: timeout reading the command queue
Jun 22 22:05:33 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: commands_consumer: going to read the queue last_macro_command=None
Jun 22 22:06:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: timeout reading the command queue
Jun 22 22:06:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: commands_consumer: going to read the queue last_macro_command=None
Jun 22 22:06:33 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: timeout reading the command queue
Jun 22 22:06:33 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: commands_consumer: going to read the queue last_macro_command=None
Jun 22 22:07:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: timeout reading the command queue
Jun 22 22:07:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: commands_consumer: going to read the queue last_macro_command=None
Jun 22 22:07:33 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: timeout reading the command queue
Jun 22 22:07:33 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: commands_consumer: going to read the queue last_macro_command=None
Jun 22 22:08:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: timeout reading the command queue
Jun 22 22:08:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: commands_consumer: going to read the queue last_macro_command=None
Jun 22 22:08:33 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: timeout reading the command queue
Jun 22 22:08:33 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: commands_consumer: going to read the queue last_macro_command=None
Jun 22 22:09:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: timeout reading the command queue
Jun 22 22:09:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: commands_consumer: going to read the queue last_macro_command=None
Jun 22 22:09:33 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: timeout reading the command queue
Jun 22 22:09:33 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: commands_consumer: going to read the queue last_macro_command=None
Jun 22 22:10:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: timeout reading the command queue
Jun 22 22:10:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: commands_consumer: going to read the queue last_macro_command=None
Jun 22 22:10:33 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: timeout reading the command queue
Jun 22 22:10:33 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: commands_consumer: going to read the queue last_macro_command=None
Jun 22 22:11:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: timeout reading the command queue
Jun 22 22:11:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: commands_consumer: going to read the queue last_macro_command=None
Jun 22 22:11:33 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: timeout reading the command queue
Jun 22 22:11:33 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: commands_consumer: going to read the queue last_macro_command=None
Jun 22 22:12:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: timeout reading the command queue
Jun 22 22:12:03 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: commands_consumer: going to read the queue last_macro_command=None
[...]
After manual stop milter process:
Jun 22 22:12:20 WARNING:purepythonmilter.server.connectionhandler:e208edf4[1410568]: Reading packets task is done without having writer closed. writer=<StreamWriter transport=<_SelectorSocketTransport fd=25 read=idle write=<idle, bufsize=0>> reader=<StreamReader eof transport=<_SelectorSocketTransport fd=25 read=idle write=<idle, bufsize=0>>>>
Jun 22 22:12:20 DEBUG:purepythonmilter.server.connectionhandler:e208edf4[1410568]: DISCONNECTED reader=<StreamReader eof transport=<_SelectorSocketTransport fd=25 read=idle write=<idle, bufsize=0>>> writer=<StreamWriter transport=<_SelectorSocketTransport fd=25 read=idle write=<idle, bufsize=0>> reader=<StreamReader eof transport=<_SelectorSocketTransport fd=25 read=idle write=<idle, bufsize=0>>>>
Jun 22 22:12:20 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: commands_consumer task cancelled! read_queue_inner_task.cancelled()=True
Jun 22 22:12:20 DEBUG:purepythonmilter.server.session:e208edf4[1410568]: task done! [task=commands_consumer_task-e208edf4, done=True, cancelled=False]
π
task.cancel()does not stop_commands_consumerβ causes infinite timeout loop and socket leakThe
_commands_consumertask is started as follows:(Line 76: https://github.com/gertvdijk/purepythonmilter/blob/develop/src/purepythonmilter/server/session.py#L76)
When the MTA closes the connection (
Milter-MTA connection closed),_stop_commands_consumer()is called viaclose_bottom_up()and is expected tocancel()the_commands_consumertask:Lines 220β232
π The problem is that
task.cancel()does not actually stop the infinitewhile Trueloop in_commands_consumer, which continues executing.This results in an endless timeout loop, and the socket remains open:
Show Timeout Log
π§΅
lsofreveals the socket stays inCLOSE_WAIT:Milter:
Postfix:
Shortly after Postfix closes the connection, but the milter keeps its socket open:
Milter:
Postfix:
This seems to happen when another milter rejects the message before
purepythonmilterhas a chance to use the queue'sConnectcommand.This causes
_commands_consumerto continue executing, andtask.cancel()doesn't work as expected; the loop continues despite thetask.cancel()call.Show Debug Stack With Probleme
Show Debug Stack Without Problème
And server crashing when sockets limit was reached with
Too many open files:β Temporary workaround
In my fork, I fixed/bypass the issue by pushing a sentinel value (
None) into the queue right before callingtask.cancel():This allows
_commands_consumerto return and exit cleanly.π§ Suggestion
The best fix would be to understand why
task.cancel()isn't actually stopping the consumer