-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.go
55 lines (48 loc) · 1.31 KB
/
server.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package jumpserver
import (
gohtmlmetadata "github.com/go-i2p/go-html-metadata"
"github.com/go-i2p/onramp"
)
type JumpServer struct {
*gohtmlmetadata.Extractor
Index string `json:"index"` // The intro page/index page content of the jump server
Hostnames []*Hostname `json:"hostnames"` // The hostnames of the jump server
SyncURLs []string `json:"syncurls"` // The URLs to sync the hostnames of the jump server with
Garlic *onramp.Garlic
}
func (j *JumpServer) AddHostname(h *Hostname) {
j.Hostnames = append(j.Hostnames, h)
}
func (j *JumpServer) RemoveHostname(h *Hostname) {
for i, host := range j.Hostnames {
if host == h {
j.Hostnames = append(j.Hostnames[:i], j.Hostnames[i+1:]...)
}
}
}
type SearchResult struct {
*Hostname
Registrar bool
Text bool
Tag bool
Addr bool
Host bool
}
type SearchResults []*SearchResult
func (j *JumpServer) Search(query string) SearchResults {
var results SearchResults
for _, host := range j.Hostnames {
registrar, text, tag, addr, hostname := host.FullSearch(query)
if registrar || text || tag || addr || hostname {
results = append(results, &SearchResult{
Hostname: host,
Registrar: registrar,
Text: text,
Tag: tag,
Addr: addr,
Host: hostname,
})
}
}
return results
}