HNHacker News
TopNewBestAskShowJobs

alduin32

182 karma · joined March 10, 2022

submissionscomments
alduin32··on How NAT traversal works (2020)
This is a really well written article, one of the best summaries of NAT traversal I have ever read. I started to laugh mid-way, because it's amusing (and a bit sad) the lengths we have to go to establish communications using the IPv4 addressing space.

It's good to learn about ICE too. I had'nt thought about the security implications : indeed this whole mess makes it very easy for an unprivileged attacker to trick the endpoints into relaying the traffic to their own gateway. For example, if I understand things well, another user behind the NAT can easily make the NAT device relay the traffic to them by sending probes at the same time. I'm not sure how can this be defended against, and if it's even possible.

Is anyone aware of any interesting reading on the subject of MITM of NAT traversal ?

Are there any good software libraries that abstract away all these details

alduin32··on How to Learn Nix
Nix allows to have a "declarative" approach to configuration management, whereas Ansible uses a more "imperative" approach.

For example, applying a Nix configuration is more-or-less guaranteed to be an idempotent operation, while this is not guaranteed at all using Ansible : many Ansible modules are not idempotent at all.

This brings many useful features, for example the ability to rollback to a previous state, or more generally the ability to have some determinism in configuration management of complex systems.

Nix and Docker can be combined together, I have many hosts where some services run in Docker containers, where the Dockerfile is defined in the Nix configuration itself, or generated by composing the upstream Dockerfile with my own configuration values.

alduin32··on How to Learn Nix
I've found the Nix language to be a really useful configuration language, even "outside" of the NixOS ecosystem. I reuse nixpkgs's module system, but to describe things that are used outside of the NixOS system (for example in an Ansible playbook).

For example, I'm using it to describe a set of containers and services in my infrastructure, and it allows me to properly describe the interfaces between the different components of the infrastructure, using several modules : - a "base" module defines the options used for describing the services - one defines the services themselves - one handles the reverse proxy configuration for these services (for multiple frontends), as well as the SSL certificates and DNS zones - one handles the containers themselves (through Docker or LXD) - one handles the networking overlay - one handles the "shared services" (databases, caches, etc)

Each of these modules is basically a function that takes the resulting configuration as argument, allowing it to reuse values defined by the other modules, and the configuration itself is the fixpoint of the composition of all of these functions.

It all composes quite well, and the nixpkgs module system allows me to document the options provided by each module. I can even reuse some of the existing NixOS to create a web interface where other admins can search for configuration options and lookup their documentation. Some things are exported in JSON, some are used directly as NixOS modules, some things source the inventory for Ansible playbooks, etc.

It allowed me to create a well-defined source of truth for a very heteregenous architecture, while preserving some of the existing workflows and tooling.

It's not ideal of course : Nix itself is not typed, the nixpkgs module system provides some typing, but the integration is not perfect, and this makes error handling quite tedious. Also, the interpreter is quite slow, there is no documented way to embed it into your own program, and I

alduin32··on Python built-ins worth learning (2019)
A good example scenario for setdefault/defaultdict is grouping a list of tuples :

    grouped = {}
    for (key, value) in ungrouped:
        group = new.setdefault(key, [])
        group.append(value)
defaultdict(list) would make it even shorter, but setdefault() is more general, as it makes it possible to have a "default" value that depends on the key itself.

defaultdict combined with late-binding closures also allows to define nested dictionaries :

    nested_dict = lambda: defaultdict(nested)
    nested = nested_dict()
    nested[0][1][2] = "value"
alduin32··on Python built-ins worth learning (2019)
The advent of declarative package management (poetry et al.) is a significant change. Not that hard to get working with, but definitely a big departure from previous practices.
alduin32··on Directly converting CO2 into a gasoline fuel (2017)
Wouldn't absorbing 0.06% of the incoming solar energy have a significant impact on the planet's ecosystems, either by the absorbed energy by the massive production of PV and storage required for that end ?

I think that your statement does not rebutt the parent comment : producing the energy required to sustain our modern lifestyle and population count will have significant impacts on the ecosystems, whatever the source we use for that energy.

← PreviousPage 3 of 3