justcoding121 / titanium-web-proxy

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

Unable to proxy Socks5 in beta #721

Open bbhxwl opened 4 years ago

bbhxwl commented 4 years ago

I ran titanium.web.proxy.examples.basic, released the comments of the following code, tested the native 127.0.0.1 and port 1080, unable to run normally?

var socksEndPoint = new SocksProxyEndPoint(IPAddress.Any, 1080, true) { // Generic Certificate hostname to use // When SNI is disabled by client GenericCertificateName = "google.com" };

       proxyServer.AddEndPoint(socksEndPoint);
honfika commented 4 years ago

What is the problem?

bbhxwl commented 4 years ago

What is the problem?

Is this the key code of Socks5? Did I test or couldn't support Socks5?

honfika commented 4 years ago

Yes, that is the code.

bbhxwl commented 4 years ago

After I enable it, I can't connect to Socks5 properly. Is there a bug?

bbhxwl commented 4 years ago

There is a problem. UDP function cannot be proxy

bbhxwl commented 4 years ago

QQ图片20191227193120

honfika commented 4 years ago

Yes, this is TCP only

bbhxwl commented 4 years ago

Will UDP compatible forwarding be considered in the future?

honfika commented 4 years ago

Could you please translate your screnshot? I can't speak chinese, and can1t copy the characters from an image:)

honfika commented 4 years ago

How do you use UDP Socks from a browser? Or what is the source of your HTTP requests?

bbhxwl commented 4 years ago

The text of the picture is probably that the test TCP passed and UDP failed. If you want to be a proxy server, you can not only speed up HTTP and UDP, but also speed up the game. If it is compatible, it will be a more powerful project.

honfika commented 4 years ago

But TWP is a HTTP proxy... it accepts only HTTP requests in SOCKS protocol.... there are many simple socks proxy on the internet.

bbhxwl commented 4 years ago

Well, I want to integrate.

bbhxwl commented 4 years ago

Can't you make something like a plug-in? Support for UDP will not affect the TCP function of Socks5.

bbhxwl commented 4 years ago

But TWP is a HTTP proxy... it accepts only HTTP requests in SOCKS protocol.... there are many simple socks proxy on the internet.

Does the official version support Socks5 authentication? Hope to consider adding a UDP forwarding.

honfika commented 4 years ago

Yes, it supports authentication, you have to set the ProxyBasicAuthenticateFunc property to authorize the connection.

honfika commented 4 years ago

However i did not found any browser which supprots SOCKS5 authentication. It is possible only with a Firefox addon, FoxyProxy. I tried that, and it was working with TWP.

bbhxwl commented 4 years ago

I want to know HTTP authentication and sock5 authentication. In addition to limiting the account and password, I can get the IP of the client. I want to do the IP restriction

bbhxwl commented 4 years ago

If I don't want to intercept HTTPS and forward data directly, can I not write the onbeforetunnelconnectrequest event? Is the default e.decryptssl = false?

honfika commented 4 years ago

The default is "true".

If you don't want to decrypt any traffic, i suggest you to disable decryption globally in the endpoint constructor.

Currently the client infomration is not available for SOCKS authentication (the SessionEventArgsBase parameter is null)

bbhxwl commented 4 years ago

explicitEndPoint.DecryptSsl is read-only If I don't want to intercept any data and just want to be an HTTP proxy, I can add no events, right? Just add an explicitproxyendpoint.

honfika commented 4 years ago

Set the constructor parameter of the endpoint object.

bbhxwl commented 4 years ago

Sock5 authentication cannot be restricted in proxybasicauthenticatefunc, right?

proxyServer.ProxyBasicAuthenticateFunc = async (args, userName, password) => {

            return true;
        };

var socksEndPoint = new SocksProxyEndPoint(IPAddress.Any, 1080,false) { // Generic Certificate hostname to use // When SNI is disabled by client GenericCertificateName = "google.com" };

        proxyServer.AddEndPoint(socksEndPoint);
honfika commented 4 years ago

It can be restricted as you wrote.

bbhxwl commented 4 years ago

So you can limit sock5? Recommend the author's S5 client program sstap and C ා open source program netch. Is the author not going to support UDP forwarding?

bbhxwl commented 4 years ago

Is there a way that the user can not enter the password? I will judge the authorization according to the IP. If the user enters the account and password, I will judge with the account and password. It seems that after writing proxybasicauthenticatefunc, you must enter the account and password, right?

honfika commented 4 years ago

Yes, if you set the proxybasicauthenticatefunc the user must enter the username and password.

bbhxwl commented 4 years ago

I have written these codes that can be used normally. There are some parameters that I don't understand.

For example, I don't know proxyserver.enablewinauth

What is the function of this parameter? Is args.clientremoteendpoint.address.maptoipv4() in proxyserver.proxybasicauthenticatefunc the IP address of the connector? Is proxyendpoint the IP address of the connected (server)? Should clientlocalendpoint be the server's native IP?

Is proxyserver.forwardtoupstreamgateway important? What will happen if I cancel? Does enabling http2 have any effect on the load?

proxyServer = new ProxyServer(); proxyServer.EnableHttp2 = true; proxyServer.ExceptionFunc = exception => {

            };
            proxyServer.ForwardToUpstreamGateway = true;

proxyServer.BeforeRequest += onRequest; proxyServer.BeforeResponse += onResponse; proxyServer.EnableWinAuth = true; proxyServer.ProxyBasicAuthenticateFunc = async (args, userName, password) => { return true; }; explicitEndPoint = new ExplicitProxyEndPoint(IPAddress.Any, TcpPort, false); proxyServer.AddEndPoint(explicitEndPoint); proxyServer.Start();