Closed gamalan closed 2 weeks ago
Hi @gamalan , glad you noticed that deprecation warning. I was hoping it would surface someone(s) who actually used that feature. Answers:
haraka-net-utils.get_mx
. So you could instead do something like this:const nu = require('haraka-net-utils')
let mxes = await nu.get_mx('gmail.com')
for const (mx of mxes) {
mx.bind = 'X.X.X.X' // maybe with conditional logic
}
// the rest of your code
➜ node
Welcome to Node.js v22.7.0.
> const nu = require('haraka-net-utils')
> await nu.get_mx('gmail.com')
[
HarakaMx {
exchange: 'alt3.gmail-smtp-in.l.google.com',
priority: 30,
from_dns: 'gmail.com',
bind_helo: 'home.simerson.net'
},
HarakaMx {
exchange: 'gmail-smtp-in.l.google.com',
priority: 5,
from_dns: 'gmail.com',
bind_helo: 'home.simerson.net'
},
HarakaMx {
exchange: 'alt2.gmail-smtp-in.l.google.com',
priority: 20,
from_dns: 'gmail.com',
bind_helo: 'home.simerson.net'
},
HarakaMx {
exchange: 'alt4.gmail-smtp-in.l.google.com',
priority: 40,
from_dns: 'gmail.com',
bind_helo: 'home.simerson.net'
},
HarakaMx {
exchange: 'alt1.gmail-smtp-in.l.google.com',
priority: 10,
from_dns: 'gmail.com',
bind_helo: 'home.simerson.net'
}
]
One of the issues you might encounter is that you need to know if the remote IP is IPv4 or IPv6, and use that to choose which local IP you bind to. You can do that as well (something that's far too late to set a note for):
> const nu = require('haraka-net-utils')
> const mxes = await nu.get_mx('gmail.com')
> const ips = await nu.resolve_mx_hosts(mxes)
> console.log(ips)
[
{
exchange: '2607:f8b0:4023:1004::1a',
priority: 10,
from_dns: 'alt1.gmail-smtp-in.l.google.com',
bind_helo: 'home.simerson.net'
},
{
exchange: '142.250.115.27',
priority: 10,
from_dns: 'alt1.gmail-smtp-in.l.google.com',
bind_helo: 'home.simerson.net'
},
{
exchange: '2607:f8b0:4001:c56::1b',
priority: 30,
from_dns: 'alt3.gmail-smtp-in.l.google.com',
bind_helo: 'home.simerson.net'
},
{
exchange: '142.250.152.26',
priority: 30,
from_dns: 'alt3.gmail-smtp-in.l.google.com',
bind_helo: 'home.simerson.net'
},
{
exchange: '2607:f8b0:400e:c03::1a',
priority: 5,
from_dns: 'gmail-smtp-in.l.google.com',
bind_helo: 'home.simerson.net'
},
{
exchange: '74.125.195.26',
priority: 5,
from_dns: 'gmail-smtp-in.l.google.com',
bind_helo: 'home.simerson.net'
},
{
exchange: '2607:f8b0:4003:c04::1a',
priority: 20,
from_dns: 'alt2.gmail-smtp-in.l.google.com',
bind_helo: 'home.simerson.net'
},
{
exchange: '108.177.104.27',
priority: 20,
from_dns: 'alt2.gmail-smtp-in.l.google.com',
bind_helo: 'home.simerson.net'
},
{
exchange: '2607:f8b0:4023:1::1b',
priority: 40,
from_dns: 'alt4.gmail-smtp-in.l.google.com',
bind_helo: 'home.simerson.net'
},
{
exchange: '172.253.113.27',
priority: 40,
from_dns: 'alt4.gmail-smtp-in.l.google.com',
bind_helo: 'home.simerson.net'
}
]
Does that help?
@msimerson that helps. need to update our internal plugin then.
Describe the bug
Before Haraka 3.0.4. Using multiple outbound could be set using get_mx_hook or using notes.outbound_ip. Which is helpful, because we could set it without messing the mx lookup in haraka itself. But in the haraka 3.0.4 it's being deprecated. While it's understandable to be deprecated, this also means we need to use get_mx_hook. @baudehlo give example in #442
Which is somehow outbound.lookup_mx doesn't exist anymore in 3.0.4. While using notes.outbound_ip is still possible it also produce some error. Namely it fail to bind the socket first time, but it works in subsequent try, which introducing a delay in delivery process.
My question is,
System Info
Please report your OS, Node version, and Haraka version by running this shell script on your Haraka server and replacing this section with the output.