Skip to content

Commit

Permalink
Merge pull request #1 from anfernee/kep
Browse files Browse the repository at this point in the history
gRPC Change
  • Loading branch information
cheftako authored Mar 27, 2019
2 parents 8c1df8e + 495ddf0 commit 9face4e
Showing 1 changed file with 15 additions and 88 deletions.
103 changes: 15 additions & 88 deletions keps/sig-api-machinery/20190226-network-proxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,102 +241,29 @@ or which user/tenant tries to initiate the request, etc.

### Proxy gRPC definition

In order to serve a proxy request, one gRPC bidirectional stream on proxy
server is created to serve it. It's a 1:1 mapping from TCP connection to a
gRPC stream, so the state of TCP connection is exactly the same as the gRPC
stream state.

```grpc
syntax = "proto3";
service ProxyService {
// Proxy connects to a remote address by stream id, and establish
// a bi-directional stream of packet exchange.
rpc Proxy(stream Packet) returns (stream Packet) {}
}
enum PacketType {
DIAL_REQ = 0;
DIAL_RSP = 1;
CLOSE_REQ = 2;
CLOSE_RSP = 3;
DATA = 4;
}
message Packet {
PacketType type = 1;
oneof payload {
DialRequest dialRequest = 2;
DialResponse dialResponse = 3;
CloseRequest closeRequest = 4;
CloseResponse closeResponse = 5;
Data data = 6;
}
}
// Error is sent when error happens from remote side of connection when it tries
// to read or write from it
enum Error {
EOF = 0;
EIO = 1;
ECONNRESET = 2;
ETIMEOUT = 3;
EADDRNOTAVAIL = 4;
EMFILE = 5;
// …
// Proxy a TCP connection to a remote address defined by ConnectParam.
// The ConnectParam is defined in metadata under key "x-kube-net-proxy".
// metadata["x-kube-net-proxy"] = base64.Encode(proto.Marshal(connectOptions))
rpc Proxy(stream Payload) returns (stream Payload) {}
}
// DialRequest represents a request to dial to an address on the other
// side of the tunnel. The format is inspired by golang's net interface
// https://golang.org/pkg/net/#Dial
message DialRequest {
// network representing a named network. "Tcp" is the only supported
// value
string network = 1;
// For TCP network, the address has the form "ip:port", where host must
// be IP address.
string address = 2;
// random is the randomly generated bytes that represents a given dial request.
// the number is kept unchanged across the proxies, and copied to DialResponse
// from the other side of the tunnel. The number cannot be reused across
// different DialRequests.
bytes random = 3;
// ConnectOptions defines the remote TCP endpoint to connect
message ConnectOptions {
string remote_addr = 1; // remote address to connect to. e.g. 8.8.8.8:53
}
// DialResponse is the response to a DialRequest.
message DialResponse {
// Error when the dial request cannot be fulfilled.
Error error = 1;
// connectID represents a unique connect ID for the connection/stream.
int64 connectID = 2;
// Copied from DialRequest. Explained also in DialRequest.
bytes random = 3;
}
// CloseRequest requests to close a connection
message CloseRequest {
// connection id to close.
int64 connectID = 1;
}
// CloseResponse is the response to a close connection request.
message CloseResponse {
// connection id to close.
int64 connectionID = 1;
// Error when close request cannot be fulfilled.
Error error = 2;
}
message Data {
// connectID that data or error payload is belonged to
int32 connectID = 1;
// data payload
bytes data = 2;
// Error that happens to the connection.
Error error = 3;
// Payload defines a TCP payload.
message Payload {
bytes data = 1;
}
```

Expand Down

0 comments on commit 9face4e

Please sign in to comment.