Skip to content

Commit 7f552ff

Browse files
authored
tayga: 0.9.2 -> 0.9.5 (NixOS#432528)
2 parents e85a6e6 + 4548324 commit 7f552ff

File tree

3 files changed

+68
-16
lines changed

3 files changed

+68
-16
lines changed

nixos/modules/services/networking/tayga.nix

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ let
2323
data-dir ${cfg.dataDir}
2424
2525
${concatStringsSep "\n" (mapAttrsToList (ipv4: ipv6: "map " + ipv4 + " " + ipv6) cfg.mappings)}
26+
27+
${optionalString ((builtins.length cfg.log) > 0) ''
28+
log ${concatStringsSep " " cfg.log}
29+
''}
30+
31+
wkpf-strict ${if cfg.wkpfStrict then "yes" else "no"}
2632
'';
2733

2834
addrOpts =
@@ -132,6 +138,21 @@ in
132138
}
133139
'';
134140
};
141+
142+
log = mkOption {
143+
type = types.listOf types.str;
144+
default = [ ];
145+
description = "Packet errors to log (drop, reject, icmp, self)";
146+
example = literalExpression ''
147+
[ "drop" "reject" "icmp" "self" ]
148+
'';
149+
};
150+
151+
wkpfStrict = mkOption {
152+
type = types.bool;
153+
default = true;
154+
description = "Enable restrictions on the use of the well-known prefix (64:ff9b::/96) - prevents translation of non-global IPv4 ranges when using the well-known prefix. Must be enabled for RFC 6052 compatibility.";
155+
};
135156
};
136157
};
137158

@@ -171,13 +192,16 @@ in
171192
};
172193
};
173194

195+
environment.etc."tayga.conf".source = configFile;
196+
174197
systemd.services.tayga = {
175198
description = "Stateless NAT64 implementation";
176199
wantedBy = [ "multi-user.target" ];
177200
after = [ "network.target" ];
178201

202+
reloadTriggers = [ configFile ];
179203
serviceConfig = {
180-
ExecStart = "${cfg.package}/bin/tayga -d --nodetach --config ${configFile}";
204+
ExecStart = "${cfg.package}/bin/tayga -d --nodetach --config /etc/tayga.conf";
181205
ExecReload = "${pkgs.coreutils}/bin/kill -SIGHUP $MAINPID";
182206
Restart = "always";
183207

nixos/tests/tayga.nix

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,10 @@
3131
};
3232

3333
nodes = {
34-
# The server is configured with static IPv4 addresses. RFC 6052 Section 3.1
35-
# disallows the mapping of non-global IPv4 addresses like RFC 1918 into the
36-
# Well-Known Prefix 64:ff9b::/96. TAYGA also does not allow the mapping of
37-
# documentation space (RFC 5737). To circumvent this, 100.64.0.2/24 from
38-
# RFC 6589 (Carrier Grade NAT) is used here.
34+
# The server is configured with static IPv4 addresses. We have to disable the
35+
# well-known prefix restrictions (as required by RFC 6052 Section 3.1) because
36+
# we're using private space (TAYGA also considers documentation space non-global,
37+
# unfortunately).
3938
# To reach the IPv4 address pool of the NAT64 gateway, there is a static
4039
# route configured. In normal cases, where the router would also source NAT
4140
# the pool addresses to one IPv4 addresses, this would not be needed.
@@ -63,6 +62,7 @@
6362
};
6463
};
6564
programs.mtr.enable = true;
65+
environment.systemPackages = [ pkgs.tcpdump ];
6666
};
6767

6868
# The router is configured with static IPv4 addresses towards the server
@@ -87,6 +87,7 @@
8787
];
8888

8989
networking = {
90+
hostName = "router-systemd";
9091
useDHCP = false;
9192
useNetworkd = true;
9293
firewall.enable = false;
@@ -137,7 +138,15 @@
137138
mappings = {
138139
"192.0.2.42" = "2001:db8::2";
139140
};
141+
log = [
142+
"drop"
143+
"reject"
144+
"icmp"
145+
"self"
146+
];
147+
wkpfStrict = false;
140148
};
149+
environment.systemPackages = [ pkgs.tcpdump ];
141150
};
142151

143152
router_nixos = {
@@ -152,6 +161,7 @@
152161
];
153162

154163
networking = {
164+
hostName = "router-nixos";
155165
useDHCP = false;
156166
firewall.enable = false;
157167
interfaces.eth1 = lib.mkForce {
@@ -201,7 +211,15 @@
201211
mappings = {
202212
"192.0.2.42" = "2001:db8::2";
203213
};
214+
log = [
215+
"drop"
216+
"reject"
217+
"icmp"
218+
"self"
219+
];
220+
wkpfStrict = false;
204221
};
222+
environment.systemPackages = [ pkgs.tcpdump ];
205223
};
206224

207225
# The client is configured with static IPv6 addresses. It has also a static
@@ -233,6 +251,7 @@
233251
};
234252
};
235253
programs.mtr.enable = true;
254+
environment.systemPackages = [ pkgs.tcpdump ];
236255
};
237256
};
238257

pkgs/by-name/ta/tayga/package.nix

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,32 @@
11
{
22
lib,
33
stdenv,
4-
fetchurl,
4+
fetchFromGitHub,
55
nixosTests,
66
}:
77

88
stdenv.mkDerivation (finalAttrs: {
9-
version = "0.9.2";
9+
version = "0.9.5";
1010
pname = "tayga";
1111

12-
src = fetchurl {
13-
url = "http://www.litech.org/tayga/tayga-${finalAttrs.version}.tar.bz2";
14-
hash = "sha256-Kx95J6nS3P+Qla/zwnGSSwUsz9L6ypWIsndDGkTwAJw=";
12+
src = fetchFromGitHub {
13+
owner = "apalrd";
14+
repo = "tayga";
15+
tag = finalAttrs.version;
16+
hash = "sha256-xOm4fetFq2UGuhOojrT8WOcX78c6MLTMVbDv+O62x2E=";
1517
};
1618

17-
env.NIX_CFLAGS_COMPILE = toString [
18-
"-Wno-address-of-packed-member"
19-
"-Wno-implicit-function-declaration"
20-
];
19+
preBuild = ''
20+
echo "#define TAYGA_VERSION \"${finalAttrs.version}\"" > version.h
21+
'';
22+
23+
installPhase = ''
24+
install -Dm755 tayga $out/bin/tayga
25+
install -D tayga.conf.5 $out/share/man/man5/tayga.conf.5
26+
install -D tayga.8 $out/share/man/man8/tayga.8
27+
cp -R docs $out/share/
28+
cp tayga.conf.example $out/share/docs/
29+
'';
2130

2231
passthru.tests.tayga = nixosTests.tayga;
2332

@@ -30,7 +39,7 @@ stdenv.mkDerivation (finalAttrs: {
3039
It is intended to provide production-quality NAT64 service
3140
for networks where dedicated NAT64 hardware would be overkill.
3241
'';
33-
homepage = "http://www.litech.org/tayga";
42+
homepage = "https://github.com/apalrd/tayga";
3443
license = licenses.gpl2Plus;
3544
maintainers = with maintainers; [ _0x4A6F ];
3645
platforms = platforms.linux;

0 commit comments

Comments
 (0)