| 1 | use bytesrust-analyzer cargo bytes 1.12.1 crate/::bufrust-analyzer cargo bytes 1.12.1 buf/::Bufrust-analyzer cargo bytes 1.12.1 buf/buf_impl/Buf#; |
| 2 | use bytesrust-analyzer cargo bytes 1.12.1 crate/::Bytesrust-analyzer cargo bytes 1.12.1 bytes/Bytes#; |
| 3 | |
| 4 | use craterust-analyzer cargo sqlx-mysql 0.8.3 crate/::collationrust-analyzer cargo sqlx-mysql 0.8.3 collation/::{CharSetrust-analyzer cargo sqlx-mysql 0.8.3 collation/CharSet#, Collationrust-analyzer cargo sqlx-mysql 0.8.3 collation/Collation#}; |
| 5 | use craterust-analyzer cargo sqlx-mysql 0.8.3 crate/::commonrust-analyzer cargo sqlx-core 0.8.3 common/::StatementCacherust-analyzer cargo sqlx-core 0.8.3 common/statement_cache/StatementCache#; |
| 6 | use craterust-analyzer cargo sqlx-mysql 0.8.3 crate/::connectionrust-analyzer cargo sqlx-mysql 0.8.3 connection/::{tlsrust-analyzer cargo sqlx-mysql 0.8.3 connection/tls/, MySqlConnectionInnerrust-analyzer cargo sqlx-mysql 0.8.3 connection/MySqlConnectionInner#, MySqlStreamrust-analyzer cargo sqlx-mysql 0.8.3 connection/stream/MySqlStream#, MAX_PACKET_SIZErust-analyzer cargo sqlx-mysql 0.8.3 connection/MAX_PACKET_SIZE.}; |
| 7 | use craterust-analyzer cargo sqlx-mysql 0.8.3 crate/::errorrust-analyzer cargo sqlx-mysql 0.8.3 error/::Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#; |
| 8 | use craterust-analyzer cargo sqlx-mysql 0.8.3 crate/::netrust-analyzer cargo sqlx-core 0.8.3 net/::{Socketrust-analyzer cargo sqlx-core 0.8.3 net/socket/Socket#, WithSocketrust-analyzer cargo sqlx-core 0.8.3 net/socket/WithSocket#}; |
| 9 | use craterust-analyzer cargo sqlx-mysql 0.8.3 crate/::protocolrust-analyzer cargo sqlx-mysql 0.8.3 protocol/::connectrust-analyzer cargo sqlx-mysql 0.8.3 protocol/connect/::{ |
| 10 | AuthSwitchRequestrust-analyzer cargo sqlx-mysql 0.8.3 protocol/connect/auth_switch/AuthSwitchRequest#, AuthSwitchResponserust-analyzer cargo sqlx-mysql 0.8.3 protocol/connect/auth_switch/AuthSwitchResponse#, Handshakerust-analyzer cargo sqlx-mysql 0.8.3 protocol/connect/handshake/Handshake#, HandshakeResponserust-analyzer cargo sqlx-mysql 0.8.3 protocol/connect/handshake_response/HandshakeResponse#, |
| 11 | }; |
| 12 | use craterust-analyzer cargo sqlx-mysql 0.8.3 crate/::protocolrust-analyzer cargo sqlx-mysql 0.8.3 protocol/::Capabilitiesrust-analyzer cargo sqlx-mysql 0.8.3 protocol/capabilities/Capabilities#; |
| 13 | use craterust-analyzer cargo sqlx-mysql 0.8.3 crate/::{MySqlConnectOptionsrust-analyzer cargo sqlx-mysql 0.8.3 options/MySqlConnectOptions#, MySqlConnectionrust-analyzer cargo sqlx-mysql 0.8.3 connection/MySqlConnection#, MySqlSslModerust-analyzer cargo sqlx-mysql 0.8.3 options/ssl_mode/MySqlSslMode#}; |
| 14 | |
| 15 | impl MySqlConnectionrust-analyzer cargo sqlx-mysql 0.8.3 connection/MySqlConnection# { |
| 16 | pub(craterust-analyzer cargo sqlx-mysql 0.8.3 crate/) async fn establishrust-analyzer cargo sqlx-mysql 0.8.3 connection/establish/impl#[MySqlConnection]establish().(options: &MySqlConnectOptionsrust-analyzer cargo sqlx-mysql 0.8.3 options/MySqlConnectOptions#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo sqlx-mysql 0.8.3 connection/establish/impl#[MySqlConnection], Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> { |
| 17 | let do_handshake = DoHandshakerust-analyzer cargo sqlx-mysql 0.8.3 connection/establish/DoHandshake#::newrust-analyzer cargo sqlx-mysql 0.8.3 connection/establish/impl#[`DoHandshake<'a>`]new().(options)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 18 | |
| 19 | let handshake = match &options.socketrust-analyzer cargo sqlx-mysql 0.8.3 options/MySqlConnectOptions#socket. { |
| 20 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(path) => craterust-analyzer cargo sqlx-mysql 0.8.3 crate/::netrust-analyzer cargo sqlx-core 0.8.3 net/::connect_udsrust-analyzer cargo sqlx-core 0.8.3 net/socket/connect_uds().(path, do_handshake).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 21 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => craterust-analyzer cargo sqlx-mysql 0.8.3 crate/::netrust-analyzer cargo sqlx-core 0.8.3 net/::connect_tcprust-analyzer cargo sqlx-core 0.8.3 net/socket/connect_tcp().(&options.hostrust-analyzer cargo sqlx-mysql 0.8.3 options/MySqlConnectOptions#host., options.portrust-analyzer cargo sqlx-mysql 0.8.3 options/MySqlConnectOptions#port., do_handshake).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 22 | }; |
| 23 | |
| 24 | let stream = handshake?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 25 | |
| 26 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo sqlx-mysql 0.8.3 connection/establish/impl#[MySqlConnection] { |
| 27 | innerrust-analyzer cargo sqlx-mysql 0.8.3 connection/MySqlConnection#inner.: Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(MySqlConnectionInnerrust-analyzer cargo sqlx-mysql 0.8.3 connection/MySqlConnectionInner# { |
| 28 | streamrust-analyzer cargo sqlx-mysql 0.8.3 connection/MySqlConnectionInner#stream., |
| 29 | transaction_depthrust-analyzer cargo sqlx-mysql 0.8.3 connection/MySqlConnectionInner#transaction_depth.: 0, |
| 30 | cache_statementrust-analyzer cargo sqlx-mysql 0.8.3 connection/MySqlConnectionInner#cache_statement.: StatementCacherust-analyzer cargo sqlx-core 0.8.3 common/statement_cache/StatementCache#::newrust-analyzer cargo sqlx-core 0.8.3 common/statement_cache/impl#[`StatementCache<T>`]new().(options.statement_cache_capacityrust-analyzer cargo sqlx-mysql 0.8.3 options/MySqlConnectOptions#statement_cache_capacity.), |
| 31 | log_settingsrust-analyzer cargo sqlx-mysql 0.8.3 connection/MySqlConnectionInner#log_settings.: options.log_settingsrust-analyzer cargo sqlx-mysql 0.8.3 options/MySqlConnectOptions#log_settings..clonerust-analyzer cargo sqlx-core 0.8.3 connection/impl#[LogSettings][Clone]clone().(), |
| 32 | }), |
| 33 | }) |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | struct DoHandshakerust-analyzer cargo sqlx-mysql 0.8.3 connection/establish/DoHandshake#<'a> { |
| 38 | optionsrust-analyzer cargo sqlx-mysql 0.8.3 connection/establish/DoHandshake#options.: &'a MySqlConnectOptionsrust-analyzer cargo sqlx-mysql 0.8.3 options/MySqlConnectOptions#, |
| 39 | charsetrust-analyzer cargo sqlx-mysql 0.8.3 connection/establish/DoHandshake#charset.: CharSetrust-analyzer cargo sqlx-mysql 0.8.3 collation/CharSet#, |
| 40 | collationrust-analyzer cargo sqlx-mysql 0.8.3 connection/establish/DoHandshake#collation.: Collationrust-analyzer cargo sqlx-mysql 0.8.3 collation/Collation#, |
| 41 | } |
| 42 | |
| 43 | impl<'a> DoHandshakerust-analyzer cargo sqlx-mysql 0.8.3 connection/establish/DoHandshake#<'a> { |
| 44 | fn newrust-analyzer cargo sqlx-mysql 0.8.3 connection/establish/impl#[`DoHandshake<'a>`]new().(options: &'a MySqlConnectOptionsrust-analyzer cargo sqlx-mysql 0.8.3 options/MySqlConnectOptions#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo sqlx-mysql 0.8.3 connection/establish/impl#[`DoHandshake<'a>`], Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> { |
| 45 | let charset: CharSetrust-analyzer cargo sqlx-mysql 0.8.3 collation/CharSet# = options.charsetrust-analyzer cargo sqlx-mysql 0.8.3 options/MySqlConnectOptions#charset..parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 46 | let collation: Collationrust-analyzer cargo sqlx-mysql 0.8.3 collation/Collation# = options |
| 47 | .collationrust-analyzer cargo sqlx-mysql 0.8.3 options/MySqlConnectOptions#collation. |
| 48 | .as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().() |
| 49 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|collation| collation.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().()) |
| 50 | .transposerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<Result<T, E>>`]transpose().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). |
| 51 | .unwrap_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_else().(|| charset.default_collationrust-analyzer cargo sqlx-mysql 0.8.3 collation/impl#[CharSet]default_collation().()); |
| 52 | |
| 53 | if options.enable_cleartext_pluginrust-analyzer cargo sqlx-mysql 0.8.3 options/MySqlConnectOptions#enable_cleartext_plugin. |
| 54 | && matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!( |
| 55 | options.ssl_moderust-analyzer cargo sqlx-mysql 0.8.3 options/MySqlConnectOptions#ssl_mode., |
| 56 | MySqlSslModerust-analyzer cargo sqlx-mysql 0.8.3 options/ssl_mode/MySqlSslMode#::Disabledrust-analyzer cargo sqlx-mysql 0.8.3 options/ssl_mode/MySqlSslMode#Disabled# | MySqlSslModerust-analyzer cargo sqlx-mysql 0.8.3 options/ssl_mode/MySqlSslMode#::Preferredrust-analyzer cargo sqlx-mysql 0.8.3 options/ssl_mode/MySqlSslMode#Preferred# |
| 57 | ) |
| 58 | { |
| 59 | logrust-analyzer cargo log 0.4.34 crate/::warnrust-analyzer cargo log 0.4.34 macros/warn!!("Security warning: sending cleartext passwords without requiring SSL"); |
| 60 | } |
| 61 | |
| 62 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo sqlx-mysql 0.8.3 connection/establish/impl#[`DoHandshake<'a>`] { |
| 63 | optionsrust-analyzer cargo sqlx-mysql 0.8.3 connection/establish/DoHandshake#options., |
| 64 | charsetrust-analyzer cargo sqlx-mysql 0.8.3 connection/establish/DoHandshake#charset., |
| 65 | collationrust-analyzer cargo sqlx-mysql 0.8.3 connection/establish/DoHandshake#collation., |
| 66 | }) |
| 67 | } |
| 68 | |
| 69 | async fn do_handshakerust-analyzer cargo sqlx-mysql 0.8.3 connection/establish/impl#[`DoHandshake<'a>`]do_handshake().<S: Socketrust-analyzer cargo sqlx-core 0.8.3 net/socket/Socket#>(self, socket: S) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<MySqlStreamrust-analyzer cargo sqlx-mysql 0.8.3 connection/stream/MySqlStream#, Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> { |
| 70 | let DoHandshakerust-analyzer cargo sqlx-mysql 0.8.3 connection/establish/DoHandshake# { |
| 71 | optionsrust-analyzer cargo sqlx-mysql 0.8.3 connection/establish/DoHandshake#options., |
| 72 | charsetrust-analyzer cargo sqlx-mysql 0.8.3 connection/establish/DoHandshake#charset., |
| 73 | collationrust-analyzer cargo sqlx-mysql 0.8.3 connection/establish/DoHandshake#collation., |
| 74 | } = self; |
| 75 | |
| 76 | let mut stream = MySqlStreamrust-analyzer cargo sqlx-mysql 0.8.3 connection/stream/MySqlStream#::with_socketrust-analyzer cargo sqlx-mysql 0.8.3 connection/stream/impl#[`MySqlStream<S>`]with_socket().(charset, collation, options, socket); |
| 77 | |
| 78 | // https://dev.mysql.com/doc/internals/en/connection-phase.html |
| 79 | // https://mariadb.com/kb/en/connection/ |
| 80 | |
| 81 | let handshake: Handshakerust-analyzer cargo sqlx-mysql 0.8.3 protocol/connect/handshake/Handshake# = stream.recv_packetrust-analyzer cargo sqlx-mysql 0.8.3 connection/stream/impl#[`MySqlStream<S>`]recv_packet().().rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..decoderust-analyzer cargo sqlx-mysql 0.8.3 protocol/packet/impl#[`Packet<Bytes>`]decode().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 82 | |
| 83 | let mut plugin = handshake.auth_pluginrust-analyzer cargo sqlx-mysql 0.8.3 protocol/connect/handshake/Handshake#auth_plugin.; |
| 84 | let nonce = handshake.auth_plugin_datarust-analyzer cargo sqlx-mysql 0.8.3 protocol/connect/handshake/Handshake#auth_plugin_data.; |
| 85 | |
| 86 | // FIXME: server version parse is a bit ugly |
| 87 | // expecting MAJOR.MINOR.PATCH |
| 88 | |
| 89 | let mut server_version = handshake.server_versionrust-analyzer cargo sqlx-mysql 0.8.3 protocol/connect/handshake/Handshake#server_version..splitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split().('.'); |
| 90 | |
| 91 | let server_version_major: u16 = server_version |
| 92 | .nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/iter/impl#[`Split<'a, P>`][Iterator]next().() |
| 93 | .unwrap_or_defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_default().() |
| 94 | .parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().() |
| 95 | .unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_or().(0); |
| 96 | |
| 97 | let server_version_minor: u16 = server_version |
| 98 | .nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/iter/impl#[`Split<'a, P>`][Iterator]next().() |
| 99 | .unwrap_or_defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_default().() |
| 100 | .parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().() |
| 101 | .unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_or().(0); |
| 102 | |
| 103 | let server_version_patch: u16 = server_version |
| 104 | .nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/iter/impl#[`Split<'a, P>`][Iterator]next().() |
| 105 | .unwrap_or_defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_default().() |
| 106 | .parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().() |
| 107 | .unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_or().(0); |
| 108 | |
| 109 | stream.server_versionrust-analyzer cargo sqlx-mysql 0.8.3 connection/stream/MySqlStream#server_version. = ( |
| 110 | server_version_major, |
| 111 | server_version_minor, |
| 112 | server_version_patch, |
| 113 | ); |
| 114 | |
| 115 | stream.capabilitiesrust-analyzer cargo sqlx-mysql 0.8.3 connection/stream/MySqlStream#capabilities. rust-analyzer cargo sqlx-mysql 0.8.3 protocol/capabilities/impl#[Capabilities][`BitAndAssign<Self>`]bitand_assign().&=rust-analyzer cargo sqlx-mysql 0.8.3 protocol/capabilities/impl#[Capabilities][`BitAndAssign<Self>`]bitand_assign(). rust-analyzer cargo sqlx-mysql 0.8.3 protocol/capabilities/impl#[Capabilities][`BitAndAssign<Self>`]bitand_assign().handshake.server_capabilitiesrust-analyzer cargo sqlx-mysql 0.8.3 protocol/connect/handshake/Handshake#server_capabilities.; |
| 116 | stream.capabilitiesrust-analyzer cargo sqlx-mysql 0.8.3 connection/stream/MySqlStream#capabilities. rust-analyzer cargo sqlx-mysql 0.8.3 protocol/capabilities/impl#[Capabilities][`BitOrAssign<Self>`]bitor_assign().|=rust-analyzer cargo sqlx-mysql 0.8.3 protocol/capabilities/impl#[Capabilities][`BitOrAssign<Self>`]bitor_assign(). rust-analyzer cargo sqlx-mysql 0.8.3 protocol/capabilities/impl#[Capabilities][`BitOrAssign<Self>`]bitor_assign().Capabilitiesrust-analyzer cargo sqlx-mysql 0.8.3 protocol/capabilities/Capabilities#::PROTOCOL_41rust-analyzer cargo sqlx-mysql 0.8.3 protocol/capabilities/impl#[Capabilities]PROTOCOL_41.; |
| 117 | |
| 118 | let mut stream = tlsrust-analyzer cargo sqlx-mysql 0.8.3 connection/tls/::maybe_upgraderust-analyzer cargo sqlx-mysql 0.8.3 connection/tls/maybe_upgrade().(stream, self.optionsrust-analyzer cargo sqlx-mysql 0.8.3 connection/establish/DoHandshake#options.).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 119 | |
| 120 | let auth_response = if let (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(plugin), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(password)) = (plugin, &options.passwordrust-analyzer cargo sqlx-mysql 0.8.3 options/MySqlConnectOptions#password.) { |
| 121 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(plugin.scramblerust-analyzer cargo sqlx-mysql 0.8.3 connection/auth/impl#[AuthPlugin]scramble().(&mut stream, password, &nonce).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().) |
| 122 | } else { |
| 123 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 124 | }; |
| 125 | |
| 126 | stream.write_packetrust-analyzer cargo sqlx-mysql 0.8.3 connection/stream/impl#[`MySqlStream<S>`]write_packet().(HandshakeResponserust-analyzer cargo sqlx-mysql 0.8.3 protocol/connect/handshake_response/HandshakeResponse# { |
| 127 | collationrust-analyzer cargo sqlx-mysql 0.8.3 protocol/connect/handshake_response/HandshakeResponse#collation.: stream.collationrust-analyzer cargo sqlx-mysql 0.8.3 connection/stream/MySqlStream#collation. as u8, |
| 128 | max_packet_sizerust-analyzer cargo sqlx-mysql 0.8.3 protocol/connect/handshake_response/HandshakeResponse#max_packet_size.: MAX_PACKET_SIZErust-analyzer cargo sqlx-mysql 0.8.3 connection/MAX_PACKET_SIZE., |
| 129 | usernamerust-analyzer cargo sqlx-mysql 0.8.3 protocol/connect/handshake_response/HandshakeResponse#username.: &options.usernamerust-analyzer cargo sqlx-mysql 0.8.3 options/MySqlConnectOptions#username., |
| 130 | databaserust-analyzer cargo sqlx-mysql 0.8.3 protocol/connect/handshake_response/HandshakeResponse#database.: options.databaserust-analyzer cargo sqlx-mysql 0.8.3 options/MySqlConnectOptions#database..as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), |
| 131 | auth_pluginrust-analyzer cargo sqlx-mysql 0.8.3 protocol/connect/handshake_response/HandshakeResponse#auth_plugin.: plugin, |
| 132 | auth_responserust-analyzer cargo sqlx-mysql 0.8.3 protocol/connect/handshake_response/HandshakeResponse#auth_response.: auth_response.as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), |
| 133 | })?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 134 | |
| 135 | stream.flushrust-analyzer cargo sqlx-core 0.8.3 net/socket/buffered/impl#[`BufferedSocket<S>`]flush().().rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 136 | |
| 137 | loop { |
| 138 | let packet = stream.recv_packetrust-analyzer cargo sqlx-mysql 0.8.3 connection/stream/impl#[`MySqlStream<S>`]recv_packet().().rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 139 | match packet[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). { |
| 140 | 0x00 => { |
| 141 | let _ok = packet.okrust-analyzer cargo sqlx-mysql 0.8.3 protocol/packet/impl#[`Packet<Bytes>`]ok().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 142 | |
| 143 | break; |
| 144 | } |
| 145 | |
| 146 | 0xfe => { |
| 147 | let switch: AuthSwitchRequestrust-analyzer cargo sqlx-mysql 0.8.3 protocol/connect/auth_switch/AuthSwitchRequest# = |
| 148 | packet.decode_withrust-analyzer cargo sqlx-mysql 0.8.3 protocol/packet/impl#[`Packet<Bytes>`]decode_with().(self.optionsrust-analyzer cargo sqlx-mysql 0.8.3 connection/establish/DoHandshake#options..enable_cleartext_pluginrust-analyzer cargo sqlx-mysql 0.8.3 options/MySqlConnectOptions#enable_cleartext_plugin.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 149 | |
| 150 | plugin = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(switch.pluginrust-analyzer cargo sqlx-mysql 0.8.3 protocol/connect/auth_switch/AuthSwitchRequest#plugin.); |
| 151 | let nonce = switch.datarust-analyzer cargo sqlx-mysql 0.8.3 protocol/connect/auth_switch/AuthSwitchRequest#data..chainrust-analyzer cargo bytes 1.12.1 buf/buf_impl/Buf#chain().(Bytesrust-analyzer cargo bytes 1.12.1 bytes/Bytes#::newrust-analyzer cargo bytes 1.12.1 bytes/impl#[Bytes]new().()); |
| 152 | |
| 153 | let response = switch |
| 154 | .pluginrust-analyzer cargo sqlx-mysql 0.8.3 protocol/connect/auth_switch/AuthSwitchRequest#plugin. |
| 155 | .scramblerust-analyzer cargo sqlx-mysql 0.8.3 connection/auth/impl#[AuthPlugin]scramble().( |
| 156 | &mut stream, |
| 157 | options.passwordrust-analyzer cargo sqlx-mysql 0.8.3 options/MySqlConnectOptions#password..as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().().unwrap_or_defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_default().(), |
| 158 | &nonce, |
| 159 | ) |
| 160 | .rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 161 | |
| 162 | stream.write_packetrust-analyzer cargo sqlx-mysql 0.8.3 connection/stream/impl#[`MySqlStream<S>`]write_packet().(AuthSwitchResponserust-analyzer cargo sqlx-mysql 0.8.3 protocol/connect/auth_switch/AuthSwitchResponse#(response))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 163 | stream.flushrust-analyzer cargo sqlx-core 0.8.3 net/socket/buffered/impl#[`BufferedSocket<S>`]flush().().rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 164 | } |
| 165 | |
| 166 | id => { |
| 167 | if let (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(plugin), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(password)) = (plugin, &options.passwordrust-analyzer cargo sqlx-mysql 0.8.3 options/MySqlConnectOptions#password.) { |
| 168 | if plugin.handlerust-analyzer cargo sqlx-mysql 0.8.3 connection/auth/impl#[AuthPlugin]handle().(&mut stream, packet, password, &nonce).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). { |
| 169 | // plugin signaled authentication is ok |
| 170 | break; |
| 171 | } |
| 172 | |
| 173 | // plugin signaled to continue authentication |
| 174 | } else { |
| 175 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(err_protocolrust-analyzer cargo sqlx-core 0.8.3 error/err_protocol!!( |
| 176 | "unexpected packet 0x{:02x} during authentication", |
| 177 | id |
| 178 | )); |
| 179 | } |
| 180 | } |
| 181 | } |
| 182 | } |
| 183 | |
| 184 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(stream) |
| 185 | } |
| 186 | } |
| 187 | |
| 188 | impl<'a> WithSocketrust-analyzer cargo sqlx-core 0.8.3 net/socket/WithSocket# for DoHandshakerust-analyzer cargo sqlx-mysql 0.8.3 connection/establish/DoHandshake#<'a> { |
| 189 | type Outputrust-analyzer cargo sqlx-mysql 0.8.3 connection/establish/impl#[`DoHandshake<'a>`][WithSocket]Output# = Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<MySqlStreamrust-analyzer cargo sqlx-mysql 0.8.3 connection/stream/MySqlStream#, Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#>; |
| 190 | |
| 191 | async fn with_socketrust-analyzer cargo sqlx-mysql 0.8.3 connection/establish/impl#[`DoHandshake<'a>`][WithSocket]with_socket().<S: Socketrust-analyzer cargo sqlx-core 0.8.3 net/socket/Socket#>(self, socket: S) -> Selfrust-analyzer cargo sqlx-mysql 0.8.3 connection/establish/impl#[`DoHandshake<'a>`][WithSocket]::Outputrust-analyzer cargo sqlx-core 0.8.3 net/socket/WithSocket#Output# { |
| 192 | self.do_handshakerust-analyzer cargo sqlx-mysql 0.8.3 connection/establish/impl#[`DoHandshake<'a>`]do_handshake().(socket).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll(). |
| 193 | } |
| 194 | } |