add web api
This commit is contained in:
@ -31,19 +31,28 @@ func (r *hostsRegistry) Unregister(name string) {
|
||||
r.m.Delete(name)
|
||||
}
|
||||
|
||||
func (r *hostsRegistry) IsRegistered(name string) bool {
|
||||
_, ok := r.m.Load(name)
|
||||
return ok
|
||||
}
|
||||
|
||||
func (r *hostsRegistry) Get(name string) hosts.HostMapper {
|
||||
if _, ok := r.m.Load(name); !ok {
|
||||
return nil
|
||||
}
|
||||
return &hostsWrapper{name: name}
|
||||
}
|
||||
|
||||
func (r *hostsRegistry) get(name string) hosts.HostMapper {
|
||||
if v, ok := r.m.Load(name); ok {
|
||||
return v.(hosts.HostMapper)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type hostsWrapper struct {
|
||||
name string
|
||||
}
|
||||
|
||||
func (w *hostsWrapper) Lookup(network, host string) ([]net.IP, bool) {
|
||||
v := Hosts().Get(w.name)
|
||||
v := Hosts().get(w.name)
|
||||
if v == nil {
|
||||
return nil, false
|
||||
}
|
||||
|
Reference in New Issue
Block a user