Conversation
8dd4720 to
23d080c
Compare
|
|
||
| const struct profile_hostport profile_hostport_default_settings = { | ||
| .host = NULL, | ||
| .port = (unsigned int)-1 |
There was a problem hiding this comment.
UINT_MAX is what we nowadays use, since this gives some complaints somewhere. Also, end with a comma.
| } | ||
|
|
||
| static void parser_close_hostport(struct profile_parser *parser, | ||
| const struct profile_hostport *hp) |
| { | ||
| unsigned int port = hp->port; | ||
|
|
||
| if (port == (unsigned int)-1) |
| unsigned int pop3_port; | ||
| /* Deprecated: use lmtp {} { port = ... } instead. Kept for backward | ||
| * compatibility with existing profile configs that still use the | ||
| * global lmtp_port setting. */ |
There was a problem hiding this comment.
I don't think this deprecation warning is correct here? There is imap_port, pop3_port so there must be lmtp_port as well in here. There is already a deprecation comment earlier in lmtp_port setting parsing.
| ARRAY_TYPE(ip_addr_array) imap_ips; | ||
| ARRAY_TYPE(ip_addr_array) pop3_ips; | ||
| ARRAY_TYPE(ip_addr_array) lmtp_ips; | ||
| unsigned int lmtp_ip_idx; |
There was a problem hiding this comment.
These IP things belong to the next commit.
| size_t len; | ||
|
|
||
| snprintf(path, sizeof(path), "/tmp/imaptest-profile-XXXXXX"); | ||
| fd = mkstemp(path); |
There was a problem hiding this comment.
Well, it's a unit test, but still .. lets use Dovecot's safe functions. Like here safe_mkstemp()
| snprintf(path, sizeof(path), "/tmp/imaptest-profile-XXXXXX"); | ||
| fd = mkstemp(path); | ||
| if (fd < 0) { | ||
| fprintf(stderr, "mkstemp failed: %s\n", strerror(errno)); |
There was a problem hiding this comment.
And Dovecot logging functions, like i_error()
| if (write(fd, data, len) != (ssize_t)len) { | ||
| fprintf(stderr, "write failed: %s\n", strerror(errno)); | ||
| close(fd); | ||
| unlink(path); |
There was a problem hiding this comment.
i_close_fd, i_unlink (or i_unlink_if_exists). Here and elsewhere.
| return NULL; | ||
| } | ||
| close(fd); | ||
| return i_strdup(path); |
There was a problem hiding this comment.
With safe_mkstemp() return the path string from data stack, and avoid i_free()s in callers.
| port = conf.port; | ||
| else | ||
| port = POP3_DEFAULT_PORT; | ||
| client->client.port = port; |
There was a problem hiding this comment.
Annoying amount of code duplication for imap/pop3/lmtp related to all this. Not sure if it's worth the trouble to deduplicate.
- Refactor IP rotation in profile mode to ensure IMAP, POP3, and LMTP each maintain their own independent IP pool and rotation index. - Update client_init() to accept an explicit IP address, moving the selection logic to protocol-specific constructors. - Perform upfront host resolution for all protocols in profile mode. - Completely bypass global connection state (conf.ips/ip_idx) when running in profile mode.
23d080c to
58a300d
Compare
Closes #126