mirror of
https://github.com/SagerNet/sing-box.git
synced 2024-11-10 11:03:13 +00:00
b2092fafb7
Cannot use errno as method and variable due to conflict with objc
38 lines
567 B
Go
38 lines
567 B
Go
package libbox
|
|
|
|
import (
|
|
"os"
|
|
|
|
C "github.com/sagernet/sing-box/constant"
|
|
|
|
"github.com/dustin/go-humanize"
|
|
)
|
|
|
|
var (
|
|
sBasePath string
|
|
sTempPath string
|
|
sUserID int
|
|
sGroupID int
|
|
)
|
|
|
|
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()
|
|
}
|
|
}
|
|
|
|
func Version() string {
|
|
return C.Version
|
|
}
|
|
|
|
func FormatBytes(length int64) string {
|
|
return humanize.IBytes(uint64(length))
|
|
}
|