import "v.io/x/ref/examples/tunnel"
Package tunnel defines an interface for creating a network tunnel from client to server.
var ForwarderDesc rpc.InterfaceDesc = descForwarder
ForwarderDesc describes the Forwarder interface.
var TunnelDesc rpc.InterfaceDesc = descTunnel
TunnelDesc describes the Tunnel interface.
func VDLReadClientShellPacket(dec vdl.Decoder, x *ClientShellPacket) error
func VDLReadServerShellPacket(dec vdl.Decoder, x *ServerShellPacket) error
type ClientShellPacket interface { // Index returns the field index. Index() int // Interface returns the field value as an interface. Interface() interface{} // Name returns the field name. Name() string // VDLReflect describes the ClientShellPacket union type. VDLReflect(vdlClientShellPacketReflect) VDLIsZero() bool VDLWrite(vdl.Encoder) error }
ClientShellPacket represents any single field of the ClientShellPacket union type.
ClientShellPacketEndOfFile represents field EndOfFile of the ClientShellPacket union type.
Indicates that stdin should be closed. The presence of this field indicates EOF. Its actual value is ignored.
func (x ClientShellPacketEndOfFile) Index() int
func (x ClientShellPacketEndOfFile) Interface() interface{}
func (x ClientShellPacketEndOfFile) Name() string
func (x ClientShellPacketEndOfFile) VDLIsZero() bool
func (x ClientShellPacketEndOfFile) VDLReflect(vdlClientShellPacketReflect)
func (x ClientShellPacketEndOfFile) VDLWrite(enc vdl.Encoder) error
ClientShellPacketStdin represents field Stdin of the ClientShellPacket union type.
Bytes going to the shell's stdin.
func (x ClientShellPacketStdin) Index() int
func (x ClientShellPacketStdin) Interface() interface{}
func (x ClientShellPacketStdin) Name() string
func (x ClientShellPacketStdin) VDLIsZero() bool
func (x ClientShellPacketStdin) VDLReflect(vdlClientShellPacketReflect)
func (x ClientShellPacketStdin) VDLWrite(enc vdl.Encoder) error
type ClientShellPacketWinSize struct{ Value WindowSize }
ClientShellPacketWinSize represents field WinSize of the ClientShellPacket union type.
A dynamic update of the window size.
func (x ClientShellPacketWinSize) Index() int
func (x ClientShellPacketWinSize) Interface() interface{}
func (x ClientShellPacketWinSize) Name() string
func (x ClientShellPacketWinSize) VDLIsZero() bool
func (x ClientShellPacketWinSize) VDLReflect(vdlClientShellPacketReflect)
func (x ClientShellPacketWinSize) VDLWrite(enc vdl.Encoder) error
type ForwarderClientMethods interface { // The Forward method is used for network forwarding. All the data sent over // the byte stream is forwarded to a predetermined network address and all the // data received from that network connection is sent back on the reply // stream. Forward(*context.T, ...rpc.CallOpt) (ForwarderForwardClientCall, error) }
ForwarderClientMethods is the client interface containing Forwarder methods.
type ForwarderClientStub interface { ForwarderClientMethods }
ForwarderClientStub embeds ForwarderClientMethods and is a placeholder for additional management operations.
func ForwarderClient(name string) ForwarderClientStub
ForwarderClient returns a client stub for Forwarder.
type ForwarderForwardClientCall interface { ForwarderForwardClientStream // Finish performs the equivalent of SendStream().Close, then blocks until // the server is done, and returns the positional return values for the call. // // Finish returns immediately if the call has been canceled; depending on the // timing the output could either be an error signaling cancelation, or the // valid positional return values from the server. // // Calling Finish is mandatory for releasing stream resources, unless the call // has been canceled or any of the other methods return an error. Finish should // be called at most once. Finish() error }
ForwarderForwardClientCall represents the call returned from Forwarder.Forward.
type ForwarderForwardClientStream interface { // RecvStream returns the receiver side of the Forwarder.Forward client stream. RecvStream() interface { // Advance stages an item so that it may be retrieved via Value. Returns // true iff there is an item to retrieve. Advance must be called before // Value is called. May block if an item is not available. Advance() bool // Value returns the item that was staged by Advance. May panic if Advance // returned false or was not called. Never blocks. Value() []byte // Err returns any error encountered by Advance. Never blocks. Err() error } // SendStream returns the send side of the Forwarder.Forward client stream. SendStream() interface { // Send places the item onto the output stream. Returns errors // encountered while sending, or if Send is called after Close or // the stream has been canceled. Blocks if there is no buffer // space; will unblock when buffer space is available or after // the stream has been canceled. Send(item []byte) error // Close indicates to the server that no more items will be sent; // server Recv calls will receive io.EOF after all sent items. // This is an optional call - e.g. a client might call Close if it // needs to continue receiving items from the server after it's // done sending. Returns errors encountered while closing, or if // Close is called after the stream has been canceled. Like Send, // blocks if there is no buffer space available. Close() error } }
ForwarderForwardClientStream is the client stream for Forwarder.Forward.
type ForwarderForwardServerCall interface { rpc.ServerCall ForwarderForwardServerStream }
ForwarderForwardServerCall represents the context passed to Forwarder.Forward.
type ForwarderForwardServerCallStub struct { rpc.StreamServerCall // contains filtered or unexported fields }
ForwarderForwardServerCallStub is a wrapper that converts rpc.StreamServerCall into a typesafe stub that implements ForwarderForwardServerCall.
func (s *ForwarderForwardServerCallStub) Init(call rpc.StreamServerCall)
Init initializes ForwarderForwardServerCallStub from rpc.StreamServerCall.
func (s *ForwarderForwardServerCallStub) RecvStream() interface { Advance() bool Value() []byte Err() error }
RecvStream returns the receiver side of the Forwarder.Forward server stream.
func (s *ForwarderForwardServerCallStub) SendStream() interface { Send(item []byte) error }
SendStream returns the send side of the Forwarder.Forward server stream.
type ForwarderForwardServerStream interface { // RecvStream returns the receiver side of the Forwarder.Forward server stream. RecvStream() interface { // Advance stages an item so that it may be retrieved via Value. Returns // true iff there is an item to retrieve. Advance must be called before // Value is called. May block if an item is not available. Advance() bool // Value returns the item that was staged by Advance. May panic if Advance // returned false or was not called. Never blocks. Value() []byte // Err returns any error encountered by Advance. Never blocks. Err() error } // SendStream returns the send side of the Forwarder.Forward server stream. SendStream() interface { // Send places the item onto the output stream. Returns errors encountered // while sending. Blocks if there is no buffer space; will unblock when // buffer space is available. Send(item []byte) error } }
ForwarderForwardServerStream is the server stream for Forwarder.Forward.
type ForwarderServerMethods interface { // The Forward method is used for network forwarding. All the data sent over // the byte stream is forwarded to a predetermined network address and all the // data received from that network connection is sent back on the reply // stream. Forward(*context.T, ForwarderForwardServerCall) error }
ForwarderServerMethods is the interface a server writer implements for Forwarder.
type ForwarderServerStub interface { ForwarderServerStubMethods // DescribeInterfaces the Forwarder interfaces. Describe__() []rpc.InterfaceDesc }
ForwarderServerStub adds universal methods to ForwarderServerStubMethods.
func ForwarderServer(impl ForwarderServerMethods) ForwarderServerStub
ForwarderServer returns a server stub for Forwarder. It converts an implementation of ForwarderServerMethods into an object that may be used by rpc.Server.
type ForwarderServerStubMethods interface { // The Forward method is used for network forwarding. All the data sent over // the byte stream is forwarded to a predetermined network address and all the // data received from that network connection is sent back on the reply // stream. Forward(*context.T, *ForwarderForwardServerCallStub) error }
ForwarderServerStubMethods is the server interface containing Forwarder methods, as expected by rpc.Server. The only difference between this interface and ForwarderServerMethods is the streaming methods.
type ServerShellPacket interface { // Index returns the field index. Index() int // Interface returns the field value as an interface. Interface() interface{} // Name returns the field name. Name() string // VDLReflect describes the ServerShellPacket union type. VDLReflect(vdlServerShellPacketReflect) VDLIsZero() bool VDLWrite(vdl.Encoder) error }
ServerShellPacket represents any single field of the ServerShellPacket union type.
ServerShellPacketStderr represents field Stderr of the ServerShellPacket union type.
Bytes coming from the shell's stderr.
func (x ServerShellPacketStderr) Index() int
func (x ServerShellPacketStderr) Interface() interface{}
func (x ServerShellPacketStderr) Name() string
func (x ServerShellPacketStderr) VDLIsZero() bool
func (x ServerShellPacketStderr) VDLReflect(vdlServerShellPacketReflect)
func (x ServerShellPacketStderr) VDLWrite(enc vdl.Encoder) error
ServerShellPacketStdout represents field Stdout of the ServerShellPacket union type.
Bytes coming from the shell's stdout.
func (x ServerShellPacketStdout) Index() int
func (x ServerShellPacketStdout) Interface() interface{}
func (x ServerShellPacketStdout) Name() string
func (x ServerShellPacketStdout) VDLIsZero() bool
func (x ServerShellPacketStdout) VDLReflect(vdlServerShellPacketReflect)
func (x ServerShellPacketStdout) VDLWrite(enc vdl.Encoder) error
type ShellOpts struct { UsePty bool // Whether to open a pseudo-terminal. Environment []string // Environment variables to pass to the remote shell. WinSize WindowSize // The size of the window. }
type TunnelClientMethods interface { // The Forward method is used for network forwarding. All the data sent over // the byte stream is forwarded to the requested network address and all the // data received from that network connection is sent back on the reply // stream. Forward(_ *context.T, network string, address string, _ ...rpc.CallOpt) (TunnelForwardClientCall, error) // The ReverseForward method is used for network forwarding from the server // back to the client. The server process listens on the requested network // address, forwarding all connections by calling Forwarder.Forward on the // caller. ReverseForward(_ *context.T, network string, address string, _ ...rpc.CallOpt) error // The Shell method is used to either run shell commands remotely, or to open // an interactive shell. The data received over the byte stream is sent to the // shell's stdin, and the data received from the shell's stdout and stderr is // sent back in the reply stream. It returns the exit status of the shell // command as an integer exit code and a human readable string. Shell(_ *context.T, command string, shellOpts ShellOpts, _ ...rpc.CallOpt) (TunnelShellClientCall, error) }
TunnelClientMethods is the client interface containing Tunnel methods.
type TunnelClientStub interface { TunnelClientMethods }
TunnelClientStub embeds TunnelClientMethods and is a placeholder for additional management operations.
func TunnelClient(name string) TunnelClientStub
TunnelClient returns a client stub for Tunnel.
type TunnelForwardClientCall interface { TunnelForwardClientStream // Finish performs the equivalent of SendStream().Close, then blocks until // the server is done, and returns the positional return values for the call. // // Finish returns immediately if the call has been canceled; depending on the // timing the output could either be an error signaling cancelation, or the // valid positional return values from the server. // // Calling Finish is mandatory for releasing stream resources, unless the call // has been canceled or any of the other methods return an error. Finish should // be called at most once. Finish() error }
TunnelForwardClientCall represents the call returned from Tunnel.Forward.
type TunnelForwardClientStream interface { // RecvStream returns the receiver side of the Tunnel.Forward client stream. RecvStream() interface { // Advance stages an item so that it may be retrieved via Value. Returns // true iff there is an item to retrieve. Advance must be called before // Value is called. May block if an item is not available. Advance() bool // Value returns the item that was staged by Advance. May panic if Advance // returned false or was not called. Never blocks. Value() []byte // Err returns any error encountered by Advance. Never blocks. Err() error } // SendStream returns the send side of the Tunnel.Forward client stream. SendStream() interface { // Send places the item onto the output stream. Returns errors // encountered while sending, or if Send is called after Close or // the stream has been canceled. Blocks if there is no buffer // space; will unblock when buffer space is available or after // the stream has been canceled. Send(item []byte) error // Close indicates to the server that no more items will be sent; // server Recv calls will receive io.EOF after all sent items. // This is an optional call - e.g. a client might call Close if it // needs to continue receiving items from the server after it's // done sending. Returns errors encountered while closing, or if // Close is called after the stream has been canceled. Like Send, // blocks if there is no buffer space available. Close() error } }
TunnelForwardClientStream is the client stream for Tunnel.Forward.
type TunnelForwardServerCall interface { rpc.ServerCall TunnelForwardServerStream }
TunnelForwardServerCall represents the context passed to Tunnel.Forward.
type TunnelForwardServerCallStub struct { rpc.StreamServerCall // contains filtered or unexported fields }
TunnelForwardServerCallStub is a wrapper that converts rpc.StreamServerCall into a typesafe stub that implements TunnelForwardServerCall.
func (s *TunnelForwardServerCallStub) Init(call rpc.StreamServerCall)
Init initializes TunnelForwardServerCallStub from rpc.StreamServerCall.
func (s *TunnelForwardServerCallStub) RecvStream() interface { Advance() bool Value() []byte Err() error }
RecvStream returns the receiver side of the Tunnel.Forward server stream.
func (s *TunnelForwardServerCallStub) SendStream() interface { Send(item []byte) error }
SendStream returns the send side of the Tunnel.Forward server stream.
type TunnelForwardServerStream interface { // RecvStream returns the receiver side of the Tunnel.Forward server stream. RecvStream() interface { // Advance stages an item so that it may be retrieved via Value. Returns // true iff there is an item to retrieve. Advance must be called before // Value is called. May block if an item is not available. Advance() bool // Value returns the item that was staged by Advance. May panic if Advance // returned false or was not called. Never blocks. Value() []byte // Err returns any error encountered by Advance. Never blocks. Err() error } // SendStream returns the send side of the Tunnel.Forward server stream. SendStream() interface { // Send places the item onto the output stream. Returns errors encountered // while sending. Blocks if there is no buffer space; will unblock when // buffer space is available. Send(item []byte) error } }
TunnelForwardServerStream is the server stream for Tunnel.Forward.
type TunnelServerMethods interface { // The Forward method is used for network forwarding. All the data sent over // the byte stream is forwarded to the requested network address and all the // data received from that network connection is sent back on the reply // stream. Forward(_ *context.T, _ TunnelForwardServerCall, network string, address string) error // The ReverseForward method is used for network forwarding from the server // back to the client. The server process listens on the requested network // address, forwarding all connections by calling Forwarder.Forward on the // caller. ReverseForward(_ *context.T, _ rpc.ServerCall, network string, address string) error // The Shell method is used to either run shell commands remotely, or to open // an interactive shell. The data received over the byte stream is sent to the // shell's stdin, and the data received from the shell's stdout and stderr is // sent back in the reply stream. It returns the exit status of the shell // command as an integer exit code and a human readable string. Shell(_ *context.T, _ TunnelShellServerCall, command string, shellOpts ShellOpts) (exitCode int32, exitMsg string, _ error) }
TunnelServerMethods is the interface a server writer implements for Tunnel.
type TunnelServerStub interface { TunnelServerStubMethods // DescribeInterfaces the Tunnel interfaces. Describe__() []rpc.InterfaceDesc }
TunnelServerStub adds universal methods to TunnelServerStubMethods.
func TunnelServer(impl TunnelServerMethods) TunnelServerStub
TunnelServer returns a server stub for Tunnel. It converts an implementation of TunnelServerMethods into an object that may be used by rpc.Server.
type TunnelServerStubMethods interface { // The Forward method is used for network forwarding. All the data sent over // the byte stream is forwarded to the requested network address and all the // data received from that network connection is sent back on the reply // stream. Forward(_ *context.T, _ *TunnelForwardServerCallStub, network string, address string) error // The ReverseForward method is used for network forwarding from the server // back to the client. The server process listens on the requested network // address, forwarding all connections by calling Forwarder.Forward on the // caller. ReverseForward(_ *context.T, _ rpc.ServerCall, network string, address string) error // The Shell method is used to either run shell commands remotely, or to open // an interactive shell. The data received over the byte stream is sent to the // shell's stdin, and the data received from the shell's stdout and stderr is // sent back in the reply stream. It returns the exit status of the shell // command as an integer exit code and a human readable string. Shell(_ *context.T, _ *TunnelShellServerCallStub, command string, shellOpts ShellOpts) (exitCode int32, exitMsg string, _ error) }
TunnelServerStubMethods is the server interface containing Tunnel methods, as expected by rpc.Server. The only difference between this interface and TunnelServerMethods is the streaming methods.
type TunnelShellClientCall interface { TunnelShellClientStream // Finish performs the equivalent of SendStream().Close, then blocks until // the server is done, and returns the positional return values for the call. // // Finish returns immediately if the call has been canceled; depending on the // timing the output could either be an error signaling cancelation, or the // valid positional return values from the server. // // Calling Finish is mandatory for releasing stream resources, unless the call // has been canceled or any of the other methods return an error. Finish should // be called at most once. Finish() (exitCode int32, exitMsg string, _ error) }
TunnelShellClientCall represents the call returned from Tunnel.Shell.
type TunnelShellClientStream interface { // RecvStream returns the receiver side of the Tunnel.Shell client stream. RecvStream() interface { // Advance stages an item so that it may be retrieved via Value. Returns // true iff there is an item to retrieve. Advance must be called before // Value is called. May block if an item is not available. Advance() bool // Value returns the item that was staged by Advance. May panic if Advance // returned false or was not called. Never blocks. Value() ServerShellPacket // Err returns any error encountered by Advance. Never blocks. Err() error } // SendStream returns the send side of the Tunnel.Shell client stream. SendStream() interface { // Send places the item onto the output stream. Returns errors // encountered while sending, or if Send is called after Close or // the stream has been canceled. Blocks if there is no buffer // space; will unblock when buffer space is available or after // the stream has been canceled. Send(item ClientShellPacket) error // Close indicates to the server that no more items will be sent; // server Recv calls will receive io.EOF after all sent items. // This is an optional call - e.g. a client might call Close if it // needs to continue receiving items from the server after it's // done sending. Returns errors encountered while closing, or if // Close is called after the stream has been canceled. Like Send, // blocks if there is no buffer space available. Close() error } }
TunnelShellClientStream is the client stream for Tunnel.Shell.
type TunnelShellServerCall interface { rpc.ServerCall TunnelShellServerStream }
TunnelShellServerCall represents the context passed to Tunnel.Shell.
type TunnelShellServerCallStub struct { rpc.StreamServerCall // contains filtered or unexported fields }
TunnelShellServerCallStub is a wrapper that converts rpc.StreamServerCall into a typesafe stub that implements TunnelShellServerCall.
func (s *TunnelShellServerCallStub) Init(call rpc.StreamServerCall)
Init initializes TunnelShellServerCallStub from rpc.StreamServerCall.
func (s *TunnelShellServerCallStub) RecvStream() interface { Advance() bool Value() ClientShellPacket Err() error }
RecvStream returns the receiver side of the Tunnel.Shell server stream.
func (s *TunnelShellServerCallStub) SendStream() interface { Send(item ServerShellPacket) error }
SendStream returns the send side of the Tunnel.Shell server stream.
type TunnelShellServerStream interface { // RecvStream returns the receiver side of the Tunnel.Shell server stream. RecvStream() interface { // Advance stages an item so that it may be retrieved via Value. Returns // true iff there is an item to retrieve. Advance must be called before // Value is called. May block if an item is not available. Advance() bool // Value returns the item that was staged by Advance. May panic if Advance // returned false or was not called. Never blocks. Value() ClientShellPacket // Err returns any error encountered by Advance. Never blocks. Err() error } // SendStream returns the send side of the Tunnel.Shell server stream. SendStream() interface { // Send places the item onto the output stream. Returns errors encountered // while sending. Blocks if there is no buffer space; will unblock when // buffer space is available. Send(item ServerShellPacket) error } }
TunnelShellServerStream is the server stream for Tunnel.Shell.
type Unused struct { }
TODO(toddw): Replace Unused with the unnamed empty struct{}.
func (x WindowSize) VDLIsZero() bool
func (x *WindowSize) VDLRead(dec vdl.Decoder) error
func (WindowSize) VDLReflect(struct { Name string `vdl:"v.io/x/ref/examples/tunnel.WindowSize"` })
func (x WindowSize) VDLWrite(enc vdl.Encoder) error
Path | Synopsis |
---|---|
internal | Package internal defines common types and functions used by both tunnel clients and servers. |
tunneld | Command tunneld runs the tunneld daemon, which implements the Tunnel interface. |
vsh | Command vsh runs the Vanadium shell, a Tunnel client that can be used to run shell commands or start an interactive shell on a remote tunneld server. |
Package tunnel imports 7 packages (graph) and is imported by 6 packages. Updated 2021-01-19. Refresh now. Tools for package owners.