Danny-Dasilva / CycleTLS

Spoof TLS/JA3 fingerprints in GO and Javascript
GNU General Public License v3.0
893 stars 169 forks source link

Fix Dead Lock on Linux after "Error Processing Request (please open an issue on Github)" #344

Closed RealAlphabet closed 1 month ago

RealAlphabet commented 3 months ago

Under Linux, when an error is encountered, the library stops sending new requests until the process is restarted. This is because the cleanExit promise is never resolved when the exit value is false, causing the library to dead lock.

RealAlphabet commented 2 months ago

@Danny-Dasilva could you take a look at this PR please? This is necessary because when the exit boolean is false, the library will automatically try to create a new instance of CycleTLS. It should not be the responsibility of CycleTLS to decide whether the whole process should be exited. It should be up to the user. This PR prevents denial of service by the library. As for the underlying error, I don't know exactly what caused it, but it seems to happen from time to time after a long time and always does.

RealAlphabet commented 2 months ago

@Danny-Dasilva could you take a look at this PR please? This is necessary because when the output is false, the library will automatically try to create a new instance of CycleTLS. It should not be the responsibility of CycleTLS to decide whether the whole process should be exited. It should be up to the user. This PR prevents denial of service by the library. As for the underlying error, I don't know exactly what caused it, but it seems to happen from time to time after a long time and always does.

PS: A better fix would be to improve CycleTLS error handling by proposing an event that will be triggered when this type of error occurs. By default the behaviour would be to try to restart the CycleTLS instance, if it fails after three times, return an error event with a fatal boolean set to true and not try to restart the instance.

The user would have two choices. If the error is not fatal, he can still decide to stop CycleTLS by calling a CycleTLS method which allows the instance to be destroyed. If the error is fatal, he can decide to trigger the connection again.

In all cases the user could monitor via a getter if the library instance is available and if it has been stopped due to an error.