How do users connect to SocksProxyEndPoint must authenticate username and password.
I have read that in the latest version of Titanium web proxy which allows to enable username password authentication when creating a SocksProxyEndPoint. But I don't know how to write that code and also can't find illustrative example, can someone help me do this
For basic authentication, just set the ProxyBasicAuthenticateFunc
property on the ProxyServer
instance. For example:
void Main()
{
var proxyServer = new ProxyServer();
proxyServer.OnClientConnectionCreate += OnConnect;
proxyServer.BeforeRequest += OnBeforeRequest;
var socksProxy = new SocksProxyEndPoint(IPAddress.Loopback, 1080, false);
proxyServer.ProxyBasicAuthenticateFunc = OnBasicAuth;
proxyServer.AddEndPoint(socksProxy);
proxyServer.Start();
...
}
public Task<bool> OnBasicAuth(SessionEventArgsBase ev, string u, string p) {
if (u == "test" && p == "pass") {
return Task.FromResult(true);
}
return Task.FromResult(false);
}
Note that the data will be sent in plain text (no encryption). It could be acceptable in intranets, but if you allow public access to your proxy, either use a different authentication scheme (ProxySchemeAuthenticateFunc) or tunnel the traffic.