diff --git a/packages/moxxmpp/lib/src/connection.dart b/packages/moxxmpp/lib/src/connection.dart index cc4654e..1c5d9af 100644 --- a/packages/moxxmpp/lib/src/connection.dart +++ b/packages/moxxmpp/lib/src/connection.dart @@ -152,7 +152,7 @@ class XmppConnection { /// True if we are authenticated. False if not. bool _isAuthenticated = false; - /// Timer for the connecting timeout + /// Timer for the connecting timeout. Timer? _connectingTimeoutTimer; /// Completers for certain actions @@ -467,10 +467,10 @@ class XmppConnection { } /// Sends an [XMLNode] without any further processing to the server. - void sendRawXML(XMLNode node, {String? redact}) { + void sendRawXML(XMLNode node) { final string = node.toXml(); _log.finest('==> $string'); - _socket.write(string, redact: redact); + _socket.write(string); } /// Sends [raw] to the server. diff --git a/packages/moxxmpp/lib/src/negotiators/negotiator.dart b/packages/moxxmpp/lib/src/negotiators/negotiator.dart index 98c0d4f..600e872 100644 --- a/packages/moxxmpp/lib/src/negotiators/negotiator.dart +++ b/packages/moxxmpp/lib/src/negotiators/negotiator.dart @@ -43,7 +43,7 @@ class NegotiatorAttributes { ); /// Sends the nonza nonza and optionally redacts it in logs if redact is not null. - final void Function(XMLNode nonza, {String? redact}) sendNonza; + final void Function(XMLNode nonza) sendNonza; /// Returns the connection settings. final ConnectionSettings Function() getConnectionSettings; diff --git a/packages/moxxmpp/lib/src/negotiators/sasl/plain.dart b/packages/moxxmpp/lib/src/negotiators/sasl/plain.dart index 7f3acb9..b601f75 100644 --- a/packages/moxxmpp/lib/src/negotiators/sasl/plain.dart +++ b/packages/moxxmpp/lib/src/negotiators/sasl/plain.dart @@ -50,7 +50,6 @@ class SaslPlainNegotiator extends Sasl2AuthenticationNegotiator { final data = await getRawStep(''); attributes.sendNonza( SaslPlainAuthNonza(data), - redact: SaslPlainAuthNonza('******').toXml(), ); _authSent = true; return const Result(NegotiatorState.ready); diff --git a/packages/moxxmpp/lib/src/negotiators/sasl/scram.dart b/packages/moxxmpp/lib/src/negotiators/sasl/scram.dart index 61ad667..666f95b 100644 --- a/packages/moxxmpp/lib/src/negotiators/sasl/scram.dart +++ b/packages/moxxmpp/lib/src/negotiators/sasl/scram.dart @@ -259,7 +259,6 @@ class SaslScramNegotiator extends Sasl2AuthenticationNegotiator { body: await getRawStep(''), type: hashType, ), - redact: SaslScramAuthNonza(body: '******', type: hashType).toXml(), ); return const Result(NegotiatorState.ready); case ScramState.initialMessageSent: @@ -275,7 +274,6 @@ class SaslScramNegotiator extends Sasl2AuthenticationNegotiator { attributes.sendNonza( SaslScramResponseNonza(body: await getRawStep(nonza.innerText())), - redact: SaslScramResponseNonza(body: '******').toXml(), ); return const Result(NegotiatorState.ready); case ScramState.challengeResponseSent: diff --git a/packages/moxxmpp/lib/src/negotiators/sasl2.dart b/packages/moxxmpp/lib/src/negotiators/sasl2.dart index f260037..bbf481d 100644 --- a/packages/moxxmpp/lib/src/negotiators/sasl2.dart +++ b/packages/moxxmpp/lib/src/negotiators/sasl2.dart @@ -232,11 +232,11 @@ class Sasl2Negotiator extends XmppFeatureNegotiatorBase { 'mechanism': _currentSaslNegotiator!.mechanismName, }, children: [ - if (userAgent != null) userAgent!.toXml(), XMLNode( tag: 'initial-response', text: await _currentSaslNegotiator!.getRawStep(''), ), + if (userAgent != null) userAgent!.toXml(), ...children, ], ); diff --git a/packages/moxxmpp/lib/src/socket.dart b/packages/moxxmpp/lib/src/socket.dart index 4999087..d98b523 100644 --- a/packages/moxxmpp/lib/src/socket.dart +++ b/packages/moxxmpp/lib/src/socket.dart @@ -30,9 +30,8 @@ abstract class BaseSocketWrapper { /// reused by calling [this.connect] again. void close(); - /// Write [data] into the socket. If [redact] is not null, then [redact] will be - /// logged instead of [data]. - void write(String data, {String? redact}); + /// Write [data] into the socket. + void write(String data); /// This must connect to [host]:[port] and initialize the streams accordingly. /// [domain] is the domain that TLS should be validated against, in case the Socket diff --git a/packages/moxxmpp_socket_tcp/integration_test/badxmpp_certificate_test.dart b/packages/moxxmpp_socket_tcp/integration_test/badxmpp_certificate_test.dart index b93d554..6a7f8d9 100644 --- a/packages/moxxmpp_socket_tcp/integration_test/badxmpp_certificate_test.dart +++ b/packages/moxxmpp_socket_tcp/integration_test/badxmpp_certificate_test.dart @@ -18,9 +18,10 @@ Future _runTest(String domain) async { TestingReconnectionPolicy(), AlwaysConnectedConnectivityManager(), socket, - )..registerFeatureNegotiators([ - StartTlsNegotiator(), - ]); + ); + await connection.registerFeatureNegotiators([ + StartTlsNegotiator(), + ]); await connection.registerManagers([ DiscoManager([]), RosterManager(TestingRosterStateManager('', [])), diff --git a/packages/moxxmpp_socket_tcp/integration_test/failure_reconnection_test.dart b/packages/moxxmpp_socket_tcp/integration_test/failure_reconnection_test.dart index e701de1..5ede85d 100644 --- a/packages/moxxmpp_socket_tcp/integration_test/failure_reconnection_test.dart +++ b/packages/moxxmpp_socket_tcp/integration_test/failure_reconnection_test.dart @@ -19,9 +19,10 @@ void main() { TestingSleepReconnectionPolicy(10), AlwaysConnectedConnectivityManager(), TCPSocketWrapper(), - )..registerFeatureNegotiators([ - StartTlsNegotiator(), - ]); + ); + await connection.registerFeatureNegotiators([ + StartTlsNegotiator(), + ]); await connection.registerManagers([ DiscoManager([]), RosterManager(TestingRosterStateManager('', [])), @@ -68,9 +69,10 @@ void main() { TestingReconnectionPolicy(), AlwaysConnectedConnectivityManager(), TCPSocketWrapper(), - )..registerFeatureNegotiators([ - StartTlsNegotiator(), - ]); + ); + await connection.registerFeatureNegotiators([ + StartTlsNegotiator(), + ]); await connection.registerManagers([ DiscoManager([]), RosterManager(TestingRosterStateManager('', [])), diff --git a/packages/moxxmpp_socket_tcp/lib/src/socket.dart b/packages/moxxmpp_socket_tcp/lib/src/socket.dart index 49af453..883f16a 100644 --- a/packages/moxxmpp_socket_tcp/lib/src/socket.dart +++ b/packages/moxxmpp_socket_tcp/lib/src/socket.dart @@ -289,17 +289,13 @@ class TCPSocketWrapper extends BaseSocketWrapper { _eventStream.stream.asBroadcastStream(); @override - void write(String data, {String? redact}) { + void write(String data) { if (_socket == null) { _log.severe('Failed to write to socket as _socket is null'); return; } - if (redact != null) { - _log.finest('**> $redact'); - } else { - _log.finest('==> $data'); - } + _log.finest('==> $data'); try { _socket!.write(data);