-
-
Notifications
You must be signed in to change notification settings - Fork 276
Add proxy support #2192
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
Merged
Add proxy support #2192
Changes from all commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
5112a04
string based proxy config
denrase 0eae983
add Proxy class
denrase f65672d
Use proxy class, Sync to android native
denrase eac8ee6
test io client provider
denrase 8ec2844
rename file
denrase 33272ed
Merge branch 'main' into feat/proxy-setup
denrase 301fd22
update docs
denrase 1941696
fix port parsing
denrase 8dc9f47
Use client provider in SpotlightHttpTransport
denrase 488007a
check if HttpClientBasicCredentials are set
denrase 56997b9
fix init native sdk tests
denrase 101f8fa
add cl entry and format kotlin code
denrase 97a1c79
fix multilin issue
denrase 8ca76d9
use toUpperCase(Locale.ROOT)
denrase d8a516d
fix newlines
denrase 569400a
fix newline
denrase 0d11ed6
format
denrase 8e5baf1
format flutter
denrase 6b2a062
log parse error
denrase a8ae146
format by running ktlint locally
denrase 8452d39
import log
denrase c1ece00
Merge branch 'main' into feat/proxy-setup
denrase 2e9926e
fix cl
denrase 3b50810
Merge branch 'main' into feat/proxy-setup
denrase ef70ca4
fix cl
denrase a7a04d9
fix typo
denrase 4d97570
mark client providers as internal
denrase 16c6795
rename Proxy to SentryProxy
denrase 67c474f
configure url session on ios
denrase acb2658
update changelog entry
denrase 4bbf911
run swiftlingt —autocorrect
denrase f48b52d
run swiftling —autocorrect
denrase 89c0915
run format
denrase b71613a
Merge branch 'main' into feat/proxy-setup
buenaflor c5b9a93
Merge branch 'main' into feat/proxy-setup
denrase b53e604
fix cl and add log
denrase c240fc7
update docs
denrase 921b4d6
Merge branch 'main' into feat/proxy-setup
denrase 242cdb1
Merge branch 'main' into feat/proxy-setup
denrase 3c4c717
Merge branch 'main' into feat/proxy-setup
denrase 4e25d10
disable swiftlint rules
denrase bd279c7
fix swiftlint issues
denrase File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,27 @@ | |
| appRunner: () => runApp(MyApp()), | ||
| ); | ||
| ``` | ||
| - Add proxy support ([#2192](https://github.com/getsentry/sentry-dart/pull/2192)) | ||
| - Configure a `SentryProxy` object and set it on `SentryFlutter.init` | ||
| ```dart | ||
| import 'package:flutter/widgets.dart'; | ||
| import 'package:sentry_flutter/sentry_flutter.dart'; | ||
|
|
||
| Future<void> main() async { | ||
| await SentryFlutter.init( | ||
| (options) { | ||
| options.dsn = 'https://[email protected]/add-your-dsn-here'; | ||
| options.proxy = SentryProxy( | ||
| type: SenryProxyType.http, | ||
| host: 'localhost', | ||
| port: 8080, | ||
| ); | ||
| }, | ||
| // Init your App. | ||
| appRunner: () => runApp(MyApp()), | ||
| ); | ||
| } | ||
| ``` | ||
|
|
||
| ### Improvements | ||
|
|
||
|
|
@@ -72,7 +93,7 @@ SentryFlutter.init((options) => | |
| - This allows viewing the correct dart formatted raw stacktrace in the Sentry UI | ||
| - Support `ignoredExceptionsForType` ([#2150](https://github.com/getsentry/sentry-dart/pull/2150)) | ||
| - Filter out exception types by calling `SentryOptions.addExceptionFilterForType(Type exceptionType)` | ||
|
|
||
| ### Fixes | ||
|
|
||
| - Disable sff & frame delay detection on web, linux and windows ([#2182](https://github.com/getsentry/sentry-dart/pull/2182)) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import 'package:meta/meta.dart'; | ||
| import 'package:http/http.dart'; | ||
|
|
||
| import '../sentry_options.dart'; | ||
|
|
||
| @internal | ||
| ClientProvider getClientProvider() { | ||
| return ClientProvider(); | ||
| } | ||
|
|
||
| @internal | ||
| class ClientProvider { | ||
| Client getClient(SentryOptions options) { | ||
| return Client(); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| import 'dart:io'; | ||
|
|
||
| import 'package:http/http.dart'; | ||
| import 'package:http/io_client.dart'; | ||
| import 'package:meta/meta.dart'; | ||
|
|
||
| import '../protocol.dart'; | ||
| import '../protocol/sentry_proxy.dart'; | ||
| import '../sentry_options.dart'; | ||
| import 'client_provider.dart'; | ||
|
|
||
| @internal | ||
| ClientProvider getClientProvider() { | ||
| return IoClientProvider( | ||
| () { | ||
| return HttpClient(); | ||
| }, | ||
| (user, pass) { | ||
| return HttpClientBasicCredentials(user, pass); | ||
| }, | ||
| ); | ||
| } | ||
|
|
||
| @internal | ||
| class IoClientProvider implements ClientProvider { | ||
| final HttpClient Function() _httpClient; | ||
| final HttpClientCredentials Function(String, String) _httpClientCredentials; | ||
|
|
||
| IoClientProvider(this._httpClient, this._httpClientCredentials); | ||
|
|
||
| @override | ||
| Client getClient(SentryOptions options) { | ||
| final proxy = options.proxy; | ||
| if (proxy == null) { | ||
| return Client(); | ||
| } | ||
| final pac = proxy.toPacString(); | ||
| if (proxy.type == SentryProxyType.socks) { | ||
| options.logger( | ||
| SentryLevel.warning, | ||
| "Setting proxy '$pac' is not supported.", | ||
| ); | ||
| return Client(); | ||
| } | ||
| options.logger( | ||
| SentryLevel.info, | ||
| "Setting proxy '$pac'", | ||
| ); | ||
| final httpClient = _httpClient(); | ||
| httpClient.findProxy = (url) => pac; | ||
|
|
||
| final host = proxy.host; | ||
| final port = proxy.port; | ||
| final user = proxy.user; | ||
| final pass = proxy.pass; | ||
|
|
||
| if (host != null && port != null && user != null && pass != null) { | ||
| httpClient.addProxyCredentials( | ||
| host, | ||
| port, | ||
| '', | ||
| _httpClientCredentials(user, pass), | ||
| ); | ||
| } | ||
| return IOClient(httpClient); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| class SentryProxy { | ||
| final SentryProxyType type; | ||
| final String? host; | ||
| final int? port; | ||
| final String? user; | ||
| final String? pass; | ||
|
|
||
| SentryProxy({required this.type, this.host, this.port, this.user, this.pass}); | ||
|
|
||
| String toPacString() { | ||
| String type = 'DIRECT'; | ||
| switch (this.type) { | ||
| case SentryProxyType.direct: | ||
| return 'DIRECT'; | ||
| case SentryProxyType.http: | ||
| type = 'PROXY'; | ||
| break; | ||
| case SentryProxyType.socks: | ||
| type = 'SOCKS'; | ||
| break; | ||
| } | ||
| if (host != null && port != null) { | ||
| return '$type $host:$port'; | ||
| } else if (host != null) { | ||
| return '$type $host'; | ||
| } else { | ||
| return 'DIRECT'; | ||
| } | ||
| } | ||
|
|
||
| /// Produces a [Map] that can be serialized to JSON. | ||
| Map<String, dynamic> toJson() { | ||
| return { | ||
| if (host != null) 'host': host, | ||
| if (port != null) 'port': port, | ||
| 'type': type.toString().split('.').last.toUpperCase(), | ||
| if (user != null) 'user': user, | ||
| if (pass != null) 'pass': pass, | ||
| }; | ||
| } | ||
|
|
||
| SentryProxy copyWith({ | ||
| String? host, | ||
| int? port, | ||
| SentryProxyType? type, | ||
| String? user, | ||
| String? pass, | ||
| }) => | ||
| SentryProxy( | ||
| host: host ?? this.host, | ||
| port: port ?? this.port, | ||
| type: type ?? this.type, | ||
| user: user ?? this.user, | ||
| pass: pass ?? this.pass, | ||
| ); | ||
| } | ||
|
|
||
| enum SentryProxyType { | ||
| direct, | ||
| http, | ||
| socks; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.