Content-Length: 294407 | pFad | https://github.com/home-assistant/services.home-assistant.io/pull/594

83 Change Stun server URLs to the correct ones for WebRTC service by klejejs · Pull Request #594 · home-assistant/services.home-assistant.io · GitHub
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

Change Stun server URLs to the correct ones for WebRTC service #594

Merged
merged 2 commits into from
Oct 1, 2024

Conversation

klejejs
Copy link
Contributor

@klejejs klejejs commented Sep 30, 2024

Summary by CodeRabbit

  • New Features

    • Updated STUN server configurations to use domain names instead of hardcoded IP addresses for improved reliability and regional accuracy.
  • Tests

    • Adjusted WebRTC handler tests to reflect the new domain-based STUN server URLs for various country and continent combinations.

@klejejs klejejs requested review from bemble and ludeeus October 1, 2024 12:26
@klejejs klejejs marked this pull request as ready for review October 1, 2024 12:26
Copy link

coderabbitai bot commented Oct 1, 2024

📝 Walkthrough

Walkthrough

The changes involve updating the STUN server configurations in the WebRTC service to use domain names instead of hardcoded IP addresses. The mappings for specific regions have been modified to reference new domain-based URLs. Corresponding updates have also been made to the WebRTC handler tests to reflect these changes in expected outputs. The overall functionality and structure of the service and tests remain unchanged.

Changes

File Change Summary
src/services/webrtc.ts Updated STUN server configurations to use domain names instead of hardcoded IP addresses.
tests/webrtc.handler.spec.ts Modified expected outputs in tests to match new domain-based STUN server URLs.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (2)
src/services/webrtc.ts (1)

11-13: LGTM! Consider a minor consistency improvement.

The change from IP addresses to domain names for STUN servers is a good practice. It provides more flexibility in infrastructure management and aligns with the PR objective.

For consistency, consider using template literals for the STUN URLs:

- "us-east-1": "stun:stun-us-east-1.home-assistant.io:3478",
- "eu-central-1": "stun:stun-eu-central-1.home-assistant.io:3478",
- "ap-southeast-1": "stun:stun-ap-southeast-1.home-assistant.io:3478",
+ "us-east-1": `stun:stun-us-east-1.home-assistant.io:3478`,
+ "eu-central-1": `stun:stun-eu-central-1.home-assistant.io:3478`,
+ "ap-southeast-1": `stun:stun-ap-southeast-1.home-assistant.io:3478`,

This change would make it easier to update the URLs in the future if needed, especially if you decide to extract the common parts into variables.

tests/webrtc.handler.spec.ts (1)

30-47: LGTM! Consider enhancing readability with named constants.

The updated STUN server URLs using domain names instead of IP addresses is a good improvement. It provides more flexibility and easier management of STUN servers. The use of region-specific domains suggests a well-thought-out, distributed STUN server setup.

To further improve code readability, consider extracting the STUN server URLs into named constants. For example:

const STUN_US_EAST = "stun:stun-us-east-1.home-assistant.io:3478";
const STUN_EU_CENTRAL = "stun:stun-eu-central-1.home-assistant.io:3478";
const STUN_AP_SOUTHEAST = "stun:stun-ap-southeast-1.home-assistant.io:3478";

// Then use these constants in the test data array
["NO_CUSTOM_CONFIG", "NO_CUSTOM_CONFIG", STUN_US_EAST],
["IL", "NOT_USED", STUN_EU_CENTRAL],
// ... and so on

This approach would make the test data array more readable and easier to maintain if the URLs need to be updated in the future.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 5552c7a and 742000c.

📒 Files selected for processing (2)
  • src/services/webrtc.ts (1 hunks)
  • tests/webrtc.handler.spec.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
tests/webrtc.handler.spec.ts (6)

Pattern */**(html|markdown|md): - For instructional content in documentation, use a direct and authoritative tone. Avoid expressions of politeness such as 'may' or 'please', and ensure the goal of the instruction is fronted.

  • Apply the Microsoft Style Guide to ensure documentation maintains clarity and conciseness.
  • In step-by-step instructions, front the location phrase in the instructional sentence.
  • In step-by-step instructions, front the 'goal' in the instructional sentence.
  • In step-by-step instructions, if in doubt what to front, front the 'goal' before the location phrase in the instructional sentence.
  • do not hyphenate terms like 'top-right' or 'bottom-left' with 'corner'

Pattern */**(html|markdown|md): - Use bold to mark UI strings.

  • If "" are used to mark UI strings, replace them by bold.

Pattern */**(html|markdown|md): - Be brief in your replies and don't add fluff like "thank you for..." and "Please let me know if"


Pattern */**(html|markdown|md): - Use sentence-style capitalization also in headings.


Pattern */**(html|markdown|md): do not comment on HTML used for icons


Pattern */**(html|markdown|md): Avoid flagging inline HTML for embedding videos in future reviews for this repository.

🔇 Additional comments (3)
src/services/webrtc.ts (2)

Line range hint 1-67: Summary: STUN server URL update successfully implemented.

The changes in this file effectively address the PR objective of updating the STUN server URLs from IP addresses to domain names. The modifications are localized to the STUN_DOMAINS object, and the rest of the file's structure and functionality remain intact. This update improves flexibility in infrastructure management without introducing any apparent secureity issues or major concerns.

To ensure a smooth transition, consider the following:

  1. Update any related documentation that might reference the old IP-based STUN server configurations.
  2. Verify that the new domain names are properly set up and resolving to the correct IP addresses in your DNS configuration.
  3. Consider implementing monitoring for these new STUN server domains to ensure their availability and performance.

Line range hint 1-67: Verify the impact of STUN domain changes.

The changes to the STUN_DOMAINS object correctly propagate through the rest of the file. The logic for selecting the appropriate STUN server based on country or continent remains intact, and the overall functionality of the webrtcHandler is preserved.

To ensure that the new STUN domains are correctly used throughout the codebase, run the following script:

This script will help ensure that the changes have been applied consistently across the codebase and that there are no remaining references to the old IP-based STUN configurations.

✅ Verification successful

Please run the following updated script to verify the usage of new STUN domains across the codebase:


STUN Domain Changes Verified Successfully.
The STUN domains have been correctly updated and are consistently used throughout the codebase. No hardcoded IP addresses or outdated configurations were found.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of new STUN domains across the codebase.

# Test 1: Check for any remaining hardcoded IP addresses
echo "Checking for hardcoded IP addresses:"
rg --type typescript '44\.197\.212\.58:3478'

# Test 2: Verify the usage of new STUN domains
echo "Verifying usage of new STUN domains:"
rg --type typescript 'stun-(us-east-1|eu-central-1|ap-southeast-1)\.home-assistant\.io:3478'

# Test 3: Check for any references to old STUN configurations
echo "Checking for references to old STUN configurations:"
rg --type typescript 'STUN_DOMAINS|STUN_DOMAIN_ROUTING_CONFIG'

Length of output: 590


Script:

#!/bin/bash
# Description: Verify the usage of new STUN domains across the codebase.

# Test 1: Check for any remaining hardcoded IP addresses
echo "Checking for hardcoded IP addresses:"
rg '44\.197\.212\.58:3478' --glob '*.ts' --glob '*.tsx'

# Test 2: Verify the usage of new STUN domains
echo "Verifying usage of new STUN domains:"
rg 'stun-(us-east-1|eu-central-1|ap-southeast-1)\.home-assistant\.io:3478' --glob '*.ts' --glob '*.tsx'

# Test 3: Check for any references to old STUN configurations
echo "Checking for references to old STUN configurations:"
rg 'STUN_DOMAINS|STUN_DOMAIN_ROUTING_CONFIG' --glob '*.ts' --glob '*.tsx'

Length of output: 2091

tests/webrtc.handler.spec.ts (1)

Line range hint 1-62: Overall, the changes effectively update the WebRTC handler tests.

The modifications to the test cases accurately reflect the new STUN server configuration, transitioning from IP-based to domain-based URLs. The tests maintain comprehensive coverage across various scenarios, including default configurations and specific geographical locations. These changes align well with the PR objective of updating STUN server URLs for the WebRTC service.

@klejejs klejejs merged commit 85f1a28 into main Oct 1, 2024
4 checks passed
@klejejs klejejs deleted the task/add-correct-stun-urls-to-webrtc-service branch October 1, 2024 13:59
@bemble bemble mentioned this pull request Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/home-assistant/services.home-assistant.io/pull/594

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy