Table of Contents

Class HttpProxyServerOptions

Namespace
VpnHood.Net.Proxies.HttpProxyServers
Assembly
VpnHood.Net.Proxies.dll

Provides the settings of an HttpProxyServer or an HttpsProxyServer.

public class HttpProxyServerOptions
Inheritance
HttpProxyServerOptions
Inherited Members

Properties

Backlog

Gets the maximum number of pending connections the listener queues. The default is 512.

public int Backlog { get; init; }

Property Value

int

Remarks

It must be positive: the server's constructor throws ArgumentOutOfRangeException otherwise.

HandshakeTimeout

Gets how long a client has to send its request line and headers. The default is 15 seconds.

public TimeSpan HandshakeTimeout { get; init; }

Property Value

TimeSpan

Remarks

An HttpsProxyServer gives the TLS handshake the same time again, before the request. It counts whole milliseconds, a fraction dropped: −1 ms (InfiniteTimeSpan) sets no limit; zero cancels the handshake as soon as the cancel runs, so it fails unless it has passed already; −2 ms or less fails every handshake at its start, and the server closes the connection.

HostConnectionTimeout

Gets or sets how long the server may take to reach a destination: the lookup of its host name and the TCP connect. The default is 30 seconds.

public TimeSpan HostConnectionTimeout { get; set; }

Property Value

TimeSpan

Remarks

When it elapses, a CONNECT request gets 502 Bad Gateway and a plain HTTP request 504 Gateway Timeout. It is read at each connect to a destination, so a change applies to the next connect, for a client accepted already too. It counts whole milliseconds, a fraction dropped: −1 ms (InfiniteTimeSpan) sets no limit; zero cancels each connect as soon as the cancel runs, so it fails unless the destination has accepted already; −2 ms or less fails every connect at its start.

ListenEndPoint

Gets the address and port the server listens on. Port 0 lets the system choose one, which ListenerEndPoint shows once the server has started.

public required IPEndPoint ListenEndPoint { get; init; }

Property Value

IPEndPoint

MaxConnections

Gets the maximum number of client connections the server serves at once. The default is MaxValue, which means no limit.

public int MaxConnections { get; init; }

Property Value

int

Remarks

A connection beyond it is accepted and closed at once. On a host with little memory, such as a mobile network extension, set a limit that fits its budget. It must be positive: the server's constructor throws ArgumentOutOfRangeException otherwise.

Password

Gets the password clients must give with Username. null means an empty password.

public string? Password { get; init; }

Property Value

string

ServerCertificate

Gets the certificate, with its private key, that an HttpsProxyServer presents to clients.

public X509Certificate2? ServerCertificate { get; init; }

Property Value

X509Certificate2

Remarks

An HttpsProxyServer requires it; an HttpProxyServer ignores it. The server does not dispose it: keep it alive while the server runs, and until its connections' handlers have ended too, as stopping does not wait for them and one may still be in its TLS handshake; dispose it afterwards.

TunnelHalfCloseTimeout

Gets how long, after one direction of a tunnel has ended (a TCP half-close), the other direction may still carry data before the tunnel is closed. The default is 15 seconds.

public TimeSpan TunnelHalfCloseTimeout { get; init; }

Property Value

TimeSpan

Remarks

The time includes passing the end on to the other side, which an HttpsProxyServer does over TLS, where it waits on a client that reads nothing. It counts whole milliseconds, a fraction dropped: −1 ms (InfiniteTimeSpan) waits without a limit; zero, or −2 ms or less, closes the tunnel without a wait, right after it has started to pass the end on.

Username

Gets the user name clients must give with Basic authentication, in a Proxy-Authorization header, or null to serve clients without credentials.

public string? Username { get; init; }

Property Value

string

Remarks

A client without the right credentials gets 407 Proxy Authentication Required.