Skip to content
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

Accept hostnames for tcp:, tcp-listen:, udp:, udp-listen: #56

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

andersk
Copy link

@andersk andersk commented Sep 25, 2019

No description provided.

pub fn resolve_addr(
addr_str: &str,
) -> impl Future<Item = SocketAddr, Error = Box<dyn std::error::Error + 'static>> {
// TODO: resolve asynchronously
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it really needed to be resolved at connecting time, not just once at argument parsing time?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is: when running websocat as a daemon, it shouldn’t need to be restarted just because a remote DNS name changed. Additionally, one might want to point websocat at a service using DNS load balancing.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tardiness in DNS reply may not only delay establishing a new connection, but also suspend all unrelated neighbour connections - websocat is mostly single-threaded.

Copy link
Author

@andersk andersk Sep 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, until we get async DNS, that’s a tradeoff. But this design allows the user to make that tradeoff. They can always choose to provide an IP address, or to install a local caching resolver (which will do the job much better than we would—sharing the cache between all apps on the system, respecting TTLs, and so on).

.to_socket_addrs()
.and_then(|mut addrs| {
addrs
.next()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be a welcome extension.

@vi
Copy link
Owner

vi commented Sep 25, 2019

Note: I remember doing similar change (but more elaborate, supporting multiple addresses and fast fallback) in "websocket_lowlevel" branch where websocat 2.0 is cooking.

Maybe it's worth backporting it to websocat 1...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants