Skip to content

Commit ad1dc70

Browse files
authored
Add received:from:ipv4/ipv6/fqdn to inet:email:message (#3564)
1 parent 977c8c7 commit ad1dc70

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

synapse/models/inet.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1560,6 +1560,15 @@ def getModelDefs(self):
15601560
('headers', ('array', {'type': 'inet:email:header'}), {
15611561
'doc': 'An array of email headers from the message.'}),
15621562

1563+
('received:from:ipv4', ('inet:ipv4', {}), {
1564+
'doc': 'The sending SMTP server IPv4, potentially from the Received: header.'}),
1565+
1566+
('received:from:ipv6', ('inet:ipv6', {}), {
1567+
'doc': 'The sending SMTP server IPv6, potentially from the Received: header.'}),
1568+
1569+
('received:from:fqdn', ('inet:fqdn', {}), {
1570+
'doc': 'The sending server FQDN, potentially from the Received: header.'}),
1571+
15631572
)),
15641573

15651574
('inet:email:header', {}, (

synapse/tests/test_model_inet.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2662,6 +2662,9 @@ async def test_model_inet_email_message(self):
26622662
:headers=(('to', 'Visi Stark <[email protected]>'),)
26632663
26642664
:bytes="*"
2665+
:received:from:ipv4=1.2.3.4
2666+
:received:from:ipv6="::1"
2667+
:received:from:fqdn=smtp.vertex.link
26652668
]
26662669
26672670
{[( inet:email:message:link=($node, https://www.vertex.link) :text=Vertex )]}
@@ -2671,6 +2674,9 @@ async def test_model_inet_email_message(self):
26712674
self.len(1, nodes)
26722675

26732676
self.eq(nodes[0].get('cc'), ('[email protected]', '[email protected]'))
2677+
self.eq(nodes[0].get('received:from:ipv6'), '::1')
2678+
self.eq(nodes[0].get('received:from:ipv4'), 0x01020304)
2679+
self.eq(nodes[0].get('received:from:fqdn'), 'smtp.vertex.link')
26742680

26752681
self.len(1, await core.nodes('inet:email:message:[email protected]'))
26762682
self.len(1, await core.nodes('inet:email:message:date=2015'))

0 commit comments

Comments
 (0)