blob: f1bafcb088aa08b0024c9df2ccc88afe52913545 [file] [log] [blame]
Jiri Simsa756772c2015-03-25 15:40:54 -07001// Copyright 2015 The Vanadium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
Todd Wang8c4e5cc2015-04-09 11:30:52 -07005// Package tunnel defines an interface for creating a network tunnel from client
6// to server.
Jiri Simsad5aae832014-05-10 09:56:38 -07007package tunnel
8
Todd Wang387d8a42015-03-30 17:09:05 -07009import "v.io/v23/security/access"
Jiri Simsad5aae832014-05-10 09:56:38 -070010
Jiri Simsad5aae832014-05-10 09:56:38 -070011type Tunnel interface {
12 // The Forward method is used for network forwarding. All the data sent over
13 // the byte stream is forwarded to the requested network address and all the
14 // data received from that network connection is sent back in the reply
15 // stream.
Asim Shankar4794c932014-11-24 17:45:56 -080016 Forward(network, address string) stream<[]byte, []byte> error {access.Admin}
Jiri Simsad5aae832014-05-10 09:56:38 -070017
18 // The Shell method is used to either run shell commands remotely, or to open
19 // an interactive shell. The data received over the byte stream is sent to the
20 // shell's stdin, and the data received from the shell's stdout and stderr is
21 // sent back in the reply stream. It returns the exit status of the shell
22 // command.
Todd Wang8d1a5592014-12-17 18:13:34 -080023 Shell(command string, shellOpts ShellOpts) stream<ClientShellPacket, ServerShellPacket> (int32 | error) {access.Admin}
Jiri Simsad5aae832014-05-10 09:56:38 -070024}
25
26type ShellOpts struct {
Robin Thellendc14adc92015-02-11 13:02:19 -080027 UsePty bool // Whether to open a pseudo-terminal.
28 Environment []string // Environment variables to pass to the remote shell.
29 WinSize WindowSize // The size of the window.
Jiri Simsad5aae832014-05-10 09:56:38 -070030}
31
Robin Thellendc14adc92015-02-11 13:02:19 -080032type WindowSize struct {
33 Rows, Cols uint16
34}
35
36type ClientShellPacket union {
Robin Thellend9faaef32014-08-01 19:45:40 -070037 // Bytes going to the shell's stdin.
38 Stdin []byte
Robin Thellendc14adc92015-02-11 13:02:19 -080039 // Indicates that stdin should be closed. The presence of this field indicates
40 // EOF. Its actual value is ignored.
Todd Wang53a4e2e2015-03-18 10:54:54 -070041 EndOfFile unused
Robin Thellendc14adc92015-02-11 13:02:19 -080042 // A dynamic update of the window size.
43 WinSize WindowSize
Jiri Simsad5aae832014-05-10 09:56:38 -070044}
45
Robin Thellendc14adc92015-02-11 13:02:19 -080046type unused struct {}
47
48type ServerShellPacket union {
Robin Thellend9faaef32014-08-01 19:45:40 -070049 // Bytes coming from the shell's stdout.
50 Stdout []byte
51 // Bytes coming from the shell's stderr.
52 Stderr []byte
Jiri Simsad5aae832014-05-10 09:56:38 -070053}