fix: tunnel service issue
This commit is contained in:
@@ -2,7 +2,9 @@ package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/hiddify/libcore/config"
|
||||
v2 "github.com/hiddify/libcore/v2"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
@@ -10,12 +12,30 @@ import (
|
||||
|
||||
var commandService = &cobra.Command{
|
||||
Use: "tunnel run/start/stop/install/uninstall",
|
||||
Short: "Tunnel Service run/start/stop/install/uninstall",
|
||||
ValidArgs: []string{"run", "start", "stop", "install", "uninstall"},
|
||||
Short: "Tunnel Service run/start/stop/install/uninstall/activate/deactivate/exit",
|
||||
ValidArgs: []string{"run", "start", "stop", "install", "uninstall", "activate", "deactivate", "exit"},
|
||||
Args: cobra.MatchAll(cobra.ExactArgs(1), cobra.OnlyValidArgs),
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
arg := args[0]
|
||||
code, out := v2.StartTunnelService(arg)
|
||||
fmt.Printf("exitCode:%d msg=%s", code, out)
|
||||
switch arg {
|
||||
case "activate":
|
||||
config.ActivateTunnelService(config.ConfigOptions{
|
||||
InboundOptions: config.InboundOptions{
|
||||
EnableTunService: true,
|
||||
MixedPort: 2334,
|
||||
TUNStack: "gvisor",
|
||||
},
|
||||
})
|
||||
<-time.After(1 * time.Second)
|
||||
|
||||
case "deactivate":
|
||||
config.DeactivateTunnelServiceForce()
|
||||
case "exit":
|
||||
config.ExitTunnelService()
|
||||
default:
|
||||
code, out := v2.StartTunnelService(arg)
|
||||
fmt.Printf("exitCode:%d msg=%s", code, out)
|
||||
}
|
||||
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user