mirror of
https://github.com/bestnite/sub2sing-box.git
synced 2025-04-10 17:05:53 +08:00
Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
87e06ffc67 | ||
a61bb1718e | |||
07f083113b |
@ -15,7 +15,7 @@ import (
|
||||
//go:embed static
|
||||
var staticFiles embed.FS
|
||||
|
||||
func RunServer(port uint16) {
|
||||
func RunServer(bind string, port uint16) {
|
||||
tpl, err := template.ParseFS(staticFiles, "static/*")
|
||||
if err != nil {
|
||||
println(err.Error())
|
||||
@ -41,8 +41,9 @@ func RunServer(port uint16) {
|
||||
|
||||
r.GET("/convert", handler.Convert)
|
||||
|
||||
fmt.Println("Server is running on port", port)
|
||||
err = r.Run(":" + strconv.Itoa(int(port)))
|
||||
address := bind + ":" + strconv.Itoa(int(port))
|
||||
fmt.Println("Server is running on", address)
|
||||
err = r.Run(address)
|
||||
if err != nil {
|
||||
fmt.Println("Run server failed: ", err)
|
||||
}
|
||||
|
@ -6,10 +6,14 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var port uint16
|
||||
var (
|
||||
port uint16
|
||||
bind string
|
||||
)
|
||||
|
||||
func init() {
|
||||
runCmd.Flags().Uint16VarP(&port, "port", "p", 8080, "server port")
|
||||
runCmd.Flags().StringVarP(&bind, "bind", "b", "0.0.0.0", "bind address (e.g., 0.0.0.0, 127.0.0.1, localhost)")
|
||||
RootCmd.AddCommand(runCmd)
|
||||
}
|
||||
|
||||
@ -18,6 +22,6 @@ var runCmd = &cobra.Command{
|
||||
Long: "Run the server",
|
||||
Short: "Run the server",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
api.RunServer(port)
|
||||
api.RunServer(bind, port)
|
||||
},
|
||||
}
|
||||
|
@ -130,10 +130,6 @@
|
||||
"rule_set": "geosite-google",
|
||||
"outbound": "default"
|
||||
},
|
||||
{
|
||||
"rule_set": "geosite-bahamut",
|
||||
"outbound": "台湾(TW)"
|
||||
},
|
||||
{
|
||||
"process_path_regex": [
|
||||
"^.+/steam/compatibilitytools.d/.+",
|
||||
|
@ -130,10 +130,6 @@
|
||||
"rule_set": "geosite-google",
|
||||
"outbound": "default"
|
||||
},
|
||||
{
|
||||
"rule_set": "geosite-bahamut",
|
||||
"outbound": "台湾(TW)"
|
||||
},
|
||||
{
|
||||
"process_path_regex": [
|
||||
"^.+/steam/compatibilitytools.d/.+",
|
||||
|
Loading…
x
Reference in New Issue
Block a user