rcode

package module
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 19, 2022 License: MIT Imports: 16 Imported by: 0

README

rcode

Calling client VS Code from remote host.

If you use remote development using ssh, you can use code command on integrated terminal. But other terminals connecting to the remote host (such as iTerm2) can not use code command rcode enables to call VS Code from remote host.

Restriction

This needs to be able to connect client host machine from remote host.

how to use

MacOS client and Linux remote server on Virtual Machine on mac

MacOS

Install rcode.

go get github.com/74th/remote-vscode-cmd/cmd/rcode

Create rcode.command file to launch rcode. 10.37.129.2 is MacOS IP on Host Only Network.

/Users/nnyn/go/bin/rcode -server -addr 10.37.129.2:5450 -command code
chmod 755 rcode.command

Setting to launch rcode.command. "System Preferences..." -> "Users & Groups" -> select user -> "Login Items" -> Add -> select rcode.command

Virtual Machine

Install rcode.

go get github.com/74th/remote-vscode-cmd/cmd/rcode

Create /$HOME/.rcode.yaml .

  • client: MacOS IP on Host Only Network
  • remote_hostname: host name used by Remote Development SSH
client: 10.37.129.2:5450
remote_hostname: linux
using on Virtual Machine
rcode /some/dir

It will open /some/dir on VS Code on MacOS.

how it works

code has an argument --remote, it launches VS Code with Remote Development.

code --remote ssh-remote+hostname /some/dir

rcode /some/dir on the remote host connects rcode server on the client, and rcode on the client calls code --remote ssh-remote+hostname /some/dir.

how to build

go get

export GOBIN=`pwd`/.bin
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2

protoc --plugin=.bin/protoc-gen-go --go_out=. --go_opt=paths=source_relative \
    --plugin=.bin/protoc-gen-go-grpc --go-grpc_out=. --go-grpc_opt=paths=source_relative \
    rcode.proto

go build cmd/rcode

Documentation

Index

Constants

This section is empty.

Variables

View Source
var File_rcode_proto protoreflect.FileDescriptor
View Source
var Rcode_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "Rcode",
	HandlerType: (*RcodeServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "LaunchCode",
			Handler:    _Rcode_LaunchCode_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "rcode.proto",
}

Rcode_ServiceDesc is the grpc.ServiceDesc for Rcode service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

Functions

func CallServer

func CallServer(command string, args []string)

func NewServer

func NewServer(host string, command string, allowAnyCommand bool)

NewServer starts rcode server

func RegisterRcodeServer

func RegisterRcodeServer(s grpc.ServiceRegistrar, srv RcodeServer)

Types

type LaunchRequest

type LaunchRequest struct {
	RemoteHostname string   `protobuf:"bytes,1,opt,name=remote_hostname,json=remoteHostname,proto3" json:"remote_hostname,omitempty"`
	Args           []string `protobuf:"bytes,2,rep,name=args,proto3" json:"args,omitempty"`
	Command        string   `protobuf:"bytes,3,opt,name=command,proto3" json:"command,omitempty"`
	// contains filtered or unexported fields
}

func (*LaunchRequest) Descriptor deprecated

func (*LaunchRequest) Descriptor() ([]byte, []int)

Deprecated: Use LaunchRequest.ProtoReflect.Descriptor instead.

func (*LaunchRequest) GetArgs

func (x *LaunchRequest) GetArgs() []string

func (*LaunchRequest) GetCommand added in v1.1.0

func (x *LaunchRequest) GetCommand() string

func (*LaunchRequest) GetRemoteHostname

func (x *LaunchRequest) GetRemoteHostname() string

func (*LaunchRequest) ProtoMessage

func (*LaunchRequest) ProtoMessage()

func (*LaunchRequest) ProtoReflect

func (x *LaunchRequest) ProtoReflect() protoreflect.Message

func (*LaunchRequest) Reset

func (x *LaunchRequest) Reset()

func (*LaunchRequest) String

func (x *LaunchRequest) String() string

type LaunchResponse

type LaunchResponse struct {
	ReturnCode int32  `protobuf:"varint,3,opt,name=return_code,json=returnCode,proto3" json:"return_code,omitempty"`
	Message    string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"`
	// contains filtered or unexported fields
}

func (*LaunchResponse) Descriptor deprecated

func (*LaunchResponse) Descriptor() ([]byte, []int)

Deprecated: Use LaunchResponse.ProtoReflect.Descriptor instead.

func (*LaunchResponse) GetMessage

func (x *LaunchResponse) GetMessage() string

func (*LaunchResponse) GetReturnCode

func (x *LaunchResponse) GetReturnCode() int32

func (*LaunchResponse) ProtoMessage

func (*LaunchResponse) ProtoMessage()

func (*LaunchResponse) ProtoReflect

func (x *LaunchResponse) ProtoReflect() protoreflect.Message

func (*LaunchResponse) Reset

func (x *LaunchResponse) Reset()

func (*LaunchResponse) String

func (x *LaunchResponse) String() string

type RcodeClient

type RcodeClient interface {
	LaunchCode(ctx context.Context, in *LaunchRequest, opts ...grpc.CallOption) (*LaunchResponse, error)
}

RcodeClient is the client API for Rcode service.

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.

func NewRcodeClient

func NewRcodeClient(cc grpc.ClientConnInterface) RcodeClient

type RcodeConf

type RcodeConf struct {
	Client         string `yaml:"client"`
	RemoteHostname string `yaml:"remote_hostname"`
}

type RcodeServer

type RcodeServer interface {
	LaunchCode(context.Context, *LaunchRequest) (*LaunchResponse, error)
	// contains filtered or unexported methods
}

RcodeServer is the server API for Rcode service. All implementations must embed UnimplementedRcodeServer for forward compatibility

type UnimplementedRcodeServer

type UnimplementedRcodeServer struct {
}

UnimplementedRcodeServer must be embedded to have forward compatible implementations.

func (UnimplementedRcodeServer) LaunchCode

type UnsafeRcodeServer added in v1.1.0

type UnsafeRcodeServer interface {
	// contains filtered or unexported methods
}

UnsafeRcodeServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to RcodeServer will result in compilation errors.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL