mirror of
https://github.com/tuxdotrs/trok.git
synced 2025-07-05 19:46:35 +05:30
feat: rename client cmd to tcp
This commit is contained in:
@ -1,37 +0,0 @@
|
||||
/*
|
||||
Copyright © 2024 tux <0xtux@pm.me>
|
||||
*/
|
||||
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/tuxdotrs/trok/internal/client"
|
||||
)
|
||||
|
||||
// clientCmd represents the local command
|
||||
var clientCmd = &cobra.Command{
|
||||
Use: "client",
|
||||
Short: "Initiates a local proxy to the remote server",
|
||||
Long: "Initiates a local proxy to the remote server",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
serverAddr, err := cmd.Flags().GetString("serverAddr")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
localAddr, err := cmd.Flags().GetString("localAddr")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
client.Start(serverAddr, localAddr)
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(clientCmd)
|
||||
|
||||
clientCmd.Flags().StringP("serverAddr", "s", "trok.cloud:1337", "Remote server address")
|
||||
clientCmd.Flags().StringP("localAddr", "a", "0.0.0.0:80", "Local addr to expose")
|
||||
}
|
@ -27,5 +27,4 @@ func init() {
|
||||
rootCmd.AddCommand(serverCmd)
|
||||
|
||||
serverCmd.Flags().StringP("addr", "a", "0.0.0.0:1337", "Addr for the server to listen on")
|
||||
clientCmd.MarkFlagRequired("addr")
|
||||
}
|
||||
|
33
cmd/tcp.go
Normal file
33
cmd/tcp.go
Normal file
@ -0,0 +1,33 @@
|
||||
/*
|
||||
Copyright © 2024 tux <0xtux@pm.me>
|
||||
*/
|
||||
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/tuxdotrs/trok/internal/client"
|
||||
)
|
||||
|
||||
var tcpCmd = &cobra.Command{
|
||||
Use: "tcp [port]",
|
||||
Short: "Start TCP proxy",
|
||||
Args: cobra.ExactArgs(1),
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
port := args[0]
|
||||
|
||||
serverAddr, err := cmd.Flags().GetString("server")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
client.Start(serverAddr, fmt.Sprintf(":%s", port))
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(tcpCmd)
|
||||
tcpCmd.Flags().StringP("server", "s", "trok.cloud:1337", "Remote server address")
|
||||
}
|
Reference in New Issue
Block a user