Fix and improve the sendOtp for loop #21
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, the sendOtp loop is using the
ips
string's length to loop, which is wrong.I took the opportunity and changed up the code so it's cleaner (I think?) and doesn't hang if one of the hosts isn't reachable (which will be 99% of the time if the user configured more than one IP address): now, the app will shoot the OTP code to all configured clients and use the first reply received as the condition to autoclose or not.
Since any client that's actually waiting for the code will be quick to reply (while the other clients won't be running at all), this will make it feel like the current (mono-IP) version in which the app quickly opens and closes. If the user opened the app without any client running, it'll timeout all requests in five seconds and not autoclose.