Skip to content

#286: Emulator UI should not connect to 0.0.0.0 for emulators #312

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

Merged

Conversation

gautamsingal
Copy link
Contributor

Description:
- Added check whether info.host is not 0.0.0.0 or ::
- If it is present, then update the host with localhost else it remains same
- Pass the new value to hostAndPort

Description:
    - Added check whether info.host is not 0.0.0.0 or ::
    - If it is present, then update the host with localhost else it remains same
    - Pass the new value to hostAndPort
Copy link
Member

@yuchenshi yuchenshi left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution! This looks good, but one small nit: please use 127.0.0.1 for IPv4 and ::1 for IPv6 instead of localhost.

The reason is that localhost may be mapped to both on the hosts file and may differ on each device. IP addresses are more direct and uniformly handled.

@gautamsingal
Copy link
Contributor Author

@yuchenshi Will this be good?
const host = info.host === '0.0.0.0' || info.host === '::' ? info.host === '0.0.0.0' ? '127.0.0.1' : '::1' : info.host;

@yuchenshi
Copy link
Member

const host = info.host === '0.0.0.0' || info.host === '::' ? info.host === '0.0.0.0' ? '127.0.0.1' : '::1' : info.host;

That is logically correct, but for let's stay away from chained ternaries for clarity. I suggest:

let host = info.host;
if (host === '0.0.0.0') {
  host = '127.0.0.1';
} else if (host === '::') {
  host = '::1';
}

Description:
    - Added check whether info.host is not 0.0.0.0 or ::
    - If it is present, then update the host with localhost else it remains same
    - Pass the new value to hostAndPort
@gautamsingal
Copy link
Contributor Author

@yuchenshi Okay 😁

@yuchenshi yuchenshi merged commit bdb1933 into firebase:master Jun 18, 2020
@yuchenshi
Copy link
Member

This will be included in the next release. Cheers!

@gautamsingal
Copy link
Contributor Author

Great! Thanks @yuchenshi . Cheers!

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.

2 participants