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
+26
View File
@@ -0,0 +1,26 @@
package cmd
import (
"fmt"
"net/http"
"os"
"path/filepath"
"github.com/spf13/cobra"
)
var acmeHTTPPort int
var acmeHTTPCmd = &cobra.Command{
Use: "acme-http",
Short: "serve only ACME HTTP-01 challenge files",
RunE: func(cmd *cobra.Command, args []string) error {
root := os.Getenv("ACME_WEBROOT")
if root == "" { root = "/var/lib/trojan-acme-webroot" }
if err := os.MkdirAll(filepath.Join(root, ".well-known", "acme-challenge"), 0750); err != nil { return err }
addr := fmt.Sprintf("127.0.0.1:%d", acmeHTTPPort)
return http.ListenAndServe(addr, http.FileServer(http.Dir(root)))
},
}
func init() { acmeHTTPCmd.Flags().IntVar(&acmeHTTPPort, "port", 8082, "ACME HTTP listener port"); rootCmd.AddCommand(acmeHTTPCmd) }