Skip to content

Commit

Permalink
- Hide password from display (show ******)
Browse files Browse the repository at this point in the history
- Update to visualization page title
  • Loading branch information
gvensan committed Jan 31, 2024
1 parent 901a856 commit 9015938
Show file tree
Hide file tree
Showing 13 changed files with 64 additions and 24 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ stm receive
🎅 santa Hoho! No default configuration found, creating one for you...
✔ success success: initialized configuration with default command settings on 'stm-cli-config.json' successfully
ℹ info info: loading configuration 'stm-cli-config.json'
… awaiting connecting to broker [ws://localhost:8008, vpn: default, username: default, password: default]
… awaiting connecting to broker [ws://localhost:8008, vpn: default, username: default, password: ******]
✔ success success: === successfully connected and ready to receive events. ===
ℹ info info: subscribing to solace/try/me
ℹ info info: press Ctrl-C to exit
Expand All @@ -86,7 +86,7 @@ On a different window/terminal, you can launch a publisher and see the events re
``` code
stm send
ℹ info info: loading 'send' command from configuration 'stm-cli-config.json'
… awaiting connecting to broker [ws://localhost:8008, vpn: default, username: default, password: default]
… awaiting connecting to broker [ws://localhost:8008, vpn: default, username: default, password: ******]
✔ success success: === successfully connected and ready to publish events. ===
… awaiting publishing...
✔ success success: message published to topic solace/try/me
Expand Down Expand Up @@ -165,7 +165,7 @@ A receive command to cloud broker via the CLI:
``` code
stm receive --config stm-cloud-broker
ℹ info info: loading 'receive' command from configuration 'stm-cloud-broker'
… awaiting connecting to broker [wss://mr-connection-xxxx.messaging.solace.cloud:443, vpn: your-broker, username: solace-cloud-client, password: xxxx]
… awaiting connecting to broker [wss://mr-connection-******].messaging.solace.cloud:443, vpn: your-broker, username: solace-cloud-client, password: ******]
✔ success success: === successfully connected and ready to receive events. ===
ℹ info info: subscribing to solace/try/me
ℹ info info: press Ctrl-C to exit
Expand All @@ -176,7 +176,7 @@ A send command to cloud broker via the CLI:
```
stm send --config stm-cloud-broker
ℹ info info: loading 'send' command from configuration 'stm-cloud-broker'
… awaiting connecting to broker [wss://mr-connection-xxxx.messaging.solace.cloud:443, vpn: your-broker, username: solace-cloud-client, password: xxxx]
… awaiting connecting to broker [wss://mr-connection-******.messaging.solace.cloud:443, vpn: your-broker, username: solace-cloud-client, password: ******]
✔ success success: === successfully connected and ready to publish events. ===
… awaiting publishing...
✔ success success: message published to topic solace/try/me
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "stm",
"version": "0.0.23",
"version": "0.0.24",
"description": "Solace Try-Me Command Line Tool",
"keywords": [
"solace",
Expand Down
4 changes: 2 additions & 2 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title>Solace Try-Me Event Flow Visualization</title>
<title>Solace Try-Me CLI - Event Flow Visualization</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
Expand Down Expand Up @@ -44,7 +44,7 @@ <h3 style="margin: auto;" >Events</h3>
<div id="navMain">
<div class="header">
<span style="font-size:30px;cursor:pointer;" onclick="openNav()">&#9776;</span>
<h3 style="margin: auto;display:inline-flex">Solace Try-Me Event Flow Visualization<span id='heading' class='paused'>[paused]</span></h3>
<h3 style="margin: auto;display:inline-flex">Solace Try-Me CLI - Event Flow Visualization<span id='heading' class='paused'>[paused]</span></h3>
<div class="dropdown">
<button class="dropdownSlider" onclick="showDropdown()"><i class="fa fa-sliders" aria-hidden="true"></i></button>
<div id="speedDropDown" class="dropdown-content">
Expand Down
6 changes: 3 additions & 3 deletions src/common/publish-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export class SolaceClient extends VisualizeClient {

// connect the session
try {
Logger.await(`connecting to broker [${this.options.url}, vpn: ${this.options.vpn}, username: ${this.options.username}, password: ${this.options.password}]`)
Logger.await(`connecting to broker [${this.options.url}, vpn: ${this.options.vpn}, username: ${this.options.username}, password: ******]`)
if (this.options.clientName) Logger.info(`client name: ${this.clientName}`)
this.session.connect();
} catch (error:any) {
Expand Down Expand Up @@ -241,10 +241,10 @@ export class SolaceClient extends VisualizeClient {
this.setExited(true);
setTimeout(() => {
this.disconnect();
}, 1000); // wait for 1 second to disconnect
}, 500); // wait for 1 second to disconnect
setTimeout(function () {
Logger.logSuccess('exiting...')
process.exit(0);
}, 1000); // wait for 2 seconds to finish
}, 1500); // wait for 1 second to finish
};
}
8 changes: 5 additions & 3 deletions src/common/receive-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ export class SolaceClient extends VisualizeClient {

// connect the session
try {
Logger.await(`connecting to broker [${this.options.url}, vpn: ${this.options.vpn}, username: ${this.options.username}, password: ${this.options.password}]`)
Logger.await(`connecting to broker [${this.options.url}, vpn: ${this.options.vpn}, username: ${this.options.username}, password: ******]`)
if (this.options.clientName) Logger.info(`client name: ${this.options.clientName}`)
this.session.connect();
} catch (error:any) {
Expand Down Expand Up @@ -432,10 +432,12 @@ export class SolaceClient extends VisualizeClient {

exit() {
if (!this.options.queue) this.unsubscribeAll();
this.disconnect();
setTimeout(() => {
this.disconnect();
}, 500); // wait for 1 second to disconnect
setTimeout(function () {
Logger.logSuccess('exiting...')
process.exit(0);
}, 1000); // wait for 1 second to finish
}, 1500); // wait for 1 second to finish
};
}
8 changes: 4 additions & 4 deletions src/common/reply-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export class SolaceClient extends VisualizeClient {

// connect the session
try {
Logger.await(`connecting to broker [${this.options.url}, vpn: ${this.options.vpn}, username: ${this.options.username}, password: ${this.options.password}]`)
Logger.await(`connecting to broker [${this.options.url}, vpn: ${this.options.vpn}, username: ${this.options.username}, password: ******]`)
if (this.options.clientName) Logger.info(`client name: ${this.options.clientName}`)
this.session.connect();
} catch (error:any) {
Expand Down Expand Up @@ -199,7 +199,7 @@ export class SolaceClient extends VisualizeClient {
reply.setDestination(solace.SolclientFactory.createTopicDestination(this.options.replyToTopic));
else
reply.setDestination(message.getReplyTo());
Logger.logInfo('Reply To: ' + message.getReplyTo() + ' - ' + this.options.replyToTopic);
Logger.logInfo('Reply To: ' + message.getReplyTo());
this.options.deliveryMode && reply.setDeliveryMode(deliveryModeMap.get(this.options.deliveryMode.toUpperCase()) as MessageDeliveryModeType);
this.session.sendReply(message, reply);
// this.session.send(reply)
Expand Down Expand Up @@ -237,10 +237,10 @@ export class SolaceClient extends VisualizeClient {
if (this.session !== null) this.unsubscribe();
setTimeout(() => {
this.disconnect();
}, 1000); // wait for 1 second to disconnect
}, 500); // wait for 1 second to disconnect
setTimeout(function () {
Logger.logSuccess('exiting...')
process.exit(0);
}, 1000); // wait for 2 seconds to finish
}, 1500); // wait for 1 second to finish
};
}
24 changes: 19 additions & 5 deletions src/common/request-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export class SolaceClient extends VisualizeClient {

// connect the session
try {
Logger.await(`connecting to broker [${this.options.url}, vpn: ${this.options.vpn}, username: ${this.options.username}, password: ${this.options.password}]`)
Logger.await(`connecting to broker [${this.options.url}, vpn: ${this.options.vpn}, username: ${this.options.username}, password: ******]`)
if (this.options.clientName) Logger.info(`client name: ${this.options.clientName}`)
this.session.connect();
} catch (error:any) {
Expand Down Expand Up @@ -161,11 +161,25 @@ export class SolaceClient extends VisualizeClient {
this.publishVisualizationEvent(this.session, this.options, STM_EVENT_REPLY_RECEIVED, {
type: 'requestor', topicName: topicName + ' [reply]', clientName: this.clientName, uuid: uuid(), msgId: message.getApplicationMessageId()
})
this.exit();
if (this.options.waitBeforeExit) {
setTimeout(() => {
Logger.logWarn(`exiting session (waited-before-exit set for ${this.options.waitBeforeExit})...`);
this.exit();
}, this.options.waitBeforeExit * 1000);
} else {
this.exit();
}
},
(session:any, event:any) => {
Logger.logDetailedError('send request failed - ', event.infoStr)
this.exit();
if (this.options.waitBeforeExit) {
setTimeout(() => {
Logger.logWarn(`exiting session (waited-before-exit set for ${this.options.waitBeforeExit})...`);
this.exit();
}, this.options.waitBeforeExit * 1000);
} else {
this.exit();
}
},
null // not providing correlation object
);
Expand Down Expand Up @@ -199,10 +213,10 @@ export class SolaceClient extends VisualizeClient {
exit = () => {
setTimeout(() => {
this.disconnect();
}, 1000); // wait for 1 second to disconnect
}, 500); // wait for 1 second to disconnect
setTimeout(function () {
Logger.logSuccess('exiting...')
process.exit(0);
}, 1000); // wait for 2 seconds to finish
}, 1500); // wait for 1 second to finish
};
}
18 changes: 16 additions & 2 deletions src/lib/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,29 @@ const publish = async (
for (var i=0; i<options.topic.length; i++) {
publisher.publish(options.topic[i], message, 0);
}
publisher.disconnect();
if (options.waitBeforeExit) {
setTimeout(function exit() {
Logger.logWarn(`exiting session (waited-before-exit set for ${options.waitBeforeExit})...`);
publisher.exit();
}, options.waitBeforeExit * 1000);
} else {
publisher.exit();
}
} else {
for (var iter=count ? count : 1, n=1;iter > 0;iter--, n++) {
for (var i=0; i<options.topic.length; i++) {
publisher.publish(options.topic[i], message, n-1);
}
if (interval) await delay(interval)
}
publisher.disconnect();
if (options.waitBeforeExit) {
setTimeout(function exit() {
Logger.logWarn(`exiting session (waited-before-exit set for ${options.waitBeforeExit})...`);
publisher.exit();
}, options.waitBeforeExit * 1000);
} else {
publisher.exit();
}
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/lib/receive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ const receiver = (options: MessageClientOptions, optionsSource: any) => {
// if subscriptions are specified, remove the default subscription at pos-0
checkForCliTopics('topic', options, optionsSource);

// remove default subscription addition for queues
if (options.queue)
options.topic = undefined;

if (save) {
saveOrUpdateCommandSettings(options, optionsSource)
process.exit(0);
Expand Down
1 change: 1 addition & 0 deletions src/types/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ declare global {
replyToTopic?: string
userProperties?: Record<string, string | string[]>

waitBeforeExit?: number
exitAfter?: number
outputMode?: string

Expand Down
1 change: 1 addition & 0 deletions src/utils/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ export const defaultMessageReplyConfig:any = {
enabled: false, // guaranteed publisher
windowSize: 50,

waitBeforeExit: 0,
exitAfter: 0,

command: 'reply',
Expand Down
2 changes: 2 additions & 0 deletions src/utils/instances.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export class MessageClientOptionsEmpty implements StmConfigOptions, MessageConne
replyToTopic?: string | undefined
userProperties?: Record<string, string | string[]> | undefined
outputMode?: string | undefined
waitBeforeExit?: number | undefined;
exitAfter?: number | undefined
helpMore?: boolean | undefined
visualization?: string | boolean | undefined
Expand Down Expand Up @@ -113,6 +114,7 @@ export class MessageClientOptionsEmpty implements StmConfigOptions, MessageConne
this.replyToTopic = ""
this.userProperties = { "key": "value" }
this.outputMode = ""
this.waitBeforeExit = 0;
this.exitAfter = 0
this.helpMore = false
this.visualization = false
Expand Down
2 changes: 2 additions & 0 deletions src/utils/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export const addSendOptions = (cmd: Command, advanced: boolean) => {
.addOption(new Option('--keepalive-interval-limit <NUMBER>', chalk.whiteBright('[advanced] the maximum number of consecutive Keep-Alive messages that can be sent without receiving a response before the session is declared down')) .argParser(parseNumber) .default(defaultMessageConnectionConfig.keepAliveIntervalLimit) .hideHelp(!advanced))
.addOption(new Option('--include-sender-id [BOOLEAN]', chalk.whiteBright('[advanced] include a sender ID on sent messages')) .argParser(parseBoolean) .default(defaultMessageConnectionConfig.includeSenderId) .hideHelp(!advanced))
.addOption(new Option('--generate-sequence-number [BOOLEAN]', chalk.whiteBright('[advanced] include sequence number on messages sent')) .argParser(parseBoolean) .default(defaultMessageConnectionConfig.generateSequenceNumber) .hideHelp(!advanced))
.addOption(new Option('--wait-before-exit <NUMBER>', chalk.whiteBright('[advanced] wait for the specified number of seconds before exiting')) .argParser(parseNumber) .hideHelp(true))
.addOption(new Option('--exit-after <NUMBER>', chalk.whiteBright('[advanced] exit the session after specified number of seconds')) .argParser(parseNumber) .hideHelp(true))
.addOption(new Option('--log-level <LEVEL>', chalk.whiteBright('[advanced] solace log level, one of values: FATAL, ERROR, WARN, INFO, DEBUG, TRACE')) .argParser(parseLogLevel) .default(defaultMessageConnectionConfig.logLevel) .hideHelp(!advanced))

Expand Down Expand Up @@ -211,6 +212,7 @@ export const addRequestOptions = (cmd: Command, advanced: boolean) => {
.addOption(new Option('--keepalive-interval-limit <NUMBER>', chalk.whiteBright('[advanced] the maximum number of consecutive Keep-Alive messages that can be sent without receiving a response before the session is declared down')) .argParser(parseNumber) .default(defaultMessageConnectionConfig.keepAliveIntervalLimit) .hideHelp(!advanced))
.addOption(new Option('--include-sender-id [BOOLEAN]', chalk.whiteBright('[advanced] include a sender ID on sent messages')) .argParser(parseBoolean) .default(defaultMessageConnectionConfig.includeSenderId) .hideHelp(!advanced))
.addOption(new Option('--generate-sequence-number [BOOLEAN]', chalk.whiteBright('[advanced] include sequence number on messages sent')) .argParser(parseBoolean) .default(defaultMessageConnectionConfig.generateSequenceNumber) .hideHelp(!advanced))
.addOption(new Option('--wait-before-exit <NUMBER>', chalk.whiteBright('[advanced] wait for the specified number of seconds before exiting')) .argParser(parseNumber) .hideHelp(true))
.addOption(new Option('--exit-after <NUMBER>', chalk.whiteBright('[advanced] exit the session after specified number of seconds')) .argParser(parseNumber) .hideHelp(true))
.addOption(new Option('--log-level <LEVEL>', chalk.whiteBright('[advanced] solace log level, one of values: FATAL, ERROR, WARN, INFO, DEBUG, TRACE')) .argParser(parseLogLevel) .default(defaultMessageConnectionConfig.logLevel) .hideHelp(!advanced))

Expand Down

0 comments on commit 9015938

Please sign in to comment.