-
Notifications
You must be signed in to change notification settings - Fork 379
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0f1d043
commit 8013e2b
Showing
2,568 changed files
with
590,660 additions
and
569 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package container | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"net" | ||
|
||
"github.com/loft-sh/devpod/cmd/flags" | ||
"github.com/loft-sh/devpod/pkg/tailscale" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// NetworkDaemonCmd holds the cmd flags | ||
type NetworkDaemonCmd struct { | ||
*flags.GlobalFlags | ||
|
||
AccessKey string | ||
PlatformHost string | ||
NetworkHostname string | ||
} | ||
|
||
// NewDaemonCmd creates a new command | ||
func NewNetworkDaemonCmd(flags *flags.GlobalFlags) *cobra.Command { | ||
cmd := &NetworkDaemonCmd{ | ||
GlobalFlags: flags, | ||
} | ||
daemonCmd := &cobra.Command{ | ||
Use: "network-daemon", | ||
Short: "Starts tailscale network daemon", | ||
Args: cobra.NoArgs, | ||
RunE: cmd.Run, | ||
} | ||
daemonCmd.Flags().StringVar(&cmd.AccessKey, "access-key", "", "") | ||
daemonCmd.Flags().StringVar(&cmd.PlatformHost, "host", "", "") | ||
daemonCmd.Flags().StringVar(&cmd.NetworkHostname, "hostname", "", "") | ||
return daemonCmd | ||
} | ||
|
||
// Run runs the command logic | ||
func (cmd *NetworkDaemonCmd) Run(_ *cobra.Command, _ []string) error { | ||
tsNet := tailscale.NewTSNet(&tailscale.TSNetConfig{ | ||
AccessKey: cmd.AccessKey, | ||
Host: tailscale.RemoveProtocol(cmd.PlatformHost), | ||
Hostname: cmd.NetworkHostname, | ||
PortHandlers: map[string]func(net.Listener){ | ||
"8022": tailscale.ReverseProxyHandler("127.0.0.1:8022"), | ||
}, | ||
}) | ||
if err := tsNet.Start(context.TODO()); err != nil { | ||
return fmt.Errorf("cannot start tsNet server: %w", err) | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.