2024-03-10 23:21:55 +01:00
|
|
|
{ config, lib, ... }:
|
|
|
|
let
|
|
|
|
cfg = config.networking.dn42;
|
|
|
|
in
|
|
|
|
{
|
2024-03-12 01:15:56 +01:00
|
|
|
imports = [
|
|
|
|
./firewall.nix
|
2024-03-14 18:56:09 +01:00
|
|
|
./bird2.nix
|
2024-03-12 01:15:56 +01:00
|
|
|
];
|
|
|
|
|
2024-03-10 23:21:55 +01:00
|
|
|
options.networking.dn42 = {
|
|
|
|
enable = lib.mkEnableOption "Whether to enable dn42 integration.";
|
|
|
|
|
|
|
|
routerId = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
|
|
|
description = "32bit router identifier.";
|
2024-03-11 23:04:11 +01:00
|
|
|
default = cfg.addr.v4;
|
2024-03-10 23:21:55 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
as = lib.mkOption {
|
|
|
|
type = lib.types.int;
|
2024-03-11 22:32:09 +01:00
|
|
|
description = "Autonomous System Number";
|
2024-03-10 23:21:55 +01:00
|
|
|
};
|
|
|
|
|
2024-03-14 21:42:08 +01:00
|
|
|
geo = lib.mkOption {
|
|
|
|
type = lib.types.int;
|
|
|
|
description = "";
|
|
|
|
};
|
|
|
|
|
|
|
|
country = lib.mkOption {
|
|
|
|
type = lib.types.int;
|
|
|
|
description = "";
|
|
|
|
};
|
|
|
|
|
|
|
|
blockedAs = lib.mkOption {
|
|
|
|
type = lib.types.listOf lib.types.int;
|
|
|
|
description = "";
|
|
|
|
};
|
|
|
|
|
2024-03-10 23:21:55 +01:00
|
|
|
addr = {
|
|
|
|
v4 = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
2024-03-11 22:32:09 +01:00
|
|
|
description = "Primary IPv4 address";
|
2024-03-10 23:21:55 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
v6 = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
2024-03-11 22:32:09 +01:00
|
|
|
description = "Primary IPv6 address";
|
2024-03-10 23:21:55 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-03-11 22:38:29 +01:00
|
|
|
nets = {
|
2024-03-10 23:21:55 +01:00
|
|
|
v4 = lib.mkOption {
|
2024-03-11 22:38:29 +01:00
|
|
|
type = with lib.types; listOf str;
|
2024-03-11 23:06:05 +01:00
|
|
|
description = "Own IPv4 networks, list of CIDR";
|
2024-03-10 23:21:55 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
v6 = lib.mkOption {
|
2024-03-11 22:38:29 +01:00
|
|
|
type = with lib.types; listOf str;
|
2024-03-11 23:06:05 +01:00
|
|
|
description = "Own IPv6 networks, list of CIDR";
|
2024-03-10 23:21:55 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
peers = lib.mkOption {
|
|
|
|
type = lib.types.attrsOf (lib.types.submodule ({ config, name, ... }: {
|
|
|
|
options = {
|
|
|
|
as = lib.mkOption {
|
|
|
|
type = lib.types.int;
|
2024-03-11 22:32:09 +01:00
|
|
|
description = "Autonomous System number of the peer.";
|
2024-03-10 23:21:55 +01:00
|
|
|
};
|
|
|
|
|
2024-03-12 19:56:30 +01:00
|
|
|
extendedNextHop = lib.mkOption {
|
|
|
|
type = lib.types.bool;
|
|
|
|
description = "If extended next-hop should be used. Creating IPv4 routes using an IPv6 next-hop address.";
|
|
|
|
default = false;
|
2024-03-10 23:21:55 +01:00
|
|
|
};
|
|
|
|
|
2024-03-14 21:42:08 +01:00
|
|
|
latency = lib.mkOption {
|
|
|
|
type = lib.types.int;
|
|
|
|
description = "";
|
|
|
|
};
|
|
|
|
|
|
|
|
bandwidth = lib.mkOption {
|
|
|
|
type = lib.types.int;
|
|
|
|
description = "";
|
|
|
|
};
|
|
|
|
|
|
|
|
crypto = lib.mkOption {
|
|
|
|
type = lib.types.int;
|
|
|
|
description = "";
|
|
|
|
};
|
|
|
|
|
2024-03-15 22:15:51 +01:00
|
|
|
transit = lib.mkOption {
|
|
|
|
type = lib.types.bool;
|
|
|
|
description = "";
|
|
|
|
};
|
|
|
|
|
2024-03-10 23:21:55 +01:00
|
|
|
addr = {
|
|
|
|
v4 = lib.mkOption {
|
2024-03-12 19:56:30 +01:00
|
|
|
type = lib.types.nullOr lib.types.str;
|
2024-03-10 23:21:55 +01:00
|
|
|
description = "IPv4 address of the peer.";
|
2024-03-12 19:56:30 +01:00
|
|
|
default = null;
|
2024-03-10 23:21:55 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
v6 = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
|
|
|
description = "IPv6 address of the peer.";
|
|
|
|
};
|
|
|
|
};
|
2024-03-12 00:20:15 +01:00
|
|
|
|
|
|
|
srcAddr = {
|
|
|
|
v4 = lib.mkOption {
|
|
|
|
type = with lib.types; nullOr str;
|
|
|
|
description = "Local IPv4 address to use for BGP.";
|
2024-03-12 19:56:30 +01:00
|
|
|
default = null;
|
2024-03-12 00:20:15 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
v6 = lib.mkOption {
|
|
|
|
type = with lib.types; nullOr str;
|
|
|
|
description = "Local IPv6 address to use for BGP.";
|
|
|
|
};
|
|
|
|
};
|
2024-03-12 19:56:30 +01:00
|
|
|
|
|
|
|
interface = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
|
|
|
description = "Interface name of the peer.";
|
|
|
|
};
|
2024-03-10 23:21:55 +01:00
|
|
|
};
|
|
|
|
}));
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|