Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions docs/streamer_types.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Streamer Types

`gnetcli` supports different connection types (streamers) for connecting to network equipment: SSH, Telnet.

## Supported Types

### SSH (StreamerType_ssh)
- **Value**: `0`
- **Description**: Connection via SSH protocol (default)
- **Default port**: 22
- **Features**:
- SSH tunnel support (ProxyJump)
- SSH Control Files support
- SSH Agent support
- Private key authentication
- SFTP for file transfers

### Telnet (StreamerType_telnet)
- **Value**: `1`
- **Description**: Connection via Telnet protocol
- **Default port**: 23
- **Features**:
- Plain text connection
- Username/password authentication
- Custom port support

## API Usage

### Via gRPC
The streamer type is specified in host parameters:

```protobuf
message HostParams {
string host = 1;
Credentials credentials = 2;
int32 port = 3;
string device = 4;
string ip = 5;
StreamerType streamer_type = 6; // SSH or Telnet
}
```

### Example Request
```json
{
"host": "192.168.1.1",
"cmd": "show version",
"host_params": {
"streamer_type": 1, // Use Telnet
"port": 23,
"credentials": {
"login": "admin",
"password": "password"
}
}
}
```

## Choosing Streamer Type

### SSH is recommended for:
- Modern network equipment
- Production environments where security is important
- Devices supporting cryptographic authentication
- Cases requiring file transfers

### Telnet is suitable for:
- Legacy equipment without SSH support
- Lab and test environments
- Devices with limited computational resources
- Connection debugging and diagnostics

## Default Configuration

If `streamer_type` is not explicitly specified, SSH is used as the more secure default option.
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ require (
go.uber.org/zap v1.26.0
golang.org/x/crypto v0.14.0
golang.org/x/exp v0.0.0-20230725093048-515e97ebf090
golang.org/x/net v0.16.0
golang.org/x/sync v0.4.0
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1
google.golang.org/genproto/googleapis/api v0.0.0-20231002182017-d307bd883b97
google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97
google.golang.org/grpc v1.58.2
Expand All @@ -30,6 +30,7 @@ require (
github.com/golang/protobuf v1.5.3 // indirect
github.com/kr/fs v0.1.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
golang.org/x/net v0.16.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97 // indirect
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
Expand Down
7 changes: 6 additions & 1 deletion grpc_sdk/python/gnetclisdk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from contextlib import asynccontextmanager
from dataclasses import dataclass, field
from functools import partial
from typing import Any, AsyncIterator, List, Optional, Tuple, Dict, Callable
from typing import Any, AsyncIterator, List, Optional, Tuple, Dict, Callable, Union

import grpc
from google.protobuf.message import Message
Expand All @@ -25,6 +25,9 @@
SERVER_ENV = "GNETCLI_SERVER"
GRPC_MAX_MESSAGE_LENGTH = 130 * 1024**2

STREAMER_SSH = server_pb2.StreamerType_ssh
STREAMER_TELNET = server_pb2.StreamerType_telnet

default_grpc_options: List[Tuple[str, Any]] = [
("grpc.max_concurrent_streams", 900),
("grpc.max_send_message_length", GRPC_MAX_MESSAGE_LENGTH),
Expand Down Expand Up @@ -72,6 +75,7 @@ class HostParams:
hostname: Optional[str] = None
credentials: Optional[Credentials] = None
ip: Optional[str] = None
streamer_type: Optional[int] = None

def make_pb(self) -> server_pb2.HostParams:
creds_pb: Optional[server_pb2.Credentials] = None
Expand All @@ -83,6 +87,7 @@ def make_pb(self) -> server_pb2.HostParams:
credentials=creds_pb,
device=self.device,
ip=self.ip,
streamer_type=self.streamer_type if self.streamer_type is not None else server_pb2.StreamerType_ssh,
)
return pbcmd

Expand Down
Loading
Loading