feat: add compatible Trojan manager image
This commit is contained in:
@@ -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) }
|
||||
Reference in New Issue
Block a user