feat: add compatible Trojan manager image

This commit is contained in:
chermack
2026-07-26 05:01:15 +08:00
parent 059be96536
commit cb17d56cae
26 changed files with 320 additions and 41 deletions
+6 -6
View File
@@ -48,20 +48,20 @@ func ControlMenu() {
}
// Restart 重启trojan
func Restart() {
func Restart() error {
util.OpenPort(core.GetConfig().LocalPort)
util.SystemctlRestart("trojan")
return util.SystemctlRestart("trojan")
}
// Start 启动trojan
func Start() {
func Start() error {
util.OpenPort(core.GetConfig().LocalPort)
util.SystemctlStart("trojan")
return util.SystemctlStart("trojan")
}
// Stop 停止trojan
func Stop() {
util.SystemctlStop("trojan")
func Stop() error {
return util.SystemctlStop("trojan")
}
// Status 获取trojan状态
+4
View File
@@ -4,6 +4,7 @@ import (
"crypto/sha256"
"fmt"
"trojan/core"
"trojan/managerconfig"
"trojan/util"
)
@@ -52,5 +53,8 @@ func SetDomain(domain string) {
// GetDomainAndPort 获取域名和端口
func GetDomainAndPort() (string, int) {
config := core.GetConfig()
if managed, err := managerconfig.Load(); err == nil && managed.Public.Port != 0 {
return config.SSl.Sni, managed.Public.Port
}
return config.SSl.Sni, config.LocalPort
}