mirror of
https://github.com/tobychui/zoraxy.git
synced 2025-06-06 07:37:21 +02:00

+ Updated acme well known take-over regrex + Added experimental config export and import + Added unit test for location rewrite in dpcore + Moved all config files to ./conf and original proxy files to ./conf/proxy + Minor optimization on UI regarding TLS verification logo on subdomain and vdir list
38 lines
673 B
Go
38 lines
673 B
Go
//go:build linux
|
|
// +build linux
|
|
|
|
package ganserv
|
|
|
|
import (
|
|
"os"
|
|
"os/exec"
|
|
"os/user"
|
|
"strings"
|
|
|
|
"imuslab.com/zoraxy/mod/utils"
|
|
)
|
|
|
|
func readAuthTokenAsAdmin() (string, error) {
|
|
if utils.FileExists("./conf/authtoken.secret") {
|
|
authKey, err := os.ReadFile("./conf/authtoken.secret")
|
|
if err == nil {
|
|
return strings.TrimSpace(string(authKey)), nil
|
|
}
|
|
}
|
|
|
|
cmd := exec.Command("sudo", "cat", "/var/lib/zerotier-one/authtoken.secret")
|
|
output, err := cmd.Output()
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
return string(output), nil
|
|
}
|
|
|
|
func isAdmin() bool {
|
|
currentUser, err := user.Current()
|
|
if err != nil {
|
|
return false
|
|
}
|
|
return currentUser.Username == "root"
|
|
}
|