mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-03-25 04:17:42 +00:00
MINOR: server/bind: add support of new prefixes for addresses.
Since the internal function str2sa_range is used to addresses for different objects ('server', 'bind' but also 'log' or 'nameserver') we notice that some combinations are missing. "ip@" is introduced to authorize the prefix "dgram+ip@" or "stream+ip@" which dectects automatically IP version but specify dgram or stream. "tcp@" was introduced and is an alias for "stream+ip@". "tcp6" and "tcp4" are now aliases for "stream+ipv6@" and "stream+ipv4@". "uxst@" and "uxdg@" are now aliases for "stream+unix@" and "dgram+unix@". This patch also adds a complete section in documentation to describe adresses and their prefixes.
This commit is contained in:
parent
a68380524b
commit
ce325c4360
@ -129,6 +129,10 @@ Summary
|
||||
10.2. Default parameters
|
||||
10.3. Limitations
|
||||
|
||||
11. Address formats
|
||||
11.1. Address family prefixes
|
||||
11.2. Socket type prefixes
|
||||
11.3. Protocol prefixes
|
||||
|
||||
1. Quick reminder about HTTP
|
||||
----------------------------
|
||||
@ -21550,6 +21554,150 @@ processing error is returned. It means the record FCGI_PARAM, once encoded,
|
||||
must not exceeds the size of a buffer. However, there is no reserve to respect
|
||||
here.
|
||||
|
||||
|
||||
11. Address formats
|
||||
-------------------
|
||||
|
||||
Several statements as "bind, "server", "nameserver" and "log" requires an
|
||||
address.
|
||||
|
||||
This address can be a host name, an IPv4 address, an IPv6 address, or '*'.
|
||||
The '*' is equal to the special address "0.0.0.0" and can be used, in the case
|
||||
of "bind" or "dgram-bind" to listen on all IPv4 of the system.The IPv6
|
||||
equivalent is '::'.
|
||||
|
||||
Depending of the statement, a port or port range follows the IP address. This
|
||||
is mandatory on 'bind' statement, optional on 'server'.
|
||||
|
||||
This address can also begin with a slash '/'. It is considered as the "unix"
|
||||
family, and '/' and following characters must be present the path.
|
||||
|
||||
Default socket type or transport method "datagram" or "stream" depends on the
|
||||
configuration statement showing the address. Indeed, 'bind' and 'server' will
|
||||
use a "stream" socket type by default whereas 'log', 'nameserver' or
|
||||
'dgram-bind' will use a "datagram".
|
||||
|
||||
Optionally, a prefix could be used to force the address family and/or the
|
||||
socket type and the transport method.
|
||||
|
||||
|
||||
11.1 Address family prefixes
|
||||
----------------------------
|
||||
|
||||
'abns@<name>' following <name> is an abstract namespace (Linux only).
|
||||
|
||||
'fd@<n>' following address is a file descriptor <n> inherited from the
|
||||
parent. The fd must be bound and may or may not already be
|
||||
listening.
|
||||
|
||||
'ip@<address>[:port1[-port2]]' following <address> is considered as an IPv4 or
|
||||
IPv6 address depending on the syntax. Depending
|
||||
on the statement using this address, a port or
|
||||
a port range may or must be specified.
|
||||
|
||||
'ipv4@<address>[:port1[-port2]]' following <address> is always considered as
|
||||
an IPv4 address. Depending on the statement
|
||||
using this address, a port or a port range
|
||||
may or must be specified.
|
||||
|
||||
'ipv6@<address>[:port1[-port2]]' following <address> is always considered as
|
||||
an IPv6 address. Depending on the statement
|
||||
using this address, a port or a port range
|
||||
may or must be specified.
|
||||
|
||||
'sockpair@<n>' following address is the file descriptor of a connected unix
|
||||
socket or of a socketpair. During a connection, the initiator
|
||||
creates a pair of connected sockets, and passes one of them
|
||||
over the FD to the other end. The listener waits to receive
|
||||
the FD from the unix socket and uses it as if it were the FD
|
||||
of an accept(). Should be used carefully.
|
||||
|
||||
'unix@<path>' following string is considered as a UNIX socket <path>. this
|
||||
prefix is useful to declare an UNIX socket path which don't
|
||||
start by slash '/'.
|
||||
|
||||
|
||||
11.2 Socket type prefixes
|
||||
-------------------------
|
||||
|
||||
Previous "Address family prefixes" can also be prefixed to force the socket
|
||||
type and the transport method. The default depends of the statement using
|
||||
this address but in some cases the user may force it to a different one.
|
||||
This is the case for "log" statement where the default is syslog over UDP
|
||||
but we could force to use syslog over TCP.
|
||||
|
||||
Those prefixes were designed for internal purpose and users should
|
||||
instead use aliases of the next section "11.5.3 Protocol prefixes".
|
||||
|
||||
If users need one those prefixes to perform what they expect because
|
||||
they can not configure the same using the protocol prefixes, they should
|
||||
report this to the maintainers.
|
||||
|
||||
'stream+<family>@<address>' forces socket type and transport method
|
||||
to "stream"
|
||||
|
||||
'dgram+<family>@<address>' forces socket type and transport method
|
||||
to "datagram".
|
||||
|
||||
|
||||
11.3 Protocol prefixes
|
||||
----------------------
|
||||
|
||||
'tcp@<address>[:port1[-port2]]' following <address> is considered as an IPv4
|
||||
or IPv6 address depending of the syntax but
|
||||
socket type and transport method is forced to
|
||||
"stream". Depending on the statement using
|
||||
this address, a port or a port range can or
|
||||
must be specified. It is considered as an alias
|
||||
of 'stream+ip@'.
|
||||
|
||||
'tcp4@<address>[:port1[-port2]]' following <address> is always considered as
|
||||
an IPv4 address but socket type and transport
|
||||
method is forced to "stream". Depending on the
|
||||
statement using this address, a port or port
|
||||
range can or must be specified.
|
||||
It is considered as an alias of 'stream+ipv4@'.
|
||||
|
||||
'tcp6@<address>[:port1[-port2]]' following <address> is always considered as
|
||||
an IPv6 address but socket type and transport
|
||||
method is forced to "stream". Depending on the
|
||||
statement using this address, a port or port
|
||||
range can or must be specified.
|
||||
It is considered as an alias of 'stream+ipv4@'.
|
||||
|
||||
'udp@<address>[:port1[-port2]]' following <address> is considered as an IPv4
|
||||
or IPv6 address depending of the syntax but
|
||||
socket type and transport method is forced to
|
||||
"datagram". Depending on the statement using
|
||||
this address, a port or a port range can or
|
||||
must be specified. It is considered as an alias
|
||||
of 'dgram+ip@'.
|
||||
|
||||
'udp4@<address>[:port1[-port2]]' following <address> is always considered as
|
||||
an IPv4 address but socket type and transport
|
||||
method is forced to "datagram". Depending on
|
||||
the statement using this address, a port or
|
||||
port range can or must be specified.
|
||||
It is considered as an alias of 'stream+ipv4@'.
|
||||
|
||||
'udp6@<address>[:port1[-port2]]' following <address> is always considered as
|
||||
an IPv6 address but socket type and transport
|
||||
method is forced to "datagram". Depending on
|
||||
the statement using this address, a port or
|
||||
port range can or must be specified.
|
||||
It is considered as an alias of 'stream+ipv4@'.
|
||||
|
||||
'uxdg@<path>' following string is considered as a unix socket <path> but
|
||||
transport method is forced to "datagram". It is considered as
|
||||
an alias of 'dgram+unix@'.
|
||||
|
||||
'uxst@<path>' following string is considered as a unix socket <path> but
|
||||
transport method is forced to "stream". It is considered as
|
||||
an alias of 'stream+unix@'.
|
||||
|
||||
In future versions, other prefixes could be used to specify protocols like
|
||||
QUIC which proposes stream transport based on socket of type "datagram".
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* fill-column: 79
|
||||
|
31
src/tools.c
31
src/tools.c
@ -930,11 +930,27 @@ struct sockaddr_storage *str2sa_range(const char *str, int *port, int *low, int
|
||||
abstract = 0;
|
||||
ss.ss_family = AF_UNIX;
|
||||
}
|
||||
else if (strncmp(str2, "uxdg@", 5) == 0) {
|
||||
str2 += 5;
|
||||
abstract = 0;
|
||||
ss.ss_family = AF_UNIX;
|
||||
sock_type = ctrl_type = SOCK_DGRAM;
|
||||
}
|
||||
else if (strncmp(str2, "uxst@", 5) == 0) {
|
||||
str2 += 5;
|
||||
abstract = 0;
|
||||
ss.ss_family = AF_UNIX;
|
||||
sock_type = ctrl_type = SOCK_STREAM;
|
||||
}
|
||||
else if (strncmp(str2, "abns@", 5) == 0) {
|
||||
str2 += 5;
|
||||
abstract = 1;
|
||||
ss.ss_family = AF_UNIX;
|
||||
}
|
||||
else if (strncmp(str2, "ip@", 3) == 0) {
|
||||
str2 += 3;
|
||||
ss.ss_family = AF_UNSPEC;
|
||||
}
|
||||
else if (strncmp(str2, "ipv4@", 5) == 0) {
|
||||
str2 += 5;
|
||||
ss.ss_family = AF_INET;
|
||||
@ -943,16 +959,31 @@ struct sockaddr_storage *str2sa_range(const char *str, int *port, int *low, int
|
||||
str2 += 5;
|
||||
ss.ss_family = AF_INET6;
|
||||
}
|
||||
else if (strncmp(str2, "tcp4@", 5) == 0) {
|
||||
str2 += 5;
|
||||
ss.ss_family = AF_INET;
|
||||
sock_type = ctrl_type = SOCK_STREAM;
|
||||
}
|
||||
else if (strncmp(str2, "udp4@", 5) == 0) {
|
||||
str2 += 5;
|
||||
ss.ss_family = AF_INET;
|
||||
sock_type = ctrl_type = SOCK_DGRAM;
|
||||
}
|
||||
else if (strncmp(str2, "tcp6@", 5) == 0) {
|
||||
str2 += 5;
|
||||
ss.ss_family = AF_INET6;
|
||||
sock_type = ctrl_type = SOCK_STREAM;
|
||||
}
|
||||
else if (strncmp(str2, "udp6@", 5) == 0) {
|
||||
str2 += 5;
|
||||
ss.ss_family = AF_INET6;
|
||||
sock_type = ctrl_type = SOCK_DGRAM;
|
||||
}
|
||||
else if (strncmp(str2, "tcp@", 4) == 0) {
|
||||
str2 += 4;
|
||||
ss.ss_family = AF_UNSPEC;
|
||||
sock_type = ctrl_type = SOCK_STREAM;
|
||||
}
|
||||
else if (strncmp(str2, "udp@", 4) == 0) {
|
||||
str2 += 4;
|
||||
ss.ss_family = AF_UNSPEC;
|
||||
|
Loading…
Reference in New Issue
Block a user