diff --git a/docs/api/Titanium.Web.Proxy.EventArguments.SessionEventArgs.html b/docs/api/Titanium.Web.Proxy.EventArguments.SessionEventArgs.html index ccb3ceb88..c40bbbd7e 100644 --- a/docs/api/Titanium.Web.Proxy.EventArguments.SessionEventArgs.html +++ b/docs/api/Titanium.Web.Proxy.EventArguments.SessionEventArgs.html @@ -155,6 +155,9 @@
Inherited Members
SessionEventArgsBase.IsTransparent
+
+ SessionEventArgsBase.IsSocks +
SessionEventArgsBase.Exception
diff --git a/docs/api/Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.html b/docs/api/Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.html index d93b876ef..a61efe48e 100644 --- a/docs/api/Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.html +++ b/docs/api/Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.html @@ -390,7 +390,7 @@
Property Value
Improve this Doc - View Source + View Source

Exception

@@ -478,6 +478,37 @@
Property Value
+ + | + Improve this Doc + + + View Source + + +

IsSocks

+

Is this a SOCKS endpoint?

+
+
+
Declaration
+
+
public bool IsSocks { get; }
+
+
Property Value
+ + + + + + + + + + + + + +
TypeDescription
Boolean
| Improve this Doc @@ -702,7 +733,7 @@

Methods Improve this Doc - View Source + View Source

Dispose()

@@ -718,7 +749,7 @@
Declaration
Improve this Doc
- View Source + View Source

TerminateSession()

@@ -736,7 +767,7 @@

Events Improve this Doc - View Source + View Source

DataReceived

Fired when data is received within this session from client/server.

@@ -766,7 +797,7 @@
Event Type
Improve this Doc - View Source + View Source

DataSent

Fired when data is sent within this session to server/client.

diff --git a/docs/api/Titanium.Web.Proxy.EventArguments.TunnelConnectSessionEventArgs.html b/docs/api/Titanium.Web.Proxy.EventArguments.TunnelConnectSessionEventArgs.html index 9d1257b4a..e983805b8 100644 --- a/docs/api/Titanium.Web.Proxy.EventArguments.TunnelConnectSessionEventArgs.html +++ b/docs/api/Titanium.Web.Proxy.EventArguments.TunnelConnectSessionEventArgs.html @@ -152,6 +152,9 @@
Inherited Members
SessionEventArgsBase.IsTransparent
+
+ SessionEventArgsBase.IsSocks +
SessionEventArgsBase.Exception
diff --git a/docs/index.json b/docs/index.json index 0f395cfdf..5d32a1e71 100644 --- a/docs/index.json +++ b/docs/index.json @@ -32,17 +32,17 @@ "api/Titanium.Web.Proxy.EventArguments.SessionEventArgs.html": { "href": "api/Titanium.Web.Proxy.EventArguments.SessionEventArgs.html", "title": "Class SessionEventArgs | Titanium Web Proxy", - "keywords": "Class SessionEventArgs Holds info related to a single proxy session (single request/response sequence). A proxy session is bounded to a single connection from client. A proxy session ends when client terminates connection to proxy or when server terminates connection from proxy. Inheritance Object SessionEventArgsBase SessionEventArgs Implements IDisposable Inherited Members SessionEventArgsBase.ClientConnectionId SessionEventArgsBase.ServerConnectionId SessionEventArgsBase.BufferPool SessionEventArgsBase.ExceptionFunc SessionEventArgsBase.TimeLine SessionEventArgsBase.UserData SessionEventArgsBase.EnableWinAuth SessionEventArgsBase.IsHttps SessionEventArgsBase.ClientLocalEndPoint SessionEventArgsBase.ClientRemoteEndPoint SessionEventArgsBase.ClientEndPoint SessionEventArgsBase.HttpClient SessionEventArgsBase.WebSession SessionEventArgsBase.CustomUpStreamProxy SessionEventArgsBase.CustomUpStreamProxyUsed SessionEventArgsBase.ProxyEndPoint SessionEventArgsBase.LocalEndPoint SessionEventArgsBase.IsTransparent SessionEventArgsBase.Exception SessionEventArgsBase.DataSent SessionEventArgsBase.DataReceived SessionEventArgsBase.TerminateSession() Namespace : Titanium.Web.Proxy.EventArguments Assembly : Titanium.Web.Proxy.dll Syntax public class SessionEventArgs : SessionEventArgsBase, IDisposable Properties | Improve this Doc View Source IsPromise Is this session a HTTP/2 promise? Declaration public bool IsPromise { get; } Property Value Type Description Boolean | Improve this Doc View Source ReRequest Should we send the request again ? Declaration public bool ReRequest { get; set; } Property Value Type Description Boolean | Improve this Doc View Source WebSocketDecoder Declaration public WebSocketDecoder WebSocketDecoder { get; } Property Value Type Description WebSocketDecoder Methods | Improve this Doc View Source Dispose() Implement any cleanup here Declaration public override void Dispose() Overrides SessionEventArgsBase.Dispose() | Improve this Doc View Source GenericResponse(Byte[], HttpStatusCode, Dictionary, Boolean) Before request is made to server respond with the specified byte[], the specified status to client. And then ignore the request. Declaration public void GenericResponse(byte[] result, HttpStatusCode status, Dictionary headers, bool closeServerConnection = false) Parameters Type Name Description Byte [] result The bytes to sent. HttpStatusCode status The HTTP status code. Dictionary < String , HttpHeader > headers The HTTP headers. Boolean closeServerConnection Close the server connection used by request if any? | Improve this Doc View Source GenericResponse(String, HttpStatusCode, Dictionary, Boolean) Before request is made to server respond with the specified HTML string and the specified status to client. And then ignore the request. Declaration public void GenericResponse(string html, HttpStatusCode status, Dictionary headers = null, bool closeServerConnection = false) Parameters Type Name Description String html The html content. HttpStatusCode status The HTTP status code. Dictionary < String , HttpHeader > headers The HTTP headers. Boolean closeServerConnection Close the server connection used by request if any? | Improve this Doc View Source GetRequestBody(CancellationToken) Gets the request body as bytes. Declaration public Task GetRequestBody(CancellationToken cancellationToken = default(CancellationToken)) Parameters Type Name Description CancellationToken cancellationToken Optional cancellation token for this async task. Returns Type Description Task < Byte []> The body as bytes. | Improve this Doc View Source GetRequestBodyAsString(CancellationToken) Gets the request body as string. Declaration public Task GetRequestBodyAsString(CancellationToken cancellationToken = default(CancellationToken)) Parameters Type Name Description CancellationToken cancellationToken Optional cancellation token for this async task. Returns Type Description Task < String > The body as string. | Improve this Doc View Source GetResponseBody(CancellationToken) Gets the response body as bytes. Declaration public Task GetResponseBody(CancellationToken cancellationToken = default(CancellationToken)) Parameters Type Name Description CancellationToken cancellationToken Optional cancellation token for this async task. Returns Type Description Task < Byte []> The resulting bytes. | Improve this Doc View Source GetResponseBodyAsString(CancellationToken) Gets the response body as string. Declaration public Task GetResponseBodyAsString(CancellationToken cancellationToken = default(CancellationToken)) Parameters Type Name Description CancellationToken cancellationToken Optional cancellation token for this async task. Returns Type Description Task < String > The string body. | Improve this Doc View Source Ok(Byte[], Dictionary, Boolean) Before request is made to server respond with the specified byte[] to client and ignore the request. Declaration public void Ok(byte[] result, Dictionary headers = null, bool closeServerConnection = false) Parameters Type Name Description Byte [] result The html content bytes. Dictionary < String , HttpHeader > headers The HTTP headers. Boolean closeServerConnection Close the server connection used by request if any? | Improve this Doc View Source Ok(String, Dictionary, Boolean) Before request is made to server respond with the specified HTML string to client and ignore the request. Declaration public void Ok(string html, Dictionary headers = null, bool closeServerConnection = false) Parameters Type Name Description String html HTML content to sent. Dictionary < String , HttpHeader > headers HTTP response headers. Boolean closeServerConnection Close the server connection used by request if any? | Improve this Doc View Source Redirect(String, Boolean) Redirect to provided URL. Declaration public void Redirect(string url, bool closeServerConnection = false) Parameters Type Name Description String url The URL to redirect. Boolean closeServerConnection Close the server connection used by request if any? | Improve this Doc View Source Respond(Response, Boolean) Respond with given response object to client. Declaration public void Respond(Response response, bool closeServerConnection = false) Parameters Type Name Description Response response The response object. Boolean closeServerConnection Close the server connection used by request if any? | Improve this Doc View Source SetRequestBody(Byte[]) Sets the request body. Declaration public void SetRequestBody(byte[] body) Parameters Type Name Description Byte [] body The request body bytes. | Improve this Doc View Source SetRequestBodyString(String) Sets the body with the specified string. Declaration public void SetRequestBodyString(string body) Parameters Type Name Description String body The request body string to set. | Improve this Doc View Source SetResponseBody(Byte[]) Set the response body bytes. Declaration public void SetResponseBody(byte[] body) Parameters Type Name Description Byte [] body The body bytes to set. | Improve this Doc View Source SetResponseBodyString(String) Replace the response body with the specified string. Declaration public void SetResponseBodyString(string body) Parameters Type Name Description String body The body string to set. | Improve this Doc View Source TerminateServerConnection() Terminate the connection to server at the end of this HTTP request/response session. Declaration public void TerminateServerConnection() Events | Improve this Doc View Source MultipartRequestPartSent Occurs when multipart request part sent. Declaration public event EventHandler MultipartRequestPartSent Event Type Type Description EventHandler < MultipartRequestPartSentEventArgs > Implements System.IDisposable" + "keywords": "Class SessionEventArgs Holds info related to a single proxy session (single request/response sequence). A proxy session is bounded to a single connection from client. A proxy session ends when client terminates connection to proxy or when server terminates connection from proxy. Inheritance Object SessionEventArgsBase SessionEventArgs Implements IDisposable Inherited Members SessionEventArgsBase.ClientConnectionId SessionEventArgsBase.ServerConnectionId SessionEventArgsBase.BufferPool SessionEventArgsBase.ExceptionFunc SessionEventArgsBase.TimeLine SessionEventArgsBase.UserData SessionEventArgsBase.EnableWinAuth SessionEventArgsBase.IsHttps SessionEventArgsBase.ClientLocalEndPoint SessionEventArgsBase.ClientRemoteEndPoint SessionEventArgsBase.ClientEndPoint SessionEventArgsBase.HttpClient SessionEventArgsBase.WebSession SessionEventArgsBase.CustomUpStreamProxy SessionEventArgsBase.CustomUpStreamProxyUsed SessionEventArgsBase.ProxyEndPoint SessionEventArgsBase.LocalEndPoint SessionEventArgsBase.IsTransparent SessionEventArgsBase.IsSocks SessionEventArgsBase.Exception SessionEventArgsBase.DataSent SessionEventArgsBase.DataReceived SessionEventArgsBase.TerminateSession() Namespace : Titanium.Web.Proxy.EventArguments Assembly : Titanium.Web.Proxy.dll Syntax public class SessionEventArgs : SessionEventArgsBase, IDisposable Properties | Improve this Doc View Source IsPromise Is this session a HTTP/2 promise? Declaration public bool IsPromise { get; } Property Value Type Description Boolean | Improve this Doc View Source ReRequest Should we send the request again ? Declaration public bool ReRequest { get; set; } Property Value Type Description Boolean | Improve this Doc View Source WebSocketDecoder Declaration public WebSocketDecoder WebSocketDecoder { get; } Property Value Type Description WebSocketDecoder Methods | Improve this Doc View Source Dispose() Implement any cleanup here Declaration public override void Dispose() Overrides SessionEventArgsBase.Dispose() | Improve this Doc View Source GenericResponse(Byte[], HttpStatusCode, Dictionary, Boolean) Before request is made to server respond with the specified byte[], the specified status to client. And then ignore the request. Declaration public void GenericResponse(byte[] result, HttpStatusCode status, Dictionary headers, bool closeServerConnection = false) Parameters Type Name Description Byte [] result The bytes to sent. HttpStatusCode status The HTTP status code. Dictionary < String , HttpHeader > headers The HTTP headers. Boolean closeServerConnection Close the server connection used by request if any? | Improve this Doc View Source GenericResponse(String, HttpStatusCode, Dictionary, Boolean) Before request is made to server respond with the specified HTML string and the specified status to client. And then ignore the request. Declaration public void GenericResponse(string html, HttpStatusCode status, Dictionary headers = null, bool closeServerConnection = false) Parameters Type Name Description String html The html content. HttpStatusCode status The HTTP status code. Dictionary < String , HttpHeader > headers The HTTP headers. Boolean closeServerConnection Close the server connection used by request if any? | Improve this Doc View Source GetRequestBody(CancellationToken) Gets the request body as bytes. Declaration public Task GetRequestBody(CancellationToken cancellationToken = default(CancellationToken)) Parameters Type Name Description CancellationToken cancellationToken Optional cancellation token for this async task. Returns Type Description Task < Byte []> The body as bytes. | Improve this Doc View Source GetRequestBodyAsString(CancellationToken) Gets the request body as string. Declaration public Task GetRequestBodyAsString(CancellationToken cancellationToken = default(CancellationToken)) Parameters Type Name Description CancellationToken cancellationToken Optional cancellation token for this async task. Returns Type Description Task < String > The body as string. | Improve this Doc View Source GetResponseBody(CancellationToken) Gets the response body as bytes. Declaration public Task GetResponseBody(CancellationToken cancellationToken = default(CancellationToken)) Parameters Type Name Description CancellationToken cancellationToken Optional cancellation token for this async task. Returns Type Description Task < Byte []> The resulting bytes. | Improve this Doc View Source GetResponseBodyAsString(CancellationToken) Gets the response body as string. Declaration public Task GetResponseBodyAsString(CancellationToken cancellationToken = default(CancellationToken)) Parameters Type Name Description CancellationToken cancellationToken Optional cancellation token for this async task. Returns Type Description Task < String > The string body. | Improve this Doc View Source Ok(Byte[], Dictionary, Boolean) Before request is made to server respond with the specified byte[] to client and ignore the request. Declaration public void Ok(byte[] result, Dictionary headers = null, bool closeServerConnection = false) Parameters Type Name Description Byte [] result The html content bytes. Dictionary < String , HttpHeader > headers The HTTP headers. Boolean closeServerConnection Close the server connection used by request if any? | Improve this Doc View Source Ok(String, Dictionary, Boolean) Before request is made to server respond with the specified HTML string to client and ignore the request. Declaration public void Ok(string html, Dictionary headers = null, bool closeServerConnection = false) Parameters Type Name Description String html HTML content to sent. Dictionary < String , HttpHeader > headers HTTP response headers. Boolean closeServerConnection Close the server connection used by request if any? | Improve this Doc View Source Redirect(String, Boolean) Redirect to provided URL. Declaration public void Redirect(string url, bool closeServerConnection = false) Parameters Type Name Description String url The URL to redirect. Boolean closeServerConnection Close the server connection used by request if any? | Improve this Doc View Source Respond(Response, Boolean) Respond with given response object to client. Declaration public void Respond(Response response, bool closeServerConnection = false) Parameters Type Name Description Response response The response object. Boolean closeServerConnection Close the server connection used by request if any? | Improve this Doc View Source SetRequestBody(Byte[]) Sets the request body. Declaration public void SetRequestBody(byte[] body) Parameters Type Name Description Byte [] body The request body bytes. | Improve this Doc View Source SetRequestBodyString(String) Sets the body with the specified string. Declaration public void SetRequestBodyString(string body) Parameters Type Name Description String body The request body string to set. | Improve this Doc View Source SetResponseBody(Byte[]) Set the response body bytes. Declaration public void SetResponseBody(byte[] body) Parameters Type Name Description Byte [] body The body bytes to set. | Improve this Doc View Source SetResponseBodyString(String) Replace the response body with the specified string. Declaration public void SetResponseBodyString(string body) Parameters Type Name Description String body The body string to set. | Improve this Doc View Source TerminateServerConnection() Terminate the connection to server at the end of this HTTP request/response session. Declaration public void TerminateServerConnection() Events | Improve this Doc View Source MultipartRequestPartSent Occurs when multipart request part sent. Declaration public event EventHandler MultipartRequestPartSent Event Type Type Description EventHandler < MultipartRequestPartSentEventArgs > Implements System.IDisposable" }, "api/Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.html": { "href": "api/Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.html", "title": "Class SessionEventArgsBase | Titanium Web Proxy", - "keywords": "Class SessionEventArgsBase Holds info related to a single proxy session (single request/response sequence). A proxy session is bounded to a single connection from client. A proxy session ends when client terminates connection to proxy or when server terminates connection from proxy. Inheritance Object SessionEventArgsBase SessionEventArgs TunnelConnectSessionEventArgs Implements IDisposable Namespace : Titanium.Web.Proxy.EventArguments Assembly : Titanium.Web.Proxy.dll Syntax public abstract class SessionEventArgsBase : ProxyEventArgsBase, IDisposable Fields | Improve this Doc View Source BufferPool Declaration protected readonly IBufferPool BufferPool Field Value Type Description IBufferPool | Improve this Doc View Source ExceptionFunc Declaration protected readonly ExceptionHandler ExceptionFunc Field Value Type Description ExceptionHandler Properties | Improve this Doc View Source ClientConnectionId Declaration public Guid ClientConnectionId { get; } Property Value Type Description Guid | Improve this Doc View Source ClientEndPoint Declaration [Obsolete(\"Use ClientRemoteEndPoint instead.\")] public IPEndPoint ClientEndPoint { get; } Property Value Type Description IPEndPoint | Improve this Doc View Source ClientLocalEndPoint Client Local End Point. Declaration public IPEndPoint ClientLocalEndPoint { get; } Property Value Type Description IPEndPoint | Improve this Doc View Source ClientRemoteEndPoint Client Remote End Point. Declaration public IPEndPoint ClientRemoteEndPoint { get; } Property Value Type Description IPEndPoint | Improve this Doc View Source CustomUpStreamProxy Gets or sets the custom up stream proxy. Declaration public IExternalProxy? CustomUpStreamProxy { get; set; } Property Value Type Description Nullable < IExternalProxy > The custom up stream proxy. | Improve this Doc View Source CustomUpStreamProxyUsed Are we using a custom upstream HTTP(S) proxy? Declaration public IExternalProxy? CustomUpStreamProxyUsed { get; } Property Value Type Description Nullable < IExternalProxy > | Improve this Doc View Source EnableWinAuth Enable/disable Windows Authentication (NTLM/Kerberos) for the current session. Declaration public bool EnableWinAuth { get; set; } Property Value Type Description Boolean | Improve this Doc View Source Exception The last exception that happened. Declaration public Exception Exception { get; } Property Value Type Description Exception | Improve this Doc View Source HttpClient The web client used to communicate with server for this session. Declaration public HttpWebClient HttpClient { get; } Property Value Type Description HttpWebClient | Improve this Doc View Source IsHttps Does this session uses SSL? Declaration public bool IsHttps { get; } Property Value Type Description Boolean | Improve this Doc View Source IsTransparent Is this a transparent endpoint? Declaration public bool IsTransparent { get; } Property Value Type Description Boolean | Improve this Doc View Source LocalEndPoint Declaration [Obsolete(\"Use ProxyEndPoint instead.\")] public ProxyEndPoint LocalEndPoint { get; } Property Value Type Description ProxyEndPoint | Improve this Doc View Source ProxyEndPoint Local endpoint via which we make the request. Declaration public ProxyEndPoint ProxyEndPoint { get; } Property Value Type Description ProxyEndPoint | Improve this Doc View Source ServerConnectionId Declaration public Guid ServerConnectionId { get; } Property Value Type Description Guid | Improve this Doc View Source TimeLine Relative milliseconds for various events. Declaration public Dictionary TimeLine { get; } Property Value Type Description Dictionary < String , DateTime > | Improve this Doc View Source UserData Returns a user data for this request/response session which is same as the user data of HttpClient. Declaration public object UserData { get; set; } Property Value Type Description Object | Improve this Doc View Source WebSession Declaration [Obsolete(\"Use HttpClient instead.\")] public HttpWebClient WebSession { get; } Property Value Type Description HttpWebClient Methods | Improve this Doc View Source Dispose() Implements cleanup here. Declaration public virtual void Dispose() | Improve this Doc View Source TerminateSession() Terminates the session abruptly by terminating client/server connections. Declaration public void TerminateSession() Events | Improve this Doc View Source DataReceived Fired when data is received within this session from client/server. Declaration public event EventHandler DataReceived Event Type Type Description EventHandler < DataEventArgs > | Improve this Doc View Source DataSent Fired when data is sent within this session to server/client. Declaration public event EventHandler DataSent Event Type Type Description EventHandler < DataEventArgs > Implements System.IDisposable" + "keywords": "Class SessionEventArgsBase Holds info related to a single proxy session (single request/response sequence). A proxy session is bounded to a single connection from client. A proxy session ends when client terminates connection to proxy or when server terminates connection from proxy. Inheritance Object SessionEventArgsBase SessionEventArgs TunnelConnectSessionEventArgs Implements IDisposable Namespace : Titanium.Web.Proxy.EventArguments Assembly : Titanium.Web.Proxy.dll Syntax public abstract class SessionEventArgsBase : ProxyEventArgsBase, IDisposable Fields | Improve this Doc View Source BufferPool Declaration protected readonly IBufferPool BufferPool Field Value Type Description IBufferPool | Improve this Doc View Source ExceptionFunc Declaration protected readonly ExceptionHandler ExceptionFunc Field Value Type Description ExceptionHandler Properties | Improve this Doc View Source ClientConnectionId Declaration public Guid ClientConnectionId { get; } Property Value Type Description Guid | Improve this Doc View Source ClientEndPoint Declaration [Obsolete(\"Use ClientRemoteEndPoint instead.\")] public IPEndPoint ClientEndPoint { get; } Property Value Type Description IPEndPoint | Improve this Doc View Source ClientLocalEndPoint Client Local End Point. Declaration public IPEndPoint ClientLocalEndPoint { get; } Property Value Type Description IPEndPoint | Improve this Doc View Source ClientRemoteEndPoint Client Remote End Point. Declaration public IPEndPoint ClientRemoteEndPoint { get; } Property Value Type Description IPEndPoint | Improve this Doc View Source CustomUpStreamProxy Gets or sets the custom up stream proxy. Declaration public IExternalProxy? CustomUpStreamProxy { get; set; } Property Value Type Description Nullable < IExternalProxy > The custom up stream proxy. | Improve this Doc View Source CustomUpStreamProxyUsed Are we using a custom upstream HTTP(S) proxy? Declaration public IExternalProxy? CustomUpStreamProxyUsed { get; } Property Value Type Description Nullable < IExternalProxy > | Improve this Doc View Source EnableWinAuth Enable/disable Windows Authentication (NTLM/Kerberos) for the current session. Declaration public bool EnableWinAuth { get; set; } Property Value Type Description Boolean | Improve this Doc View Source Exception The last exception that happened. Declaration public Exception Exception { get; } Property Value Type Description Exception | Improve this Doc View Source HttpClient The web client used to communicate with server for this session. Declaration public HttpWebClient HttpClient { get; } Property Value Type Description HttpWebClient | Improve this Doc View Source IsHttps Does this session uses SSL? Declaration public bool IsHttps { get; } Property Value Type Description Boolean | Improve this Doc View Source IsSocks Is this a SOCKS endpoint? Declaration public bool IsSocks { get; } Property Value Type Description Boolean | Improve this Doc View Source IsTransparent Is this a transparent endpoint? Declaration public bool IsTransparent { get; } Property Value Type Description Boolean | Improve this Doc View Source LocalEndPoint Declaration [Obsolete(\"Use ProxyEndPoint instead.\")] public ProxyEndPoint LocalEndPoint { get; } Property Value Type Description ProxyEndPoint | Improve this Doc View Source ProxyEndPoint Local endpoint via which we make the request. Declaration public ProxyEndPoint ProxyEndPoint { get; } Property Value Type Description ProxyEndPoint | Improve this Doc View Source ServerConnectionId Declaration public Guid ServerConnectionId { get; } Property Value Type Description Guid | Improve this Doc View Source TimeLine Relative milliseconds for various events. Declaration public Dictionary TimeLine { get; } Property Value Type Description Dictionary < String , DateTime > | Improve this Doc View Source UserData Returns a user data for this request/response session which is same as the user data of HttpClient. Declaration public object UserData { get; set; } Property Value Type Description Object | Improve this Doc View Source WebSession Declaration [Obsolete(\"Use HttpClient instead.\")] public HttpWebClient WebSession { get; } Property Value Type Description HttpWebClient Methods | Improve this Doc View Source Dispose() Implements cleanup here. Declaration public virtual void Dispose() | Improve this Doc View Source TerminateSession() Terminates the session abruptly by terminating client/server connections. Declaration public void TerminateSession() Events | Improve this Doc View Source DataReceived Fired when data is received within this session from client/server. Declaration public event EventHandler DataReceived Event Type Type Description EventHandler < DataEventArgs > | Improve this Doc View Source DataSent Fired when data is sent within this session to server/client. Declaration public event EventHandler DataSent Event Type Type Description EventHandler < DataEventArgs > Implements System.IDisposable" }, "api/Titanium.Web.Proxy.EventArguments.TunnelConnectSessionEventArgs.html": { "href": "api/Titanium.Web.Proxy.EventArguments.TunnelConnectSessionEventArgs.html", "title": "Class TunnelConnectSessionEventArgs | Titanium Web Proxy", - "keywords": "Class TunnelConnectSessionEventArgs A class that wraps the state when a tunnel connect event happen for Explicit endpoints. Inheritance Object SessionEventArgsBase TunnelConnectSessionEventArgs Implements IDisposable Inherited Members SessionEventArgsBase.ClientConnectionId SessionEventArgsBase.ServerConnectionId SessionEventArgsBase.BufferPool SessionEventArgsBase.ExceptionFunc SessionEventArgsBase.TimeLine SessionEventArgsBase.UserData SessionEventArgsBase.EnableWinAuth SessionEventArgsBase.IsHttps SessionEventArgsBase.ClientLocalEndPoint SessionEventArgsBase.ClientRemoteEndPoint SessionEventArgsBase.ClientEndPoint SessionEventArgsBase.HttpClient SessionEventArgsBase.WebSession SessionEventArgsBase.CustomUpStreamProxy SessionEventArgsBase.CustomUpStreamProxyUsed SessionEventArgsBase.ProxyEndPoint SessionEventArgsBase.LocalEndPoint SessionEventArgsBase.IsTransparent SessionEventArgsBase.Exception SessionEventArgsBase.Dispose() SessionEventArgsBase.DataSent SessionEventArgsBase.DataReceived SessionEventArgsBase.TerminateSession() Namespace : Titanium.Web.Proxy.EventArguments Assembly : Titanium.Web.Proxy.dll Syntax public class TunnelConnectSessionEventArgs : SessionEventArgsBase, IDisposable Properties | Improve this Doc View Source DecryptSsl Should we decrypt the Ssl or relay it to server? Default is true. Declaration public bool DecryptSsl { get; set; } Property Value Type Description Boolean | Improve this Doc View Source DenyConnect When set to true it denies the connect request with a Forbidden status. Declaration public bool DenyConnect { get; set; } Property Value Type Description Boolean | Improve this Doc View Source IsHttpsConnect Is this a connect request to secure HTTP server? Or is it to some other protocol. Declaration public bool IsHttpsConnect { get; } Property Value Type Description Boolean Events | Improve this Doc View Source DecryptedDataReceived Fired when decrypted data is received within this session from client/server. Declaration public event EventHandler DecryptedDataReceived Event Type Type Description EventHandler < DataEventArgs > | Improve this Doc View Source DecryptedDataSent Fired when decrypted data is sent within this session to server/client. Declaration public event EventHandler DecryptedDataSent Event Type Type Description EventHandler < DataEventArgs > Implements System.IDisposable" + "keywords": "Class TunnelConnectSessionEventArgs A class that wraps the state when a tunnel connect event happen for Explicit endpoints. Inheritance Object SessionEventArgsBase TunnelConnectSessionEventArgs Implements IDisposable Inherited Members SessionEventArgsBase.ClientConnectionId SessionEventArgsBase.ServerConnectionId SessionEventArgsBase.BufferPool SessionEventArgsBase.ExceptionFunc SessionEventArgsBase.TimeLine SessionEventArgsBase.UserData SessionEventArgsBase.EnableWinAuth SessionEventArgsBase.IsHttps SessionEventArgsBase.ClientLocalEndPoint SessionEventArgsBase.ClientRemoteEndPoint SessionEventArgsBase.ClientEndPoint SessionEventArgsBase.HttpClient SessionEventArgsBase.WebSession SessionEventArgsBase.CustomUpStreamProxy SessionEventArgsBase.CustomUpStreamProxyUsed SessionEventArgsBase.ProxyEndPoint SessionEventArgsBase.LocalEndPoint SessionEventArgsBase.IsTransparent SessionEventArgsBase.IsSocks SessionEventArgsBase.Exception SessionEventArgsBase.Dispose() SessionEventArgsBase.DataSent SessionEventArgsBase.DataReceived SessionEventArgsBase.TerminateSession() Namespace : Titanium.Web.Proxy.EventArguments Assembly : Titanium.Web.Proxy.dll Syntax public class TunnelConnectSessionEventArgs : SessionEventArgsBase, IDisposable Properties | Improve this Doc View Source DecryptSsl Should we decrypt the Ssl or relay it to server? Default is true. Declaration public bool DecryptSsl { get; set; } Property Value Type Description Boolean | Improve this Doc View Source DenyConnect When set to true it denies the connect request with a Forbidden status. Declaration public bool DenyConnect { get; set; } Property Value Type Description Boolean | Improve this Doc View Source IsHttpsConnect Is this a connect request to secure HTTP server? Or is it to some other protocol. Declaration public bool IsHttpsConnect { get; } Property Value Type Description Boolean Events | Improve this Doc View Source DecryptedDataReceived Fired when decrypted data is received within this session from client/server. Declaration public event EventHandler DecryptedDataReceived Event Type Type Description EventHandler < DataEventArgs > | Improve this Doc View Source DecryptedDataSent Fired when decrypted data is sent within this session to server/client. Declaration public event EventHandler DecryptedDataSent Event Type Type Description EventHandler < DataEventArgs > Implements System.IDisposable" }, "api/Titanium.Web.Proxy.ExceptionHandler.html": { "href": "api/Titanium.Web.Proxy.ExceptionHandler.html", diff --git a/docs/xrefmap.yml b/docs/xrefmap.yml index 07236273b..984b1480b 100644 --- a/docs/xrefmap.yml +++ b/docs/xrefmap.yml @@ -732,6 +732,19 @@ references: isSpec: "True" fullName: Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.IsHttps nameWithType: SessionEventArgsBase.IsHttps +- uid: Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.IsSocks + name: IsSocks + href: api/Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.html#Titanium_Web_Proxy_EventArguments_SessionEventArgsBase_IsSocks + commentId: P:Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.IsSocks + fullName: Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.IsSocks + nameWithType: SessionEventArgsBase.IsSocks +- uid: Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.IsSocks* + name: IsSocks + href: api/Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.html#Titanium_Web_Proxy_EventArguments_SessionEventArgsBase_IsSocks_ + commentId: Overload:Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.IsSocks + isSpec: "True" + fullName: Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.IsSocks + nameWithType: SessionEventArgsBase.IsSocks - uid: Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.IsTransparent name: IsTransparent href: api/Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.html#Titanium_Web_Proxy_EventArguments_SessionEventArgsBase_IsTransparent diff --git a/src/Titanium.Web.Proxy/EventArguments/SessionEventArgsBase.cs b/src/Titanium.Web.Proxy/EventArguments/SessionEventArgsBase.cs index c362317ae..1e8e130a0 100644 --- a/src/Titanium.Web.Proxy/EventArguments/SessionEventArgsBase.cs +++ b/src/Titanium.Web.Proxy/EventArguments/SessionEventArgsBase.cs @@ -140,6 +140,11 @@ public bool EnableWinAuth /// public bool IsTransparent => ProxyEndPoint is TransparentProxyEndPoint; + /// + /// Is this a SOCKS endpoint? + /// + public bool IsSocks => ProxyEndPoint is SocksProxyEndPoint; + /// /// The last exception that happened. /// diff --git a/src/Titanium.Web.Proxy/RequestHandler.cs b/src/Titanium.Web.Proxy/RequestHandler.cs index ee8ec0ad8..1f74f1520 100644 --- a/src/Titanium.Web.Proxy/RequestHandler.cs +++ b/src/Titanium.Web.Proxy/RequestHandler.cs @@ -90,7 +90,7 @@ await HeaderParser.ReadHeaders(clientStream, args.HttpClient.Request.Headers, request.Method = requestLine.Method; request.HttpVersion = requestLine.Version; - if (!args.IsTransparent) + if (!args.IsTransparent && !args.IsSocks) { // proxy authorization check if (connectRequest == null && await checkAuthorization(args) == false) diff --git a/src/Titanium.Web.Proxy/ResponseHandler.cs b/src/Titanium.Web.Proxy/ResponseHandler.cs index 7e9d617eb..9e6a7ed45 100644 --- a/src/Titanium.Web.Proxy/ResponseHandler.cs +++ b/src/Titanium.Web.Proxy/ResponseHandler.cs @@ -99,7 +99,7 @@ await handleHttpSessionRequest(args, null, args.ClientConnection.NegotiatedAppli response.Locked = true; - if (!args.IsTransparent) + if (!args.IsTransparent && !args.IsSocks) { response.Headers.FixProxyHeaders(); } diff --git a/src/Titanium.Web.Proxy/SocksClientHandler.cs b/src/Titanium.Web.Proxy/SocksClientHandler.cs index cd0174e23..7716ebbb3 100644 --- a/src/Titanium.Web.Proxy/SocksClientHandler.cs +++ b/src/Titanium.Web.Proxy/SocksClientHandler.cs @@ -1,4 +1,5 @@ using System; +using System.Text; using System.Threading; using System.Threading.Tasks; using Titanium.Web.Proxy.Extensions; @@ -48,13 +49,76 @@ private async Task handleClient(SocksProxyEndPoint endPoint, TcpClientConnection } else if (buffer[0] == 5) { - if (buffer[1] == 0 || buffer[2] != 0) + int authenticationMethodCount = buffer[1]; + if (read < authenticationMethodCount + 2) { return; } - buffer[1] = 0; + int acceptedMethod = 255; + for (int i = 0; i < authenticationMethodCount; i++) + { + int method = buffer[i + 2]; + if (method == 0 && ProxyBasicAuthenticateFunc == null) + { + acceptedMethod = 0; + break; + } + + if (method == 2) + { + acceptedMethod = 2; + break; + } + } + + buffer[1] = (byte)acceptedMethod; await stream.WriteAsync(buffer, 0, 2, cancellationToken); + + if (acceptedMethod == 255) + { + // no acceptable method + return; + } + + if (acceptedMethod == 2) + { + read = await stream.ReadAsync(buffer, 0, buffer.Length, cancellationToken); + if (read < 3 || buffer[0] != 1) + { + // authentication version should be 1 + return; + } + + int userNameLength = buffer[1]; + if (read < 3 + userNameLength) + { + return; + } + + string userName = Encoding.ASCII.GetString(buffer, 2, userNameLength); + + int passwordLength = buffer[2 + userNameLength]; + if (read < 3 + userNameLength + passwordLength) + { + return; + } + + string password = Encoding.ASCII.GetString(buffer, 3 + userNameLength, passwordLength); + bool success = true; + if (ProxySchemeAuthenticateFunc != null) + { + success = await ProxyBasicAuthenticateFunc.Invoke(null, userName, password); + } + + buffer[1] = success ? (byte)0 : (byte)1; + await stream.WriteAsync(buffer, 0, 2, cancellationToken); + if (!success) + { + return; + } + } + read = await stream.ReadAsync(buffer, 0, buffer.Length, cancellationToken); if (read < 10 || buffer[1] != 1) {