■ ■ ■ ■ ■ ■
cmd/portforward/portforward.go
| skipped 18 lines |
19 | 19 | | // - parse ports args |
20 | 20 | | // - handle non-default network case |
21 | 21 | | // - handle exposing localhost ports |
22 | | - | // cdebug exec --name helper --image socat <target> <target-port> <random-port> |
23 | | - | // cdebug port-forward helper <host-port>:<random-port> |
| 22 | + | // cdebug exec --name helper --image socat <target> <target-port> <proxy-port> |
| 23 | + | // cdebug port-forward helper <host-port>:<proxy-port> |
| 24 | + | |
| 25 | + | // Possible options (kinda sorta as in ssh -L): |
| 26 | + | // - TARGET_PORT # binds TARGET_IP:TARGET_PORT to a random port on localhost |
| 27 | + | // - TARGET_IP:TARGET_PORT # The second form is needed to: |
| 28 | + | // # 1) allow target's localhost ports expose |
| 29 | + | // # 2) specify a concrete IP if a multi-network target listens on 0.0.0.0 |
| 30 | + | // |
| 31 | + | // - LOCAL_PORT:TARGET_PORT # binds TARGET_IP:TARGET_PORT to LOCAL_PORT on localhost |
| 32 | + | // - LOCAL_PORT:TARGET_IP:TARGET_PORT |
| 33 | + | // |
| 34 | + | // - LOCAL_IP:LOCAL_PORT:TARGET_PORT # binds TARGET_IP:TARGET_PORT to LOCAL_PORT on LOCAL_IP |
| 35 | + | // - LOCAL_IP:LOCAL_PORT:TARGET_IP:TARGET_PORT |
24 | 36 | | |
25 | 37 | | const ( |
26 | 38 | | helperImage = "nixery.dev/socat:latest" |
| skipped 9 lines |
36 | 48 | | var opts options |
37 | 49 | | |
38 | 50 | | cmd := &cobra.Command{ |
39 | | - | Use: "port-forward [OPTIONS] CONTAINER [LOCAL_PORT:]REMOTE_PORT [...[LOCAL_PORT_N:]REMOTE_PORT_N]", |
| 51 | + | Use: "port-forward [OPTIONS] CONTAINER [LOCAL_PORT:]TARGET_PORT [...[LOCAL_PORT_N:]TARGET_PORT_N]", |
40 | 52 | | Short: "Publish a port of an already running container (kind of)", |
41 | 53 | | Args: cobra.MinimumNArgs(2), |
42 | 54 | | RunE: func(cmd *cobra.Command, args []string) error { |
| skipped 101 lines |