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

Allow viaduct to make requests to the android emulator loopback address. #5270

Merged
merged 1 commit into from
Dec 1, 2022

Conversation

mhammond
Copy link
Member

@mhammond mhammond commented Dec 1, 2022

Viaduct itself gets the ability to allow exactly 1 arbitrary address to be connected to which isn't a https:// URL, but the FFI adds an android specific function which hard-codes the accepted address.

@csadilek said this seems to work in his testing. I don't think it's a breaking change but will require an a-c patch to expose the new method.

@badboy already pointed out my check should check just the host, but I also included the scheme. LMK if you would prefer different semantics.

Pull Request checklist

  • Quality: This PR builds and tests run cleanly
    • Note:
      • For changes that need extra cross-platform testing, consider adding [ci full] to the PR title.
      • If this pull request includes a breaking change, consider cutting a new release after merging.
  • Tests: This PR includes thorough tests or an explanation of why it does not
  • Changelog: This PR includes a changelog entry in CHANGES_UNRELEASED.md or an explanation of why it does not need one
    • Any breaking changes to Swift or Kotlin binding APIs are noted explicitly
  • Dependencies: This PR follows our dependency management guidelines
    • Any new dependencies are accompanied by a summary of the due dilligence applied in selecting them.

Branch builds: add [ff-android: firefox-android-branch-name] and/or [fenix: fenix-branch-name] to the PR title.

@mhammond mhammond force-pushed the viaduct-android-localhost branch 2 times, most recently from d787c3a to 6d3c24f Compare December 1, 2022 00:47
@mhammond
Copy link
Member Author

mhammond commented Dec 1, 2022

I can't formally ask @badboy for review, so consider this an informal request :)

@codecov-commenter
Copy link

codecov-commenter commented Dec 1, 2022

Codecov Report

Base: 44.30% // Head: 44.31% // Increases project coverage by +0.00% 🎉

Coverage data is based on head (b6a0e53) compared to base (3fb806c).
Patch coverage: 42.85% of modified lines in pull request are covered.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5270   +/-   ##
=======================================
  Coverage   44.30%   44.31%           
=======================================
  Files         175      175           
  Lines       13898    13929   +31     
=======================================
+ Hits         6158     6173   +15     
- Misses       7740     7756   +16     
Impacted Files Coverage Δ
components/viaduct/src/backend.rs 70.58% <0.00%> (-9.42%) ⬇️
components/viaduct/src/backend/ffi.rs 0.00% <0.00%> (ø)
components/viaduct/src/settings.rs 50.00% <85.71%> (+50.00%) ⬆️
components/support/viaduct-reqwest/src/lib.rs 61.42% <90.00%> (+4.76%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@badboy badboy self-requested a review December 1, 2022 09:24
Copy link
Member

@badboy badboy left a comment

Choose a reason for hiding this comment

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

Small nits, but I like how simple and clean this is.

Comment on lines 9 to 15
## Viaduct

### What's New
- Allow viaduct to make requests to the android emulator loopback address via
a new viaduct_allow_android_emulator_loopback() (in Rust)/allowAndroidEmulatorLoopback() (in Kotlin)
([#5270](https://github.com/mozilla/application-services/pull/5270))

Copy link
Member

Choose a reason for hiding this comment

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

This should be moved below line 20 (outside of the <!-- ... --> comment block)

@@ -11,10 +11,12 @@ crate-type = ["lib"]

[dependencies]
url = "2.1" # mozilla-central can't yet take 2.2 (see bug 1734538)
lazy_static = "1.4"
Copy link
Member

Choose a reason for hiding this comment

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

viaduct now uses both lazy_static and once_cell.
As a followup this should be trimmed down to only one (probably once_cell as the more "modern" variant and the API that's gonna get into libstd eventually)

Copy link
Member

Choose a reason for hiding this comment

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

Ah, this is of course the first usage of lazy_static here. Maybe just use once_cell then? We can migrate lazy_static in viaduct-reqwest later.

@@ -54,6 +54,17 @@ object RustHttpConfig {
}
}

/** Allows connections to the hard-coded address the Android Emulator uses for
* localhost (ie, http://10.0.2.2) - if you don't call this, viaduct will fail to
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* localhost (ie, http://10.0.2.2) - if you don't call this, viaduct will fail to
* the host's localhost (ie, http://10.0.2.2) - if you don't call this, viaduct will fail to

or something like that? Or leave out localhost and call it the host machine?

@mhammond mhammond force-pushed the viaduct-android-localhost branch from 6d3c24f to 0a9d36b Compare December 1, 2022 22:48
Viaduct itself gets the ability to allow exactly 1 arbitrary address to
be connected to which isn't a https:// URL, but the FFI adds an android
specific function which hard-codes the accepted address.
@mhammond mhammond force-pushed the viaduct-android-localhost branch from 0a9d36b to b6a0e53 Compare December 1, 2022 22:49
@mhammond
Copy link
Member Author

mhammond commented Dec 1, 2022

Thanks! Applied all suggestions and even made viaduct-request use once_cell instead of lazy_static!

@mhammond mhammond merged commit b813f02 into mozilla:main Dec 1, 2022
@mhammond mhammond deleted the viaduct-android-localhost branch December 1, 2022 23:08
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.

3 participants