- 重构 sysconf 为文档模型 INI Parser 与 Config Framework - 强化 hosts 解析、插入校验、写回与异常输入处理 - 完善 StarCmd 生命周期、等待 API、流式输出与 IO 重定向 - 扩展跨平台文件时间、文件锁、内存、进程与网络能力 - 将 Windows 进程适配更新到 b612.me/wincmd v0.1.0 - 移除本地 wincmd/win32api replace,改用发布版依赖 - 将最低 Go 版本提升到 1.18 - 补充 hosts、sysconf、FileLock、StarCmd 与平台适配回归测试
119 lines
2.0 KiB
Go
119 lines
2.0 KiB
Go
package staros
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
const (
|
|
KB = 1024
|
|
MB = KB << 10
|
|
GB = MB << 10
|
|
TB = GB << 10
|
|
PB = TB << 10
|
|
)
|
|
const (
|
|
TCP_UNKNOWN = iota
|
|
TCP_ESTABLISHED
|
|
TCP_SYN_SENT
|
|
TCP_SYN_RECV
|
|
TCP_FIN_WAIT1
|
|
TCP_FIN_WAIT2
|
|
TCP_TIME_WAIT
|
|
TCP_CLOSE
|
|
TCP_CLOSE_WAIT
|
|
TCP_LAST_ACK
|
|
TCP_LISTEN
|
|
TCP_CLOSING
|
|
)
|
|
|
|
const TCP_LAST_ACL = TCP_LAST_ACK
|
|
|
|
var TCP_STATE = []string{"TCP_UNKNOWN", "TCP_ESTABLISHED", "TCP_SYN_SENT", "TCP_SYN_RECV", "TCP_FIN_WAIT1", "TCP_FIN_WAIT2", "TCP_TIME_WAIT", "TCP_CLOSE", "TCP_CLOSE_WAIT", "TCP_LAST_ACK", "TCP_LISTEN", "TCP_CLOSING"}
|
|
|
|
type NetAdapter struct {
|
|
Name string
|
|
RecvBytes uint64
|
|
SendBytes uint64
|
|
}
|
|
|
|
type NetSpeed struct {
|
|
Name string
|
|
RecvSpeeds float64
|
|
SendSpeeds float64
|
|
RecvBytes uint64
|
|
SendBytes uint64
|
|
}
|
|
|
|
// Process 定义一个进程的信息
|
|
type Process struct {
|
|
PPid int64
|
|
Pid int64
|
|
Name string
|
|
ExecPath string
|
|
LocalPath string
|
|
Path string
|
|
Args []string
|
|
Env []string
|
|
RUID int
|
|
EUID int
|
|
RGID int
|
|
EGID int
|
|
TPid int64
|
|
Uptime time.Time
|
|
VmPeak int64
|
|
VmSize int64
|
|
VmLck int64
|
|
VmHWM int64
|
|
VmRSS int64
|
|
VmData int64
|
|
netConn []NetConn
|
|
netErr error
|
|
Err error
|
|
}
|
|
|
|
func (p Process) GetNetConns() ([]NetConn, error) {
|
|
return p.netConn, p.netErr
|
|
}
|
|
|
|
type MemStatus struct {
|
|
All uint64
|
|
Used uint64
|
|
Free uint64
|
|
Shared uint64
|
|
BuffCache uint64
|
|
Available uint64
|
|
SwapAll uint64
|
|
SwapUsed uint64
|
|
SwapFree uint64
|
|
VirtualAll uint64
|
|
VirtualUsed uint64
|
|
VirtualAvail uint64
|
|
AvailExtended uint64
|
|
}
|
|
|
|
type DiskStatus struct {
|
|
All uint64
|
|
Used uint64
|
|
Free uint64
|
|
Available uint64
|
|
}
|
|
|
|
type NetConn struct {
|
|
LocalAddr string
|
|
LocalPort int
|
|
Typed string
|
|
RemoteAddr string
|
|
RemotePort int
|
|
Socket string
|
|
Inode string
|
|
Status string
|
|
TX_Queue int64
|
|
RX_Queue int64
|
|
TimerActive string
|
|
TimerJiffies int64
|
|
RtoTimer int64
|
|
Pid int64
|
|
Uid int64
|
|
Process *Process
|
|
}
|