nixcloud / ip2unix

Turn IP sockets into Unix domain sockets
GNU Lesser General Public License v3.0
361 stars 10 forks source link

Add support for host names #26

Open aszlig opened 4 years ago

aszlig commented 4 years ago

Right now, we only support IP addresses when matching connections, but for test environments it's very useful if we could directly match host names. To some extent, this is already possible by using libredirect and providing a custom /etc/hosts, eg. like this:

{ stdenv, writeText, libredirect }:

stdenv.mkDerivation {
  # ...
  LD_PRELOAD = "${libredirect}/lib/libredirect.so";
  NIX_REDIRECTS = "/etc/hosts=${writeText "hosts" ''
    127.0.0.1 localhost somehost
    ::1 localhost somehost
  ''}";
  # ...
}

This however does have a few issues:

Some things we need to investigate to check whether this is worth having in ip2unix:

While there are some benefits as outlined above, it's also tricky to implement and if we don't find a way to do it elegantly or at least not ugly as hell, I won't pursue this further.