Fix postfix settings so it should load successfully and accept and send messages through tunnel

Signed-off-by: Egor Savkin <es@m-labs.hk>
This commit is contained in:
Egor Savkin 2024-10-08 16:00:18 +08:00
parent eab2d70941
commit e7570aa4ce
1 changed files with 14 additions and 10 deletions

View File

@ -262,8 +262,8 @@ in
interfaces.intl0 = { interfaces.intl0 = {
ipv4.addresses = [ ipv4.addresses = [
{ {
address = "10.47.3.2"; address = "10.47.3.1";
prefixLength = 30; prefixLength = 31;
} }
]; ];
ipv4.routes = [ ipv4.routes = [
@ -397,7 +397,7 @@ in
serviceConfig = { serviceConfig = {
Type = "oneshot"; Type = "oneshot";
RemainAfterExit = true; RemainAfterExit = true;
ExecStart = "${pkgs.iproute2}/bin/ip rule add from 10.47.3.0/30 table 3"; ExecStart = "${pkgs.iproute2}/bin/ip rule add from 10.47.3.0/31 table 3";
ExecStop = "${pkgs.iproute2}/bin/ip rule del table 3"; ExecStop = "${pkgs.iproute2}/bin/ip rule del table 3";
}; };
}; };
@ -1302,14 +1302,14 @@ in
}; };
}; };
services.postfix.mapFiles.sender_relay = pkgs.writeText "sender_relay" '' services.postfix.mapFiles.sender_transport = pkgs.writeText "sender_transport" ''
m-labs-intl.com smtptun: @m-labs-intl.com intltunnel:
* : * :
''; '';
systemd.services.postfix-rebuild-sender-relay = { systemd.services.postfix-rebuild-sender-relay = {
description = "Postfix Rebuild Sender Dependent Relayhost Maps"; description = "Postfix Rebuild Sender Dependent Transport Maps";
serviceConfig = { serviceConfig = {
ExecStart = "${pkgs.postfix}/sbin/postmap /var/lib/postfix/conf/sender_relay"; ExecStart = "${pkgs.postfix}/sbin/postmap /var/lib/postfix/conf/sender_transport";
}; };
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
}; };
@ -1325,12 +1325,16 @@ in
} // (import /etc/nixos/secret/email_settings.nix); } // (import /etc/nixos/secret/email_settings.nix);
services.postfix = { services.postfix = {
config = { config = {
sender_dependent_relayhost_maps = "hash:/var/lib/postfix/conf/sender_relay"; sender_dependent_default_transport_maps = "hash:/var/lib/postfix/conf/sender_transport";
}; };
masterConfig."smtptun" = { masterConfig."intltunnel" = {
type = "unix"; type = "unix";
command = "smtp"; command = "smtp";
args = [ "-o" "smtp_bind_address=10.47.3.2" ]; args = [
"-o" "smtp_bind_address=10.47.3.1"
"-o" "inet_interfaces=10.47.3.1"
"-o" "inet_protocols=ipv4"
];
}; };
}; };