Use postfix options for routing mails through tunnel #45

Closed
esavkin wants to merge 15 commits from enable-mail-proxy-and-tunnel into master
1 changed files with 16 additions and 7 deletions
Showing only changes of commit 6832725535 - Show all commits

View File

@ -1257,9 +1257,9 @@ in
after = [ "sockets.service" ];
serviceConfig = {
Restart = "on-failure";
User = "hydra-queue-runner"; # TODO needs new user both here and there
User = "hydra-queue-runner"; # TODO needs new user here
Group = "hydra";
ExecStart = "${pkgs.openssh}/bin/ssh -N -D 127.0.0.1:1587 zolaupd@5.78.86.156";
ExecStart = "${pkgs.openssh}/bin/ssh -N -D 127.0.0.1:1587 ssh_tunnel@5.78.86.156";
};
};
sb10q marked this conversation as resolved Outdated
Outdated
Review

"smtptun" is quite a confusing name. You'd think it's some postfix internal option. Make it more specific and explicit.

"smtptun" is quite a confusing name. You'd think it's some postfix internal option. Make it more specific and explicit.
@ -1267,10 +1267,6 @@ in
m-labs-intl.com socks:
Outdated
Review

In https://www.postfix.org/transport.5.html I don't see the syntax @domain. Just domain. What is going on?

In https://www.postfix.org/transport.5.html I don't see the syntax ``@domain``. Just ``domain``. What is going on?

I checked previously and it just didn't work until I used @domain

I checked previously and it just didn't work until I used `@domain`
Outdated
Review

Why the apparent discrepancy with the documentation? How carefully did you check?

Why the apparent discrepancy with the documentation? How carefully did you check?
* :
sb10q marked this conversation as resolved Outdated
Outdated
Review

Is this really required? I would expect NixOS to deal by itself with services.postfix.mapFiles without requiring any additional user-defined systemd services.

Is this really required? I would expect NixOS to deal by itself with ``services.postfix.mapFiles`` without requiring any additional user-defined systemd services.
Outdated
Review

https://github.com/NixOS/nixpkgs/blob/nixos-24.05/nixos/modules/services/mail/postfix.nix#L752-L755

Does this not work for some reason, or is it your usual sloppiness?

https://github.com/NixOS/nixpkgs/blob/nixos-24.05/nixos/modules/services/mail/postfix.nix#L752-L755 Does this not work for some reason, or is it your usual sloppiness?
'';
Outdated
Review

Is the line * : needed?

Is the line ``* :`` needed?
environment.etc."tsocks.conf".text = ''
server = 127.0.0.1
server_port = 1587
'';
systemd.services.postfix-rebuild-sender-relay = {
description = "Postfix Rebuild Sender Dependent Relayhost Maps";
serviceConfig = {
@ -1288,6 +1284,19 @@ in
enablePop3Ssl = true;
certificateScheme = "acme-nginx";
} // (import /etc/nixos/secret/email_settings.nix);
ssh_proxy_conf = builtins.toFile "proxychains.conf" ''
strict_chain
tcp_read_time_out 15000
Outdated
Review

Are the last two lines necessary, considering the first line?

Are the last two lines necessary, considering the first line?
tcp_connect_time_out 8000
localnet 192.168.1.0/255.255.255.0
localnet 127.0.0.0/255.0.0.0
localnet ::1/128
localnet 94.190.212.123/255.255.255.255
localnet 202.77.7.238/255.255.255.255
localnet 2001:470:18:390::2/255.255.255.255
[ProxyList]
socks5 127.0.0.1 1587
'';
services.postfix = {
config = {
sender_dependent_relayhost_maps = "hash:/etc/postfix/sender_relay";
@ -1296,7 +1305,7 @@ in
masterConfig.socks = {
type = "unix";
command = "pipe";
args = "flags=R user=nobody argv=${pkgs.tsocks}/bin/tsocks ${pkgs.postfix}/bin/sendmail -oi -f $sender $recipient";
args = "flags=R user=nobody argv=${pkgs.proxychains-ng}/bin/proxychains4 -f ${config.ssh_proxy_conf} ${pkgs.postfix}/bin/sendmail -oi -f $sender $recipient";
};
};
};