New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: provide a way to listen to progress and logger messages #741
Conversation
feat: provide a way to listen to logger messages feat: Make SshnpCore, SshnpDartPureImpl and SshnpOpensshLocalImpl emit progress messages refactor: Swapped around clientPort and daemonPort for the legacy reverse ssh impl, for consistency
import 'package:at_utils/at_logger.dart'; | ||
import 'package:logging/logging.dart'; | ||
|
||
class StreamingLoggingHandler implements LoggingHandler { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A new at_logger LoggingHandler so we have a way to provide a stream of log messages
@@ -90,7 +91,7 @@ class SshnpUnsignedImpl extends SshnpCore | |||
..sharedBy = params.clientAtSign | |||
..sharedWith = params.sshnpdAtSign | |||
..metadata = (Metadata()..ttl = 10000), | |||
'$localPort ${srvdChannel.clientPort} ${keyUtil.username} ${srvdChannel.host} $sessionId', | |||
'$localPort ${srvdChannel.daemonPort} ${keyUtil.username} ${srvdChannel.host} $sessionId', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made the legacy impl code consistent with the current impls (dart, openssh)
Stream<List<int>> get stdout; | ||
} | ||
|
||
abstract interface class Sshnp { | ||
static final StreamingLoggingHandler _slh = | ||
StreamingLoggingHandler(AtSignLogger.defaultLoggingHandler); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make one of our StreamingLoggingHandlers, and wrap the current defaultLoggingHandler in it
/// Legacy v3.x.x client | ||
@Deprecated( | ||
'Legacy unsigned client - only for connecting with ^3.0.0 daemons') | ||
factory Sshnp.unsigned({ | ||
required AtClient atClient, | ||
required SshnpParams params, | ||
}) { | ||
return SshnpUnsignedImpl(atClient: atClient, params: params); | ||
AtSignLogger.defaultLoggingHandler = _slh; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set the defaultLoggingHandler to our StreamingLoggingHandler
@@ -122,7 +122,7 @@ abstract class SrvdChannel<T> with AsyncInitialization, AtClientBindings { | |||
if (params.host.startsWith('@')) { | |||
srv = srvGenerator( | |||
host, | |||
daemonPort!, // everything was backwards back then | |||
clientPort, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made the legacy impl code consistent with the current impls (dart, openssh)
} | ||
|
||
sshnp.progressStream?.listen((s) => logProgress(s)); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a simple progress listener into the sshnp CLI so that, if run in non-verbose mode, the user will get enough output to keep them from wondering what is going on and why. (If run in verbose mode, a normal user gets too much information)
- What I did
- How I did it
- How to verify it