Compare commits

...

5 Commits

Author SHA1 Message Date
fengcaiwen
4c616bda95 chore: try to fix testcase 2023-10-21 19:13:48 +08:00
fengcaiwen
7ef69b5f30 chore: add comment 2023-10-21 18:48:14 +08:00
guoguangwu
afb2e9b667 chore: remove refs to deprecated io/ioutil 2023-10-17 11:20:20 +08:00
fengcaiwen
4c0715e83c feat: multiple connect 2023-10-13 15:41:05 +08:00
wencaiwulue
6252c57b6f feat: update krew index version to refs/tags/v2.0.0 2023-10-02 16:10:43 +08:00
12 changed files with 415 additions and 158 deletions

View File

@@ -0,0 +1,81 @@
package cmds
import (
"fmt"
"os"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
"k8s.io/kubectl/pkg/util/i18n"
"k8s.io/kubectl/pkg/util/templates"
"github.com/wencaiwulue/kubevpn/pkg/config"
"github.com/wencaiwulue/kubevpn/pkg/handler"
"github.com/wencaiwulue/kubevpn/pkg/util"
)
func CmdConnectFork(f cmdutil.Factory) *cobra.Command {
var connect = &handler.ConnectOptions{}
var sshConf = &util.SshConfig{}
var transferImage bool
cmd := &cobra.Command{
Hidden: true,
Use: "connect-fork",
Short: i18n.T("Connect to kubernetes cluster network"),
Long: templates.LongDesc(i18n.T(`Connect to kubernetes cluster network`)),
Example: templates.Examples(i18n.T(`
# Connect to k8s cluster network
kubevpn connect
# Connect to api-server behind of bastion host or ssh jump host
kubevpn connect --ssh-addr 192.168.1.100:22 --ssh-username root --ssh-keyfile /Users/naison/.ssh/ssh.pem
kubevpn connect --ssh-addr 192.168.1.100:22 --ssh-username root --ssh-keyfile ~/.ssh/ssh.pem
# it also support ProxyJump, like
┌──────┐ ┌──────┐ ┌──────┐ ┌──────┐ ┌────────────┐
│ pc ├────►│ ssh1 ├────►│ ssh2 ├────►│ ssh3 ├─────►... ─────► │ api-server │
└──────┘ └──────┘ └──────┘ └──────┘ └────────────┘
kubevpn connect --ssh-alias <alias>
`)),
PreRunE: func(cmd *cobra.Command, args []string) (err error) {
util.InitLogger(false)
if transferImage {
err = util.TransferImage(cmd.Context(), sshConf, config.OriginImage, config.Image, os.Stdout)
if err != nil {
return err
}
}
return handler.SshJumpAndSetEnv(cmd.Context(), sshConf, cmd.Flags(), true)
},
RunE: func(cmd *cobra.Command, args []string) error {
if err := connect.InitClient(f); err != nil {
return err
}
_, err := connect.RentInnerIP(cmd.Context())
if err != nil {
return err
}
err = connect.DoConnect(cmd.Context())
if err != nil {
log.Errorln(err)
connect.Cleanup()
} else {
util.Print(os.Stdout, "Now you can access resources in the kubernetes cluster, enjoy it :)")
}
<-cmd.Context().Done()
return nil
},
}
cmd.Flags().BoolVar(&config.Debug, "debug", false, "enable debug mode or not, true or false")
cmd.Flags().StringVar(&config.Image, "image", config.Image, "use this image to startup container")
cmd.Flags().StringArrayVar(&connect.ExtraCIDR, "extra-cidr", []string{}, "Extra cidr string, eg: --extra-cidr 192.168.0.159/24 --extra-cidr 192.168.1.160/32")
cmd.Flags().StringArrayVar(&connect.ExtraDomain, "extra-domain", []string{}, "Extra domain string, the resolved ip will add to route table, eg: --extra-domain test.abc.com --extra-domain foo.test.com")
cmd.Flags().BoolVar(&transferImage, "transfer-image", false, "transfer image to remote registry, it will transfer image "+config.OriginImage+" to flags `--image` special image, default: "+config.Image)
cmd.Flags().BoolVar(&connect.UseLocalDNS, "use-localdns", false, "if use-lcoaldns is true, kubevpn will start coredns listen at 53 to forward your dns queries. only support on linux now")
cmd.Flags().StringVar((*string)(&connect.Engine), "engine", string(config.EngineRaw), fmt.Sprintf(`transport engine ("%s"|"%s") %s: use gvisor and raw both (both performance and stable), %s: use raw mode (best stable)`, config.EngineMix, config.EngineRaw, config.EngineMix, config.EngineRaw))
addSshFlags(cmd, sshConf)
return cmd
}

View File

@@ -1,11 +1,9 @@
package cmds
import (
"context"
"fmt"
"io"
"os"
"time"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
@@ -63,49 +61,46 @@ func CmdConnect(f cmdutil.Factory) *cobra.Command {
SshJump: sshConf.ToRPC(),
TransferImage: transferImage,
Foreground: foreground,
Image: config.Image,
Level: int32(log.DebugLevel),
}
cli := daemon.GetClient(false)
resp, err := cli.Connect(cmd.Context(), req)
if err != nil {
return err
}
for {
recv, err := resp.Recv()
if err == io.EOF {
break
} else if code := status.Code(err); code == codes.DeadlineExceeded || code == codes.Canceled {
return nil
} else if err != nil {
return err
}
fmt.Fprint(os.Stdout, recv.GetMessage())
}
util.Print(os.Stdout, "Now you can access resources in the kubernetes cluster, enjoy it :)")
// hangup
// if is foreground, send to sudo daemon server
if foreground {
// disconnect from cluster network
<-cmd.Context().Done()
now := time.Now()
stream, err := cli.Disconnect(context.Background(), &rpc.DisconnectRequest{})
fmt.Printf("call api disconnect use %s\n", time.Now().Sub(now).String())
cli := daemon.GetClient(true)
resp, err := cli.ConnectFork(cmd.Context(), req)
if err != nil {
return err
}
var resp *rpc.DisconnectResponse
for {
resp, err = stream.Recv()
recv, err := resp.Recv()
if err == io.EOF {
return nil
break
} else if code := status.Code(err); code == codes.DeadlineExceeded || code == codes.Canceled {
return nil
} else if err != nil {
return err
}
fmt.Fprint(os.Stdout, resp.Message)
fmt.Fprint(os.Stdout, recv.GetMessage())
}
} else {
cli := daemon.GetClient(false)
resp, err := cli.Connect(cmd.Context(), req)
if err != nil {
return err
}
for {
recv, err := resp.Recv()
if err == io.EOF {
break
} else if code := status.Code(err); code == codes.DeadlineExceeded || code == codes.Canceled {
return nil
} else if err != nil {
return err
}
fmt.Fprint(os.Stdout, recv.GetMessage())
}
util.Print(os.Stdout, "Now you can access resources in the kubernetes cluster, enjoy it :)")
}
return nil
},
@@ -117,7 +112,7 @@ func CmdConnect(f cmdutil.Factory) *cobra.Command {
cmd.Flags().BoolVar(&transferImage, "transfer-image", false, "transfer image to remote registry, it will transfer image "+config.OriginImage+" to flags `--image` special image, default: "+config.Image)
cmd.Flags().BoolVar(&connect.UseLocalDNS, "use-localdns", false, "if use-lcoaldns is true, kubevpn will start coredns listen at 53 to forward your dns queries. only support on linux now")
cmd.Flags().StringVar((*string)(&connect.Engine), "engine", string(config.EngineRaw), fmt.Sprintf(`transport engine ("%s"|"%s") %s: use gvisor and raw both (both performance and stable), %s: use raw mode (best stable)`, config.EngineMix, config.EngineRaw, config.EngineMix, config.EngineRaw))
cmd.Flags().BoolVar(&foreground, "foreground", false, "foreground hang up")
cmd.Flags().BoolVar(&foreground, "foreground", false, "connect to multiple cluster, you needs to special this options")
addSshFlags(cmd, sshConf)
return cmd

View File

@@ -50,6 +50,7 @@ func NewKubeVPNCommand() *cobra.Command {
Message: "Develop commands:",
Commands: []*cobra.Command{
CmdConnect(factory),
CmdConnectFork(factory),
CmdDisconnect(factory),
CmdProxy(factory),
CmdLeave(factory),

View File

@@ -0,0 +1,105 @@
package action
import (
"context"
"fmt"
"io"
"os"
"os/exec"
"strings"
log "github.com/sirupsen/logrus"
"k8s.io/apimachinery/pkg/util/sets"
"github.com/wencaiwulue/kubevpn/pkg/config"
"github.com/wencaiwulue/kubevpn/pkg/daemon/rpc"
"github.com/wencaiwulue/kubevpn/pkg/util"
)
func (svr *Server) ConnectFork(req *rpc.ConnectRequest, resp rpc.Daemon_ConnectForkServer) error {
defer func() {
log.SetOutput(svr.LogFile)
log.SetLevel(log.DebugLevel)
}()
out := io.MultiWriter(newWarp(resp), svr.LogFile)
log.SetOutput(out)
log.SetLevel(log.InfoLevel)
if !svr.IsSudo {
return fmt.Errorf("connect-fork should not send to sudo daemon server")
}
ctx := resp.Context()
return fork(ctx, req, out)
}
func fork(ctx context.Context, req *rpc.ConnectRequest, out io.Writer) error {
exe, err := os.Executable()
if err != nil {
return fmt.Errorf("get executable error: %s", err.Error())
}
var args = []string{"connect-fork"}
if req.SshJump != nil {
if req.SshJump.Addr != "" {
args = append(args, "--ssh-addr", req.SshJump.Addr)
}
if req.SshJump.User != "" {
args = append(args, "--ssh-username", req.SshJump.User)
}
if req.SshJump.Password != "" {
args = append(args, "--ssh-password", req.SshJump.Password)
}
if req.SshJump.Keyfile != "" {
args = append(args, "--ssh-keyfile", req.SshJump.Keyfile)
}
if req.SshJump.ConfigAlias != "" { // alias in ~/.ssh/config
args = append(args, "--ssh-alias", req.SshJump.ConfigAlias)
}
if req.SshJump.RemoteKubeconfig != "" { // remote path in ssh server
args = append(args, "--remote-kubeconfig", req.SshJump.RemoteKubeconfig)
}
}
if req.KubeconfigBytes != "" {
var path string
path, err = util.ConvertToTempKubeconfigFile([]byte(req.KubeconfigBytes))
if err != nil {
return err
}
args = append(args, "--kubeconfig", path)
}
if req.Namespace != "" {
args = append(args, "-n", req.Namespace)
}
if req.Image != "" {
args = append(args, "--image", req.Image)
}
if req.TransferImage {
args = append(args, "--transfer-image")
}
for _, v := range req.ExtraCIDR {
args = append(args, "--extra-cidr", v)
}
for _, v := range req.ExtraDomain {
args = append(args, "--extra-domain", v)
}
env := os.Environ()
envKeys := sets.New[string](config.EnvInboundPodTunIPv4, config.EnvInboundPodTunIPv6, config.EnvTunNameOrLUID)
for i := 0; i < len(env); i++ {
index := strings.Index(env[i], "=")
envKey := env[i][:index]
if envKeys.HasAny(envKey) {
env = append(env[:i], env[i+1:]...)
i--
continue
}
}
cmd := exec.CommandContext(ctx, exe, args...)
cmd.Env = env
cmd.Stdout = out
cmd.Stderr = out
err = cmd.Run()
if err != nil {
return fmt.Errorf("fork to exec connect error: %s", err.Error())
}
return nil
}

View File

@@ -38,8 +38,10 @@ type ConnectRequest struct {
// transfer image
TransferImage bool `protobuf:"varint,10,opt,name=TransferImage,proto3" json:"TransferImage,omitempty"`
Image string `protobuf:"bytes,11,opt,name=Image,proto3" json:"Image,omitempty"`
// foreground
Foreground bool `protobuf:"varint,12,opt,name=Foreground,proto3" json:"Foreground,omitempty"`
// log level
Level int32 `protobuf:"varint,12,opt,name=Level,proto3" json:"Level,omitempty"`
Level int32 `protobuf:"varint,13,opt,name=Level,proto3" json:"Level,omitempty"`
}
func (x *ConnectRequest) Reset() {
@@ -151,6 +153,13 @@ func (x *ConnectRequest) GetImage() string {
return ""
}
func (x *ConnectRequest) GetForeground() bool {
if x != nil {
return x.Foreground
}
return false
}
func (x *ConnectRequest) GetLevel() int32 {
if x != nil {
return x.Level
@@ -1701,7 +1710,7 @@ var File_daemon_proto protoreflect.FileDescriptor
var file_daemon_proto_rawDesc = []byte{
0x0a, 0x0c, 0x64, 0x61, 0x65, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x03,
0x72, 0x70, 0x63, 0x22, 0xe2, 0x03, 0x0a, 0x0e, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x52,
0x72, 0x70, 0x63, 0x22, 0x82, 0x04, 0x0a, 0x0e, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x52,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x28, 0x0a, 0x0f, 0x4b, 0x75, 0x62, 0x65, 0x63, 0x6f,
0x6e, 0x66, 0x69, 0x67, 0x42, 0x79, 0x74, 0x65, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
0x0f, 0x4b, 0x75, 0x62, 0x65, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x42, 0x79, 0x74, 0x65, 0x73,
@@ -1726,8 +1735,10 @@ var file_daemon_proto_rawDesc = []byte{
0x61, 0x6e, 0x73, 0x66, 0x65, 0x72, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28,
0x08, 0x52, 0x0d, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x66, 0x65, 0x72, 0x49, 0x6d, 0x61, 0x67, 0x65,
0x12, 0x14, 0x0a, 0x05, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52,
0x05, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x18,
0x0c, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x1a, 0x3a, 0x0a, 0x0c,
0x05, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x46, 0x6f, 0x72, 0x65, 0x67, 0x72,
0x6f, 0x75, 0x6e, 0x64, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x46, 0x6f, 0x72, 0x65,
0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x18,
0x0d, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x1a, 0x3a, 0x0a, 0x0c,
0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03,
0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14,
0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76,
@@ -1869,60 +1880,64 @@ var file_daemon_proto_rawDesc = []byte{
0x69, 0x61, 0x73, 0x12, 0x2a, 0x0a, 0x10, 0x52, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x4b, 0x75, 0x62,
0x65, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x52,
0x65, 0x6d, 0x6f, 0x74, 0x65, 0x4b, 0x75, 0x62, 0x65, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x32,
0xc1, 0x06, 0x0a, 0x06, 0x44, 0x61, 0x65, 0x6d, 0x6f, 0x6e, 0x12, 0x38, 0x0a, 0x07, 0x43, 0x6f,
0xff, 0x06, 0x0a, 0x06, 0x44, 0x61, 0x65, 0x6d, 0x6f, 0x6e, 0x12, 0x38, 0x0a, 0x07, 0x43, 0x6f,
0x6e, 0x6e, 0x65, 0x63, 0x74, 0x12, 0x13, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x6f, 0x6e, 0x6e,
0x65, 0x63, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x72, 0x70, 0x63,
0x2e, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x22, 0x00, 0x30, 0x01, 0x12, 0x41, 0x0a, 0x0a, 0x44, 0x69, 0x73, 0x63, 0x6f, 0x6e, 0x6e, 0x65,
0x63, 0x74, 0x12, 0x16, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x69, 0x73, 0x63, 0x6f, 0x6e, 0x6e,
0x65, 0x63, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x72, 0x70, 0x63,
0x2e, 0x44, 0x69, 0x73, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x6e, 0x73, 0x65, 0x22, 0x00, 0x30, 0x01, 0x12, 0x36, 0x0a, 0x05, 0x50, 0x72, 0x6f, 0x78, 0x79,
0x12, 0x13, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x52, 0x65,
0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x6f, 0x6e, 0x6e,
0x65, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x30, 0x01, 0x12,
0x32, 0x0a, 0x05, 0x4c, 0x65, 0x61, 0x76, 0x65, 0x12, 0x11, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x4c,
0x65, 0x61, 0x76, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x72, 0x70,
0x63, 0x2e, 0x4c, 0x65, 0x61, 0x76, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22,
0x00, 0x30, 0x01, 0x12, 0x32, 0x0a, 0x05, 0x43, 0x6c, 0x6f, 0x6e, 0x65, 0x12, 0x11, 0x2e, 0x72,
0x70, 0x63, 0x2e, 0x43, 0x6c, 0x6f, 0x6e, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,
0x12, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x6c, 0x6f, 0x6e, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x6e, 0x73, 0x65, 0x22, 0x00, 0x30, 0x01, 0x12, 0x35, 0x0a, 0x06, 0x52, 0x65, 0x6d, 0x6f, 0x76,
0x65, 0x12, 0x12, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x52, 0x65,
0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x6d, 0x6f,
0x76, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x30, 0x01, 0x12, 0x3c,
0x0a, 0x09, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x41, 0x64, 0x64, 0x12, 0x15, 0x2e, 0x72, 0x70,
0x63, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x41, 0x64, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x41,
0x64, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x45, 0x0a, 0x0c,
0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x12, 0x18, 0x2e, 0x72,
0x70, 0x63, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x52,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x6f, 0x6e,
0x66, 0x69, 0x67, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x22, 0x00, 0x12, 0x2d, 0x0a, 0x04, 0x4c, 0x6f, 0x67, 0x73, 0x12, 0x0f, 0x2e, 0x72, 0x70,
0x63, 0x2e, 0x4c, 0x6f, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x10, 0x2e, 0x72,
0x70, 0x63, 0x2e, 0x4c, 0x6f, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00,
0x30, 0x01, 0x12, 0x2d, 0x0a, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x10, 0x2e, 0x72, 0x70, 0x63,
0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x72,
0x70, 0x63, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22,
0x00, 0x12, 0x2a, 0x0a, 0x03, 0x47, 0x65, 0x74, 0x12, 0x0f, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47,
0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x10, 0x2e, 0x72, 0x70, 0x63, 0x2e,
0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x36, 0x0a,
0x07, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x12, 0x13, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x55,
0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e,
0x72, 0x70, 0x63, 0x2e, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x33, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12,
0x12, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73,
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x36, 0x0a, 0x07, 0x56, 0x65,
0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x13, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x56, 0x65, 0x72, 0x73,
0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x72, 0x70, 0x63,
0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x22, 0x00, 0x12, 0x2f, 0x0a, 0x04, 0x51, 0x75, 0x69, 0x74, 0x12, 0x10, 0x2e, 0x72, 0x70, 0x63,
0x2e, 0x51, 0x75, 0x69, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x72,
0x70, 0x63, 0x2e, 0x51, 0x75, 0x69, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22,
0x00, 0x30, 0x01, 0x42, 0x07, 0x5a, 0x05, 0x2e, 0x3b, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x33,
0x22, 0x00, 0x30, 0x01, 0x12, 0x3c, 0x0a, 0x0b, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x46,
0x6f, 0x72, 0x6b, 0x12, 0x13, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63,
0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x43,
0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00,
0x30, 0x01, 0x12, 0x41, 0x0a, 0x0a, 0x44, 0x69, 0x73, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74,
0x12, 0x16, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x69, 0x73, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63,
0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x44,
0x69, 0x73, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x22, 0x00, 0x30, 0x01, 0x12, 0x36, 0x0a, 0x05, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x12, 0x13,
0x2e, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63,
0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x30, 0x01, 0x12, 0x32, 0x0a,
0x05, 0x4c, 0x65, 0x61, 0x76, 0x65, 0x12, 0x11, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x4c, 0x65, 0x61,
0x76, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x72, 0x70, 0x63, 0x2e,
0x4c, 0x65, 0x61, 0x76, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x30,
0x01, 0x12, 0x32, 0x0a, 0x05, 0x43, 0x6c, 0x6f, 0x6e, 0x65, 0x12, 0x11, 0x2e, 0x72, 0x70, 0x63,
0x2e, 0x43, 0x6c, 0x6f, 0x6e, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e,
0x72, 0x70, 0x63, 0x2e, 0x43, 0x6c, 0x6f, 0x6e, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x22, 0x00, 0x30, 0x01, 0x12, 0x35, 0x0a, 0x06, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x12,
0x12, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65,
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x30, 0x01, 0x12, 0x3c, 0x0a, 0x09,
0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x41, 0x64, 0x64, 0x12, 0x15, 0x2e, 0x72, 0x70, 0x63, 0x2e,
0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x41, 0x64, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x1a, 0x16, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x41, 0x64, 0x64,
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x45, 0x0a, 0x0c, 0x43, 0x6f,
0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x12, 0x18, 0x2e, 0x72, 0x70, 0x63,
0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x52, 0x65, 0x71,
0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69,
0x67, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22,
0x00, 0x12, 0x2d, 0x0a, 0x04, 0x4c, 0x6f, 0x67, 0x73, 0x12, 0x0f, 0x2e, 0x72, 0x70, 0x63, 0x2e,
0x4c, 0x6f, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x10, 0x2e, 0x72, 0x70, 0x63,
0x2e, 0x4c, 0x6f, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x30, 0x01,
0x12, 0x2d, 0x0a, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x10, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x4c,
0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x72, 0x70, 0x63,
0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12,
0x2a, 0x0a, 0x03, 0x47, 0x65, 0x74, 0x12, 0x0f, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x10, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65,
0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x36, 0x0a, 0x07, 0x55,
0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x12, 0x13, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x55, 0x70, 0x67,
0x72, 0x61, 0x64, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x72, 0x70,
0x63, 0x2e, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x22, 0x00, 0x12, 0x33, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x12, 0x2e,
0x72, 0x70, 0x63, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x1a, 0x13, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x36, 0x0a, 0x07, 0x56, 0x65, 0x72, 0x73,
0x69, 0x6f, 0x6e, 0x12, 0x13, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f,
0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x56,
0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00,
0x12, 0x2f, 0x0a, 0x04, 0x51, 0x75, 0x69, 0x74, 0x12, 0x10, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x51,
0x75, 0x69, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x72, 0x70, 0x63,
0x2e, 0x51, 0x75, 0x69, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x30,
0x01, 0x42, 0x07, 0x5a, 0x05, 0x2e, 0x3b, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x33,
}
var (
@@ -1980,37 +1995,39 @@ var file_daemon_proto_depIdxs = []int32{
29, // 4: rpc.ConfigAddRequest.SshJump:type_name -> rpc.SshJump
26, // 5: rpc.GetResponse.metadata:type_name -> rpc.metadata
0, // 6: rpc.Daemon.Connect:input_type -> rpc.ConnectRequest
2, // 7: rpc.Daemon.Disconnect:input_type -> rpc.DisconnectRequest
0, // 8: rpc.Daemon.Proxy:input_type -> rpc.ConnectRequest
4, // 9: rpc.Daemon.Leave:input_type -> rpc.LeaveRequest
6, // 10: rpc.Daemon.Clone:input_type -> rpc.CloneRequest
8, // 11: rpc.Daemon.Remove:input_type -> rpc.RemoveRequest
16, // 12: rpc.Daemon.ConfigAdd:input_type -> rpc.ConfigAddRequest
18, // 13: rpc.Daemon.ConfigRemove:input_type -> rpc.ConfigRemoveRequest
20, // 14: rpc.Daemon.Logs:input_type -> rpc.LogRequest
22, // 15: rpc.Daemon.List:input_type -> rpc.ListRequest
24, // 16: rpc.Daemon.Get:input_type -> rpc.GetRequest
27, // 17: rpc.Daemon.Upgrade:input_type -> rpc.UpgradeRequest
12, // 18: rpc.Daemon.Status:input_type -> rpc.StatusRequest
14, // 19: rpc.Daemon.Version:input_type -> rpc.VersionRequest
10, // 20: rpc.Daemon.Quit:input_type -> rpc.QuitRequest
1, // 21: rpc.Daemon.Connect:output_type -> rpc.ConnectResponse
3, // 22: rpc.Daemon.Disconnect:output_type -> rpc.DisconnectResponse
1, // 23: rpc.Daemon.Proxy:output_type -> rpc.ConnectResponse
5, // 24: rpc.Daemon.Leave:output_type -> rpc.LeaveResponse
7, // 25: rpc.Daemon.Clone:output_type -> rpc.CloneResponse
9, // 26: rpc.Daemon.Remove:output_type -> rpc.RemoveResponse
17, // 27: rpc.Daemon.ConfigAdd:output_type -> rpc.ConfigAddResponse
19, // 28: rpc.Daemon.ConfigRemove:output_type -> rpc.ConfigRemoveResponse
21, // 29: rpc.Daemon.Logs:output_type -> rpc.LogResponse
23, // 30: rpc.Daemon.List:output_type -> rpc.ListResponse
25, // 31: rpc.Daemon.Get:output_type -> rpc.GetResponse
28, // 32: rpc.Daemon.Upgrade:output_type -> rpc.UpgradeResponse
13, // 33: rpc.Daemon.Status:output_type -> rpc.StatusResponse
15, // 34: rpc.Daemon.Version:output_type -> rpc.VersionResponse
11, // 35: rpc.Daemon.Quit:output_type -> rpc.QuitResponse
21, // [21:36] is the sub-list for method output_type
6, // [6:21] is the sub-list for method input_type
0, // 7: rpc.Daemon.ConnectFork:input_type -> rpc.ConnectRequest
2, // 8: rpc.Daemon.Disconnect:input_type -> rpc.DisconnectRequest
0, // 9: rpc.Daemon.Proxy:input_type -> rpc.ConnectRequest
4, // 10: rpc.Daemon.Leave:input_type -> rpc.LeaveRequest
6, // 11: rpc.Daemon.Clone:input_type -> rpc.CloneRequest
8, // 12: rpc.Daemon.Remove:input_type -> rpc.RemoveRequest
16, // 13: rpc.Daemon.ConfigAdd:input_type -> rpc.ConfigAddRequest
18, // 14: rpc.Daemon.ConfigRemove:input_type -> rpc.ConfigRemoveRequest
20, // 15: rpc.Daemon.Logs:input_type -> rpc.LogRequest
22, // 16: rpc.Daemon.List:input_type -> rpc.ListRequest
24, // 17: rpc.Daemon.Get:input_type -> rpc.GetRequest
27, // 18: rpc.Daemon.Upgrade:input_type -> rpc.UpgradeRequest
12, // 19: rpc.Daemon.Status:input_type -> rpc.StatusRequest
14, // 20: rpc.Daemon.Version:input_type -> rpc.VersionRequest
10, // 21: rpc.Daemon.Quit:input_type -> rpc.QuitRequest
1, // 22: rpc.Daemon.Connect:output_type -> rpc.ConnectResponse
1, // 23: rpc.Daemon.ConnectFork:output_type -> rpc.ConnectResponse
3, // 24: rpc.Daemon.Disconnect:output_type -> rpc.DisconnectResponse
1, // 25: rpc.Daemon.Proxy:output_type -> rpc.ConnectResponse
5, // 26: rpc.Daemon.Leave:output_type -> rpc.LeaveResponse
7, // 27: rpc.Daemon.Clone:output_type -> rpc.CloneResponse
9, // 28: rpc.Daemon.Remove:output_type -> rpc.RemoveResponse
17, // 29: rpc.Daemon.ConfigAdd:output_type -> rpc.ConfigAddResponse
19, // 30: rpc.Daemon.ConfigRemove:output_type -> rpc.ConfigRemoveResponse
21, // 31: rpc.Daemon.Logs:output_type -> rpc.LogResponse
23, // 32: rpc.Daemon.List:output_type -> rpc.ListResponse
25, // 33: rpc.Daemon.Get:output_type -> rpc.GetResponse
28, // 34: rpc.Daemon.Upgrade:output_type -> rpc.UpgradeResponse
13, // 35: rpc.Daemon.Status:output_type -> rpc.StatusResponse
15, // 36: rpc.Daemon.Version:output_type -> rpc.VersionResponse
11, // 37: rpc.Daemon.Quit:output_type -> rpc.QuitResponse
22, // [22:38] is the sub-list for method output_type
6, // [6:22] is the sub-list for method input_type
6, // [6:6] is the sub-list for extension type_name
6, // [6:6] is the sub-list for extension extendee
0, // [0:6] is the sub-list for field type_name

View File

@@ -6,6 +6,7 @@ package rpc;
service Daemon {
rpc Connect (ConnectRequest) returns (stream ConnectResponse) {}
rpc ConnectFork (ConnectRequest) returns (stream ConnectResponse) {}
rpc Disconnect (DisconnectRequest) returns (stream DisconnectResponse) {}
rpc Proxy (ConnectRequest) returns (stream ConnectResponse) {}
rpc Leave (LeaveRequest) returns (stream LeaveResponse) {}
@@ -40,8 +41,11 @@ message ConnectRequest {
bool TransferImage = 10;
string Image = 11;
// foreground
bool Foreground = 12;
// log level
int32 Level = 12;
int32 Level = 13;
}
message ConnectResponse {

View File

@@ -20,6 +20,7 @@ const _ = grpc.SupportPackageIsVersion7
const (
Daemon_Connect_FullMethodName = "/rpc.Daemon/Connect"
Daemon_ConnectFork_FullMethodName = "/rpc.Daemon/ConnectFork"
Daemon_Disconnect_FullMethodName = "/rpc.Daemon/Disconnect"
Daemon_Proxy_FullMethodName = "/rpc.Daemon/Proxy"
Daemon_Leave_FullMethodName = "/rpc.Daemon/Leave"
@@ -41,6 +42,7 @@ const (
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type DaemonClient interface {
Connect(ctx context.Context, in *ConnectRequest, opts ...grpc.CallOption) (Daemon_ConnectClient, error)
ConnectFork(ctx context.Context, in *ConnectRequest, opts ...grpc.CallOption) (Daemon_ConnectForkClient, error)
Disconnect(ctx context.Context, in *DisconnectRequest, opts ...grpc.CallOption) (Daemon_DisconnectClient, error)
Proxy(ctx context.Context, in *ConnectRequest, opts ...grpc.CallOption) (Daemon_ProxyClient, error)
Leave(ctx context.Context, in *LeaveRequest, opts ...grpc.CallOption) (Daemon_LeaveClient, error)
@@ -97,8 +99,40 @@ func (x *daemonConnectClient) Recv() (*ConnectResponse, error) {
return m, nil
}
func (c *daemonClient) ConnectFork(ctx context.Context, in *ConnectRequest, opts ...grpc.CallOption) (Daemon_ConnectForkClient, error) {
stream, err := c.cc.NewStream(ctx, &Daemon_ServiceDesc.Streams[1], Daemon_ConnectFork_FullMethodName, opts...)
if err != nil {
return nil, err
}
x := &daemonConnectForkClient{stream}
if err := x.ClientStream.SendMsg(in); err != nil {
return nil, err
}
if err := x.ClientStream.CloseSend(); err != nil {
return nil, err
}
return x, nil
}
type Daemon_ConnectForkClient interface {
Recv() (*ConnectResponse, error)
grpc.ClientStream
}
type daemonConnectForkClient struct {
grpc.ClientStream
}
func (x *daemonConnectForkClient) Recv() (*ConnectResponse, error) {
m := new(ConnectResponse)
if err := x.ClientStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
func (c *daemonClient) Disconnect(ctx context.Context, in *DisconnectRequest, opts ...grpc.CallOption) (Daemon_DisconnectClient, error) {
stream, err := c.cc.NewStream(ctx, &Daemon_ServiceDesc.Streams[1], Daemon_Disconnect_FullMethodName, opts...)
stream, err := c.cc.NewStream(ctx, &Daemon_ServiceDesc.Streams[2], Daemon_Disconnect_FullMethodName, opts...)
if err != nil {
return nil, err
}
@@ -130,7 +164,7 @@ func (x *daemonDisconnectClient) Recv() (*DisconnectResponse, error) {
}
func (c *daemonClient) Proxy(ctx context.Context, in *ConnectRequest, opts ...grpc.CallOption) (Daemon_ProxyClient, error) {
stream, err := c.cc.NewStream(ctx, &Daemon_ServiceDesc.Streams[2], Daemon_Proxy_FullMethodName, opts...)
stream, err := c.cc.NewStream(ctx, &Daemon_ServiceDesc.Streams[3], Daemon_Proxy_FullMethodName, opts...)
if err != nil {
return nil, err
}
@@ -162,7 +196,7 @@ func (x *daemonProxyClient) Recv() (*ConnectResponse, error) {
}
func (c *daemonClient) Leave(ctx context.Context, in *LeaveRequest, opts ...grpc.CallOption) (Daemon_LeaveClient, error) {
stream, err := c.cc.NewStream(ctx, &Daemon_ServiceDesc.Streams[3], Daemon_Leave_FullMethodName, opts...)
stream, err := c.cc.NewStream(ctx, &Daemon_ServiceDesc.Streams[4], Daemon_Leave_FullMethodName, opts...)
if err != nil {
return nil, err
}
@@ -194,7 +228,7 @@ func (x *daemonLeaveClient) Recv() (*LeaveResponse, error) {
}
func (c *daemonClient) Clone(ctx context.Context, in *CloneRequest, opts ...grpc.CallOption) (Daemon_CloneClient, error) {
stream, err := c.cc.NewStream(ctx, &Daemon_ServiceDesc.Streams[4], Daemon_Clone_FullMethodName, opts...)
stream, err := c.cc.NewStream(ctx, &Daemon_ServiceDesc.Streams[5], Daemon_Clone_FullMethodName, opts...)
if err != nil {
return nil, err
}
@@ -226,7 +260,7 @@ func (x *daemonCloneClient) Recv() (*CloneResponse, error) {
}
func (c *daemonClient) Remove(ctx context.Context, in *RemoveRequest, opts ...grpc.CallOption) (Daemon_RemoveClient, error) {
stream, err := c.cc.NewStream(ctx, &Daemon_ServiceDesc.Streams[5], Daemon_Remove_FullMethodName, opts...)
stream, err := c.cc.NewStream(ctx, &Daemon_ServiceDesc.Streams[6], Daemon_Remove_FullMethodName, opts...)
if err != nil {
return nil, err
}
@@ -276,7 +310,7 @@ func (c *daemonClient) ConfigRemove(ctx context.Context, in *ConfigRemoveRequest
}
func (c *daemonClient) Logs(ctx context.Context, in *LogRequest, opts ...grpc.CallOption) (Daemon_LogsClient, error) {
stream, err := c.cc.NewStream(ctx, &Daemon_ServiceDesc.Streams[6], Daemon_Logs_FullMethodName, opts...)
stream, err := c.cc.NewStream(ctx, &Daemon_ServiceDesc.Streams[7], Daemon_Logs_FullMethodName, opts...)
if err != nil {
return nil, err
}
@@ -353,7 +387,7 @@ func (c *daemonClient) Version(ctx context.Context, in *VersionRequest, opts ...
}
func (c *daemonClient) Quit(ctx context.Context, in *QuitRequest, opts ...grpc.CallOption) (Daemon_QuitClient, error) {
stream, err := c.cc.NewStream(ctx, &Daemon_ServiceDesc.Streams[7], Daemon_Quit_FullMethodName, opts...)
stream, err := c.cc.NewStream(ctx, &Daemon_ServiceDesc.Streams[8], Daemon_Quit_FullMethodName, opts...)
if err != nil {
return nil, err
}
@@ -389,6 +423,7 @@ func (x *daemonQuitClient) Recv() (*QuitResponse, error) {
// for forward compatibility
type DaemonServer interface {
Connect(*ConnectRequest, Daemon_ConnectServer) error
ConnectFork(*ConnectRequest, Daemon_ConnectForkServer) error
Disconnect(*DisconnectRequest, Daemon_DisconnectServer) error
Proxy(*ConnectRequest, Daemon_ProxyServer) error
Leave(*LeaveRequest, Daemon_LeaveServer) error
@@ -413,6 +448,9 @@ type UnimplementedDaemonServer struct {
func (UnimplementedDaemonServer) Connect(*ConnectRequest, Daemon_ConnectServer) error {
return status.Errorf(codes.Unimplemented, "method Connect not implemented")
}
func (UnimplementedDaemonServer) ConnectFork(*ConnectRequest, Daemon_ConnectForkServer) error {
return status.Errorf(codes.Unimplemented, "method ConnectFork not implemented")
}
func (UnimplementedDaemonServer) Disconnect(*DisconnectRequest, Daemon_DisconnectServer) error {
return status.Errorf(codes.Unimplemented, "method Disconnect not implemented")
}
@@ -489,6 +527,27 @@ func (x *daemonConnectServer) Send(m *ConnectResponse) error {
return x.ServerStream.SendMsg(m)
}
func _Daemon_ConnectFork_Handler(srv interface{}, stream grpc.ServerStream) error {
m := new(ConnectRequest)
if err := stream.RecvMsg(m); err != nil {
return err
}
return srv.(DaemonServer).ConnectFork(m, &daemonConnectForkServer{stream})
}
type Daemon_ConnectForkServer interface {
Send(*ConnectResponse) error
grpc.ServerStream
}
type daemonConnectForkServer struct {
grpc.ServerStream
}
func (x *daemonConnectForkServer) Send(m *ConnectResponse) error {
return x.ServerStream.SendMsg(m)
}
func _Daemon_Disconnect_Handler(srv interface{}, stream grpc.ServerStream) error {
m := new(DisconnectRequest)
if err := stream.RecvMsg(m); err != nil {
@@ -804,6 +863,11 @@ var Daemon_ServiceDesc = grpc.ServiceDesc{
Handler: _Daemon_Connect_Handler,
ServerStreams: true,
},
{
StreamName: "ConnectFork",
Handler: _Daemon_ConnectFork_Handler,
ServerStreams: true,
},
{
StreamName: "Disconnect",
Handler: _Daemon_Disconnect_Handler,

View File

@@ -77,6 +77,7 @@ type ConnectOptions struct {
ExtraDomain []string
UseLocalDNS bool
Engine config.Engine
Foreground bool
ctx context.Context
cancel context.CancelFunc

View File

@@ -3,15 +3,11 @@ package handler
import (
"context"
"fmt"
"k8s.io/apimachinery/pkg/util/intstr"
json2 "k8s.io/apimachinery/pkg/util/json"
"net"
"net/http"
"os/exec"
"reflect"
"runtime"
"sigs.k8s.io/yaml"
"strings"
"sync"
"testing"
"time"
@@ -20,6 +16,8 @@ import (
corev1 "k8s.io/api/core/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/util/intstr"
json2 "k8s.io/apimachinery/pkg/util/json"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/client-go/kubernetes"
@@ -27,6 +25,7 @@ import (
"k8s.io/client-go/tools/clientcmd"
"k8s.io/client-go/util/retry"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
"sigs.k8s.io/yaml"
"github.com/wencaiwulue/kubevpn/pkg/util"
)
@@ -308,24 +307,16 @@ func server(port int) {
func kubevpnConnect(t *testing.T) {
ctx2, timeoutFunc := context.WithTimeout(context.Background(), 2*time.Hour)
defer timeoutFunc()
cmd := exec.Command("kubevpn", "proxy", "--debug", "deployments/reviews")
go func() {
stdout, stderr, err := util.RunWithRollingOutWithChecker(cmd, func(log string) {
ok := strings.Contains(log, "dns service ok")
if ok {
timeoutFunc()
}
})
defer timeoutFunc()
if err != nil {
t.Log(stdout, stderr)
t.Error(err)
t.Fail()
return
}
}()
<-ctx2.Done()
cmd := exec.CommandContext(ctx2, "kubevpn", "proxy", "--debug", "deployments/reviews")
output, err := cmd.CombinedOutput()
if err != nil {
t.Log(string(output))
t.Error(err)
t.Fail()
return
}
}
func init1() {

View File

@@ -6,7 +6,6 @@ package main
import (
"io"
"io/ioutil"
"math"
"net/http"
"time"
@@ -46,7 +45,7 @@ func checkRetry(resp *http.Response, err error) bool {
func drainBody(b io.ReadCloser) {
defer b.Close()
io.Copy(ioutil.Discard, io.LimitReader(b, int64(4096)))
io.Copy(io.Discard, io.LimitReader(b, int64(4096)))
}
func backoff(min, max time.Duration, attemptNum int) time.Duration {

View File

@@ -4,7 +4,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"net"
"net/http"
"sort"
@@ -334,7 +333,7 @@ func (pf *PortForwarder) handleConnection(conn net.Conn, port ForwardedPort) {
errorChan := make(chan error)
go func() {
message, err := ioutil.ReadAll(errorStream)
message, err := io.ReadAll(errorStream)
switch {
case err != nil:
errorChan <- fmt.Errorf("error reading from error stream for port %d -> %d: %v", port.Local, port.Remote, err)

View File

@@ -18,7 +18,7 @@ spec:
os: windows
arch: amd64
uri: https://github.com/KubeNetworks/kubevpn/releases/download/v2.0.0/kubevpn_v2.0.0_windows_amd64.zip
sha256: 881fe4779f573eb2ae3f4d0a94429980635ab5c92a9511ef975759dde8bd55fb
sha256: 7c8f08873bf1e9ec781b120c96b38fa12bbeda8badcdf5c870e145818a971c46
files:
- from: ./bin/kubevpn.exe
to: .
@@ -30,7 +30,7 @@ spec:
os: windows
arch: arm64
uri: https://github.com/KubeNetworks/kubevpn/releases/download/v2.0.0/kubevpn_v2.0.0_windows_arm64.zip
sha256: 1dbee51e4244b896d97a58250d8aa695c71436c4ef1f4ad627d64a29ffcd9c54
sha256: e2c968b7ee1cb36887d4084d2054ea2bbaca74b0ffe837c0458650e8d9b31f86
files:
- from: ./bin/kubevpn.exe
to: .
@@ -42,7 +42,7 @@ spec:
os: windows
arch: 386
uri: https://github.com/KubeNetworks/kubevpn/releases/download/v2.0.0/kubevpn_v2.0.0_windows_386.zip
sha256: 38a4adee218937f35c694be865d0d870f1ed74c3d869fc413c213e2405cbd272
sha256: ec3368c949e7b506e96a0d671be347f9770adf3763eab4ef8d000312709802f7
files:
- from: ./bin/kubevpn.exe
to: .
@@ -54,7 +54,7 @@ spec:
os: linux
arch: amd64
uri: https://github.com/KubeNetworks/kubevpn/releases/download/v2.0.0/kubevpn_v2.0.0_linux_amd64.zip
sha256: 942ec4b6ebb17a4eb0cb7e7b86b9d81f470c0f549f2098f0b57344b4b447ba53
sha256: 713f5b413e28daf136f57b210b8f556a2c67c5f6d526ccdd3ef08a5d751af405
files:
- from: ./bin/kubevpn
to: .
@@ -66,7 +66,7 @@ spec:
os: linux
arch: arm64
uri: https://github.com/KubeNetworks/kubevpn/releases/download/v2.0.0/kubevpn_v2.0.0_linux_arm64.zip
sha256: 19e41c058b457912c0b532c634e938920093a21a36d087444a4bb3c748343755
sha256: 2f89315db4324e68c05a26e4a6ed6cb74216685aa63871096606929c221d8602
files:
- from: ./bin/kubevpn
to: .
@@ -78,7 +78,7 @@ spec:
os: linux
arch: 386
uri: https://github.com/KubeNetworks/kubevpn/releases/download/v2.0.0/kubevpn_v2.0.0_linux_386.zip
sha256: c213052f98a096cc818776f1df5a80bc15b4b60c761457a4bf1eaebd5621aa7f
sha256: 51090123d2b4b9b9ac9caf688569aa6db25fc3e97c7bf091d925ec94e68cd642
files:
- from: ./bin/kubevpn
to: .
@@ -90,7 +90,7 @@ spec:
os: darwin
arch: amd64
uri: https://github.com/KubeNetworks/kubevpn/releases/download/v2.0.0/kubevpn_v2.0.0_darwin_amd64.zip
sha256: cf8061f8ad0ad2bee110a1a229f3b6e5bf35a2fe77cecf7cc40e101d44874346
sha256: 04c5feed4e020b0bea8659da9d8d3f9a4aa258754f9e41351ee59f2826cae37f
files:
- from: ./bin/kubevpn
to: .
@@ -102,7 +102,7 @@ spec:
os: darwin
arch: arm64
uri: https://github.com/KubeNetworks/kubevpn/releases/download/v2.0.0/kubevpn_v2.0.0_darwin_arm64.zip
sha256: 8e747b39b8367a9b909d38a6a11b4a1644f1f8ecc786be54b3d13437a61fe73a
sha256: efb2efe4b6a075d2a3f17693e4996e42adf7fc4e1a9f16193388d14f3e37ac82
files:
- from: ./bin/kubevpn
to: .