fix(style): Format using dart format
This commit is contained in:
parent
38155051f5
commit
8b0f118e2d
@ -22,7 +22,8 @@ class TCPSocketWrapper extends BaseSocketWrapper {
|
|||||||
final StreamController<String> _dataStream = StreamController.broadcast();
|
final StreamController<String> _dataStream = StreamController.broadcast();
|
||||||
|
|
||||||
/// The stream of outgoing (TCPSocketWrapper -> XmppConnection) events.
|
/// The stream of outgoing (TCPSocketWrapper -> XmppConnection) events.
|
||||||
final StreamController<XmppSocketEvent> _eventStream = StreamController.broadcast();
|
final StreamController<XmppSocketEvent> _eventStream =
|
||||||
|
StreamController.broadcast();
|
||||||
|
|
||||||
/// A subscription on the socket's data stream.
|
/// A subscription on the socket's data stream.
|
||||||
StreamSubscription<dynamic>? _socketSubscription;
|
StreamSubscription<dynamic>? _socketSubscription;
|
||||||
@ -68,7 +69,7 @@ class TCPSocketWrapper extends BaseSocketWrapper {
|
|||||||
bool onBadCertificate(dynamic certificate, String domain) {
|
bool onBadCertificate(dynamic certificate, String domain) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> _xep368Connect(String domain) async {
|
Future<bool> _xep368Connect(String domain) async {
|
||||||
// TODO(Unknown): Maybe do DNSSEC one day
|
// TODO(Unknown): Maybe do DNSSEC one day
|
||||||
final results = await srvQuery('_xmpps-client._tcp.$domain', false);
|
final results = await srvQuery('_xmpps-client._tcp.$domain', false);
|
||||||
@ -80,7 +81,9 @@ class TCPSocketWrapper extends BaseSocketWrapper {
|
|||||||
results.sort(srvRecordSortComparator);
|
results.sort(srvRecordSortComparator);
|
||||||
for (final srv in results) {
|
for (final srv in results) {
|
||||||
try {
|
try {
|
||||||
_log.finest('Attempting secure connection to ${srv.target}:${srv.port}...');
|
_log.finest(
|
||||||
|
'Attempting secure connection to ${srv.target}:${srv.port}...',
|
||||||
|
);
|
||||||
|
|
||||||
// Workaround: We cannot set the SNI directly when using SecureSocket.connect.
|
// Workaround: We cannot set the SNI directly when using SecureSocket.connect.
|
||||||
// instead, we connect using a regular socket and then secure it. This allows
|
// instead, we connect using a regular socket and then secure it. This allows
|
||||||
@ -93,14 +96,14 @@ class TCPSocketWrapper extends BaseSocketWrapper {
|
|||||||
_socket = await SecureSocket.secure(
|
_socket = await SecureSocket.secure(
|
||||||
sock,
|
sock,
|
||||||
host: domain,
|
host: domain,
|
||||||
supportedProtocols: const [ xmppClientALPNId ],
|
supportedProtocols: const [xmppClientALPNId],
|
||||||
onBadCertificate: (cert) => onBadCertificate(cert, domain),
|
onBadCertificate: (cert) => onBadCertificate(cert, domain),
|
||||||
);
|
);
|
||||||
|
|
||||||
_secure = true;
|
_secure = true;
|
||||||
_log.finest('Success!');
|
_log.finest('Success!');
|
||||||
return true;
|
return true;
|
||||||
} on Exception catch(e) {
|
} on Exception catch (e) {
|
||||||
_log.finest('Failure! $e');
|
_log.finest('Failure! $e');
|
||||||
|
|
||||||
if (e is HandshakeException) {
|
if (e is HandshakeException) {
|
||||||
@ -112,10 +115,10 @@ class TCPSocketWrapper extends BaseSocketWrapper {
|
|||||||
if (failedDueToTLS) {
|
if (failedDueToTLS) {
|
||||||
_eventStream.add(XmppSocketTLSFailedEvent());
|
_eventStream.add(XmppSocketTLSFailedEvent());
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> _rfc6120Connect(String domain) async {
|
Future<bool> _rfc6120Connect(String domain) async {
|
||||||
// TODO(Unknown): Maybe do DNSSEC one day
|
// TODO(Unknown): Maybe do DNSSEC one day
|
||||||
final results = await srvQuery('_xmpp-client._tcp.$domain', false);
|
final results = await srvQuery('_xmpp-client._tcp.$domain', false);
|
||||||
@ -132,7 +135,7 @@ class TCPSocketWrapper extends BaseSocketWrapper {
|
|||||||
|
|
||||||
_log.finest('Success!');
|
_log.finest('Success!');
|
||||||
return true;
|
return true;
|
||||||
} on Exception catch(e) {
|
} on Exception catch (e) {
|
||||||
_log.finest('Failure! $e');
|
_log.finest('Failure! $e');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -154,7 +157,7 @@ class TCPSocketWrapper extends BaseSocketWrapper {
|
|||||||
);
|
);
|
||||||
_log.finest('Success!');
|
_log.finest('Success!');
|
||||||
return true;
|
return true;
|
||||||
} on Exception catch(e) {
|
} on Exception catch (e) {
|
||||||
_log.finest('Failure! $e');
|
_log.finest('Failure! $e');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -180,14 +183,14 @@ class TCPSocketWrapper extends BaseSocketWrapper {
|
|||||||
_log.severe('Failed to secure socket since _socket is null');
|
_log.severe('Failed to secure socket since _socket is null');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// The socket is closed during the entire process
|
// The socket is closed during the entire process
|
||||||
_expectSocketClosure = true;
|
_expectSocketClosure = true;
|
||||||
|
|
||||||
_socket = await SecureSocket.secure(
|
_socket = await SecureSocket.secure(
|
||||||
_socket!,
|
_socket!,
|
||||||
supportedProtocols: const [ xmppClientALPNId ],
|
supportedProtocols: const [xmppClientALPNId],
|
||||||
onBadCertificate: (cert) => onBadCertificate(cert, domain),
|
onBadCertificate: (cert) => onBadCertificate(cert, domain),
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -204,7 +207,7 @@ class TCPSocketWrapper extends BaseSocketWrapper {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _setupStreams() {
|
void _setupStreams() {
|
||||||
if (_socket == null) {
|
if (_socket == null) {
|
||||||
_log.severe('Failed to setup streams as _socket is null');
|
_log.severe('Failed to setup streams as _socket is null');
|
||||||
@ -230,9 +233,9 @@ class TCPSocketWrapper extends BaseSocketWrapper {
|
|||||||
_expectSocketClosure = false;
|
_expectSocketClosure = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<bool> connect(String domain, { String? host, int? port }) async {
|
Future<bool> connect(String domain, {String? host, int? port}) async {
|
||||||
_expectSocketClosure = false;
|
_expectSocketClosure = false;
|
||||||
_secure = false;
|
_secure = false;
|
||||||
|
|
||||||
@ -280,7 +283,7 @@ class TCPSocketWrapper extends BaseSocketWrapper {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
_socket!.close();
|
_socket!.close();
|
||||||
} catch(e) {
|
} catch (e) {
|
||||||
_log.warning('Closing socket threw exception: $e');
|
_log.warning('Closing socket threw exception: $e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -289,10 +292,11 @@ class TCPSocketWrapper extends BaseSocketWrapper {
|
|||||||
Stream<String> getDataStream() => _dataStream.stream.asBroadcastStream();
|
Stream<String> getDataStream() => _dataStream.stream.asBroadcastStream();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Stream<XmppSocketEvent> getEventStream() => _eventStream.stream.asBroadcastStream();
|
Stream<XmppSocketEvent> getEventStream() =>
|
||||||
|
_eventStream.stream.asBroadcastStream();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void write(Object? data, { String? redact }) {
|
void write(Object? data, {String? redact}) {
|
||||||
if (_socket == null) {
|
if (_socket == null) {
|
||||||
_log.severe('Failed to write to socket as _socket is null');
|
_log.severe('Failed to write to socket as _socket is null');
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user