t_array_init(&alt_usernames, 4);
i_zero(reply_r);
+ reply_r->proxy_host_immediate_failure_after_secs =
+ LOGIN_PROXY_DEFAULT_HOST_IMMEDIATE_FAILURE_AFTER_SECS;
for (; *args != NULL; args++) {
p = strchr(*args, '=');
"proxy_timeout value '%s': %s",
value, error);
}
+ } else if (strcmp(key, "proxy_host_immediate_failure_after") == 0) {
+ if (settings_get_time(value,
+ &reply_r->proxy_host_immediate_failure_after_secs,
+ &error) < 0) {
+ e_error(client->event,
+ "BUG: Auth service returned invalid "
+ "proxy_host_immediate_failure_after value '%s': %s",
+ value, error);
+ }
} else if (strcmp(key, "proxy_refresh") == 0) {
if (str_to_uint(value, &reply_r->proxy_refresh_secs) < 0) {
e_error(client->event,
proxy_set.connect_timeout_msecs = client->set->login_proxy_timeout;
proxy_set.notify_refresh_secs = reply->proxy_refresh_secs;
proxy_set.ssl_flags = reply->ssl_flags;
+ proxy_set.host_immediate_failure_after_secs =
+ reply->proxy_host_immediate_failure_after_secs;
/* Include destination ip:port also in the log prefix */
event_set_append_log_prefix(event, t_strdup_printf(
in_port_t port;
unsigned int proxy_timeout_msecs;
unsigned int proxy_refresh_secs;
+ unsigned int proxy_host_immediate_failure_after_secs;
enum login_proxy_ssl_flags ssl_flags;
/* all the key=value fields returned by passdb */
#define KILLED_BY_ADMIN_REASON "Disconnected by proxy: Kicked by admin"
#define KILLED_BY_DIRECTOR_REASON "Disconnected by proxy: Kicked via director"
#define KILLED_BY_SHUTDOWN_REASON "Disconnected by proxy: Process shutting down"
-#define PROXY_IMMEDIATE_FAILURE_SECS 30
/* Wait this long before retrying on reconnect */
#define PROXY_CONNECT_RETRY_MSECS 1000
/* Don't even try to reconnect if proxying will timeout in less than this. */
in_port_t port;
unsigned int connect_timeout_msecs;
unsigned int notify_refresh_secs;
+ unsigned int host_immediate_failure_after_secs;
unsigned int reconnect_count;
enum login_proxy_ssl_flags ssl_flags;
the check below. */
rec->last_success.tv_sec = ioloop_timeval.tv_sec - 1;
}
- if (timeval_cmp(&rec->last_failure, &rec->last_success) > 0 &&
- rec->last_failure.tv_sec - rec->last_success.tv_sec > PROXY_IMMEDIATE_FAILURE_SECS &&
+ if (proxy->host_immediate_failure_after_secs != 0 &&
+ timeval_cmp(&rec->last_failure, &rec->last_success) > 0 &&
+ rec->last_failure.tv_sec - rec->last_success.tv_sec >
+ proxy->host_immediate_failure_after_secs &&
rec->num_waiting_connections > 1) {
/* the server is down. fail immediately */
proxy->disable_reconnect = TRUE;
proxy->port = set->port;
proxy->connect_timeout_msecs = set->connect_timeout_msecs;
proxy->notify_refresh_secs = set->notify_refresh_secs;
+ proxy->host_immediate_failure_after_secs =
+ set->host_immediate_failure_after_secs;
proxy->ssl_flags = set->ssl_flags;
proxy->state_rec = login_proxy_state_get(proxy_state, &proxy->ip,
proxy->port);
handle the user. This only works if both proxies support the Dovecot
TTL extension feature. */
#define LOGIN_PROXY_TTL 5
+#define LOGIN_PROXY_DEFAULT_HOST_IMMEDIATE_FAILURE_AFTER_SECS 30
#define LOGIN_PROXY_FAILURE_MSG "Account is temporarily unavailable."
/* send a notification about proxy connection to proxy-notify pipe
every n seconds */
unsigned int notify_refresh_secs;
+ unsigned int host_immediate_failure_after_secs;
enum login_proxy_ssl_flags ssl_flags;
};