Skip to content

Move remaining config option parsing to ConfigLoad() #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 1, 2021

Conversation

JonathonReinhart
Copy link
Collaborator

@JonathonReinhart JonathonReinhart commented Mar 14, 2021

Move remaining parsing of config options from server callbacks to ConfigLoad():

  • allowed_sender regex compilation
  • allowed_recipients regex compilation
  • SMTP auth setup and validation (remote_auth, remote_user, remote_password)

With this change, we can catch configuration errors during startup and avoid an error case during connection handling.

This also introduces a none type for remote_auth, and makes it the default. This is a more explicit equivalent of an empty username/password before this change.

This was identified during review of #13 and implementation of #15.

This has several benefits:
- Configuration errors are caught at startup rather than upon a connection
- senderChecker() has less work to do for each connection
This has several benefits:
- Configuration errors are caught at startup rather than upon a connection
- recipientChecker() has less work to do for each connection
@JonathonReinhart JonathonReinhart requested a review from decke March 14, 2021 16:52
@JonathonReinhart JonathonReinhart changed the title Move allowed_sender/allowed_recipients compilation to ConfigLoad() Move more config option parsing to ConfigLoad() Mar 14, 2021
@JonathonReinhart JonathonReinhart changed the title Move more config option parsing to ConfigLoad() Move remaining config option parsing to ConfigLoad() Mar 14, 2021
This has several benefits:
- Configuration errors are caught at startup rather than upon a connection
- mailHandler() has less work to do for each connection

Rather than relying on remote_user and remote_pass to control whether
authentication is used, introduce an explicit "none" type for
remote_auth, and make that the default. (This is effectively the same
default behavior since remote_user and remote_pass default to empty.)

Also, we are in a better position to more thoroughly check for
configuration errors or mismatches:
- If remote_auth is given, remote_user and remote_pass are required.
- If remote_auth is given, remote_host is also required (because it
  makes no sense to say we're going to authenticate if we have no server
  to which to authenticate.)
- If remote_user or remote_pass are given, remote_auth cannot be "none".
@JonathonReinhart JonathonReinhart force-pushed the allow-any-sender-recipient branch from 797ad12 to 22ef0c2 Compare March 14, 2021 22:42
@JonathonReinhart JonathonReinhart requested a review from decke March 23, 2021 22:22
@decke
Copy link
Owner

decke commented Mar 31, 2021

Sorry that it took me so long to come back to this but my dayjob is keeping me extremely busy these days.

@JonathonReinhart
Copy link
Collaborator Author

JonathonReinhart commented Mar 31, 2021

No worries! Thanks for merging approving. I'm really liking these changes of checking for configuration errors earlier. As more people use smtprelay, it will hopefully cut-back on the support issues.

Do you still want to be the one to click "Merge" after approving a PR? I'm fine with that, but just want to make sure we're on the same page with procedure.

@decke decke merged commit 2cd636c into master Apr 1, 2021
@JonathonReinhart JonathonReinhart deleted the allow-any-sender-recipient branch April 1, 2021 04:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants