ExchangeUnion / xud

Exchange Union Daemon 🔁 ⚡️
https://exchangeunion.com
GNU Affero General Public License v3.0
115 stars 49 forks source link

fix: tls certificate check on startup (#1510) #1964

Closed rsercano closed 3 years ago

rsercano commented 3 years ago

resolves #1510

This's the only thing that I could think of to prevent startup if tls.certdoesn't exist. But this spits command help followed by error message.

rsercano commented 3 years ago

Changed message to xud is in initialization state, please wait since this looks more convenient @raladev @kilrau

kilrau commented 3 years ago

Can shorten xud is in initialization state, please wait -> xud is initializing, please wait @rsercano

raladev commented 3 years ago

Perhaps instead we can wait a few seconds if we detect that the cert does not exist, try again, and if it still doesn't exist proceed with a message that we could not find the tls cert at the provided path?

on slow machines tls creation can take 10-15 sec, so im not sure that timer based solution is good. Maybe we can some flag that says:

  1. creation flow was not initialized - print with creation/unlocking suggestion (we already have it)
  2. creation flow was initialialized, but not finished - print 'xud is initializing'
  3. creation flow was finished successfully/ with error - print err instead of 'xud is initializing'
sangaman commented 3 years ago

Perhaps instead we can wait a few seconds if we detect that the cert does not exist, try again, and if it still doesn't exist proceed with a message that we could not find the tls cert at the provided path?

on slow machines tls creation can take 10-15 sec, so im not sure that timer based solution is good. Maybe we can some flag that says:

1. creation flow was not initialized - print with creation/unlocking suggestion (we already have it)

2. creation flow was initialialized, but not finished - print 'xud is initializing'

3. creation flow was finished successfully/ with error - print err instead of 'xud is initializing'

10-15 seconds is a lot more than what I've experienced or would have expected, is that something you've encountered?

I'm not sure how the flag you're suggesting would work, would that be a flag on the xucli command? And how would we know what's going on with the creation flow?

Since the issue appears to arise when running xud through docker, maybe we should handle that there? Docker can detect the ENOENT error and if it's the very first time we're running xud handle it appropriately.

raladev commented 3 years ago

10-15 seconds is a lot more than what I've experienced or would have expected, is that something you've encountered?

Yeap, usually on my VM, not on host machine.

I'm not sure how the flag you're suggesting would work, would that be a flag on the xucli command? And how would we know what's going on with the creation flow?

for first point, yes, it can be on xucli side, but for third point it seems impossible to get result of create/initialize flow from xud if tls was not created. So it would be better to handle the case on xud-docker side like it was made in the status command.

Since the issue appears to arise when running xud through docker, maybe we should handle that there? Docker can detect the ENOENT error and if it's the very first time we're running xud handle it appropriately.

make sense, we have xud is starting case for status command, maybe we can try to use same logic for the check on xud-docker side.

rsercano commented 3 years ago

So, what's the current plan for this please?

rsercano commented 3 years ago

There were some unnecessary whitespace changes, removed them @raladev @erkarl