2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-09-01 06:25:34 +00:00

[#3477] Making socket name/address exclusive (1)

This commit is contained in:
Francis Dupont
2024-07-23 15:57:34 +02:00
parent 32040d36b5
commit bf4ed59d63
9 changed files with 21 additions and 31 deletions

View File

@@ -52,8 +52,7 @@
"socket-type": "https", "socket-type": "https",
// Address of the HTTPS socket the Kea DHCP-DDNS server should // Address of the HTTPS socket the Kea DHCP-DDNS server should
// listen for incoming queries. In fact an alias of // listen for incoming queries.
// socket-name.
"socket-address": "127.0.0.1", "socket-address": "127.0.0.1",
// Port of the HTTPS socket the Kea DHCP-DDNS server // Port of the HTTPS socket the Kea DHCP-DDNS server

View File

@@ -160,8 +160,7 @@
"socket-type": "https", "socket-type": "https",
// Address of the HTTPS socket the Kea DHCPv4 server should // Address of the HTTPS socket the Kea DHCPv4 server should
// listen for incoming queries. In fact an alias of // listen for incoming queries.
// socket-name.
"socket-address": "127.0.0.1", "socket-address": "127.0.0.1",
// Port of the HTTPS socket the Kea DHCPv4 server // Port of the HTTPS socket the Kea DHCPv4 server

View File

@@ -111,8 +111,7 @@
"socket-type": "https", "socket-type": "https",
// Address of the HTTPS socket the Kea DHCPv6 server should // Address of the HTTPS socket the Kea DHCPv6 server should
// listen for incoming queries. In fact an alias of // listen for incoming queries.
// socket-name.
"socket-address": "::1", "socket-address": "::1",
// Port of the HTTPS socket the Kea DHCPv6 server // Port of the HTTPS socket the Kea DHCPv6 server

View File

@@ -844,6 +844,7 @@ control_socket_type_value:
control_socket_name: SOCKET_NAME { control_socket_name: SOCKET_NAME {
ctx.unique("socket-name", ctx.loc2pos(@1)); ctx.unique("socket-name", ctx.loc2pos(@1));
ctx.unique("socket-address", ctx.loc2pos(@1));
ctx.enter(ctx.NO_KEYWORD); ctx.enter(ctx.NO_KEYWORD);
} COLON STRING { } COLON STRING {
ElementPtr name(new StringElement($4, ctx.loc2pos(@4))); ElementPtr name(new StringElement($4, ctx.loc2pos(@4)));
@@ -853,6 +854,7 @@ control_socket_name: SOCKET_NAME {
control_socket_address: SOCKET_ADDRESS { control_socket_address: SOCKET_ADDRESS {
ctx.unique("socket-address", ctx.loc2pos(@1)); ctx.unique("socket-address", ctx.loc2pos(@1));
ctx.unique("socket-name", ctx.loc2pos(@1));
ctx.enter(ctx.NO_KEYWORD); ctx.enter(ctx.NO_KEYWORD);
} COLON STRING { } COLON STRING {
ElementPtr address(new StringElement($4, ctx.loc2pos(@4))); ElementPtr address(new StringElement($4, ctx.loc2pos(@4)));

View File

@@ -2591,6 +2591,7 @@ control_socket_type_value:
control_socket_name: SOCKET_NAME { control_socket_name: SOCKET_NAME {
ctx.unique("socket-name", ctx.loc2pos(@1)); ctx.unique("socket-name", ctx.loc2pos(@1));
ctx.unique("socket-address", ctx.loc2pos(@1));
ctx.enter(ctx.NO_KEYWORD); ctx.enter(ctx.NO_KEYWORD);
} COLON STRING { } COLON STRING {
ElementPtr name(new StringElement($4, ctx.loc2pos(@4))); ElementPtr name(new StringElement($4, ctx.loc2pos(@4)));
@@ -2600,6 +2601,7 @@ control_socket_name: SOCKET_NAME {
control_socket_address: SOCKET_ADDRESS { control_socket_address: SOCKET_ADDRESS {
ctx.unique("socket-address", ctx.loc2pos(@1)); ctx.unique("socket-address", ctx.loc2pos(@1));
ctx.unique("socket-name", ctx.loc2pos(@1));
ctx.enter(ctx.NO_KEYWORD); ctx.enter(ctx.NO_KEYWORD);
} COLON STRING { } COLON STRING {
ElementPtr address(new StringElement($4, ctx.loc2pos(@4))); ElementPtr address(new StringElement($4, ctx.loc2pos(@4)));

View File

@@ -2720,6 +2720,7 @@ control_socket_type_value:
control_socket_name: SOCKET_NAME { control_socket_name: SOCKET_NAME {
ctx.unique("socket-name", ctx.loc2pos(@1)); ctx.unique("socket-name", ctx.loc2pos(@1));
ctx.unique("socket-address", ctx.loc2pos(@1));
ctx.enter(ctx.NO_KEYWORD); ctx.enter(ctx.NO_KEYWORD);
} COLON STRING { } COLON STRING {
ElementPtr name(new StringElement($4, ctx.loc2pos(@4))); ElementPtr name(new StringElement($4, ctx.loc2pos(@4)));
@@ -2729,6 +2730,7 @@ control_socket_name: SOCKET_NAME {
control_socket_address: SOCKET_ADDRESS { control_socket_address: SOCKET_ADDRESS {
ctx.unique("socket-address", ctx.loc2pos(@1)); ctx.unique("socket-address", ctx.loc2pos(@1));
ctx.unique("socket-name", ctx.loc2pos(@1));
ctx.enter(ctx.NO_KEYWORD); ctx.enter(ctx.NO_KEYWORD);
} COLON STRING { } COLON STRING {
ElementPtr address(new StringElement($4, ctx.loc2pos(@4))); ElementPtr address(new StringElement($4, ctx.loc2pos(@4)));

View File

@@ -51,24 +51,18 @@ HttpCommandConfig::HttpCommandConfig(ConstElementPtr config)
<< socket_type_ << "' not 'http' or 'https'"); << socket_type_ << "' not 'http' or 'https'");
} }
} }
// Reject UNIX only socket-name.
// Get socket address. if (config->contains("socket-name")) {
ConstElementPtr socket_name = config->get("socket-name");
ConstElementPtr socket_address = config->get("socket-address");
if (socket_name) {
// socket-name is an alias of socket-address.
if (socket_address) {
isc_throw(DhcpConfigError, isc_throw(DhcpConfigError,
"specify both 'socket-name' and 'socket-address' " "parameter 'socket-name' is not supported by HTTP "
"is forbidden"); "control sockets");
}
socket_address = socket_name;
} }
// Get socket address.
ConstElementPtr socket_address = config->get("socket-address");
if (socket_address) { if (socket_address) {
if (socket_address->getType() != Element::string) { if (socket_address->getType() != Element::string) {
isc_throw(DhcpConfigError, isc_throw(DhcpConfigError,
"invalid type specified for parameter 'socket-" "invalid type specified for parameter 'socket-address' ("
<< (socket_name ? "name" : "address") << "' ("
<< socket_address->getPosition() << ")"); << socket_address->getPosition() << ")");
} }
try { try {

View File

@@ -102,16 +102,9 @@ TEST_F(HttpCommandConfigTest, errors) {
"unsupported 'socket-type' 'unix' not 'http' or 'https'" "unsupported 'socket-type' 'unix' not 'http' or 'https'"
}, },
{ {
"both socket-name and socket-address", "unsupported socket-name",
R"( { "socket-name": "::1", "socket-address": "::1" } )", R"( { "socket-name": "::1" } )",
"specify both 'socket-name' and 'socket-address' " "parameter 'socket-name' is not supported by HTTP control sockets"
"is forbidden"
},
{
"bad socket-name type",
R"( { "socket-name": 8000 } )",
"invalid type specified for parameter 'socket-name' "
"(<string>:1:19)"
}, },
{ {
"bad socket-address type", "bad socket-address type",