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

fix: better options handling for public host #112

Merged
merged 6 commits into from
Aug 27, 2023
Merged

fix: better options handling for public host #112

merged 6 commits into from
Aug 27, 2023

Conversation

pi0
Copy link
Member

@pi0 pi0 commented Aug 27, 2023

πŸ”— Linked issue

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

This PR improves the options handling for public hosts.

If public is not explicitly provided, we infer it in this order:

  • hostname is explicitly localhost ? false
  • hostname is explicitly anyhost range ? true
  • --host flag provided (any value)? true (this is for CLI auto compatibility)
  • production env ? true
  • false

Listhen also shows smart warnings if options are used wrongly together:

  • Public enabled and hostname is localhost:
    • Show a warning that it is not going to listhen to anything public
    • Fix internal public option to false
  • Public is disabled and hostname is anyhost:
    • Show a warning that public config is going to be disabled
    • Force listen to localhost to avoid security implications

Note: Tunnel is a separate concept from public. One might choose to listen on either localhost or local network exposed server and expose a (private by default) tunnel.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@codecov
Copy link

codecov bot commented Aug 27, 2023

Codecov Report

Merging #112 (dfef4aa) into main (a5bf8db) will increase coverage by 0.07%.
Report is 1 commits behind head on main.
The diff coverage is 56.25%.

@@            Coverage Diff             @@
##             main     #112      +/-   ##
==========================================
+ Coverage   51.05%   51.12%   +0.07%     
==========================================
  Files          10       10              
  Lines        1608     1639      +31     
  Branches      115      122       +7     
==========================================
+ Hits          821      838      +17     
- Misses        787      801      +14     
Files Changed Coverage Ξ”
src/listen.ts 79.92% <36.36%> (-3.80%) ⬇️
src/_utils.ts 60.21% <100.00%> (+4.79%) ⬆️

@pi0 pi0 merged commit bff03a1 into main Aug 27, 2023
4 checks passed
@pi0 pi0 deleted the fix/hostname branch August 27, 2023 17:19
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

1 participant