| // This file was auto-generated by the veyron vdl tool. |
| // Source: tunnel.vdl |
| |
| // Package tunnel describes a service that can be used to create a |
| // network tunnel from the client to the server. |
| package tunnel |
| |
| import ( |
| // VDL system imports |
| "io" |
| "v.io/core/veyron2" |
| "v.io/core/veyron2/context" |
| "v.io/core/veyron2/ipc" |
| "v.io/core/veyron2/vdl" |
| |
| // VDL user imports |
| "v.io/core/veyron2/services/security/access" |
| ) |
| |
| type ShellOpts struct { |
| UsePty bool // Whether to open a pseudo-terminal |
| Environment []string // Environment variables to pass to the remote shell. |
| Rows uint32 // Window size. |
| Cols uint32 |
| } |
| |
| func (ShellOpts) __VDLReflect(struct { |
| Name string "v.io/apps/tunnel.ShellOpts" |
| }) { |
| } |
| |
| type ClientShellPacket struct { |
| // Bytes going to the shell's stdin. |
| Stdin []byte |
| // Indicates that stdin should be closed. |
| EOF bool |
| // A dynamic update of the window size. The default value of 0 means no-change. |
| Rows uint32 |
| Cols uint32 |
| } |
| |
| func (ClientShellPacket) __VDLReflect(struct { |
| Name string "v.io/apps/tunnel.ClientShellPacket" |
| }) { |
| } |
| |
| type ServerShellPacket struct { |
| // Bytes coming from the shell's stdout. |
| Stdout []byte |
| // Bytes coming from the shell's stderr. |
| Stderr []byte |
| } |
| |
| func (ServerShellPacket) __VDLReflect(struct { |
| Name string "v.io/apps/tunnel.ServerShellPacket" |
| }) { |
| } |
| |
| func init() { |
| vdl.Register(ShellOpts{}) |
| vdl.Register(ClientShellPacket{}) |
| vdl.Register(ServerShellPacket{}) |
| } |
| |
| // TunnelClientMethods is the client interface |
| // containing Tunnel methods. |
| 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 in the reply |
| // stream. |
| Forward(ctx *context.T, network string, address string, opts ...ipc.CallOpt) (TunnelForwardCall, 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. |
| Shell(ctx *context.T, command string, shellOpts ShellOpts, opts ...ipc.CallOpt) (TunnelShellCall, error) |
| } |
| |
| // TunnelClientStub adds universal methods to TunnelClientMethods. |
| type TunnelClientStub interface { |
| TunnelClientMethods |
| ipc.UniversalServiceMethods |
| } |
| |
| // TunnelClient returns a client stub for Tunnel. |
| func TunnelClient(name string, opts ...ipc.BindOpt) TunnelClientStub { |
| var client ipc.Client |
| for _, opt := range opts { |
| if clientOpt, ok := opt.(ipc.Client); ok { |
| client = clientOpt |
| } |
| } |
| return implTunnelClientStub{name, client} |
| } |
| |
| type implTunnelClientStub struct { |
| name string |
| client ipc.Client |
| } |
| |
| func (c implTunnelClientStub) c(ctx *context.T) ipc.Client { |
| if c.client != nil { |
| return c.client |
| } |
| return veyron2.GetClient(ctx) |
| } |
| |
| func (c implTunnelClientStub) Forward(ctx *context.T, i0 string, i1 string, opts ...ipc.CallOpt) (ocall TunnelForwardCall, err error) { |
| var call ipc.Call |
| if call, err = c.c(ctx).StartCall(ctx, c.name, "Forward", []interface{}{i0, i1}, opts...); err != nil { |
| return |
| } |
| ocall = &implTunnelForwardCall{Call: call} |
| return |
| } |
| |
| func (c implTunnelClientStub) Shell(ctx *context.T, i0 string, i1 ShellOpts, opts ...ipc.CallOpt) (ocall TunnelShellCall, err error) { |
| var call ipc.Call |
| if call, err = c.c(ctx).StartCall(ctx, c.name, "Shell", []interface{}{i0, i1}, opts...); err != nil { |
| return |
| } |
| ocall = &implTunnelShellCall{Call: call} |
| return |
| } |
| |
| // TunnelForwardClientStream is the client stream for 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 |
| } |
| } |
| |
| // TunnelForwardCall represents the call returned from Tunnel.Forward. |
| type TunnelForwardCall 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 |
| } |
| |
| type implTunnelForwardCall struct { |
| ipc.Call |
| valRecv []byte |
| errRecv error |
| } |
| |
| func (c *implTunnelForwardCall) RecvStream() interface { |
| Advance() bool |
| Value() []byte |
| Err() error |
| } { |
| return implTunnelForwardCallRecv{c} |
| } |
| |
| type implTunnelForwardCallRecv struct { |
| c *implTunnelForwardCall |
| } |
| |
| func (c implTunnelForwardCallRecv) Advance() bool { |
| c.c.errRecv = c.c.Recv(&c.c.valRecv) |
| return c.c.errRecv == nil |
| } |
| func (c implTunnelForwardCallRecv) Value() []byte { |
| return c.c.valRecv |
| } |
| func (c implTunnelForwardCallRecv) Err() error { |
| if c.c.errRecv == io.EOF { |
| return nil |
| } |
| return c.c.errRecv |
| } |
| func (c *implTunnelForwardCall) SendStream() interface { |
| Send(item []byte) error |
| Close() error |
| } { |
| return implTunnelForwardCallSend{c} |
| } |
| |
| type implTunnelForwardCallSend struct { |
| c *implTunnelForwardCall |
| } |
| |
| func (c implTunnelForwardCallSend) Send(item []byte) error { |
| return c.c.Send(item) |
| } |
| func (c implTunnelForwardCallSend) Close() error { |
| return c.c.CloseSend() |
| } |
| func (c *implTunnelForwardCall) Finish() (err error) { |
| if ierr := c.Call.Finish(&err); ierr != nil { |
| err = ierr |
| } |
| return |
| } |
| |
| // TunnelShellClientStream is the client stream for 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 |
| } |
| } |
| |
| // TunnelShellCall represents the call returned from Tunnel.Shell. |
| type TunnelShellCall 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() (int32, error) |
| } |
| |
| type implTunnelShellCall struct { |
| ipc.Call |
| valRecv ServerShellPacket |
| errRecv error |
| } |
| |
| func (c *implTunnelShellCall) RecvStream() interface { |
| Advance() bool |
| Value() ServerShellPacket |
| Err() error |
| } { |
| return implTunnelShellCallRecv{c} |
| } |
| |
| type implTunnelShellCallRecv struct { |
| c *implTunnelShellCall |
| } |
| |
| func (c implTunnelShellCallRecv) Advance() bool { |
| c.c.valRecv = ServerShellPacket{} |
| c.c.errRecv = c.c.Recv(&c.c.valRecv) |
| return c.c.errRecv == nil |
| } |
| func (c implTunnelShellCallRecv) Value() ServerShellPacket { |
| return c.c.valRecv |
| } |
| func (c implTunnelShellCallRecv) Err() error { |
| if c.c.errRecv == io.EOF { |
| return nil |
| } |
| return c.c.errRecv |
| } |
| func (c *implTunnelShellCall) SendStream() interface { |
| Send(item ClientShellPacket) error |
| Close() error |
| } { |
| return implTunnelShellCallSend{c} |
| } |
| |
| type implTunnelShellCallSend struct { |
| c *implTunnelShellCall |
| } |
| |
| func (c implTunnelShellCallSend) Send(item ClientShellPacket) error { |
| return c.c.Send(item) |
| } |
| func (c implTunnelShellCallSend) Close() error { |
| return c.c.CloseSend() |
| } |
| func (c *implTunnelShellCall) Finish() (o0 int32, err error) { |
| if ierr := c.Call.Finish(&o0, &err); ierr != nil { |
| err = ierr |
| } |
| return |
| } |
| |
| // TunnelServerMethods is the interface a server writer |
| // implements for Tunnel. |
| 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 in the reply |
| // stream. |
| Forward(ctx TunnelForwardContext, 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. |
| Shell(ctx TunnelShellContext, command string, shellOpts ShellOpts) (int32, error) |
| } |
| |
| // TunnelServerStubMethods is the server interface containing |
| // Tunnel methods, as expected by ipc.Server. |
| // The only difference between this interface and TunnelServerMethods |
| // is the streaming methods. |
| 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 in the reply |
| // stream. |
| Forward(ctx *TunnelForwardContextStub, 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. |
| Shell(ctx *TunnelShellContextStub, command string, shellOpts ShellOpts) (int32, error) |
| } |
| |
| // TunnelServerStub adds universal methods to TunnelServerStubMethods. |
| type TunnelServerStub interface { |
| TunnelServerStubMethods |
| // Describe the Tunnel interfaces. |
| Describe__() []ipc.InterfaceDesc |
| } |
| |
| // TunnelServer returns a server stub for Tunnel. |
| // It converts an implementation of TunnelServerMethods into |
| // an object that may be used by ipc.Server. |
| func TunnelServer(impl TunnelServerMethods) TunnelServerStub { |
| stub := implTunnelServerStub{ |
| impl: impl, |
| } |
| // Initialize GlobState; always check the stub itself first, to handle the |
| // case where the user has the Glob method defined in their VDL source. |
| if gs := ipc.NewGlobState(stub); gs != nil { |
| stub.gs = gs |
| } else if gs := ipc.NewGlobState(impl); gs != nil { |
| stub.gs = gs |
| } |
| return stub |
| } |
| |
| type implTunnelServerStub struct { |
| impl TunnelServerMethods |
| gs *ipc.GlobState |
| } |
| |
| func (s implTunnelServerStub) Forward(ctx *TunnelForwardContextStub, i0 string, i1 string) error { |
| return s.impl.Forward(ctx, i0, i1) |
| } |
| |
| func (s implTunnelServerStub) Shell(ctx *TunnelShellContextStub, i0 string, i1 ShellOpts) (int32, error) { |
| return s.impl.Shell(ctx, i0, i1) |
| } |
| |
| func (s implTunnelServerStub) Globber() *ipc.GlobState { |
| return s.gs |
| } |
| |
| func (s implTunnelServerStub) Describe__() []ipc.InterfaceDesc { |
| return []ipc.InterfaceDesc{TunnelDesc} |
| } |
| |
| // TunnelDesc describes the Tunnel interface. |
| var TunnelDesc ipc.InterfaceDesc = descTunnel |
| |
| // descTunnel hides the desc to keep godoc clean. |
| var descTunnel = ipc.InterfaceDesc{ |
| Name: "Tunnel", |
| PkgPath: "v.io/apps/tunnel", |
| Methods: []ipc.MethodDesc{ |
| { |
| Name: "Forward", |
| Doc: "// The Forward method is used for network forwarding. All the data sent over\n// the byte stream is forwarded to the requested network address and all the\n// data received from that network connection is sent back in the reply\n// stream.", |
| InArgs: []ipc.ArgDesc{ |
| {"network", ``}, // string |
| {"address", ``}, // string |
| }, |
| OutArgs: []ipc.ArgDesc{ |
| {"", ``}, // error |
| }, |
| Tags: []vdl.AnyRep{access.Tag("Admin")}, |
| }, |
| { |
| Name: "Shell", |
| Doc: "// The Shell method is used to either run shell commands remotely, or to open\n// an interactive shell. The data received over the byte stream is sent to the\n// shell's stdin, and the data received from the shell's stdout and stderr is\n// sent back in the reply stream. It returns the exit status of the shell\n// command.", |
| InArgs: []ipc.ArgDesc{ |
| {"command", ``}, // string |
| {"shellOpts", ``}, // ShellOpts |
| }, |
| OutArgs: []ipc.ArgDesc{ |
| {"", ``}, // int32 |
| {"", ``}, // error |
| }, |
| Tags: []vdl.AnyRep{access.Tag("Admin")}, |
| }, |
| }, |
| } |
| |
| // TunnelForwardServerStream is the server stream for Tunnel.Forward. |
| 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 |
| } |
| } |
| |
| // TunnelForwardContext represents the context passed to Tunnel.Forward. |
| type TunnelForwardContext interface { |
| ipc.ServerContext |
| TunnelForwardServerStream |
| } |
| |
| // TunnelForwardContextStub is a wrapper that converts ipc.ServerCall into |
| // a typesafe stub that implements TunnelForwardContext. |
| type TunnelForwardContextStub struct { |
| ipc.ServerCall |
| valRecv []byte |
| errRecv error |
| } |
| |
| // Init initializes TunnelForwardContextStub from ipc.ServerCall. |
| func (s *TunnelForwardContextStub) Init(call ipc.ServerCall) { |
| s.ServerCall = call |
| } |
| |
| // RecvStream returns the receiver side of the Tunnel.Forward server stream. |
| func (s *TunnelForwardContextStub) RecvStream() interface { |
| Advance() bool |
| Value() []byte |
| Err() error |
| } { |
| return implTunnelForwardContextRecv{s} |
| } |
| |
| type implTunnelForwardContextRecv struct { |
| s *TunnelForwardContextStub |
| } |
| |
| func (s implTunnelForwardContextRecv) Advance() bool { |
| s.s.errRecv = s.s.Recv(&s.s.valRecv) |
| return s.s.errRecv == nil |
| } |
| func (s implTunnelForwardContextRecv) Value() []byte { |
| return s.s.valRecv |
| } |
| func (s implTunnelForwardContextRecv) Err() error { |
| if s.s.errRecv == io.EOF { |
| return nil |
| } |
| return s.s.errRecv |
| } |
| |
| // SendStream returns the send side of the Tunnel.Forward server stream. |
| func (s *TunnelForwardContextStub) SendStream() interface { |
| Send(item []byte) error |
| } { |
| return implTunnelForwardContextSend{s} |
| } |
| |
| type implTunnelForwardContextSend struct { |
| s *TunnelForwardContextStub |
| } |
| |
| func (s implTunnelForwardContextSend) Send(item []byte) error { |
| return s.s.Send(item) |
| } |
| |
| // TunnelShellServerStream is the server stream for Tunnel.Shell. |
| 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 |
| } |
| } |
| |
| // TunnelShellContext represents the context passed to Tunnel.Shell. |
| type TunnelShellContext interface { |
| ipc.ServerContext |
| TunnelShellServerStream |
| } |
| |
| // TunnelShellContextStub is a wrapper that converts ipc.ServerCall into |
| // a typesafe stub that implements TunnelShellContext. |
| type TunnelShellContextStub struct { |
| ipc.ServerCall |
| valRecv ClientShellPacket |
| errRecv error |
| } |
| |
| // Init initializes TunnelShellContextStub from ipc.ServerCall. |
| func (s *TunnelShellContextStub) Init(call ipc.ServerCall) { |
| s.ServerCall = call |
| } |
| |
| // RecvStream returns the receiver side of the Tunnel.Shell server stream. |
| func (s *TunnelShellContextStub) RecvStream() interface { |
| Advance() bool |
| Value() ClientShellPacket |
| Err() error |
| } { |
| return implTunnelShellContextRecv{s} |
| } |
| |
| type implTunnelShellContextRecv struct { |
| s *TunnelShellContextStub |
| } |
| |
| func (s implTunnelShellContextRecv) Advance() bool { |
| s.s.valRecv = ClientShellPacket{} |
| s.s.errRecv = s.s.Recv(&s.s.valRecv) |
| return s.s.errRecv == nil |
| } |
| func (s implTunnelShellContextRecv) Value() ClientShellPacket { |
| return s.s.valRecv |
| } |
| func (s implTunnelShellContextRecv) Err() error { |
| if s.s.errRecv == io.EOF { |
| return nil |
| } |
| return s.s.errRecv |
| } |
| |
| // SendStream returns the send side of the Tunnel.Shell server stream. |
| func (s *TunnelShellContextStub) SendStream() interface { |
| Send(item ServerShellPacket) error |
| } { |
| return implTunnelShellContextSend{s} |
| } |
| |
| type implTunnelShellContextSend struct { |
| s *TunnelShellContextStub |
| } |
| |
| func (s implTunnelShellContextSend) Send(item ServerShellPacket) error { |
| return s.s.Send(item) |
| } |