Source File
hosts.go
Belonging Package
net
byAddr map[string][]string
expire time.Time
path string
mtime time.Time
size int64
}
func () {
:= time.Now()
:= testHookHostsPath
if .Before(hosts.expire) && hosts.path == && len(hosts.byName) > 0 {
return
}
, , := stat()
if == nil && hosts.path == && hosts.mtime.Equal() && hosts.size == {
hosts.expire = .Add(cacheMaxAge)
return
}
:= make(map[string][]string)
:= make(map[string][]string)
var *file
if , _ = open(); == nil {
return
}
for , := .readLine(); ; , = .readLine() {
= [0:]
}
:= getFields()
if len() < 2 {
continue
}
:= parseLiteralIP([0])
if == "" {
continue
}
for := 1; < len(); ++ {
:= absDomainName([]byte([]))
:= []byte([])
lowerASCIIBytes()
:= absDomainName()
[] = append([], )
[] = append([], )
}
:= []byte()
lowerASCIIBytes()
if , := hosts.byName[absDomainName()]; {
:= make([]string, len())
copy(, )
return
}
}
return nil
}
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |