-
Notifications
You must be signed in to change notification settings - Fork 0
opts string #17
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
base: main
Are you sure you want to change the base?
opts string #17
Conversation
Improved encode and parse functions to handle TLS options and extended URL parsing capabilities. Refactored property encoding and decoding logic for better maintainability. Introduced test cases to ensure correct handling of TLS and URL parsing features.
) { | ||
u = new URL(opts.servers[0]); | ||
} else { | ||
u = new URL(`nats://${opts.servers[0]}`); |
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.
Should this do something to start with the opts.servers starting with something other than wss://
or ws://
? It looks like if I provide nats://
then this will turn it into nats://nats://whatever
, and tls://x
into nats://tls://x
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.
for the javascript client you don't provide the scheme - it is host port, the only one that needs to have a scheme is ws/s
or I cannot tell what they are. - But possibly the thing to do is whip through all the servers and rip out the scheme if it isn't ws/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.
I have added a check for this - the javascript clients strops nats/tls
type schemes if they are included as they are meaningless. For secure options, tls
needs to be set, this prevents inconsistencies where a client connects via TLS on one server, but not in another because of some prefix.
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.
So you've now introduced in parse() handling for natss:
to do the TLS-handshake-on-connect behavior, which is great. But doesn't this mean that encode()
should also check for natss:
and avoid prepending nats:
to that? Or are we relying upon the parse inserting only the hostname into the server list, so encode will never see that?
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.
Encode is using the connection options, there's no such prefix that is understood - the serialized version does do that, but when decoded recreates the connect options.
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.
If you include a check for the natss:
protocol scheme in the tests you added, to prove that things encode sanely, I'll approve.
No description provided.