展示服务器列表

This commit is contained in:
奶爸
2019-12-09 18:14:31 +08:00
parent 58277ba0b6
commit bfe6d48927
18 changed files with 173 additions and 77 deletions

View File

@@ -7,8 +7,6 @@ const CtxKeyIsUserLogin = "ckiul"
// CtxKeyOauth2State ..
const CtxKeyOauth2State = "cko2s"
// CtxKeyServer ..
const CtxKeyServer = "cks"
// Common ..
type Common struct {

View File

@@ -11,8 +11,8 @@ const (
// State ..
type State struct {
CPU float64
MEMTotal uint64
MEMUsed uint64
MemTotal uint64
MemUsed uint64
SwapTotal uint64
SwapUsed uint64
DiskTotal uint64
@@ -25,8 +25,8 @@ type State struct {
func (s *State) PB() *pb.State {
return &pb.State{
Cpu: s.CPU,
MemTotal: s.MEMTotal,
MemUsed: s.MEMUsed,
MemTotal: s.MemTotal,
MemUsed: s.MemUsed,
SwapTotal: s.SwapTotal,
SwapUsed: s.SwapUsed,
DiskTotal: s.DiskTotal,
@@ -36,6 +36,21 @@ func (s *State) PB() *pb.State {
}
}
// PB2State ..
func PB2State(s *pb.State) State {
return State{
CPU: s.GetCpu(),
MemTotal: s.GetMemTotal(),
MemUsed: s.GetMemUsed(),
SwapTotal: s.GetSwapTotal(),
SwapUsed: s.GetSwapUsed(),
DiskTotal: s.GetDiskTotal(),
DiskUsed: s.GetDiskUsed(),
NetIn: s.GetNetIn(),
NetOut: s.GetNetOut(),
}
}
// Host ..
type Host struct {
Platform string
@@ -65,3 +80,19 @@ func (h *Host) PB() *pb.Host {
Version: h.Version,
}
}
// PB2Host ...
func PB2Host(h *pb.Host) Host {
return Host{
Platform: h.GetPlatform(),
PlatformVersion: h.GetPlatformVersion(),
CPU: h.GetCpu(),
Arch: h.GetArch(),
Virtualization: h.GetVirtualization(),
Uptime: h.GetUptime(),
BootTime: h.GetBootTime(),
IP: h.GetIp(),
CountryCode: h.GetCountryCode(),
Version: h.GetVersion(),
}
}

View File

@@ -5,4 +5,7 @@ type Server struct {
Common
Name string
Secret string
Host Host
State State
}