justcoding121 / titanium-web-proxy

A cross-platform asynchronous HTTP(S) proxy server in C#.
MIT License
1.93k stars 618 forks source link

How to make Socks5 authenticate username/password #860

Open handestd opened 3 years ago

handestd commented 3 years ago

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

honfika commented 3 years ago

Set the ProxyBasicAuthenticateFunc property of your ProxyServer object to a function which does this authentication. The string parameters are the username and password.

But I found a bug in this. I fix it and create new beta package.

handestd commented 3 years ago

Set the ProxyBasicAuthenticateFunc property of your ProxyServer object to a function which does this authentication. The string parameters are the username and password.

But I found a bug in this. I fix it and create new beta package.

Can you provide me a sample code to set up the Socksproxyendpoint account and password for Socksproxyendpoint, I really need it, I researched for a week now ..

handestd commented 3 years ago

I'm on 3.1.1358-beta and which version should I use

honfika commented 3 years ago

3.1.1363-beta

honfika commented 3 years ago

The password settings is common for the SOCKS and other (e.g Explicit) endpoint endpoint. so it can't be set there. You can set it on the ProxyServer object:

proxyServer.ProxyBasicAuthenticateFunc = MyAuthFunc;

async bool MyAuthFunc(SessionEventArgsBase args, string username, string password) { }

Or similar, sorry, I can't test it, just wrote here without trying it.

handestd commented 3 years ago

The password settings is common for the SOCKS and other (e.g Explicit) endpoint endpoint. so it can't be set there. You can set it on the ProxyServer object:

proxyServer.ProxyBasicAuthenticateFunc = MyAuthFunc;

async bool MyAuthFunc(SessionEventArgsBase args, string username, string password) { }

Or similar, sorry, I can't test it, just wrote here without trying it.

Can you help me write sample code, set username = admin, password = admin for a certain port eg 18883 for each SocksProxyEndPoint. How to distinguish that

honfika commented 3 years ago

Currently it is not possible to set authentication for a certain port only. So if you set the authentication it will be the same for each endpoint. Sorry.

handestd commented 3 years ago

Currently it is not possible to set authentication for a certain port only. So if you set the authentication it will be the same for each endpoint. Sorry.

I think I can rely on SessionEventArgbase to classify the ports, but it returns null, how do I get the sessionEventArgsbase info, thank you so much for your enthusiasm

honfika commented 3 years ago

This is why i said that it is not possible. It is always null in socks. It is not null for other endpoint types.

Maybe later i'll add a possibility to detect the endpoint, but I can't promise any deadline.

You need different usernames and passwords for different endpoints? Maybe you should create different proxyServer objects as a workaround.

handestd commented 3 years ago

This is why i said that it is not possible. It is always null in socks. It is not null for other endpoint types.

Maybe later i'll add a possibility to detect the endpoint, but I can't promise any deadline.

You need different usernames and passwords for different endpoints? Maybe you should create different proxyServer objects as a workaround.

Thank you very much, I wish that SessionEventArgsBase returned all the information, so the code would be very neat and optimal. However thanks for pointing me out one way