summaryrefslogtreecommitdiff
path: root/def.go
diff options
context:
space:
mode:
authorRikki <i@rikki.moe>2025-05-12 15:50:39 +0800
committerRikki <i@rikki.moe>2025-05-12 15:50:39 +0800
commitce8dbb7686bd1d9729b0396d7557db8126fe5cae (patch)
treed57872feae02e8b4e2c798580b2b015414b7f419 /def.go
parent01d8c1c87f545eb1c14221f7a3e5820fc5055496 (diff)
use influx db insteadHEADmaster
Diffstat (limited to 'def.go')
-rw-r--r--def.go66
1 files changed, 0 insertions, 66 deletions
diff --git a/def.go b/def.go
deleted file mode 100644
index e9951ad..0000000
--- a/def.go
+++ /dev/null
@@ -1,66 +0,0 @@
-package v2stat
-
-import (
- "strings"
-)
-
-type TrafficDirection int
-
-const (
- DirectionDownlink TrafficDirection = iota
- DirectionUplink
-)
-
-type ConnectionType int
-
-const (
- ConnTypeUser ConnectionType = iota
- ConnTypeInbound
- ConnTypeOutbound
-)
-
-type ConnInfo struct {
- Type ConnectionType `json:"type"`
- Name string `json:"name"`
-}
-
-type TrafficStat struct {
- Time string `json:"time"`
- Downlink int64 `json:"downlink"`
- Uplink int64 `json:"uplink"`
-}
-
-func (ci *ConnInfo) String() string {
- switch ci.Type {
- case ConnTypeUser:
- return "user:" + ci.Name
- case ConnTypeInbound:
- return "inbound:" + ci.Name
- case ConnTypeOutbound:
- return "outbound:" + ci.Name
- default:
- return "unknown:" + ci.Name
- }
-}
-
-func ParseConnInfo(s string) (ConnInfo, bool) {
- parts := strings.Split(s, ":")
- if len(parts) != 2 {
- return ConnInfo{}, false
- }
- var connType ConnectionType
- switch parts[0] {
- case "user":
- connType = ConnTypeUser
- case "inbound":
- connType = ConnTypeInbound
- case "outbound":
- connType = ConnTypeOutbound
- default:
- return ConnInfo{}, false
- }
- return ConnInfo{
- Type: connType,
- Name: parts[1],
- }, true
-} \ No newline at end of file