mirror of
https://github.com/mjl-/mox.git
synced 2025-07-10 10:34:40 +03:00
add TransportDirect transport
The `TransportDirect` transport allows to tweak outgoing SMTP connections to remote servers. Currently, it only allows to select network IP family (ipv4, ipv6 or both). For example, to disable ipv6 for all outgoing SMTP connections: - add these lines in mox.conf to create a new transport named "disableipv6": ``` Transports: disableipv6: Direct: DisableIpv6: true ``` - then add these lines in domains.conf to use this transport: ``` Routes: - Transport: disableipv6 ``` fix #149
This commit is contained in:
@ -929,6 +929,19 @@ func PrepareStaticConfig(ctx context.Context, log mlog.Log, configFile string, c
|
||||
}
|
||||
}
|
||||
|
||||
checkTransportDirect := func(name string, t *config.TransportDirect) {
|
||||
if t.DisableIPv4 && t.DisableIPv6 {
|
||||
addErrorf("transport %s: both IPv4 and IPv6 are disabled, enable at least one", name)
|
||||
}
|
||||
t.IPFamily = "ip"
|
||||
if t.DisableIPv4 {
|
||||
t.IPFamily = "ip6"
|
||||
}
|
||||
if t.DisableIPv6 {
|
||||
t.IPFamily = "ip4"
|
||||
}
|
||||
}
|
||||
|
||||
for name, t := range c.Transports {
|
||||
n := 0
|
||||
if t.Submissions != nil {
|
||||
@ -947,6 +960,10 @@ func PrepareStaticConfig(ctx context.Context, log mlog.Log, configFile string, c
|
||||
n++
|
||||
checkTransportSocks(name, t.Socks)
|
||||
}
|
||||
if t.Direct != nil {
|
||||
n++
|
||||
checkTransportDirect(name, t.Direct)
|
||||
}
|
||||
if n > 1 {
|
||||
addErrorf("transport %s: cannot have multiple methods in a transport", name)
|
||||
}
|
||||
|
Reference in New Issue
Block a user