Todd Wang | e5d67b4 | 2014-05-27 10:48:07 -0700 | [diff] [blame] | 1 | // This file was auto-generated by the veyron vdl tool. |
Tilak Sharma | 43395f3 | 2014-05-27 11:33:38 -0700 | [diff] [blame] | 2 | // Source: tunnel.vdl |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 3 | |
| 4 | package tunnel |
| 5 | |
| 6 | import ( |
| 7 | "veyron2/security" |
| 8 | |
| 9 | // The non-user imports are prefixed with "_gen_" to prevent collisions. |
Cosmos Nicolaou | b07fa77 | 2014-05-16 08:07:02 -0700 | [diff] [blame] | 10 | _gen_veyron2 "veyron2" |
Matt Rosencrantz | 29147f7 | 2014-06-06 12:46:01 -0700 | [diff] [blame] | 11 | _gen_context "veyron2/context" |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 12 | _gen_ipc "veyron2/ipc" |
| 13 | _gen_naming "veyron2/naming" |
Cosmos Nicolaou | ae67894 | 2014-05-17 17:21:43 -0700 | [diff] [blame] | 14 | _gen_rt "veyron2/rt" |
Todd Wang | 0ecdd7a | 2014-07-14 16:24:38 -0700 | [diff] [blame] | 15 | _gen_vdlutil "veyron2/vdl/vdlutil" |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 16 | _gen_wiretype "veyron2/wiretype" |
| 17 | ) |
| 18 | |
| 19 | type ShellOpts struct { |
| 20 | UsePty bool // Whether to open a pseudo-terminal |
| 21 | Environment []string // Environment variables to pass to the remote shell. |
| 22 | Rows uint32 // Window size. |
| 23 | Cols uint32 |
| 24 | } |
Todd Wang | e5d67b4 | 2014-05-27 10:48:07 -0700 | [diff] [blame] | 25 | |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 26 | type ClientShellPacket struct { |
| 27 | // Bytes going to the shell's stdin. |
| 28 | Stdin []byte |
| 29 | // A dynamic update of the window size. The default value of 0 means no-change. |
| 30 | Rows uint32 |
| 31 | Cols uint32 |
| 32 | } |
Todd Wang | e5d67b4 | 2014-05-27 10:48:07 -0700 | [diff] [blame] | 33 | |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 34 | type ServerShellPacket struct { |
| 35 | // Bytes coming from the shell's stdout. |
| 36 | Stdout []byte |
| 37 | // Bytes coming from the shell's stderr. |
| 38 | Stderr []byte |
| 39 | } |
| 40 | |
| 41 | // Tunnel is the interface the client binds and uses. |
Benjamin Prosnitz | dcddb93 | 2014-05-27 15:55:58 -0700 | [diff] [blame] | 42 | // Tunnel_ExcludingUniversal is the interface without internal framework-added methods |
| 43 | // to enable embedding without method collisions. Not to be used directly by clients. |
| 44 | type Tunnel_ExcludingUniversal interface { |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 45 | // The Forward method is used for network forwarding. All the data sent over |
| 46 | // the byte stream is forwarded to the requested network address and all the |
| 47 | // data received from that network connection is sent back in the reply |
| 48 | // stream. |
Matt Rosencrantz | 29147f7 | 2014-06-06 12:46:01 -0700 | [diff] [blame] | 49 | Forward(ctx _gen_context.T, network string, address string, opts ..._gen_ipc.CallOpt) (reply TunnelForwardStream, err error) |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 50 | // The Shell method is used to either run shell commands remotely, or to open |
| 51 | // an interactive shell. The data received over the byte stream is sent to the |
| 52 | // shell's stdin, and the data received from the shell's stdout and stderr is |
| 53 | // sent back in the reply stream. It returns the exit status of the shell |
| 54 | // command. |
Matt Rosencrantz | 29147f7 | 2014-06-06 12:46:01 -0700 | [diff] [blame] | 55 | Shell(ctx _gen_context.T, command string, shellOpts ShellOpts, opts ..._gen_ipc.CallOpt) (reply TunnelShellStream, err error) |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 56 | } |
| 57 | type Tunnel interface { |
Benjamin Prosnitz | dcddb93 | 2014-05-27 15:55:58 -0700 | [diff] [blame] | 58 | _gen_ipc.UniversalServiceMethods |
| 59 | Tunnel_ExcludingUniversal |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | // TunnelService is the interface the server implements. |
| 63 | type TunnelService interface { |
| 64 | |
| 65 | // The Forward method is used for network forwarding. All the data sent over |
| 66 | // the byte stream is forwarded to the requested network address and all the |
| 67 | // data received from that network connection is sent back in the reply |
| 68 | // stream. |
Matt Rosencrantz | f5afcaf | 2014-06-02 11:31:22 -0700 | [diff] [blame] | 69 | Forward(context _gen_ipc.ServerContext, network string, address string, stream TunnelServiceForwardStream) (err error) |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 70 | // The Shell method is used to either run shell commands remotely, or to open |
| 71 | // an interactive shell. The data received over the byte stream is sent to the |
| 72 | // shell's stdin, and the data received from the shell's stdout and stderr is |
| 73 | // sent back in the reply stream. It returns the exit status of the shell |
| 74 | // command. |
Matt Rosencrantz | f5afcaf | 2014-06-02 11:31:22 -0700 | [diff] [blame] | 75 | Shell(context _gen_ipc.ServerContext, command string, shellOpts ShellOpts, stream TunnelServiceShellStream) (reply int32, err error) |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | // TunnelForwardStream is the interface for streaming responses of the method |
| 79 | // Forward in the service interface Tunnel. |
| 80 | type TunnelForwardStream interface { |
| 81 | |
Bogdan Caprita | a5ef10c | 2014-07-18 14:23:16 -0700 | [diff] [blame] | 82 | // Send places the item onto the output stream, blocking if there is no |
| 83 | // buffer space available. Calls to Send after having called CloseSend |
| 84 | // or Cancel will fail. Any blocked Send calls will be unblocked upon |
| 85 | // calling Cancel. |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 86 | Send(item []byte) error |
| 87 | |
Bogdan Caprita | a5ef10c | 2014-07-18 14:23:16 -0700 | [diff] [blame] | 88 | // CloseSend indicates to the server that no more items will be sent; |
| 89 | // server Recv calls will receive io.EOF after all sent items. This is |
| 90 | // an optional call - it's used by streaming clients that need the |
| 91 | // server to receive the io.EOF terminator before the client calls |
| 92 | // Finish (for example, if the client needs to continue receiving items |
| 93 | // from the server after having finished sending). |
| 94 | // Calls to CloseSend after having called Cancel will fail. |
| 95 | // Like Send, CloseSend blocks when there's no buffer space available. |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 96 | CloseSend() error |
| 97 | |
| 98 | // Recv returns the next item in the input stream, blocking until |
Bogdan Caprita | a5ef10c | 2014-07-18 14:23:16 -0700 | [diff] [blame] | 99 | // an item is available. Returns io.EOF to indicate graceful end of |
| 100 | // input. |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 101 | Recv() (item []byte, err error) |
| 102 | |
Bogdan Caprita | a5ef10c | 2014-07-18 14:23:16 -0700 | [diff] [blame] | 103 | // Finish performs the equivalent of CloseSend, then blocks until the server |
| 104 | // is done, and returns the positional return values for call. |
| 105 | // |
| 106 | // If Cancel has been called, Finish will return immediately; the output of |
| 107 | // Finish could either be an error signalling cancelation, or the correct |
| 108 | // positional return values from the server depending on the timing of the |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 109 | // call. |
Bogdan Caprita | a5ef10c | 2014-07-18 14:23:16 -0700 | [diff] [blame] | 110 | // |
| 111 | // Calling Finish is mandatory for releasing stream resources, unless Cancel |
| 112 | // has been called or any of the other methods return a non-EOF error. |
| 113 | // Finish should be called at most once. |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 114 | Finish() (err error) |
| 115 | |
Bogdan Caprita | a5ef10c | 2014-07-18 14:23:16 -0700 | [diff] [blame] | 116 | // Cancel cancels the RPC, notifying the server to stop processing. It |
| 117 | // is safe to call Cancel concurrently with any of the other stream methods. |
| 118 | // Calling Cancel after Finish has returned is a no-op. |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 119 | Cancel() |
| 120 | } |
| 121 | |
| 122 | // Implementation of the TunnelForwardStream interface that is not exported. |
| 123 | type implTunnelForwardStream struct { |
Matt Rosencrantz | f5afcaf | 2014-06-02 11:31:22 -0700 | [diff] [blame] | 124 | clientCall _gen_ipc.Call |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 125 | } |
| 126 | |
| 127 | func (c *implTunnelForwardStream) Send(item []byte) error { |
| 128 | return c.clientCall.Send(item) |
| 129 | } |
| 130 | |
| 131 | func (c *implTunnelForwardStream) CloseSend() error { |
| 132 | return c.clientCall.CloseSend() |
| 133 | } |
| 134 | |
| 135 | func (c *implTunnelForwardStream) Recv() (item []byte, err error) { |
| 136 | err = c.clientCall.Recv(&item) |
| 137 | return |
| 138 | } |
| 139 | |
| 140 | func (c *implTunnelForwardStream) Finish() (err error) { |
| 141 | if ierr := c.clientCall.Finish(&err); ierr != nil { |
| 142 | err = ierr |
| 143 | } |
| 144 | return |
| 145 | } |
| 146 | |
| 147 | func (c *implTunnelForwardStream) Cancel() { |
| 148 | c.clientCall.Cancel() |
| 149 | } |
| 150 | |
| 151 | // TunnelServiceForwardStream is the interface for streaming responses of the method |
| 152 | // Forward in the service interface Tunnel. |
| 153 | type TunnelServiceForwardStream interface { |
| 154 | // Send places the item onto the output stream, blocking if there is no buffer |
Bogdan Caprita | a5ef10c | 2014-07-18 14:23:16 -0700 | [diff] [blame] | 155 | // space available. If the client has canceled, an error is returned. |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 156 | Send(item []byte) error |
| 157 | |
| 158 | // Recv fills itemptr with the next item in the input stream, blocking until |
| 159 | // an item is available. Returns io.EOF to indicate graceful end of input. |
| 160 | Recv() (item []byte, err error) |
| 161 | } |
| 162 | |
| 163 | // Implementation of the TunnelServiceForwardStream interface that is not exported. |
| 164 | type implTunnelServiceForwardStream struct { |
| 165 | serverCall _gen_ipc.ServerCall |
| 166 | } |
| 167 | |
| 168 | func (s *implTunnelServiceForwardStream) Send(item []byte) error { |
| 169 | return s.serverCall.Send(item) |
| 170 | } |
| 171 | |
| 172 | func (s *implTunnelServiceForwardStream) Recv() (item []byte, err error) { |
| 173 | err = s.serverCall.Recv(&item) |
| 174 | return |
| 175 | } |
| 176 | |
| 177 | // TunnelShellStream is the interface for streaming responses of the method |
| 178 | // Shell in the service interface Tunnel. |
| 179 | type TunnelShellStream interface { |
| 180 | |
Bogdan Caprita | a5ef10c | 2014-07-18 14:23:16 -0700 | [diff] [blame] | 181 | // Send places the item onto the output stream, blocking if there is no |
| 182 | // buffer space available. Calls to Send after having called CloseSend |
| 183 | // or Cancel will fail. Any blocked Send calls will be unblocked upon |
| 184 | // calling Cancel. |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 185 | Send(item ClientShellPacket) error |
| 186 | |
Bogdan Caprita | a5ef10c | 2014-07-18 14:23:16 -0700 | [diff] [blame] | 187 | // CloseSend indicates to the server that no more items will be sent; |
| 188 | // server Recv calls will receive io.EOF after all sent items. This is |
| 189 | // an optional call - it's used by streaming clients that need the |
| 190 | // server to receive the io.EOF terminator before the client calls |
| 191 | // Finish (for example, if the client needs to continue receiving items |
| 192 | // from the server after having finished sending). |
| 193 | // Calls to CloseSend after having called Cancel will fail. |
| 194 | // Like Send, CloseSend blocks when there's no buffer space available. |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 195 | CloseSend() error |
| 196 | |
| 197 | // Recv returns the next item in the input stream, blocking until |
Bogdan Caprita | a5ef10c | 2014-07-18 14:23:16 -0700 | [diff] [blame] | 198 | // an item is available. Returns io.EOF to indicate graceful end of |
| 199 | // input. |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 200 | Recv() (item ServerShellPacket, err error) |
| 201 | |
Bogdan Caprita | a5ef10c | 2014-07-18 14:23:16 -0700 | [diff] [blame] | 202 | // Finish performs the equivalent of CloseSend, then blocks until the server |
| 203 | // is done, and returns the positional return values for call. |
| 204 | // |
| 205 | // If Cancel has been called, Finish will return immediately; the output of |
| 206 | // Finish could either be an error signalling cancelation, or the correct |
| 207 | // positional return values from the server depending on the timing of the |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 208 | // call. |
Bogdan Caprita | a5ef10c | 2014-07-18 14:23:16 -0700 | [diff] [blame] | 209 | // |
| 210 | // Calling Finish is mandatory for releasing stream resources, unless Cancel |
| 211 | // has been called or any of the other methods return a non-EOF error. |
| 212 | // Finish should be called at most once. |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 213 | Finish() (reply int32, err error) |
| 214 | |
Bogdan Caprita | a5ef10c | 2014-07-18 14:23:16 -0700 | [diff] [blame] | 215 | // Cancel cancels the RPC, notifying the server to stop processing. It |
| 216 | // is safe to call Cancel concurrently with any of the other stream methods. |
| 217 | // Calling Cancel after Finish has returned is a no-op. |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 218 | Cancel() |
| 219 | } |
| 220 | |
| 221 | // Implementation of the TunnelShellStream interface that is not exported. |
| 222 | type implTunnelShellStream struct { |
Matt Rosencrantz | f5afcaf | 2014-06-02 11:31:22 -0700 | [diff] [blame] | 223 | clientCall _gen_ipc.Call |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 224 | } |
| 225 | |
| 226 | func (c *implTunnelShellStream) Send(item ClientShellPacket) error { |
| 227 | return c.clientCall.Send(item) |
| 228 | } |
| 229 | |
| 230 | func (c *implTunnelShellStream) CloseSend() error { |
| 231 | return c.clientCall.CloseSend() |
| 232 | } |
| 233 | |
| 234 | func (c *implTunnelShellStream) Recv() (item ServerShellPacket, err error) { |
| 235 | err = c.clientCall.Recv(&item) |
| 236 | return |
| 237 | } |
| 238 | |
| 239 | func (c *implTunnelShellStream) Finish() (reply int32, err error) { |
| 240 | if ierr := c.clientCall.Finish(&reply, &err); ierr != nil { |
| 241 | err = ierr |
| 242 | } |
| 243 | return |
| 244 | } |
| 245 | |
| 246 | func (c *implTunnelShellStream) Cancel() { |
| 247 | c.clientCall.Cancel() |
| 248 | } |
| 249 | |
| 250 | // TunnelServiceShellStream is the interface for streaming responses of the method |
| 251 | // Shell in the service interface Tunnel. |
| 252 | type TunnelServiceShellStream interface { |
| 253 | // Send places the item onto the output stream, blocking if there is no buffer |
Bogdan Caprita | a5ef10c | 2014-07-18 14:23:16 -0700 | [diff] [blame] | 254 | // space available. If the client has canceled, an error is returned. |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 255 | Send(item ServerShellPacket) error |
| 256 | |
| 257 | // Recv fills itemptr with the next item in the input stream, blocking until |
| 258 | // an item is available. Returns io.EOF to indicate graceful end of input. |
| 259 | Recv() (item ClientShellPacket, err error) |
| 260 | } |
| 261 | |
| 262 | // Implementation of the TunnelServiceShellStream interface that is not exported. |
| 263 | type implTunnelServiceShellStream struct { |
| 264 | serverCall _gen_ipc.ServerCall |
| 265 | } |
| 266 | |
| 267 | func (s *implTunnelServiceShellStream) Send(item ServerShellPacket) error { |
| 268 | return s.serverCall.Send(item) |
| 269 | } |
| 270 | |
| 271 | func (s *implTunnelServiceShellStream) Recv() (item ClientShellPacket, err error) { |
| 272 | err = s.serverCall.Recv(&item) |
| 273 | return |
| 274 | } |
| 275 | |
| 276 | // BindTunnel returns the client stub implementing the Tunnel |
| 277 | // interface. |
| 278 | // |
| 279 | // If no _gen_ipc.Client is specified, the default _gen_ipc.Client in the |
| 280 | // global Runtime is used. |
| 281 | func BindTunnel(name string, opts ..._gen_ipc.BindOpt) (Tunnel, error) { |
| 282 | var client _gen_ipc.Client |
| 283 | switch len(opts) { |
| 284 | case 0: |
| 285 | client = _gen_rt.R().Client() |
| 286 | case 1: |
| 287 | switch o := opts[0].(type) { |
Cosmos Nicolaou | b07fa77 | 2014-05-16 08:07:02 -0700 | [diff] [blame] | 288 | case _gen_veyron2.Runtime: |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 289 | client = o.Client() |
| 290 | case _gen_ipc.Client: |
| 291 | client = o |
| 292 | default: |
Todd Wang | 0ecdd7a | 2014-07-14 16:24:38 -0700 | [diff] [blame] | 293 | return nil, _gen_vdlutil.ErrUnrecognizedOption |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 294 | } |
| 295 | default: |
Todd Wang | 0ecdd7a | 2014-07-14 16:24:38 -0700 | [diff] [blame] | 296 | return nil, _gen_vdlutil.ErrTooManyOptionsToBind |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 297 | } |
| 298 | stub := &clientStubTunnel{client: client, name: name} |
| 299 | |
| 300 | return stub, nil |
| 301 | } |
| 302 | |
| 303 | // NewServerTunnel creates a new server stub. |
| 304 | // |
| 305 | // It takes a regular server implementing the TunnelService |
| 306 | // interface, and returns a new server stub. |
| 307 | func NewServerTunnel(server TunnelService) interface{} { |
| 308 | return &ServerStubTunnel{ |
| 309 | service: server, |
| 310 | } |
| 311 | } |
| 312 | |
| 313 | // clientStubTunnel implements Tunnel. |
| 314 | type clientStubTunnel struct { |
| 315 | client _gen_ipc.Client |
| 316 | name string |
| 317 | } |
| 318 | |
Matt Rosencrantz | 29147f7 | 2014-06-06 12:46:01 -0700 | [diff] [blame] | 319 | func (__gen_c *clientStubTunnel) Forward(ctx _gen_context.T, network string, address string, opts ..._gen_ipc.CallOpt) (reply TunnelForwardStream, err error) { |
Matt Rosencrantz | f5afcaf | 2014-06-02 11:31:22 -0700 | [diff] [blame] | 320 | var call _gen_ipc.Call |
| 321 | if call, err = __gen_c.client.StartCall(ctx, __gen_c.name, "Forward", []interface{}{network, address}, opts...); err != nil { |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 322 | return |
| 323 | } |
| 324 | reply = &implTunnelForwardStream{clientCall: call} |
| 325 | return |
| 326 | } |
| 327 | |
Matt Rosencrantz | 29147f7 | 2014-06-06 12:46:01 -0700 | [diff] [blame] | 328 | func (__gen_c *clientStubTunnel) Shell(ctx _gen_context.T, command string, shellOpts ShellOpts, opts ..._gen_ipc.CallOpt) (reply TunnelShellStream, err error) { |
Matt Rosencrantz | f5afcaf | 2014-06-02 11:31:22 -0700 | [diff] [blame] | 329 | var call _gen_ipc.Call |
| 330 | if call, err = __gen_c.client.StartCall(ctx, __gen_c.name, "Shell", []interface{}{command, shellOpts}, opts...); err != nil { |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 331 | return |
| 332 | } |
| 333 | reply = &implTunnelShellStream{clientCall: call} |
| 334 | return |
| 335 | } |
| 336 | |
Matt Rosencrantz | 29147f7 | 2014-06-06 12:46:01 -0700 | [diff] [blame] | 337 | func (__gen_c *clientStubTunnel) UnresolveStep(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply []string, err error) { |
Matt Rosencrantz | f5afcaf | 2014-06-02 11:31:22 -0700 | [diff] [blame] | 338 | var call _gen_ipc.Call |
| 339 | if call, err = __gen_c.client.StartCall(ctx, __gen_c.name, "UnresolveStep", nil, opts...); err != nil { |
Benjamin Prosnitz | dcddb93 | 2014-05-27 15:55:58 -0700 | [diff] [blame] | 340 | return |
| 341 | } |
| 342 | if ierr := call.Finish(&reply, &err); ierr != nil { |
| 343 | err = ierr |
| 344 | } |
| 345 | return |
| 346 | } |
| 347 | |
Matt Rosencrantz | 29147f7 | 2014-06-06 12:46:01 -0700 | [diff] [blame] | 348 | func (__gen_c *clientStubTunnel) Signature(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply _gen_ipc.ServiceSignature, err error) { |
Matt Rosencrantz | f5afcaf | 2014-06-02 11:31:22 -0700 | [diff] [blame] | 349 | var call _gen_ipc.Call |
| 350 | if call, err = __gen_c.client.StartCall(ctx, __gen_c.name, "Signature", nil, opts...); err != nil { |
Benjamin Prosnitz | dcddb93 | 2014-05-27 15:55:58 -0700 | [diff] [blame] | 351 | return |
| 352 | } |
| 353 | if ierr := call.Finish(&reply, &err); ierr != nil { |
| 354 | err = ierr |
| 355 | } |
| 356 | return |
| 357 | } |
| 358 | |
Matt Rosencrantz | 29147f7 | 2014-06-06 12:46:01 -0700 | [diff] [blame] | 359 | func (__gen_c *clientStubTunnel) GetMethodTags(ctx _gen_context.T, method string, opts ..._gen_ipc.CallOpt) (reply []interface{}, err error) { |
Matt Rosencrantz | f5afcaf | 2014-06-02 11:31:22 -0700 | [diff] [blame] | 360 | var call _gen_ipc.Call |
| 361 | if call, err = __gen_c.client.StartCall(ctx, __gen_c.name, "GetMethodTags", []interface{}{method}, opts...); err != nil { |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 362 | return |
| 363 | } |
| 364 | if ierr := call.Finish(&reply, &err); ierr != nil { |
| 365 | err = ierr |
| 366 | } |
| 367 | return |
| 368 | } |
| 369 | |
| 370 | // ServerStubTunnel wraps a server that implements |
| 371 | // TunnelService and provides an object that satisfies |
| 372 | // the requirements of veyron2/ipc.ReflectInvoker. |
| 373 | type ServerStubTunnel struct { |
| 374 | service TunnelService |
| 375 | } |
| 376 | |
Benjamin Prosnitz | dcddb93 | 2014-05-27 15:55:58 -0700 | [diff] [blame] | 377 | func (__gen_s *ServerStubTunnel) GetMethodTags(call _gen_ipc.ServerCall, method string) ([]interface{}, error) { |
| 378 | // TODO(bprosnitz) GetMethodTags() will be replaces with Signature(). |
| 379 | // Note: This exhibits some weird behavior like returning a nil error if the method isn't found. |
| 380 | // This will change when it is replaced with Signature(). |
| 381 | switch method { |
| 382 | case "Forward": |
| 383 | return []interface{}{security.Label(4)}, nil |
| 384 | case "Shell": |
| 385 | return []interface{}{security.Label(4)}, nil |
| 386 | default: |
| 387 | return nil, nil |
| 388 | } |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 389 | } |
| 390 | |
Benjamin Prosnitz | dcddb93 | 2014-05-27 15:55:58 -0700 | [diff] [blame] | 391 | func (__gen_s *ServerStubTunnel) Signature(call _gen_ipc.ServerCall) (_gen_ipc.ServiceSignature, error) { |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 392 | result := _gen_ipc.ServiceSignature{Methods: make(map[string]_gen_ipc.MethodSignature)} |
| 393 | result.Methods["Forward"] = _gen_ipc.MethodSignature{ |
| 394 | InArgs: []_gen_ipc.MethodArgument{ |
| 395 | {Name: "network", Type: 3}, |
| 396 | {Name: "address", Type: 3}, |
| 397 | }, |
| 398 | OutArgs: []_gen_ipc.MethodArgument{ |
| 399 | {Name: "", Type: 65}, |
| 400 | }, |
| 401 | InStream: 67, |
| 402 | OutStream: 67, |
| 403 | } |
| 404 | result.Methods["Shell"] = _gen_ipc.MethodSignature{ |
| 405 | InArgs: []_gen_ipc.MethodArgument{ |
| 406 | {Name: "command", Type: 3}, |
| 407 | {Name: "shellOpts", Type: 68}, |
| 408 | }, |
| 409 | OutArgs: []_gen_ipc.MethodArgument{ |
| 410 | {Name: "", Type: 36}, |
| 411 | {Name: "", Type: 65}, |
| 412 | }, |
| 413 | InStream: 69, |
| 414 | OutStream: 70, |
| 415 | } |
| 416 | |
Todd Wang | 0ecdd7a | 2014-07-14 16:24:38 -0700 | [diff] [blame] | 417 | result.TypeDefs = []_gen_vdlutil.Any{ |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 418 | _gen_wiretype.NamedPrimitiveType{Type: 0x1, Name: "error", Tags: []string(nil)}, _gen_wiretype.NamedPrimitiveType{Type: 0x32, Name: "byte", Tags: []string(nil)}, _gen_wiretype.SliceType{Elem: 0x42, Name: "", Tags: []string(nil)}, _gen_wiretype.StructType{ |
| 419 | []_gen_wiretype.FieldType{ |
| 420 | _gen_wiretype.FieldType{Type: 0x2, Name: "UsePty"}, |
| 421 | _gen_wiretype.FieldType{Type: 0x3d, Name: "Environment"}, |
| 422 | _gen_wiretype.FieldType{Type: 0x34, Name: "Rows"}, |
| 423 | _gen_wiretype.FieldType{Type: 0x34, Name: "Cols"}, |
| 424 | }, |
Todd Wang | e5d67b4 | 2014-05-27 10:48:07 -0700 | [diff] [blame] | 425 | "veyron/examples/tunnel.ShellOpts", []string(nil)}, |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 426 | _gen_wiretype.StructType{ |
| 427 | []_gen_wiretype.FieldType{ |
| 428 | _gen_wiretype.FieldType{Type: 0x43, Name: "Stdin"}, |
| 429 | _gen_wiretype.FieldType{Type: 0x34, Name: "Rows"}, |
| 430 | _gen_wiretype.FieldType{Type: 0x34, Name: "Cols"}, |
| 431 | }, |
Todd Wang | e5d67b4 | 2014-05-27 10:48:07 -0700 | [diff] [blame] | 432 | "veyron/examples/tunnel.ClientShellPacket", []string(nil)}, |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 433 | _gen_wiretype.StructType{ |
| 434 | []_gen_wiretype.FieldType{ |
| 435 | _gen_wiretype.FieldType{Type: 0x43, Name: "Stdout"}, |
| 436 | _gen_wiretype.FieldType{Type: 0x43, Name: "Stderr"}, |
| 437 | }, |
Todd Wang | e5d67b4 | 2014-05-27 10:48:07 -0700 | [diff] [blame] | 438 | "veyron/examples/tunnel.ServerShellPacket", []string(nil)}, |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 439 | } |
| 440 | |
| 441 | return result, nil |
| 442 | } |
| 443 | |
Benjamin Prosnitz | dcddb93 | 2014-05-27 15:55:58 -0700 | [diff] [blame] | 444 | func (__gen_s *ServerStubTunnel) UnresolveStep(call _gen_ipc.ServerCall) (reply []string, err error) { |
| 445 | if unresolver, ok := __gen_s.service.(_gen_ipc.Unresolver); ok { |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 446 | return unresolver.UnresolveStep(call) |
| 447 | } |
| 448 | if call.Server() == nil { |
| 449 | return |
| 450 | } |
| 451 | var published []string |
| 452 | if published, err = call.Server().Published(); err != nil || published == nil { |
| 453 | return |
| 454 | } |
| 455 | reply = make([]string, len(published)) |
| 456 | for i, p := range published { |
| 457 | reply[i] = _gen_naming.Join(p, call.Name()) |
| 458 | } |
| 459 | return |
| 460 | } |
| 461 | |
| 462 | func (__gen_s *ServerStubTunnel) Forward(call _gen_ipc.ServerCall, network string, address string) (err error) { |
| 463 | stream := &implTunnelServiceForwardStream{serverCall: call} |
| 464 | err = __gen_s.service.Forward(call, network, address, stream) |
| 465 | return |
| 466 | } |
| 467 | |
| 468 | func (__gen_s *ServerStubTunnel) Shell(call _gen_ipc.ServerCall, command string, shellOpts ShellOpts) (reply int32, err error) { |
| 469 | stream := &implTunnelServiceShellStream{serverCall: call} |
| 470 | reply, err = __gen_s.service.Shell(call, command, shellOpts, stream) |
| 471 | return |
| 472 | } |