forked from davrodpin/mole
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start_remote.go
49 lines (38 loc) · 1.24 KB
/
start_remote.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package cmd
import (
"fmt"
"os"
"github.com/davrodpin/mole/mole"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
const (
RemoteForwardDoc = `Remote Forwarding allows anyone to expose a service running locally to a remote machine.
This could be particular useful for giving someone on the outside access to an internal web application, for example.
Source endpoints are addresses on the jump server where clients can connect to access services running on the corresponding destination endpoints.
Destination endpoints are addresses of services running on the same machine where mole is getting executed.`
)
var startRemoteCmd = &cobra.Command{
Use: "remote",
Short: "Starts a ssh remote port forwarding tunnel",
Long: fmt.Sprintf("Starts a ssh remote port forwarding tunnel.\n%s", RemoteForwardDoc),
Args: func(cmd *cobra.Command, args []string) error {
conf.TunnelType = "remote"
return nil
},
Run: func(cmd *cobra.Command, arg []string) {
client := mole.New(conf)
err := client.Start()
if err != nil {
os.Exit(1)
}
},
}
func init() {
err := bindFlags(conf, startRemoteCmd)
if err != nil {
log.WithError(err).Error("error parsing command line arguments")
os.Exit(1)
}
startCmd.AddCommand(startRemoteCmd)
}