This commit is contained in:
chermack
2026-07-26 00:09:57 +08:00
commit 059be96536
134 changed files with 19678 additions and 0 deletions
+50
View File
@@ -0,0 +1,50 @@
package core
import (
"encoding/json"
"fmt"
"os"
"trojan/asset"
)
// ClientConfig 结构体
type ClientConfig struct {
Config
SSl ClientSSL `json:"ssl"`
Tcp ClientTCP `json:"tcp"`
}
// ClientSSL 结构体
type ClientSSL struct {
SSL
Verify bool `json:"verify"`
VerifyHostname bool `json:"verify_hostname"`
}
// ClientTCP 结构体
type ClientTCP struct {
TCP
}
// WriteClient 生成客户端json
func WriteClient(port int, password, domain, writePath string) bool {
data := asset.GetAsset("client.json")
config := ClientConfig{}
if err := json.Unmarshal(data, &config); err != nil {
fmt.Println(err)
return false
}
config.RemoteAddr = domain
config.RemotePort = port
config.Password = []string{password}
outData, err := json.MarshalIndent(config, "", " ")
if err != nil {
fmt.Println(err)
return false
}
if err = os.WriteFile(writePath, outData, 0644); err != nil {
fmt.Println(err)
return false
}
return true
}