2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-31 05:55:28 +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",
// Address of the HTTPS socket the Kea DHCP-DDNS server should
// listen for incoming queries. In fact an alias of
// socket-name.
// listen for incoming queries.
"socket-address": "127.0.0.1",
// Port of the HTTPS socket the Kea DHCP-DDNS server

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -92,7 +92,7 @@ HttpCommandMgrImpl::configure(HttpCommandConfigPtr config) {
(config->getCertRequired() != current_config_->getCertRequired())) {
LOG_WARN(command_logger, HTTP_COMMAND_MGR_IGNORED_TLS_SETUP_CHANGES);
// Overwrite the authentication setup and the emulation flag
//in the response creator config.
// in the response creator config.
current_config_->setAuthConfig(config->getAuthConfig());
current_config_->setEmulateAgentResponse(config->getEmulateAgentResponse());
} else {

View File

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