{ config, lib, inputs, ... }:

{
  networking.firewall.allowedTCPPorts = [ 3000 1179 ];

  services.fernglas = {
    enable = true;
    settings = {
      api.bind = "[::1]:3000";
      collectors = [
        {
          collector_type = "Bgp";
          bind = "[::]:1179";
          default_peer_config = {
            asn = 4242422953;
            router_id = "${(lib.head config.networking.interfaces.ens18.ipv4.addresses).address}";
            route_state = "Accepted";
            add_path = true;
          };
        }
      ];
    };
  };

  services.nginx.virtualHosts = {
    "lg.ildix.clerie.de" = {
      enableACME = true;
      forceSSL = true;
      locations."/" = {
        root = inputs.fernglas.packages."x86_64-linux"."fernglas-frontend";
      };
      locations."/api/" = {
        proxyPass = "http://${config.services.fernglas.settings.api.bind}";
      };
    };
  };
}