Skip to content

Commit

Permalink
Breaking out separate sock_telnet argument
Browse files Browse the repository at this point in the history
  • Loading branch information
ktbyers committed Nov 10, 2023
1 parent e88f450 commit 49c920b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions netmiko/base_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import re
import socket
import telnetlib
import telnet_proxy
import time
from collections import deque
from os import path
Expand Down Expand Up @@ -62,6 +61,7 @@
calc_old_timeout,
)
from netmiko.utilities import m_exec_time # noqa
from netmiko import telnet_proxy

if TYPE_CHECKING:
from os import PathLike
Expand Down Expand Up @@ -182,6 +182,7 @@ def __init__(
allow_auto_change: bool = False,
encoding: str = "utf-8",
sock: Optional[socket.socket] = None,
sock_telnet: Optional[Dict[str, Any]] = None,
auto_connect: bool = True,
delay_factor_compat: bool = False,
disable_lf_normalization: bool = False,
Expand Down Expand Up @@ -287,6 +288,9 @@ def __init__(
:param sock: An open socket or socket-like object (such as a `.Channel`) to use for
communication to the target host (default: None).
:param sock_telnet: A dictionary of telnet socket parameters (SOCKS proxy). See
telnet_proxy.py code for details.
:param global_cmd_verify: Control whether command echo verification is enabled or disabled
(default: None). Global attribute takes precedence over function `cmd_verify`
argument. Value of `None` indicates to use function `cmd_verify` argument.
Expand Down Expand Up @@ -353,6 +357,7 @@ def __init__(
self.allow_auto_change = allow_auto_change
self.encoding = encoding
self.sock = sock
self.sock_telnet = sock_telnet
self.fast_cli = fast_cli
self._legacy_mode = _legacy_mode
self.global_delay_factor = global_delay_factor
Expand Down Expand Up @@ -1089,12 +1094,12 @@ def establish_connection(self, width: int = 511, height: int = 1000) -> None:
"""
self.channel: Channel
if self.protocol == "telnet":
if self.sock:
if self.sock_telnet:
self.remote_conn = telnet_proxy.Telnet(
self.host,
port=self.port,
timeout=self.timeout,
proxy_dict=self.sock,
proxy_dict=self.sock_telnet,
)
else:
self.remote_conn = telnetlib.Telnet(
Expand Down

0 comments on commit 49c920b

Please sign in to comment.