Merge pull request #32212 from ryantrinkle/nat-port-forwarding-ranges
Nat port forwarding ranges
This commit is contained in:
commit
3807408c38
@ -219,6 +219,14 @@ rec {
|
|||||||
*/
|
*/
|
||||||
escapeShellArgs = concatMapStringsSep " " escapeShellArg;
|
escapeShellArgs = concatMapStringsSep " " escapeShellArg;
|
||||||
|
|
||||||
|
/* Turn a string into a Nix expression representing that string
|
||||||
|
|
||||||
|
Example:
|
||||||
|
escapeNixString "hello\${}\n"
|
||||||
|
=> "\"hello\\\${}\\n\""
|
||||||
|
*/
|
||||||
|
escapeNixString = s: escape ["$"] (builtins.toJSON s);
|
||||||
|
|
||||||
/* Obsolete - use replaceStrings instead. */
|
/* Obsolete - use replaceStrings instead. */
|
||||||
replaceChars = builtins.replaceStrings or (
|
replaceChars = builtins.replaceStrings or (
|
||||||
del: new: s:
|
del: new: s:
|
||||||
|
@ -174,6 +174,13 @@ rec {
|
|||||||
merge = mergeOneOption;
|
merge = mergeOneOption;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
strMatching = pattern: mkOptionType {
|
||||||
|
name = "strMatching ${escapeNixString pattern}";
|
||||||
|
description = "string matching the pattern ${pattern}";
|
||||||
|
check = x: str.check x && builtins.match pattern x != null;
|
||||||
|
inherit (str) merge;
|
||||||
|
};
|
||||||
|
|
||||||
# Merge multiple definitions by concatenating them (with the given
|
# Merge multiple definitions by concatenating them (with the given
|
||||||
# separator between the values).
|
# separator between the values).
|
||||||
separatedString = sep: mkOptionType rec {
|
separatedString = sep: mkOptionType rec {
|
||||||
|
@ -110,6 +110,12 @@
|
|||||||
<listitem><para>A string. Multiple definitions are concatenated with a
|
<listitem><para>A string. Multiple definitions are concatenated with a
|
||||||
collon <literal>":"</literal>.</para></listitem>
|
collon <literal>":"</literal>.</para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term><varname>types.strMatching</varname></term>
|
||||||
|
<listitem><para>A string matching a specific regular expression. Multiple
|
||||||
|
definitions cannot be merged. The regular expression is processed using
|
||||||
|
<literal>builtins.match</literal>.</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
</variablelist>
|
</variablelist>
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
|
@ -131,15 +131,15 @@ in
|
|||||||
type = with types; listOf (submodule {
|
type = with types; listOf (submodule {
|
||||||
options = {
|
options = {
|
||||||
sourcePort = mkOption {
|
sourcePort = mkOption {
|
||||||
type = types.int;
|
type = types.either types.int (types.strMatching "[[:digit:]]+:[[:digit:]]+");
|
||||||
example = 8080;
|
example = 8080;
|
||||||
description = "Source port of the external interface";
|
description = "Source port of the external interface; to specify a port range, use a string with a colon (e.g. \"60000:61000\")";
|
||||||
};
|
};
|
||||||
|
|
||||||
destination = mkOption {
|
destination = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
example = "10.0.0.1:80";
|
example = "10.0.0.1:80";
|
||||||
description = "Forward connection to destination ip:port";
|
description = "Forward connection to destination ip:port; to specify a port range, use ip:start-end";
|
||||||
};
|
};
|
||||||
|
|
||||||
proto = mkOption {
|
proto = mkOption {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user