简体   繁体   中英

Make Socks 5 requires username / password authentication? Titanium web proxy

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM