-
Notifications
You must be signed in to change notification settings - Fork 366
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
Modularize - Ability for server to be used as a package #27
Conversation
…ored client handling code.
Remove old `server` package Refactor cmd package to work with new server Remove `models.go`, remove parts and refactor other parts into either `server.go` or `client.go` Change format of `allowed_hosts` to JSON array from comma separated string
Refactor NewServer and server.run into server file Remove requirement for servers to receive appconfig
Refactor MD5Hash method to not use pointers to strings (go strings are pointers under the hood already anyway) Refactor mysql+redis backend implementation to work with new backend interface and modified client struct Move concern of reading a configuration file to the command line interface
* tls sate always goes back to command state
Thanks. Code looks very neat. Some feedback There's some imports still pointing to your fork (serve.go) parseHeaders() - maybe parsing headers could be left to the backends? If possible, looking to defer as much work as possible to the backends, or even further down the stack. Would also like to avoid regex where possible. The previous implementation used a simple string compare to find the subject only and stopped scanning once found it, but full header parsing might be better to avoid until later? parseHeaders() - not all emails can have headers, and data can be unpredictable. The code would panic if the map was nil. parseHeaders() - to detect header start / end, would it be easier to get a slice like this: For parsing headers, these readers may be useful https://golang.org/pkg/net/textproto/ rather than the http package. ClientStartTLS - found a bug that would cause an infinite loop if client closes connection during negotiation. (This was already there before) ClientStartTLS - according to rfc3207, it should not respond with any 220 message after TLS negotiation, but go into expecting EHLO from the client. Your mod to reset the client is correct. ClientStartTLS - If TLS negotiation failed, it might as well go back to command state without any additional message, the client can decide whenever to continue or not since it would know if TLS failed or not. (Interpreting rfc3207) So... Committed some fixes to this PR & took the server for a spin on production! |
Thanks for the feedback. I'll move the header parsing to a util function and leave it to the backend and try to figure out what is causing those errors. |
* added some kills for read errors
Still not sure what is causing the above problem. It looks like the number of connected clients fills up quickly to the max (5000) and then the "too many open file" errors come in this form:
Noticed that there is a bug when in DATA state, if the host is not allowed, it will still go to save the email & respond with two messages, Making some fixes, will commit and send them up soon, then test again |
Still getting the errors after the bug fixes. Slight correction to the above message: server fills up to about 1000 clients before going into weird state. |
…l workers from being created and causing deadlock in the Redis+MySQL backend
Thanks for updates, including the Readme update - was going to ask you about it, but looks like we're on the same page! We should be ready to merge this soon? Regarding the c *Client, what would you say if we placed the c.Data, c.MailFrom, c.RcptTo, c.Helo, c.Address, c.TLS, in their own struct, eg. |
I agree. Separating public Client data into its own struct is a good idea. I can do that later today. After that it should be ready to merge. |
Thanks! That will be another bounty earned! Before merging, a thorough test will be done on Guerrilla Mail production. Btw, In the future, considering to change Data to a []byte - the reason is because string assumes text, however Data is just a raw chunk of bytes that does not really represent text, eg it could be 8bitmime. The other reason, it would be more efficient to use with Reader / Writer to avoid the string to []byte conversion. What do you think? |
If we're leaving the interpretation of the DATA to backends, I think leaving |
…e. Move `Client#Hash` into sql+redis backend
Thanks. That was quick! Regarding MailData, do you think this would be the best name, or could there be more concise alternatives? Eg. Envelope or any other ideas? |
Last push fixed a bug that caused start tls to be advertised even though when it was off. Also, STARTTLS command will be ignored if it is disabled (lots of clients try it despite not advertised). Getting more stable to merge. Is there anything else you wanted to add? |
Nice. I would like to come up with a better name than Maybe one of: And do you want to change |
I'm happy to merge now, unless you want to change the |
Envelope would be a good metaphor. Good point on the EmailParts, EmailAddress is better. Also, in the client struct, Address was changed to RemoteAddress, just to make things clear. So testing is going great! This branch has been running on Guerrilla Mail for the last 12 hours, usually middle of the week is the most busiest time for a battle test. Looks like ready to go. Thanks for another bounty earned! |
For #20