Skip to content

Commit

Permalink
Add option to specify port of smtp_-server
Browse files Browse the repository at this point in the history
This option was requested in issue #336.

Signed-off-by: Quentin Armitage <quentin@armitage.org.uk>
  • Loading branch information
pqarmitage committed May 19, 2016
1 parent 9c498c6 commit 128cd24
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
4 changes: 3 additions & 1 deletion doc/keepalived.conf.SYNOPSIS
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ global_defs { # Block identification
}
notification_email_from <EMAIL ADDRESS> # Email From dealing with SMTP proto
# defaults to keepalived@<local host name>
smtp_server <ADDRESS>|<DOMAIN_NAME> # SMTP server IP address or domain name
smtp_server <ADDRESS>|<DOMAIN_NAME> [<PORT>]
# SMTP server IP address or domain name
# with optional port number (defaults to 25)
smtp_helo_name <HOST_NAME> # name to use in HELO messages
# defaults to local host name
smtp_connect_timeout <INTEGER> # Number of seconds timeout connect
Expand Down
4 changes: 3 additions & 1 deletion doc/man/man5/keepalived.conf.5
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ and
}
# From: from address that will be in the header (default keepalived@<local host name>)
notification_email_from admin@example.com
smtp_server 127.0.0.1 # IP address or domain name
smtp_server 127.0.0.1 [<PORT>]
# IP address or domain name
# with optional port number (default 25)
smtp_helo_name <HOST_NAME> # name to use in HELO messages
# defaults to local host name
smtp_connect_timeout 30 # integer, seconds
Expand Down
9 changes: 7 additions & 2 deletions keepalived/core/global_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,19 @@ static void
smtpserver_handler(vector_t *strvec)
{
int ret = -1;
char *port_str = SMTP_PORT_STR;

/* Has a port number been specified? */
if (vector_size(strvec) >= 3)
port_str = vector_slot(strvec,2);

/* It can't be an IP address if it contains '-' or '/', and
inet_stosockaddr() modifies the string if it contains either of them */
if (!strpbrk(vector_slot(strvec, 1), "-/"))
ret = inet_stosockaddr(vector_slot(strvec, 1), SMTP_PORT_STR, &global_data->smtp_server);
ret = inet_stosockaddr(vector_slot(strvec, 1), port_str, &global_data->smtp_server);

if (ret < 0)
domain_stosockaddr(vector_slot(strvec, 1), SMTP_PORT_STR, &global_data->smtp_server);
domain_stosockaddr(vector_slot(strvec, 1), port_str, &global_data->smtp_server);
}
static void
smtphelo_handler(vector_t *strvec)
Expand Down

0 comments on commit 128cd24

Please sign in to comment.