@@ -22,6 +22,11 @@ pub enum ClientType {
2222 #[ allow( missing_docs) ]
2323 TCP ( RawClient < ElectrumPlaintextStream > ) ,
2424 #[ allow( missing_docs) ]
25+ #[ cfg( any(
26+ feature = "use-rustls" ,
27+ feature = "use-rustls-ring" ,
28+ feature = "use-openssl" ,
29+ ) ) ]
2530 SSL ( RawClient < ElectrumSslStream > ) ,
2631 #[ allow( missing_docs) ]
2732 #[ cfg( feature = "proxy" ) ]
@@ -44,6 +49,11 @@ macro_rules! impl_inner_call {
4449 let read_client = $self. client_type. read( ) . unwrap( ) ;
4550 let res = match & * read_client {
4651 ClientType :: TCP ( inner) => inner. $name( $( $args, ) * ) ,
52+ #[ cfg( any(
53+ feature = "use-rustls" ,
54+ feature = "use-rustls-ring" ,
55+ feature = "use-openssl" ,
56+ ) ) ]
4757 ClientType :: SSL ( inner) => inner. $name( $( $args, ) * ) ,
4858 #[ cfg( feature = "proxy" ) ]
4959 ClientType :: Socks5 ( inner) => inner. $name( $( $args, ) * ) ,
@@ -110,8 +120,19 @@ impl ClientType {
110120 /// Constructor that supports multiple backends and allows configuration through
111121 /// the [Config]
112122 pub fn from_config ( url : & str , config : & Config ) -> Result < Self , Error > {
113- if url. starts_with ( "ssl://" ) {
123+ // TLS.
124+ #[ cfg( any(
125+ feature = "use-rustls" ,
126+ feature = "use-rustls-ring" ,
127+ feature = "use-openssl" ,
128+ ) ) ]
129+ let client = {
114130 let url = url. replacen ( "ssl://" , "" , 1 ) ;
131+
132+ #[ cfg( not( feature = "proxy" ) ) ]
133+ let client =
134+ RawClient :: new_ssl ( url. as_str ( ) , config. validate_domain ( ) , config. timeout ( ) ) ?;
135+
115136 #[ cfg( feature = "proxy" ) ]
116137 let client = match config. socks5 ( ) {
117138 Some ( socks5) => RawClient :: new_proxy_ssl (
@@ -124,12 +145,16 @@ impl ClientType {
124145 RawClient :: new_ssl ( url. as_str ( ) , config. validate_domain ( ) , config. timeout ( ) ) ?
125146 }
126147 } ;
127- #[ cfg( not( feature = "proxy" ) ) ]
128- let client =
129- RawClient :: new_ssl ( url. as_str ( ) , config. validate_domain ( ) , config. timeout ( ) ) ?;
130148
131- Ok ( ClientType :: SSL ( client) )
132- } else {
149+ ClientType :: SSL ( client)
150+ } ;
151+ // Plain TCP.
152+ #[ cfg( not( any(
153+ feature = "use-rustls" ,
154+ feature = "use-rustls-ring" ,
155+ feature = "use-openssl" ,
156+ ) ) ) ]
157+ let client = {
133158 let url = url. replacen ( "tcp://" , "" , 1 ) ;
134159
135160 #[ cfg( feature = "proxy" ) ]
@@ -145,8 +170,10 @@ impl ClientType {
145170 #[ cfg( not( feature = "proxy" ) ) ]
146171 let client = ClientType :: TCP ( RawClient :: new ( url. as_str ( ) , config. timeout ( ) ) ?) ;
147172
148- Ok ( client)
149- }
173+ client
174+ } ;
175+
176+ Ok ( client)
150177 }
151178}
152179
0 commit comments