-
Notifications
You must be signed in to change notification settings - Fork 1
/
uptime.go
51 lines (46 loc) · 1.75 KB
/
uptime.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
package gonion
// GetUptime returns results from https://onionoo.torproject.org/uptime.
func GetUptime(client HTTPClient, args Params) (*Uptime, error) {
uptime := &Uptime{}
err := getEndp(client, "uptime", args, uptime)
if err != nil {
return nil, err
}
return uptime, nil
}
// Uptime represents the datastructure defined by Onionoo.
// See https://metrics.torproject.org/onionoo.html#uptime.
type Uptime struct {
Version string `json:"version"`
BuildRevision string `json:"build_revision"`
RelaysPublished string `json:"relays_published"`
RelaysSkipped *int `json:"relays_skipped,omitempty"`
Relays []UptimeRelay `json:"relays"`
RelaysTruncated *int `json:"relays_truncated,omitempty"`
BridgesPublished string `json:"bridges_published"`
Bridges []interface{} `json:"bridges"`
BridgesTruncated *int `json:"bridges_truncated,omitempty"`
}
// UptimeRelay is a sub-Uptime datastructure.
type UptimeRelay struct {
Fingerprint string `json:"fingerprint"`
Uptime *History `json:"uptime,omitempty"`
Flags *Flags `json:"flags,omitempty"`
}
// Flags is a sub-UptimeRelay datastructure.
type Flags struct {
Exit *History `json:"Exit,omitempty"`
Fast *History `json:"Fast,omitempty"`
Guard *History `json:"Guard,omitempty"`
HSDir *History `json:"HSDir,omitempty"`
Running *History `json:"Running,omitempty"`
Stable *History `json:"Stable,omitempty"`
StaleDesc *History `json:"StaleDesc,omitempty"`
V2Dir *History `json:"V2Dir,omitempty"`
Valid *History `json:"Valid,omitempty"`
}
// UptimeBridge is a sub-Uptime datastructure.
type UptimeBridge struct {
Fingerprint string `json:"fingerprint"`
Uptime History `json:"uptime"`
}