Skip to content

Commit

Permalink
Merge pull request #642 from nats-io/url-parse-update
Browse files Browse the repository at this point in the history
Allow downstream implementations of url parse to know whether we are connected securely or not
  • Loading branch information
aricart committed Dec 4, 2023
2 parents 2aeb0e1 + f612ee2 commit b8f806b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion nats-base-client/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1422,7 +1422,7 @@ export interface Base {
}

export interface URLParseFn {
(u: string): string;
(u: string, encrypted?: boolean): string;
}

export enum ServiceVerb {
Expand Down
2 changes: 1 addition & 1 deletion nats-base-client/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ export class ProtocolHandler implements Dispatcher<ParserEvent> {
this.info = info;
const updates = this.options && this.options.ignoreClusterUpdates
? undefined
: this.servers.update(info);
: this.servers.update(info, this.transport.isEncrypted());
if (!this.infoReceived) {
this.features.update(parseSemVer(info.version));
this.infoReceived = true;
Expand Down
4 changes: 2 additions & 2 deletions nats-base-client/servers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,15 +282,15 @@ export class Servers {
return this.servers;
}

update(info: ServerInfo): ServersChanged {
update(info: ServerInfo, encrypted?: boolean): ServersChanged {
const added: string[] = [];
let deleted: string[] = [];

const urlParseFn = getUrlParseFn();
const discovered = new Map<string, ServerImpl>();
if (info.connect_urls && info.connect_urls.length > 0) {
info.connect_urls.forEach((hp) => {
hp = urlParseFn ? urlParseFn(hp) : hp;
hp = urlParseFn ? urlParseFn(hp, encrypted) : hp;
const s = new ServerImpl(hp, true);
discovered.set(hp, s);
});
Expand Down

0 comments on commit b8f806b

Please sign in to comment.