Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
POST /api/v1/recon/scan probes fleet ports from the server host, crawls owned HTTP targets, maps findings to spread lanes, and records optional oath ledger rows.
41 lines
730 B
Go
41 lines
730 B
Go
package recon
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"golang.org/x/net/html"
|
|
)
|
|
|
|
type htmlNode struct {
|
|
tag string
|
|
attrs map[string]string
|
|
children []*htmlNode
|
|
}
|
|
|
|
func (n *htmlNode) attr(key string) string {
|
|
if n == nil || n.attrs == nil {
|
|
return ""
|
|
}
|
|
return n.attrs[key]
|
|
}
|
|
|
|
func parseHTMLTree(body string) (*html.Node, error) {
|
|
return html.Parse(strings.NewReader(body))
|
|
}
|
|
|
|
func toHTMLNode(n *html.Node) *htmlNode {
|
|
if n == nil {
|
|
return nil
|
|
}
|
|
out := &htmlNode{tag: n.Data, attrs: map[string]string{}}
|
|
for _, a := range n.Attr {
|
|
out.attrs[a.Key] = a.Val
|
|
}
|
|
for c := n.FirstChild; c != nil; c = c.NextSibling {
|
|
if child := toHTMLNode(c); child != nil {
|
|
out.children = append(out.children, child)
|
|
}
|
|
}
|
|
return out
|
|
}
|