|
| 1 | +using System.Diagnostics; |
| 2 | +using System.Net; |
| 3 | +using System.Threading.Tasks; |
| 4 | +using Titanium.Web.Proxy.EventArguments; |
| 5 | +using Titanium.Web.Proxy.Extensions; |
| 6 | + |
| 7 | +namespace Titanium.Web.Proxy.Models |
| 8 | +{ |
| 9 | + /// <summary> |
| 10 | + /// A proxy end point client is not aware of. |
| 11 | + /// Useful when requests are redirected to this proxy end point through port forwarding via router. |
| 12 | + /// </summary> |
| 13 | + [DebuggerDisplay("SOCKS: {IpAddress}:{Port}")] |
| 14 | + public class SocksProxyEndPoint : TransparentBaseProxyEndPoint |
| 15 | + { |
| 16 | + /// <summary> |
| 17 | + /// Initialize a new instance. |
| 18 | + /// </summary> |
| 19 | + /// <param name="ipAddress">Listening Ip address.</param> |
| 20 | + /// <param name="port">Listening port.</param> |
| 21 | + /// <param name="decryptSsl">Should we decrypt ssl?</param> |
| 22 | + public SocksProxyEndPoint(IPAddress ipAddress, int port, bool decryptSsl = true) : base(ipAddress, port, |
| 23 | + decryptSsl) |
| 24 | + { |
| 25 | + GenericCertificateName = "localhost"; |
| 26 | + } |
| 27 | + |
| 28 | + /// <summary> |
| 29 | + /// Name of the Certificate need to be sent (same as the hostname we want to proxy). |
| 30 | + /// This is valid only when UseServerNameIndication is set to false. |
| 31 | + /// </summary> |
| 32 | + public override string GenericCertificateName { get; set; } |
| 33 | + |
| 34 | + /// <summary> |
| 35 | + /// Before Ssl authentication this event is fired. |
| 36 | + /// </summary> |
| 37 | + public event AsyncEventHandler<BeforeSslAuthenticateEventArgs>? BeforeSslAuthenticate; |
| 38 | + |
| 39 | + internal override async Task InvokeBeforeSslAuthenticate(ProxyServer proxyServer, |
| 40 | + BeforeSslAuthenticateEventArgs connectArgs, ExceptionHandler exceptionFunc) |
| 41 | + { |
| 42 | + if (BeforeSslAuthenticate != null) |
| 43 | + { |
| 44 | + await BeforeSslAuthenticate.InvokeAsync(proxyServer, connectArgs, exceptionFunc); |
| 45 | + } |
| 46 | + } |
| 47 | + } |
| 48 | +} |
0 commit comments