This cleans up code recently added to support the --altdnsnames flag and
DCRD_ALT_DNSNAMES environment variable to match the project standards,
simplify it, and correct some issues with standalone test binaries.
- Gets rid of the setup func which had several issues:
- It was creating a file that was not needed (and without even
checking the error)
- Since it was parsing flags and missing with os.Args in a func, it
was not possible to individual run the test funcs without failure
due to the additional flags
- Performs the flag parsing and removal in an init func that only runs
once when the tests are run (and before TestMain)
- Avoids creating empty objects when nil will suffice
- Uses full sentences and periods in the comment and properly spaces
them out so they are consistent with the rest of the code
- Adds comments to all of the added test functions as required by the
code contribution guidelines
- Closes the create temp files before trying to write to them in the cert
generation
- Defers the removal of the temp files directly after they are created so
they are removed properly if the next one fails to create
- Uses consistent camel case in the variable names
- rpcserver: Adds ability to allow alternative dns names for TLS.
- Adds AltDNSNames config for passing additional hostnames to the
TLS certificate generate method. Without this change there is no
way to pass in alternative dns names for the rpc server.
- Additionally this commit allows the user to set 'DCRD_ALT_DNSNAMES'
as an environment variable when starting dcrd. This is useful for
docker and other app runtimes that require apps to be 12 factor.