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

Feature/ubf adds proxy and dev setting #90

Merged
merged 6 commits into from
May 14, 2024

Conversation

choli
Copy link
Contributor

@choli choli commented May 10, 2024

Summary by CodeRabbit

  • New Features

    • Added a new section for "Proxy settings" in the DevToolsView struct, including toggles and text fields for proxy configuration.
    • Introduced new user defaults for enabling networking proxy settings, setting proxy host, and setting proxy port.
  • Enhancements

    • Updated UBURLSessionConfiguration with a proxy property and methods for proxy configuration.
  • Documentation

    • Updated user defaults documentation to include new settings for networking proxy configurations.

Copy link

coderabbitai bot commented May 10, 2024

Walkthrough

The recent updates focus on enhancing proxy configuration capabilities within the UBDevTools and UBFoundation modules. These changes introduce new features for setting up proxies, managing server trust, and seamlessly integrating these settings into networking configurations, enhancing security and flexibility in data transmission.

Changes

File Path Changes Summary
.../DevTools.swift, .../DevToolsView.swift Added a new section for "Proxy settings" in the DevToolsView struct, including toggles and text fields for proxy configuration. Introduced new user defaults for enabling networking proxy settings, setting proxy host, and setting proxy port.
.../ProxyDevTool.swift, .../Networking/UBURLSession+Proxy.swift Introduced classes, extensions, and protocols for proxy management in networking.
.../Networking/HTTPHeaderField.swift, .../Networking/UBURLSession+Configuration.swift Enhanced networking headers and session configuration to support proxy settings.

🐰✨
A hop through code, a leap through net,
With proxy settings, our needs are met.
Secure and swift, the data shall flow,
Thanks to the updates, we're good to go!
🌐🔐


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between ad0e3f4 and 7a795f2.
Files selected for processing (6)
  • Sources/UBDevTools/DevTools.swift (2 hunks)
  • Sources/UBDevTools/DevToolsView.swift (2 hunks)
  • Sources/UBDevTools/ProxyDevTool.swift (1 hunks)
  • Sources/UBFoundation/Networking/HTTPHeaderField.swift (1 hunks)
  • Sources/UBFoundation/Networking/UBURLSession+Configuration.swift (2 hunks)
  • Sources/UBFoundation/Networking/UBURLSession+Proxy.swift (1 hunks)
Files skipped from review due to trivial changes (1)
  • Sources/UBFoundation/Networking/HTTPHeaderField.swift
Additional comments not posted (7)
Sources/UBFoundation/Networking/UBURLSession+Proxy.swift (1)

10-19: Well-defined protocol for proxy configuration in URL sessions.

Sources/UBDevTools/ProxyDevTool.swift (2)

11-18: Proper use of singleton pattern and method implementation in UBDevToolsProxyHelper.


20-26: Proxy struct correctly implements the proxy configuration protocol and extends functionality with domain-specific settings.

Sources/UBDevTools/DevTools.swift (1)

46-50: Method setupProxySettings correctly integrates with UBDevToolsProxyHelper and passes parameters effectively.

Sources/UBFoundation/Networking/UBURLSession+Configuration.swift (2)

36-54: Enhancements to init method correctly integrate proxy settings into the session configuration.


Line range hint 57-89: Enhancements to applyDefaultHeaders method correctly handle proxy authorization headers based on provided credentials.

Sources/UBDevTools/DevToolsView.swift (1)

153-161: New UI elements for proxy settings in DevToolsView provide a user-friendly way to configure and enable proxy settings.

@maerki maerki requested review from maerki and zenokoller May 13, 2024 12:27
Copy link
Contributor

@zenokoller zenokoller left a comment

Choose a reason for hiding this comment

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

Sieht gut aus; wir haben im Weekly noch überlegt, dass wir eventuell eine Lösung brauchen, dass man das nicht 1x anschaltet und es dann immer auf dem Proxy bleibt. Wir haben folgende Varianten diskutiert:

  • Proxy am nächsten Tag zurücksetzen (z.B. proxyEnabledDate setzen und beim nächsten App start prüfen und ggf. zurücksetzen)
  • Visueller Indicator, dass Proxy drin ist
    Was meinst du?

@@ -150,6 +150,15 @@ public struct DevToolsView: View {
CacheDevTools.clearCache(cache)
}
}
Section(header: Text("Proxy settings")) {
Toggle("Start Proxy", isOn: Binding(get: { Self.enableNetworkingProxySettings }, set: { Self.enableNetworkingProxySettings = $0 }))
Copy link
Contributor

Choose a reason for hiding this comment

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

Den Restart brauchen wir hier nicht, weil man sowieso Save and exit klickt, oder?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Genau, hatte ich ursprünglich drin, bis ich den "Speichern" Button gesehen habe.

@@ -42,6 +43,12 @@ public enum UBDevTools {
CacheDevTools.additionalCaches = caches
}

public static func setupProxySettings(host: String, port: Int, username: String?, password: String?, proxiedDomains: [String]? = nil) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Hier könnte man noch die default Argumente setzen (proxy.ubique.rocks, etc) oder als doc comments hinzufügen

Copy link
Contributor

Choose a reason for hiding this comment

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

Und dass man die friendlyDefaultSession brauchen muss. Sonst brauchen wir ja häufig die sharedSession

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Default values würde ich nicht, das ist ein öffentliches Repo. Ich mache mal ein bisschen Docs rein.

@choli choli force-pushed the feature/UBF-adds-proxy-and-dev-setting branch from 7a795f2 to c778731 Compare May 13, 2024 15:47
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

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 7a795f2 and c778731.
Files selected for processing (6)
  • Sources/UBDevTools/DevTools.swift (2 hunks)
  • Sources/UBDevTools/DevToolsView.swift (2 hunks)
  • Sources/UBDevTools/ProxyDevTool.swift (1 hunks)
  • Sources/UBFoundation/Networking/HTTPHeaderField.swift (1 hunks)
  • Sources/UBFoundation/Networking/UBURLSession+Configuration.swift (2 hunks)
  • Sources/UBFoundation/Networking/UBURLSession+Proxy.swift (1 hunks)
Files skipped from review as they are similar to previous changes (6)
  • Sources/UBDevTools/DevTools.swift
  • Sources/UBDevTools/DevToolsView.swift
  • Sources/UBDevTools/ProxyDevTool.swift
  • Sources/UBFoundation/Networking/HTTPHeaderField.swift
  • Sources/UBFoundation/Networking/UBURLSession+Configuration.swift
  • Sources/UBFoundation/Networking/UBURLSession+Proxy.swift

@@ -188,4 +197,13 @@ public struct DevToolsView: View {

@UBUserDefault(key: "io.openmobilemaps.debug.rastertiles.enabled", defaultValue: false)
public static var mapRasterTilesDebugOverlay: Bool

@UBUserDefault(key: "ubkit.devtools.proxy.enabled.key", defaultValue: false)
public static var enableNetworkingProxySettings: Bool
Copy link
Contributor

Choose a reason for hiding this comment

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

Damit man das nicht aus Versehen für immer laufe lässt, zwei Vorschläge:

  • Lösung 1: Statt Bool ein Start-Date speichern und enableNetworkingProxySettings als startDate <24h definieren
  • Lösung 2: Einen Badge, Banner als Overlay über die App legen

Copy link

Quality Gate Passed Quality Gate passed

Issues
8 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

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

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between c778731 and 0fb59c4.
Files selected for processing (1)
  • Sources/UBDevTools/DevToolsView.swift (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • Sources/UBDevTools/DevToolsView.swift

@choli choli merged commit 6714c30 into main May 14, 2024
3 checks passed
@choli choli deleted the feature/UBF-adds-proxy-and-dev-setting branch May 14, 2024 15:34
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