1 { config, lib, pkgs, ... }:
6 cfg = config.services.bird-lg;
13 default = pkgs.bird-lg;
14 defaultText = literalExpression "pkgs.bird-lg";
15 description = lib.mdDoc "The Bird Looking Glass package to use.";
21 description = lib.mdDoc "User to run the service.";
27 description = lib.mdDoc "Group to run the service.";
31 enable = mkEnableOption (lib.mdDoc "Bird Looking Glass Frontend Webserver");
33 listenAddress = mkOption {
35 default = "127.0.0.1:5000";
36 description = lib.mdDoc "Address to listen on.";
39 proxyPort = mkOption {
42 description = lib.mdDoc "Port bird-lg-proxy is running on.";
48 example = "dn42.lantian.pub";
49 description = lib.mdDoc "Server name domain suffixes.";
53 type = types.listOf types.str;
55 example = [ "gigsgigscloud" "hostdare" ];
56 description = lib.mdDoc "Server name prefixes.";
61 default = "whois.verisign-grs.com";
62 description = lib.mdDoc "Whois server for queries.";
65 dnsInterface = mkOption {
67 default = "asn.cymru.com";
68 description = lib.mdDoc "DNS zone to query ASN information.";
71 bgpMapInfo = mkOption {
72 type = types.listOf types.str;
73 default = [ "asn" "as-name" "ASName" "descr" ];
74 description = lib.mdDoc "Information displayed in bgpmap.";
77 titleBrand = mkOption {
79 default = "Bird-lg Go";
80 description = lib.mdDoc "Prefix of page titles in browser tabs.";
83 netSpecificMode = mkOption {
87 description = lib.mdDoc "Apply network-specific changes for some networks.";
90 protocolFilter = mkOption {
91 type = types.listOf types.str;
94 description = lib.mdDoc "Information displayed in bgpmap.";
97 nameFilter = mkOption {
101 description = lib.mdDoc "Protocol names to hide in summary tables (RE2 syntax),";
107 description = lib.mdDoc "Time before request timed out, in seconds.";
113 default = "Bird-lg Go";
114 description = lib.mdDoc "Brand to show in the navigation bar .";
117 brandURL = mkOption {
120 description = lib.mdDoc "URL of the brand to show in the navigation bar.";
123 allServers = mkOption {
125 default = "ALL Servers";
126 description = lib.mdDoc "Text of 'All server' button in the navigation bar.";
129 allServersURL = mkOption {
132 description = lib.mdDoc "URL of 'All servers' button.";
136 extraArgs = mkOption {
139 description = lib.mdDoc ''
140 Extra parameters documented [here](https://github.com/xddxdd/bird-lg-go#frontend).
146 enable = mkEnableOption (lib.mdDoc "Bird Looking Glass Proxy");
148 listenAddress = mkOption {
150 default = "127.0.0.1:8000";
151 description = lib.mdDoc "Address to listen on.";
154 allowedIPs = mkOption {
155 type = types.listOf types.str;
157 example = [ "192.168.25.52" "192.168.25.53" ];
158 description = lib.mdDoc "List of IPs to allow (default all allowed).";
161 birdSocket = mkOption {
163 default = "/run/bird.ctl";
164 example = "/var/run/bird/bird.ctl";
165 description = lib.mdDoc "Bird control socket path.";
171 default = "${pkgs.traceroute}/bin/traceroute";
172 defaultText = literalExpression ''"''${pkgs.traceroute}/bin/traceroute"'';
173 description = lib.mdDoc "Traceroute's binary path.";
176 rawOutput = mkOption {
179 description = lib.mdDoc "Display traceroute output in raw format.";
183 extraArgs = mkOption {
186 description = lib.mdDoc ''
187 Extra parameters documented [here](https://github.com/xddxdd/bird-lg-go#proxy).
194 ###### implementation
198 bird-lg-frontend = mkIf cfg.frontend.enable {
200 after = [ "network.target" ];
201 wantedBy = [ "multi-user.target" ];
202 description = "Bird Looking Glass Frontend Webserver";
205 Restart = "on-failure";
206 ProtectSystem = "full";
208 MemoryDenyWriteExecute = "yes";
213 ${cfg.package}/bin/frontend \
214 --servers ${concatStringsSep "," cfg.frontend.servers } \
215 --domain ${cfg.frontend.domain} \
216 --listen ${cfg.frontend.listenAddress} \
217 --proxy-port ${toString cfg.frontend.proxyPort} \
218 --whois ${cfg.frontend.whois} \
219 --dns-interface ${cfg.frontend.dnsInterface} \
220 --bgpmap-info ${concatStringsSep "," cfg.frontend.bgpMapInfo } \
221 --title-brand ${cfg.frontend.titleBrand} \
222 --navbar-brand ${cfg.frontend.navbar.brand} \
223 --navbar-brand-url ${cfg.frontend.navbar.brandURL} \
224 --navbar-all-servers ${cfg.frontend.navbar.allServers} \
225 --navbar-all-url ${cfg.frontend.navbar.allServersURL} \
226 --net-specific-mode ${cfg.frontend.netSpecificMode} \
227 --protocol-filter ${concatStringsSep "," cfg.frontend.protocolFilter } \
228 --name-filter ${cfg.frontend.nameFilter} \
229 --time-out ${toString cfg.frontend.timeout} \
230 ${cfg.frontend.extraArgs}
234 bird-lg-proxy = mkIf cfg.proxy.enable {
236 after = [ "network.target" ];
237 wantedBy = [ "multi-user.target" ];
238 description = "Bird Looking Glass Proxy";
241 Restart = "on-failure";
242 ProtectSystem = "full";
244 MemoryDenyWriteExecute = "yes";
249 ${cfg.package}/bin/proxy \
250 --allowed ${concatStringsSep "," cfg.proxy.allowedIPs } \
251 --bird ${cfg.proxy.birdSocket} \
252 --listen ${cfg.proxy.listenAddress} \
253 --traceroute_bin ${cfg.proxy.traceroute.binary}
254 --traceroute_raw ${boolToString cfg.proxy.traceroute.rawOutput}
255 ${cfg.proxy.extraArgs}
259 users = mkIf (cfg.frontend.enable || cfg.proxy.enable) {
260 groups."bird-lg" = mkIf (cfg.group == "bird-lg") { };
261 users."bird-lg" = mkIf (cfg.user == "bird-lg") {
262 description = "Bird Looking Glass user";
263 extraGroups = lib.optionals (config.services.bird2.enable) [ "bird2" ];