mirror of
https://blitiri.com.ar/repos/chasquid
synced 2025-12-17 14:37:02 +00:00
Distinguish between SMTP and submission ports
We want to be able to distinguish between connections for SMTP and connections for submission, so we can make different policy decisions. To do that, we first make the configuration aware of the different kinds of addresses. This is done in this patch in a backwards-incompatible way, but at this point in time it is ok to do so. Then, we extend systemd's socket passing library to support socket naming, so we can tell the different sockets apart. This is done via the LISTEN_FDNAMES/FileDescriptorName mechanism. And finally we make the server and connection types aware of the socket mode.
This commit is contained in:
@@ -40,8 +40,12 @@ func TestEmptyConfig(t *testing.T) {
|
||||
t.Errorf("max data size != 50: %d", c.MaxDataSizeMb)
|
||||
}
|
||||
|
||||
if len(c.Address) != 1 || c.Address[0] != "systemd" {
|
||||
t.Errorf("unexpected address default: %v", c.Address)
|
||||
if len(c.SmtpAddress) != 1 || c.SmtpAddress[0] != "systemd" {
|
||||
t.Errorf("unexpected address default: %v", c.SmtpAddress)
|
||||
}
|
||||
|
||||
if len(c.SubmissionAddress) != 1 || c.SubmissionAddress[0] != "systemd" {
|
||||
t.Errorf("unexpected address default: %v", c.SubmissionAddress)
|
||||
}
|
||||
|
||||
if c.MonitoringAddress != "" {
|
||||
@@ -53,8 +57,8 @@ func TestEmptyConfig(t *testing.T) {
|
||||
func TestFullConfig(t *testing.T) {
|
||||
confStr := `
|
||||
hostname: "joust"
|
||||
address: ":1234"
|
||||
address: ":5678"
|
||||
smtp_address: ":1234"
|
||||
smtp_address: ":5678"
|
||||
monitoring_address: ":1111"
|
||||
max_data_size_mb: 26
|
||||
`
|
||||
@@ -75,9 +79,9 @@ func TestFullConfig(t *testing.T) {
|
||||
t.Errorf("max data size != 26: %d", c.MaxDataSizeMb)
|
||||
}
|
||||
|
||||
if len(c.Address) != 2 ||
|
||||
c.Address[0] != ":1234" || c.Address[1] != ":5678" {
|
||||
t.Errorf("different address: %v", c.Address)
|
||||
if len(c.SmtpAddress) != 2 ||
|
||||
c.SmtpAddress[0] != ":1234" || c.SmtpAddress[1] != ":5678" {
|
||||
t.Errorf("different address: %v", c.SmtpAddress)
|
||||
}
|
||||
|
||||
if c.MonitoringAddress != ":1111" {
|
||||
|
||||
Reference in New Issue
Block a user