@@ -9,10 +9,13 @@ defmodule SSHKit.Channel do
99 * `id` - the unique channel id
1010 """
1111
12- defstruct [ :connection , :type , :id , impl: :ssh_connection ]
12+ defstruct [ :connection , :type , :id ]
1313
1414 @ type t ( ) :: % __MODULE__ { }
1515
16+ # credo:disable-for-next-line
17+ @ core Application . get_env ( :sshkit , :ssh_connection , :ssh_connection )
18+
1619 @ doc """
1720 Opens a channel on an SSH connection.
1821
@@ -31,15 +34,14 @@ defmodule SSHKit.Channel do
3134 timeout = Keyword . get ( options , :timeout , :infinity )
3235 ini_window_size = Keyword . get ( options , :initial_window_size , 128 * 1024 )
3336 max_packet_size = Keyword . get ( options , :max_packet_size , 32 * 1024 )
34- impl = Keyword . get ( options , :impl , :ssh_connection )
3537
36- with { :ok , id } <- impl . session_channel ( conn . ref , ini_window_size , max_packet_size , timeout ) do
37- { :ok , new ( conn , id , impl ) }
38+ with { :ok , id } <- @ core . session_channel ( conn . ref , ini_window_size , max_packet_size , timeout ) do
39+ { :ok , new ( conn , id ) }
3840 end
3941 end
4042
41- defp new ( conn , id , impl ) do
42- % __MODULE__ { connection: conn , type: :session , id: id , impl: impl }
43+ defp new ( conn , id ) do
44+ % __MODULE__ { connection: conn , type: :session , id: id }
4345 end
4446
4547 @ doc """
@@ -53,7 +55,7 @@ defmodule SSHKit.Channel do
5355 :success | :failure | { :error , reason :: String . t ( ) }
5456 def subsystem ( channel , subsystem , options \\ [ ] ) do
5557 timeout = Keyword . get ( options , :timeout , :infinity )
56- channel . impl . subsystem ( channel . connection . ref , channel . id , to_charlist ( subsystem ) , timeout )
58+ @ core . subsystem ( channel . connection . ref , channel . id , to_charlist ( subsystem ) , timeout )
5759 end
5860
5961 @ doc """
@@ -64,7 +66,7 @@ defmodule SSHKit.Channel do
6466 For more details, see [`:ssh_connection.close/2`](http://erlang.org/doc/man/ssh_connection.html#close-2).
6567 """
6668 def close ( channel ) do
67- channel . impl . close ( channel . connection . ref , channel . id )
69+ @ core . close ( channel . connection . ref , channel . id )
6870 end
6971
7072 @ doc """
@@ -86,7 +88,7 @@ defmodule SSHKit.Channel do
8688 end
8789
8890 def exec ( channel , command , timeout ) do
89- channel . impl . exec ( channel . connection . ref , channel . id , command , timeout )
91+ @ core . exec ( channel . connection . ref , channel . id , command , timeout )
9092 end
9193
9294 @ doc """
@@ -97,7 +99,7 @@ defmodule SSHKit.Channel do
9799 For more details, see [`:ssh_connection.ptty_alloc/4`](http://erlang.org/doc/man/ssh_connection.html#ptty_alloc-4).
98100 """
99101 def ptty ( channel , options \\ [ ] , timeout \\ :infinity ) do
100- channel . impl . ptty_alloc ( channel . connection . ref , channel . id , options , timeout )
102+ @ core . ptty_alloc ( channel . connection . ref , channel . id , options , timeout )
101103 end
102104
103105 @ doc """
@@ -112,7 +114,7 @@ defmodule SSHKit.Channel do
112114 def send ( channel , type \\ 0 , data , timeout \\ :infinity )
113115
114116 def send ( channel , type , data , timeout ) when is_binary ( data ) or is_list ( data ) do
115- channel . impl . send ( channel . connection . ref , channel . id , type , data , timeout )
117+ @ core . send ( channel . connection . ref , channel . id , type , data , timeout )
116118 end
117119
118120 def send ( channel , type , data , timeout ) do
@@ -130,7 +132,7 @@ defmodule SSHKit.Channel do
130132 For more details, see [`:ssh_connection.send_eof/2`](http://erlang.org/doc/man/ssh_connection.html#send_eof-2).
131133 """
132134 def eof ( channel ) do
133- channel . impl . send_eof ( channel . connection . ref , channel . id )
135+ @ core . send_eof ( channel . connection . ref , channel . id )
134136 end
135137
136138 @ doc """
@@ -190,6 +192,6 @@ defmodule SSHKit.Channel do
190192 For more details, see [`:ssh_connection.adjust_window/3`](http://erlang.org/doc/man/ssh_connection.html#adjust_window-3).
191193 """
192194 def adjust ( channel , size ) when is_integer ( size ) do
193- channel . impl . adjust_window ( channel . connection . ref , channel . id , size )
195+ @ core . adjust_window ( channel . connection . ref , channel . id , size )
194196 end
195197end
0 commit comments