This repository has been archived by the owner on May 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 275
/
proto.go
97 lines (81 loc) · 4.19 KB
/
proto.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package main
import (
"fmt"
"time"
"github.com/openatx/androidutils"
)
type CpuInfo struct {
Cores int `json:"cores"`
Hardware string `json:"hardware"`
}
type MemoryInfo struct {
Total int `json:"total"` // unit kB
Around string `json:"around,omitempty"`
}
type OwnerInfo struct {
IP string `json:"ip"`
}
type DeviceInfo struct {
Udid string `json:"udid,omitempty"` // Unique device identifier
PropertyId string `json:"propertyId,omitempty"` // For device managerment, eg: HIH-PHO-1122
Version string `json:"version,omitempty"` // ro.build.version.release
Serial string `json:"serial,omitempty"` // ro.serialno
Brand string `json:"brand,omitempty"` // ro.product.brand
Model string `json:"model,omitempty"` // ro.product.model
HWAddr string `json:"hwaddr,omitempty"` // persist.sys.wifi.mac
Notes string `json:"notes,omitempty"` // device notes
IP string `json:"ip,omitempty"`
Port int `json:"port,omitempty"`
ReverseProxyAddr string `json:"reverseProxyAddr,omitempty"`
ReverseProxyServerAddr string `json:"reverseProxyServerAddr,omitempty"`
Sdk int `json:"sdk,omitempty"`
AgentVersion string `json:"agentVersion,omitempty"`
Display *androidutils.Display `json:"display,omitempty"`
Battery *androidutils.Battery `json:"battery,omitempty"`
Memory *MemoryInfo `json:"memory,omitempty"` // proc/meminfo
Cpu *CpuInfo `json:"cpu,omitempty"` // proc/cpuinfo
Arch string `json:"arch"`
Owner *OwnerInfo `json:"owner" gorethink:"owner,omitempty"`
Reserved string `json:"reserved,omitempty"`
ConnectionCount int `json:"-"` // > 1 happended when phone redial server
CreatedAt time.Time `json:"-" gorethink:"createdAt,omitempty"`
PresenceChangedAt time.Time `json:"presenceChangedAt,omitempty"`
UsingBeganAt time.Time `json:"usingBeganAt,omitempty" gorethink:"usingBeganAt,omitempty"`
Ready *bool `json:"ready,omitempty"`
Present *bool `json:"present,omitempty"`
Using *bool `json:"using,omitempty"`
Product *Product `json:"product" gorethink:"product_id,reference,omitempty" gorethink_ref:"id"`
Provider *Provider `json:"provider" gorethink:"provider_id,reference,omitempty" gorethink_ref:"id"`
// only works when there is provider
ProviderForwardedPort int `json:"providerForwardedPort,omitempty"`
// used for provider to known agent server url
ServerURL string `json:"serverUrl,omitempty"`
}
// "Brand Model Memory CPU" together can define a phone
type Product struct {
Id string `json:"id" gorethink:"id,omitempty"`
Name string `json:"name" gorethink:"name,omitempty"`
Brand string `json:"brand" gorethink:"brand,omitempty"`
Model string `json:"model" gorethink:"model,omitempty"`
Memory string `json:"memory,omitempty"` // eg: 4GB
Cpu string `json:"cpu,omitempty"`
Coverage float32 `json:"coverage" gorethink:"coverage,omitempty"`
Gpu string `json:"gpu,omitempty"`
Link string `json:"link,omitempty"` // Outside link
// AntutuScore int `json:"antutuScore,omitempty"`
}
// u2init
type Provider struct {
Id string `json:"id" gorethink:"id,omitempty"` // machine id
IP string `json:"ip" gorethink:"ip,omitempty"`
Port int `json:"port" gorethink:"port,omitempty"`
Present *bool `json:"present,omitempty"`
Notes string `json:"notes" gorethink:"notes,omitempty"`
Devices []DeviceInfo `json:"devices" gorethink:"devices,omitempty"`
CreatedAt time.Time `json:"createdAt,omitempty"`
PresenceChangedAt time.Time `json:"presenceChangedAt,omitempty"`
}
// Addr combined with ip:port
func (p *Provider) Addr() string {
return fmt.Sprintf("%s:%d", p.IP, p.Port)
}