Files
sing-box-extended-mirror/experimental/libbox/setup.go
T

38 lines
567 B
Go
Raw Normal View History

2022-10-25 12:55:00 +08:00
package libbox
2023-03-01 10:37:47 +08:00
import (
2023-04-21 17:29:00 +08:00
"os"
2023-03-01 10:37:47 +08:00
C "github.com/sagernet/sing-box/constant"
"github.com/dustin/go-humanize"
)
2022-10-25 12:55:00 +08:00
2023-04-21 17:29:00 +08:00
var (
sBasePath string
sTempPath string
sUserID int
sGroupID int
)
2023-02-22 20:52:57 +08:00
2023-04-21 17:29:00 +08:00
func Setup(basePath string, tempPath string, userID int, groupID int) {
sBasePath = basePath
sTempPath = tempPath
sUserID = userID
sGroupID = groupID
if sUserID == -1 {
sUserID = os.Getuid()
}
if sGroupID == -1 {
sGroupID = os.Getgid()
}
}
2023-02-22 20:52:57 +08:00
func Version() string {
return C.Version
}
2023-03-01 10:37:47 +08:00
func FormatBytes(length int64) string {
2023-03-16 11:15:55 +08:00
return humanize.IBytes(uint64(length))
2023-03-01 10:37:47 +08:00
}