mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-11-13 09:17:07 +03:00
Merge pull request #95220 from obsidiansystems/ipfs-quic-socket-activated
nixos/ipfs: Allow QUIC connections to socket activate too
This commit is contained in:
commit
6fffd50623
@ -25,6 +25,15 @@ let
|
||||
then "/${lib.concatStringsSep "/" (lib.tail addr)}"
|
||||
else null; # not valid for listen stream, skip
|
||||
|
||||
multiaddrToListenDatagram = addrRaw: let
|
||||
addr = splitMulitaddr addrRaw;
|
||||
s = builtins.elemAt addr;
|
||||
in if s 0 == "ip4" && s 2 == "udp"
|
||||
then "${s 1}:${s 3}"
|
||||
else if s 0 == "ip6" && s 2 == "udp"
|
||||
then "[${s 1}]:${s 3}"
|
||||
else null; # not valid for listen datagram, skip
|
||||
|
||||
in {
|
||||
|
||||
###### interface
|
||||
@ -268,9 +277,14 @@ in {
|
||||
|
||||
systemd.sockets.ipfs-gateway = {
|
||||
wantedBy = [ "sockets.target" ];
|
||||
socketConfig.ListenStream = let
|
||||
fromCfg = multiaddrToListenStream cfg.gatewayAddress;
|
||||
in [ "" ] ++ lib.optional (fromCfg != null) fromCfg;
|
||||
socketConfig = {
|
||||
ListenStream = let
|
||||
fromCfg = multiaddrToListenStream cfg.gatewayAddress;
|
||||
in [ "" ] ++ lib.optional (fromCfg != null) fromCfg;
|
||||
ListenDatagram = let
|
||||
fromCfg = multiaddrToListenDatagram cfg.gatewayAddress;
|
||||
in [ "" ] ++ lib.optional (fromCfg != null) fromCfg;
|
||||
};
|
||||
};
|
||||
|
||||
systemd.sockets.ipfs-api = {
|
||||
|
@ -379,6 +379,16 @@ in rec {
|
||||
'';
|
||||
};
|
||||
|
||||
listenDatagrams = mkOption {
|
||||
default = [];
|
||||
type = types.listOf types.str;
|
||||
example = [ "0.0.0.0:993" "/run/my-socket" ];
|
||||
description = ''
|
||||
For each item in this list, a <literal>ListenDatagram</literal>
|
||||
option in the <literal>[Socket]</literal> section will be created.
|
||||
'';
|
||||
};
|
||||
|
||||
socketConfig = mkOption {
|
||||
default = {};
|
||||
example = { ListenStream = "/run/my-socket"; };
|
||||
|
@ -354,6 +354,7 @@ let
|
||||
[Socket]
|
||||
${attrsToSection def.socketConfig}
|
||||
${concatStringsSep "\n" (map (s: "ListenStream=${s}") def.listenStreams)}
|
||||
${concatStringsSep "\n" (map (s: "ListenDatagram=${s}") def.listenDatagrams)}
|
||||
'';
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user