@@ -205,7 +205,8 @@ public Func<SessionEventArgs, Task<ExternalProxy>> GetCustomUpStreamHttpsProxyFu
205205 /// <summary>
206206 /// List of supported Ssl versions
207207 /// </summary>
208- public SslProtocols SupportedSslProtocols { get ; set ; } = SslProtocols . Tls | SslProtocols . Tls11 | SslProtocols . Tls12 | SslProtocols . Ssl3 ;
208+ public SslProtocols SupportedSslProtocols { get ; set ; } = SslProtocols . Tls
209+ | SslProtocols . Tls11 | SslProtocols . Tls12 | SslProtocols . Ssl3 ;
209210
210211 /// <summary>
211212 /// Constructor
@@ -242,7 +243,8 @@ public ProxyServer(string rootCertificateName, string rootCertificateIssuerName)
242243 /// <param name="endPoint"></param>
243244 public void AddEndPoint ( ProxyEndPoint endPoint )
244245 {
245- if ( ProxyEndPoints . Any ( x => x . IpAddress . Equals ( endPoint . IpAddress ) && endPoint . Port != 0 && x . Port == endPoint . Port ) )
246+ if ( ProxyEndPoints . Any ( x => x . IpAddress . Equals ( endPoint . IpAddress )
247+ && endPoint . Port != 0 && x . Port == endPoint . Port ) )
246248 {
247249 throw new Exception ( "Cannot add another endpoint to same port & ip address" ) ;
248250 }
@@ -281,6 +283,11 @@ public void RemoveEndPoint(ProxyEndPoint endPoint)
281283 /// <param name="endPoint"></param>
282284 public void SetAsSystemHttpProxy ( ExplicitProxyEndPoint endPoint )
283285 {
286+ if ( RunTime . IsRunningOnMono ( ) )
287+ {
288+ throw new Exception ( "Mono Runtime do not support system proxy settings." ) ;
289+ }
290+
284291 ValidateEndPointAsSystemProxy ( endPoint ) ;
285292
286293 //clear any settings previously added
@@ -304,6 +311,11 @@ public void SetAsSystemHttpProxy(ExplicitProxyEndPoint endPoint)
304311 /// <param name="endPoint"></param>
305312 public void SetAsSystemHttpsProxy ( ExplicitProxyEndPoint endPoint )
306313 {
314+ if ( RunTime . IsRunningOnMono ( ) )
315+ {
316+ throw new Exception ( "Mono Runtime do not support system proxy settings." ) ;
317+ }
318+
307319 ValidateEndPointAsSystemProxy ( endPoint ) ;
308320
309321 if ( ! endPoint . EnableSsl )
@@ -312,14 +324,17 @@ public void SetAsSystemHttpsProxy(ExplicitProxyEndPoint endPoint)
312324 }
313325
314326 //clear any settings previously added
315- ProxyEndPoints . OfType < ExplicitProxyEndPoint > ( ) . ToList ( ) . ForEach ( x => x . IsSystemHttpsProxy = false ) ;
316-
327+ ProxyEndPoints . OfType < ExplicitProxyEndPoint > ( )
328+ . ToList ( )
329+ . ForEach ( x => x . IsSystemHttpsProxy = false ) ;
317330
318331 //If certificate was trusted by the machine
319332 if ( certValidated )
320333 {
321334 systemProxySettingsManager . SetHttpsProxy (
322- Equals ( endPoint . IpAddress , IPAddress . Any ) | Equals ( endPoint . IpAddress , IPAddress . Loopback ) ? "127.0.0.1" : endPoint . IpAddress . ToString ( ) ,
335+ Equals ( endPoint . IpAddress , IPAddress . Any ) |
336+ Equals ( endPoint . IpAddress , IPAddress . Loopback ) ?
337+ "127.0.0.1" : endPoint . IpAddress . ToString ( ) ,
323338 endPoint . Port ) ;
324339 }
325340
@@ -329,14 +344,20 @@ public void SetAsSystemHttpsProxy(ExplicitProxyEndPoint endPoint)
329344#if ! DEBUG
330345 firefoxProxySettingsManager . AddFirefox ( ) ;
331346#endif
332- Console . WriteLine ( "Set endpoint at Ip {0} and port: {1} as System HTTPS Proxy" , endPoint . IpAddress , endPoint . Port ) ;
347+ Console . WriteLine ( "Set endpoint at Ip {0} and port: {1} as System HTTPS Proxy" ,
348+ endPoint . IpAddress , endPoint . Port ) ;
333349 }
334350
335351 /// <summary>
336352 /// Remove any HTTP proxy setting of current machien
337353 /// </summary>
338354 public void DisableSystemHttpProxy ( )
339355 {
356+ if ( RunTime . IsRunningOnMono ( ) )
357+ {
358+ throw new Exception ( "Mono Runtime do not support system proxy settings." ) ;
359+ }
360+
340361 systemProxySettingsManager . RemoveHttpProxy ( ) ;
341362 }
342363
@@ -345,6 +366,11 @@ public void DisableSystemHttpProxy()
345366 /// </summary>
346367 public void DisableSystemHttpsProxy ( )
347368 {
369+ if ( RunTime . IsRunningOnMono ( ) )
370+ {
371+ throw new Exception ( "Mono Runtime do not support system proxy settings." ) ;
372+ }
373+
348374 systemProxySettingsManager . RemoveHttpsProxy ( ) ;
349375 }
350376
@@ -353,6 +379,11 @@ public void DisableSystemHttpsProxy()
353379 /// </summary>
354380 public void DisableAllSystemProxies ( )
355381 {
382+ if ( RunTime . IsRunningOnMono ( ) )
383+ {
384+ throw new Exception ( "Mono Runtime do not support system proxy settings." ) ;
385+ }
386+
356387 systemProxySettingsManager . DisableAllProxy ( ) ;
357388 }
358389
@@ -372,7 +403,7 @@ public void Start()
372403
373404 certValidated = certificateCacheManager . CreateTrustedRootCertificate ( ) ;
374405
375- if ( TrustRootCertificate )
406+ if ( TrustRootCertificate )
376407 {
377408 //current user
378409 certificateCacheManager
@@ -383,7 +414,8 @@ public void Start()
383414 . TrustRootCertificate ( StoreLocation . LocalMachine , exceptionFunc ) ;
384415 }
385416
386- if ( ForwardToUpstreamGateway && GetCustomUpStreamHttpProxyFunc == null && GetCustomUpStreamHttpsProxyFunc == null )
417+ if ( ForwardToUpstreamGateway && GetCustomUpStreamHttpProxyFunc == null
418+ && GetCustomUpStreamHttpsProxyFunc == null )
387419 {
388420 GetCustomUpStreamHttpProxyFunc = GetSystemUpStreamProxy ;
389421 GetCustomUpStreamHttpsProxyFunc = GetSystemUpStreamProxy ;
0 commit comments