mirror of
https://github.com/gensokyo-zone/infrastructure.git
synced 2026-02-09 04:19:19 -08:00
feat(access): a llama
This commit is contained in:
parent
e3b6048e32
commit
7bf1ce71de
14 changed files with 323 additions and 6 deletions
19
lib.nix
19
lib.nix
|
|
@ -35,6 +35,19 @@
|
|||
then addr
|
||||
else trimAddress6 addrReplaced;
|
||||
|
||||
bindToAddress = {
|
||||
localhost ? null,
|
||||
localhost4 ? coalesce [localhost "127.0.0.1"],
|
||||
localhost6 ? coalesce [localhost "::1"],
|
||||
}: listen:
|
||||
if listen == "localhost"
|
||||
then coalesce [localhost listen]
|
||||
else if listen == "0.0.0.0"
|
||||
then localhost4
|
||||
else if getAddress6 listen == "::"
|
||||
then localhost6
|
||||
else listen;
|
||||
|
||||
parseUrl = url: let
|
||||
parts' = Regex.match ''^([^:]+)://(\[[0-9a-fA-F:]+]|[^/:\[]+)(|:[0-9]+)(|/.*)$'' url;
|
||||
parts = parts'.value;
|
||||
|
|
@ -60,6 +73,10 @@
|
|||
if Str.hasInfix ":" addr && ! Str.hasPrefix "[" addr
|
||||
then "[${addr}]"
|
||||
else addr;
|
||||
getAddress6 = addr:
|
||||
if Str.hasInfix ":" addr
|
||||
then Str.removePrefix "[" (Str.removeSuffix "]" addr)
|
||||
else addr;
|
||||
|
||||
coalesce = values: Opt.default null (List.find (v: v != null) values);
|
||||
mapListToAttrs = f: l: listToAttrs (map f l);
|
||||
|
|
@ -116,7 +133,9 @@ in {
|
|||
mkWinPath
|
||||
mkBaseDn
|
||||
mkAddress6
|
||||
getAddress6
|
||||
trimAddress6
|
||||
bindToAddress
|
||||
mapListToAttrs
|
||||
coalesce
|
||||
mkAlmostOptionDefault
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue