Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Patterns can be simple absolute domain names, where labels are replaceable with a single glob *
or a globstar **
.
A single glob will match any label in its place, where globstar will greedily match as many labels as possible towards the left.
Admits the escape sequences from domain names. See DNS
.
Note: Currently a globstar is only supported on the left-most label.
Examples of valid patterns are:
*.foo.bar. **.foo.bar. foo.*.bar. foo.bar.*.
Synopsis
- data DomainPattern
- data LabelPattern
- matchesPattern :: Domain -> DomainPattern -> Bool
- patternWorksInside :: DomainPattern -> Domain -> Bool
- labelMatchesPattern :: DomainLabel -> LabelPattern -> Bool
- parsePattern :: Text -> Either String DomainPattern
- patternP :: Parser DomainPattern
- pprPattern :: DomainPattern -> Text
- pprPatternCF :: DomainPattern -> Text
- pprLabelPattern :: LabelPattern -> Text
- pprLabelPatternCF :: LabelPattern -> Text
Pattern language
data DomainPattern Source #
A domain pattern.
Instances
Eq DomainPattern Source # | |
Defined in Network.DNS.Pattern.Internal (==) :: DomainPattern -> DomainPattern -> Bool # (/=) :: DomainPattern -> DomainPattern -> Bool # | |
Ord DomainPattern Source # | |
Defined in Network.DNS.Pattern.Internal compare :: DomainPattern -> DomainPattern -> Ordering # (<) :: DomainPattern -> DomainPattern -> Bool # (<=) :: DomainPattern -> DomainPattern -> Bool # (>) :: DomainPattern -> DomainPattern -> Bool # (>=) :: DomainPattern -> DomainPattern -> Bool # max :: DomainPattern -> DomainPattern -> DomainPattern # min :: DomainPattern -> DomainPattern -> DomainPattern # |
data LabelPattern Source #
A pattern for a singular label.
Instances
Eq LabelPattern Source # | |
Defined in Network.DNS.Pattern.Internal (==) :: LabelPattern -> LabelPattern -> Bool # (/=) :: LabelPattern -> LabelPattern -> Bool # | |
Ord LabelPattern Source # | |
Defined in Network.DNS.Pattern.Internal compare :: LabelPattern -> LabelPattern -> Ordering # (<) :: LabelPattern -> LabelPattern -> Bool # (<=) :: LabelPattern -> LabelPattern -> Bool # (>) :: LabelPattern -> LabelPattern -> Bool # (>=) :: LabelPattern -> LabelPattern -> Bool # max :: LabelPattern -> LabelPattern -> LabelPattern # min :: LabelPattern -> LabelPattern -> LabelPattern # |
matchesPattern :: Domain -> DomainPattern -> Bool Source #
Test whether a given domain matches a DomainPattern
patternWorksInside :: DomainPattern -> Domain -> Bool Source #
Given a pattern and a DNS zone specified by a domain name, test whether or not the pattern is applicable beneath that zone.
foo.*.bar. applicable inside zone quux.bar. foo.bar. applicable inside zone bar. bar. applicable inside zone bar. foo.bar. not applicable inside zone quux.
labelMatchesPattern :: DomainLabel -> LabelPattern -> Bool Source #
Test whether a single label matches a label pattern
Parsing
parsePattern :: Text -> Either String DomainPattern Source #
Parse a domain pattern. Convenience wrapper for 'patternP.
patternP :: Parser DomainPattern Source #
Attoparsec Parser
for domain patterns. See parsePattern
for a convenince wrapper.
Pretty printing
pprPattern :: DomainPattern -> Text Source #
Print domain pattern.
This function nearly roundtrips with parsePattern
up to escape sequence equivalence.
parsePattern . pprPattern ~~~ id
pprPatternCF :: DomainPattern -> Text Source #
Print domain pattern after into presentation format after case-folding according to RFC4343.
This function nearly roundtrips with parsePattern
up to escape sequence equivalence and case folding.
parsePattern . pprPatternCF ~~~ id
pprLabelPattern :: LabelPattern -> Text Source #
Print a singular domain label pattern into a presentation format.
pprLabelPatternCF :: LabelPattern -> Text Source #
Print a singular domain label pattern into a presentation format after case-folding according to RFC4343.