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

Support proxy username and password #2044

Merged
merged 1 commit into from
Jan 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ public static class Proxy {

public String host;
public int port = 80;
public String username;
public String password;
}

public static class PreviewConfiguration {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ public class LazyHttpClient implements HttpClient {
public static volatile CountDownLatch safeToInitLatch;
public static volatile String proxyHost;
public static volatile Integer proxyPortNumber;
public static volatile String proxyUsername;
public static volatile String proxyPassword;

public static HttpClient getInstance() {
return INSTANCE;
Expand Down Expand Up @@ -109,9 +111,13 @@ private static HttpClient init() {

NettyAsyncHttpClientBuilder builder = new NettyAsyncHttpClientBuilder();
if (proxyHost != null && proxyPortNumber != null) {
builder.proxy(
ProxyOptions proxyOptions =
new ProxyOptions(
ProxyOptions.Type.HTTP, new InetSocketAddress(proxyHost, proxyPortNumber)));
ProxyOptions.Type.HTTP, new InetSocketAddress(proxyHost, proxyPortNumber));
if (proxyUsername != null) {
proxyOptions.setCredentials(proxyUsername, proxyPassword);
}
builder.proxy(proxyOptions);
}
// keeping the thread count to 1 keeps the number of 16mb io.netty.buffer.PoolChunk to 1 also
return builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ private static AppIdSupplier start(Instrumentation instrumentation) {
if (config.proxy.host != null) {
LazyHttpClient.proxyHost = config.proxy.host;
LazyHttpClient.proxyPortNumber = config.proxy.port;
LazyHttpClient.proxyUsername = config.proxy.username;
LazyHttpClient.proxyPassword = config.proxy.password;
}

List<MetricFilter> metricFilters =
Expand Down