From 9960a72f23b130b1719f66e278a7631c3e9b0373 Mon Sep 17 00:00:00 2001 From: Dylan Brasseur <103190315+dbrasseur-aneo@users.noreply.github.com> Date: Wed, 29 May 2024 17:44:59 +0200 Subject: [PATCH] Added proxy settings to properties --- Client/src/Common/Properties.cs | 37 ++++++++++++++++--- .../Submitter/ClientServiceConnector.cs | 5 +++ 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/Client/src/Common/Properties.cs b/Client/src/Common/Properties.cs index 727eb2a5..214a9fb3 100644 --- a/Client/src/Common/Properties.cs +++ b/Client/src/Common/Properties.cs @@ -1,18 +1,19 @@ // This file is part of the ArmoniK project -// -// Copyright (C) ANEO, 2021-2023. All rights reserved. -// +// +// Copyright (C) ANEO, 2021-$CURRENT_YEAR$. All rights reserved. +// // Licensed under the Apache License, Version 2.0 (the "License") // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +// using System; @@ -50,6 +51,9 @@ public class Properties private const string SectionClientKey = "ClientKey"; private const string SectionClientCertP12 = "ClientP12"; private const string SectionTargetNameOverride = "EndpointNameOverride"; + private const string SectionProxy = "Proxy"; + private const string SectionProxyUsername = "ProxyUsername"; + private const string SectionProxyPassword = "ProxyPassword"; private const string SectionRetryInitialBackoff = "RetryInitialBackoff"; private const string SectionRetryBackoffMultiplier = "RetryBackoffMultiplier"; @@ -137,7 +141,10 @@ public Properties(IConfiguration configuration, bool? sslValidation = null, TimeSpan retryInitialBackoff = new(), double retryBackoffMultiplier = 0, - TimeSpan retryMaxBackoff = new()) + TimeSpan retryMaxBackoff = new(), + string? proxy = null, + string? proxyUsername = null, + string? proxyPassword = null) { TaskOptions = options; Configuration = configuration; @@ -186,6 +193,9 @@ public Properties(IConfiguration configuration, ClientCertFilePem = clientCertFilePem ?? sectionGrpc[SectionClientCert] ?? string.Empty; ClientKeyFilePem = clientKeyFilePem ?? sectionGrpc[SectionClientKey] ?? string.Empty; ClientP12File = clientP12 ?? sectionGrpc[SectionClientCertP12] ?? string.Empty; + Proxy = proxy ?? sectionGrpc[SectionProxy] ?? string.Empty; + ProxyUsername = proxyUsername ?? sectionGrpc[SectionProxyUsername] ?? string.Empty; + ProxyPassword = proxyPassword ?? sectionGrpc[SectionProxyPassword] ?? string.Empty; if (retryInitialBackoff != TimeSpan.Zero) { @@ -369,4 +379,19 @@ public string ConnectionString /// Max backoff for retries /// public TimeSpan RetryMaxBackoff { get; } = TimeSpan.FromSeconds(30); + + /// + /// Proxy URL + /// + public string Proxy { get; set; } + + /// + /// Username for the proxy + /// + public string ProxyUsername { get; set; } + + /// + /// Password for the proxy + /// + public string ProxyPassword { get; set; } } diff --git a/Client/src/Common/Submitter/ClientServiceConnector.cs b/Client/src/Common/Submitter/ClientServiceConnector.cs index a5d19be6..641bbcc0 100644 --- a/Client/src/Common/Submitter/ClientServiceConnector.cs +++ b/Client/src/Common/Submitter/ClientServiceConnector.cs @@ -45,6 +45,11 @@ public static ChannelPool ControlPlaneConnectionPool(Properties properties, KeyPem = properties.ClientKeyFilePem, Endpoint = properties.ControlPlaneUri.ToString(), OverrideTargetName = properties.TargetNameOverride, + BackoffMultiplier = properties.RetryBackoffMultiplier, + InitialBackOff = properties.RetryInitialBackoff, + Proxy = properties.Proxy, + ProxyUsername = properties.ProxyUsername, + ProxyPassword = properties.ProxyPassword, }; return new ChannelPool(() => GrpcChannelFactory.CreateChannel(options,