aboutsummaryrefslogtreecommitdiffstats
path: root/hosts/hosts.go
diff options
context:
space:
mode:
authorMartin Polden <mpolden@mpolden.no>2019-06-08 17:28:40 +0200
committerMartin Polden <mpolden@mpolden.no>2019-06-08 17:28:40 +0200
commit6544d1d8ade6331c8c04f75439b13eec9b7fbe98 (patch)
treee6b9b9848b5936b8179b47e57f38e804d3637a9e /hosts/hosts.go
parent527e910184921230e0a97462b609b2880f045806 (diff)
Add support for inline hosts
Diffstat (limited to 'hosts/hosts.go')
-rw-r--r--hosts/hosts.go33
1 files changed, 0 insertions, 33 deletions
diff --git a/hosts/hosts.go b/hosts/hosts.go
index 1a2c066..320b96f 100644
--- a/hosts/hosts.go
+++ b/hosts/hosts.go
@@ -92,36 +92,3 @@ func (p *Parser) Parse(r io.Reader) (Hosts, error) {
}
return entries, nil
}
-
-// A Matcher matches hosts entries.
-type Matcher struct {
- hosts Hosts
- next *Matcher
-}
-
-// Match returns the IP addresses matching name.
-func (m *Matcher) Match(name string) ([]net.IPAddr, bool) {
- for m != nil {
- if m.hosts != nil {
- if ipAddrs, ok := m.hosts.Get(name); ok {
- return ipAddrs, ok
- }
- }
- m = m.next
- }
- return nil, false
-}
-
-// NewMatcher creates a matcher for given hosts.
-func NewMatcher(hosts ...Hosts) *Matcher {
- matcher := &Matcher{}
- m := matcher
- for i, h := range hosts {
- m.hosts = h
- if i < len(hosts)-1 {
- m.next = &Matcher{}
- }
- m = m.next
- }
- return matcher
-}