-
Notifications
You must be signed in to change notification settings - Fork 96
/
Copy pathstart_local.go
49 lines (39 loc) · 1.2 KB
/
start_local.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 (
"os"
"github.com/davrodpin/mole/mole"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
var localCmd = &cobra.Command{
Use: "local",
Short: "Starts a ssh local port forwarding tunnel",
Long: `Local Forwarding allows anyone to access outside services like they were
running locally on the source machine.
This could be particular useful for accesing web sites, databases or any kind of
service the source machine does not have direct access to.
Source endpoints are addresses on the same machine where mole is getting executed where clients can connect to access services on the corresponding destination endpoints.
Destination endpoints are adrresess that can be reached from the jump server.
`,
Args: func(cmd *cobra.Command, args []string) error {
conf.TunnelType = "local"
return nil
},
Run: func(cmd *cobra.Command, arg []string) {
client := mole.New(conf)
err := client.Start()
if err != nil {
log.WithError(err).Error("error starting mole")
os.Exit(1)
}
},
}
func init() {
var err error
err = bindFlags(conf, localCmd)
if err != nil {
log.WithError(err).Error("error parsing command line arguments")
os.Exit(1)
}
startCmd.AddCommand(localCmd)
}