|
31 | 31 |
|
32 | 32 | if TYPE_CHECKING:
|
33 | 33 | # pylint: disable=cyclic-import
|
34 |
| - from .connection import SSHServerConnection, SSHAcceptHandler |
| 34 | + from .connection import SSHClientConnection, SSHServerConnection |
| 35 | + from .connection import SSHAcceptHandler |
35 | 36 | from .channel import SSHServerChannel, SSHTCPChannel, SSHUNIXChannel
|
36 | 37 | from .channel import SSHTunTapChannel
|
37 | 38 | from .session import SSHServerSession, SSHTCPSession, SSHUNIXSession
|
38 | 39 | from .session import SSHTunTapSession
|
39 | 40 |
|
40 | 41 |
|
41 |
| -_NewSession = \ |
42 |
| - Union[bool, MaybeAwait['SSHServerSession'], SSHServerSessionFactory, |
| 42 | +_NewSession = Union[ |
| 43 | + bool, 'SSHClientConnection', |
| 44 | + MaybeAwait['SSHServerSession'], SSHServerSessionFactory, |
43 | 45 | Tuple['SSHServerChannel', MaybeAwait['SSHServerSession']],
|
44 | 46 | Tuple['SSHServerChannel', SSHServerSessionFactory]]
|
45 |
| -_NewTCPSession = \ |
46 |
| - Union[bool, MaybeAwait['SSHTCPSession'], SSHSocketSessionFactory, |
| 47 | +_NewTCPSession = Union[ |
| 48 | + bool, 'SSHClientConnection', |
| 49 | + MaybeAwait['SSHTCPSession'], SSHSocketSessionFactory, |
47 | 50 | Tuple['SSHTCPChannel', MaybeAwait['SSHTCPSession']],
|
48 | 51 | Tuple['SSHTCPChannel', SSHSocketSessionFactory]]
|
49 |
| -_NewUNIXSession = \ |
50 |
| - Union[bool, MaybeAwait['SSHUNIXSession'], SSHSocketSessionFactory, |
| 52 | +_NewUNIXSession = Union[ |
| 53 | + bool, 'SSHClientConnection', |
| 54 | + MaybeAwait['SSHUNIXSession'], SSHSocketSessionFactory, |
51 | 55 | Tuple['SSHUNIXChannel', MaybeAwait['SSHUNIXSession']],
|
52 | 56 | Tuple['SSHUNIXChannel', SSHSocketSessionFactory]]
|
53 |
| -_NewTunTapSession = \ |
54 |
| - Union[bool, MaybeAwait['SSHTunTapSession'], SSHSocketSessionFactory, |
| 57 | +_NewTunTapSession = Union[ |
| 58 | + bool, 'SSHClientConnection', |
| 59 | + MaybeAwait['SSHTunTapSession'], SSHSocketSessionFactory, |
55 | 60 | Tuple['SSHTunTapChannel', MaybeAwait['SSHTunTapSession']],
|
56 | 61 | Tuple['SSHTunTapChannel', SSHSocketSessionFactory]]
|
57 |
| -_NewListener = Union[bool, 'SSHAcceptHandler', MaybeAwait[SSHListener]] |
| 62 | +_NewTCPListener = Union[bool, 'SSHAcceptHandler', MaybeAwait[SSHListener]] |
| 63 | +_NewUNIXListener = Union[bool, MaybeAwait[SSHListener]] |
58 | 64 |
|
59 | 65 |
|
60 | 66 | class SSHServer:
|
@@ -749,6 +755,11 @@ def connection_requested(self, dest_host: str, dest_port: int,
|
749 | 755 | :exc:`ChannelOpenError` exception with the reason for
|
750 | 756 | the failure.
|
751 | 757 |
|
| 758 | + If the application wishes to tunnel the connection over |
| 759 | + another SSH connection, this method should return an |
| 760 | + :class:`SSHClientConnection` connected to the desired |
| 761 | + tunnel host. |
| 762 | +
|
752 | 763 | If the application wishes to process the data on the
|
753 | 764 | connection itself, this method should return either an
|
754 | 765 | :class:`SSHTCPSession` object which can be used to process the
|
@@ -802,7 +813,7 @@ def connection_requested(self, dest_host: str, dest_port: int,
|
802 | 813 | return False # pragma: no cover
|
803 | 814 |
|
804 | 815 | def server_requested(self, listen_host: str,
|
805 |
| - listen_port: int) -> MaybeAwait[_NewListener]: |
| 816 | + listen_port: int) -> MaybeAwait[_NewTCPListener]: |
806 | 817 | """Handle a request to listen on a TCP/IP address and port
|
807 | 818 |
|
808 | 819 | This method is called when a client makes a request to
|
@@ -864,6 +875,11 @@ def unix_connection_requested(self, dest_path: str) -> _NewUNIXSession:
|
864 | 875 | :exc:`ChannelOpenError` exception with the reason for
|
865 | 876 | the failure.
|
866 | 877 |
|
| 878 | + If the application wishes to tunnel the connection over |
| 879 | + another SSH connection, this method should return an |
| 880 | + :class:`SSHClientConnection` connected to the desired |
| 881 | + tunnel host. |
| 882 | +
|
867 | 883 | If the application wishes to process the data on the
|
868 | 884 | connection itself, this method should return either an
|
869 | 885 | :class:`SSHUNIXSession` object which can be used to process the
|
@@ -908,7 +924,7 @@ def unix_connection_requested(self, dest_path: str) -> _NewUNIXSession:
|
908 | 924 | return False # pragma: no cover
|
909 | 925 |
|
910 | 926 | def unix_server_requested(self, listen_path: str) -> \
|
911 |
| - MaybeAwait[_NewListener]: |
| 927 | + MaybeAwait[_NewUNIXListener]: |
912 | 928 | """Handle a request to listen on a UNIX domain socket
|
913 | 929 |
|
914 | 930 | This method is called when a client makes a request to
|
@@ -958,14 +974,19 @@ def tun_requested(self, unit: Optional[int]) -> _NewTunTapSession:
|
958 | 974 | by the server. Applications wishing to accept such tunnels must
|
959 | 975 | override this method.
|
960 | 976 |
|
961 |
| - To allow standard path forwarding of data on the connection to the |
| 977 | + To allow standard forwarding of data on the connection to the |
962 | 978 | requested TUN device, this method should return `True`.
|
963 | 979 |
|
964 | 980 | To reject this request, this method should return `False`
|
965 | 981 | to send back a "Connection refused" response or raise an
|
966 | 982 | :exc:`ChannelOpenError` exception with the reason for
|
967 | 983 | the failure.
|
968 | 984 |
|
| 985 | + If the application wishes to tunnel the data over another |
| 986 | + SSH connection, this method should return an |
| 987 | + :class:`SSHClientConnection` connected to the desired |
| 988 | + tunnel host. |
| 989 | +
|
969 | 990 | If the application wishes to process the data on the
|
970 | 991 | connection itself, this method should return either an
|
971 | 992 | :class:`SSHTunTapSession` object which can be used to process the
|
@@ -1016,14 +1037,19 @@ def tap_requested(self, unit: Optional[int]) -> _NewTunTapSession:
|
1016 | 1037 | by the server. Applications wishing to accept such tunnels must
|
1017 | 1038 | override this method.
|
1018 | 1039 |
|
1019 |
| - To allow standard path forwarding of data on the connection to the |
1020 |
| - requested TUN device, this method should return `True`. |
| 1040 | + To allow standard forwarding of data on the connection to the |
| 1041 | + requested TAP device, this method should return `True`. |
1021 | 1042 |
|
1022 | 1043 | To reject this request, this method should return `False`
|
1023 | 1044 | to send back a "Connection refused" response or raise an
|
1024 | 1045 | :exc:`ChannelOpenError` exception with the reason for
|
1025 | 1046 | the failure.
|
1026 | 1047 |
|
| 1048 | + If the application wishes to tunnel the data over another |
| 1049 | + SSH connection, this method should return an |
| 1050 | + :class:`SSHClientConnection` connected to the desired |
| 1051 | + tunnel host. |
| 1052 | +
|
1027 | 1053 | If the application wishes to process the data on the
|
1028 | 1054 | connection itself, this method should return either an
|
1029 | 1055 | :class:`SSHTunTapSession` object which can be used to process the
|
|
0 commit comments