-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add PAM v3 support Adds PAM v3 support with grantToken and setToken. fix: change subscribe loop to no longer throw Subscribe loop no longer throws on unrecoverable failure, instead waits for restart. feat: add restore method to subscription After subscribe loop fails, call restore to restart it. fix: add more specific diagnostics Adds more diagnostics for network module. fix: change whenStarts to stream WhenStarts future no longer throws and is now based on a stream. fix: release resources on failure Networking should now release all resources after a failure. fix: Signature mismatch issue. Fixes issue of Signature mismatch with PAM enabled keysets. fix: Message decryption failure in subscribe. Fixes issue of message decryption with subscription.
- Loading branch information
1 parent
92599f2
commit 08af795
Showing
40 changed files
with
369 additions
and
1,888 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export 'stub.dart' | ||
if (dart.library.io) 'io.dart' | ||
if (dart.library.html) 'html.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import 'package:pubnub/core.dart'; | ||
|
||
class HostIsDownDiagnostic extends Diagnostic { | ||
final dynamic originalException; | ||
|
||
const HostIsDownDiagnostic(this.originalException); | ||
} | ||
|
||
class HostLookupFailedDiagnostic extends Diagnostic { | ||
final dynamic originalException; | ||
|
||
const HostLookupFailedDiagnostic(this.originalException); | ||
} | ||
|
||
class UnknownHttpExceptionDiagnostic extends Diagnostic { | ||
final dynamic originalException; | ||
|
||
const UnknownHttpExceptionDiagnostic(this.originalException); | ||
} | ||
|
||
class TimeoutDiagnostic extends Diagnostic { | ||
const TimeoutDiagnostic(); | ||
} | ||
|
||
class AccessDeniedDiagnostic extends Diagnostic { | ||
AccessDeniedDiagnostic(); | ||
} | ||
|
||
Diagnostic? getNetworkDiagnostic(dynamic exception) { | ||
if (exception is RequestOtherException) { | ||
return UnknownHttpExceptionDiagnostic(exception); | ||
} | ||
|
||
if (exception is RequestTimeoutException) { | ||
return TimeoutDiagnostic(); | ||
} | ||
|
||
if (exception is RequestFailureException) { | ||
var request = exception.response; | ||
|
||
if (request.statusCode == 403) { | ||
return AccessDeniedDiagnostic(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
import 'dart:io'; | ||
import 'package:pubnub/core.dart'; | ||
|
||
class HostIsDownDiagnostic extends Diagnostic { | ||
final dynamic originalException; | ||
|
||
const HostIsDownDiagnostic(this.originalException); | ||
} | ||
|
||
class HostLookupFailedDiagnostic extends Diagnostic { | ||
final dynamic originalException; | ||
|
||
const HostLookupFailedDiagnostic(this.originalException); | ||
} | ||
|
||
class UnknownHttpExceptionDiagnostic extends Diagnostic { | ||
final dynamic originalException; | ||
|
||
const UnknownHttpExceptionDiagnostic(this.originalException); | ||
} | ||
|
||
class TimeoutDiagnostic extends Diagnostic { | ||
const TimeoutDiagnostic(); | ||
} | ||
|
||
class AccessDeniedDiagnostic extends Diagnostic { | ||
const AccessDeniedDiagnostic(); | ||
} | ||
|
||
Diagnostic? getNetworkDiagnostic(dynamic exception) { | ||
if (exception is RequestOtherException) { | ||
var originalException = exception.additionalData; | ||
|
||
if (originalException is SocketException) { | ||
if (originalException.osError?.message == | ||
'nodename nor servname provided, or not known') { | ||
return HostLookupFailedDiagnostic(originalException); | ||
} | ||
|
||
var errno = _getErrorCode(originalException.osError?.errorCode); | ||
|
||
switch (errno) { | ||
case _Errno.ECONNRESET: | ||
case _Errno.ECONNABORTED: | ||
case _Errno.ECONNREFUSED: | ||
case _Errno.ETIMEOUT: | ||
case _Errno.EHOSTUNREACH: | ||
return HostIsDownDiagnostic(originalException); | ||
case _Errno.EBADF: | ||
case _Errno.ENETUNREACH: | ||
case _Errno.unknown: | ||
return UnknownHttpExceptionDiagnostic(originalException); | ||
} | ||
} | ||
|
||
if (originalException is HttpException || | ||
originalException is HandshakeException) { | ||
return UnknownHttpExceptionDiagnostic(originalException); | ||
} | ||
} | ||
|
||
if (exception is RequestTimeoutException) { | ||
return TimeoutDiagnostic(); | ||
} | ||
|
||
if (exception is RequestFailureException) { | ||
var request = exception.response; | ||
|
||
if (request.statusCode == 403) { | ||
return AccessDeniedDiagnostic(); | ||
} | ||
} | ||
} | ||
|
||
enum _Errno { | ||
unknown, | ||
ECONNABORTED, | ||
ECONNRESET, | ||
ECONNREFUSED, | ||
EHOSTUNREACH, | ||
EBADF, | ||
ETIMEOUT, | ||
ENETUNREACH | ||
} | ||
|
||
_Errno _getErrorCode(int? errno) { | ||
if (errno == null) { | ||
return _Errno.unknown; | ||
} | ||
|
||
if (Platform.isLinux) { | ||
return _linuxErrnoCodes[errno] ?? _Errno.unknown; | ||
} else if (Platform.isWindows) { | ||
return _winErrnoCodes[errno] ?? _Errno.unknown; | ||
} else if (Platform.isMacOS || Platform.isIOS) { | ||
return _macErrnoCodes[errno] ?? _Errno.unknown; | ||
} else if (Platform.isAndroid) { | ||
return _androidErrnoCodes[errno] ?? _Errno.unknown; | ||
} else { | ||
return _Errno.unknown; | ||
} | ||
} | ||
|
||
const _linuxErrnoCodes = { | ||
9: _Errno.EBADF, | ||
101: _Errno.ENETUNREACH, | ||
103: _Errno.ECONNABORTED, | ||
104: _Errno.ECONNRESET, | ||
110: _Errno.ETIMEOUT, | ||
111: _Errno.ECONNREFUSED, | ||
113: _Errno.EHOSTUNREACH, | ||
}; | ||
|
||
const _winErrnoCodes = { | ||
9: _Errno.EBADF, | ||
106: _Errno.ECONNABORTED, | ||
107: _Errno.ECONNREFUSED, | ||
108: _Errno.ECONNRESET, | ||
110: _Errno.EHOSTUNREACH, | ||
118: _Errno.ENETUNREACH, | ||
138: _Errno.ETIMEOUT | ||
}; | ||
|
||
const _macErrnoCodes = { | ||
9: _Errno.EBADF, | ||
51: _Errno.ENETUNREACH, | ||
53: _Errno.ECONNABORTED, | ||
54: _Errno.ECONNRESET, | ||
60: _Errno.ETIMEOUT, | ||
61: _Errno.ECONNREFUSED, | ||
65: _Errno.EHOSTUNREACH | ||
}; | ||
|
||
const _androidErrnoCodes = { | ||
9: _Errno.EBADF, | ||
111: _Errno.ECONNREFUSED, | ||
113: _Errno.ECONNABORTED, | ||
114: _Errno.ENETUNREACH, | ||
116: _Errno.ETIMEOUT, | ||
118: _Errno.EHOSTUNREACH | ||
}; |
Oops, something went wrong.