openbullet / OpenBullet2

OpenBullet reinvented
https://docs.openbullet.dev/
MIT License
1.8k stars 485 forks source link

Block TCP #814

Open HuuDbi opened 2 years ago

HuuDbi commented 2 years ago

Version of the software

0.2.4

Operating system

win 10

Browser / Native

opera

What happened?

TCP block timeout does not work, interfering with CPM

Relevant LoliCode if needed

await TcpConnect(data, $"{input.DOMAIN}", PORTACON.AsInt(), ONSSL.AsBool(), 1000).ConfigureAwait(false);
openbullet commented 3 months ago

Hello, sorry for addressing this so late.

I investigated the issue and the timeout-backed cancellation token is passed correctly to the client.ConnectAsync method as you can see here:

https://github.com/openbullet/OpenBullet2/blob/19702476bb1ec86a50d4d93953d13660f61742f2/RuriLib.Proxies/ProxyClient.cs#L61-L63

I fixed the NoProxyClient case so that should also be good now, before it had a fixed 5 second timeout.

I think the problem relies on the fact that, when there is an exception such as System.Net.Sockets.SocketException | No such host is known., the Dns.GetHostEntry(ClientIP) used internally is at fault. This does not support cancellation apparently. A library such as this https://github.com/MichaCo/DnsClient.NET could be used to address the issue and pass the cancellation token to the DNS operation as well.

In any case, to resolve the issue, I suggest you only use domains that resolve to an IP address. I will keep this open and investigate the use of this library to address the issue.