diff options
author | David Bremner <david@tethera.net> | 2022-03-13 11:40:09 -0300 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2022-03-22 11:14:08 -0700 |
commit | 293e1b299445e73f9149b6e6950dcefdd3c9c299 (patch) | |
tree | 14693790a877dfa81d3d26ce975d0c1332b381b8 /src/util.lisp | |
parent | 0550b8faf77b056e383ad332abbb4304acb8c512 (diff) | |
download | consfigurator-293e1b299445e73f9149b6e6950dcefdd3c9c299.tar.gz |
add VALID-HOSTNAME-P
Initial intended application is checking data source IDEN1. This could be
done as a one-liner with a more complex regex, but that seems harder to debug.
Signed-off-by: David Bremner <david@tethera.net>
Diffstat (limited to 'src/util.lisp')
-rw-r--r-- | src/util.lisp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/util.lisp b/src/util.lisp index 63ca21a..d1658d3 100644 --- a/src/util.lisp +++ b/src/util.lisp @@ -399,6 +399,17 @@ expansion as a starting point for your own DEFPACKAGE form for your consfig." (with-standard-io-syntax (write object :stream fifo) (terpri fifo) (finish-output fifo))) +(defun valid-hostname-p (string) + "Test whether STRING looks like a valid hostname, as defined by RFCs 952 and +1123." + (and + (<= (length string) 253) + (let ((parts (split-string string :separator "."))) + (every (lambda (part) + (and (<= (length part) 63) + (re:scan "^[a-zA-Z0-9][a-zA-Z0-9-]*$" part))) + parts)))) + ;;;; Progress & debug printing |