summaryrefslogtreecommitdiffstats
path: root/krebs/4lib
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2016-02-07 05:08:32 +0100
committertv <tv@krebsco.de>2016-02-07 05:08:32 +0100
commit52fd80748d95b522561a477a1869d6923516f633 (patch)
treed094884f1c25c488d0e1d84fa31a2a92cfb05e54 /krebs/4lib
parent02c1f8d2703aa03e41adcd5aec0d3ec402bbb367 (diff)
krebs.types.{hostname,label}: check RFC952
Diffstat (limited to 'krebs/4lib')
-rw-r--r--krebs/4lib/types.nix18
1 files changed, 16 insertions, 2 deletions
diff --git a/krebs/4lib/types.nix b/krebs/4lib/types.nix
index f9150379..52eb764e 100644
--- a/krebs/4lib/types.nix
+++ b/krebs/4lib/types.nix
@@ -175,8 +175,6 @@ types // rec {
addr = str;
addr4 = str;
addr6 = str;
- hostname = str;
- label = str;
krebs.file-location = types.submodule {
options = {
@@ -195,6 +193,22 @@ types // rec {
};
};
+ # RFC952, B. Lexical grammar, <hname>
+ hostname = mkOptionType {
+ name = "hostname";
+ check = x: all label.check (splitString "." x);
+ merge = mergeOneOption;
+ };
+
+ # RFC952, B. Lexical grammar, <name>
+ # RFC1123, 2.1 Host Names and Numbers
+ label = mkOptionType {
+ name = "label";
+ # TODO case-insensitive labels
+ check = x: match "[0-9A-Za-z]([0-9A-Za-z-]*[0-9A-Za-z])?" x != null;
+ merge = mergeOneOption;
+ };
+
# POSIX.1‐2013, 3.278 Portable Filename Character Set
filename = mkOptionType {
name = "POSIX filename";