Added initiator/responder_id load tester options to enforce different identities
This commit is contained in:
@@ -64,6 +64,16 @@ struct private_load_tester_config_t {
|
|||||||
*/
|
*/
|
||||||
char *responder_auth;
|
char *responder_auth;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initiator ID to enforce
|
||||||
|
*/
|
||||||
|
char *initiator_id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Responder ID to enforce
|
||||||
|
*/
|
||||||
|
char *responder_id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IKE_SA rekeying delay
|
* IKE_SA rekeying delay
|
||||||
*/
|
*/
|
||||||
@@ -102,24 +112,46 @@ static void generate_auth_cfg(private_load_tester_config_t *this, char *str,
|
|||||||
enumerator = enumerator_create_token(str, "|", " ");
|
enumerator = enumerator_create_token(str, "|", " ");
|
||||||
while (enumerator->enumerate(enumerator, &str))
|
while (enumerator->enumerate(enumerator, &str))
|
||||||
{
|
{
|
||||||
|
id = NULL;
|
||||||
auth = auth_cfg_create();
|
auth = auth_cfg_create();
|
||||||
rnd++;
|
rnd++;
|
||||||
|
|
||||||
|
if (this->initiator_id)
|
||||||
|
{
|
||||||
|
if ((local && num) || (!local && !num))
|
||||||
|
{
|
||||||
|
snprintf(buf, sizeof(buf), this->initiator_id, num, rnd);
|
||||||
|
id = identification_create_from_string(buf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (this->responder_id)
|
||||||
|
{
|
||||||
|
if ((local && !num) || (!local && num))
|
||||||
|
{
|
||||||
|
snprintf(buf, sizeof(buf), this->responder_id, num, rnd);
|
||||||
|
id = identification_create_from_string(buf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (streq(str, "psk"))
|
if (streq(str, "psk"))
|
||||||
{ /* PSK authentication, use FQDNs */
|
{ /* PSK authentication, use FQDNs */
|
||||||
class = AUTH_CLASS_PSK;
|
class = AUTH_CLASS_PSK;
|
||||||
if ((local && !num) || (!local && num))
|
if (!id)
|
||||||
{
|
{
|
||||||
id = identification_create_from_string("srv.strongswan.org");
|
if ((local && !num) || (!local && num))
|
||||||
}
|
{
|
||||||
else if (local)
|
id = identification_create_from_string("srv.strongswan.org");
|
||||||
{
|
}
|
||||||
snprintf(buf, sizeof(buf), "c%d-r%d.strongswan.org", num, rnd);
|
else if (local)
|
||||||
id = identification_create_from_string(buf);
|
{
|
||||||
}
|
snprintf(buf, sizeof(buf), "c%d-r%d.strongswan.org",
|
||||||
else
|
num, rnd);
|
||||||
{
|
id = identification_create_from_string(buf);
|
||||||
id = identification_create_from_string("*.strongswan.org");
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
id = identification_create_from_string("*.strongswan.org");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (strneq(str, "eap", strlen("eap")))
|
else if (strneq(str, "eap", strlen("eap")))
|
||||||
@@ -133,14 +165,18 @@ static void generate_auth_cfg(private_load_tester_config_t *this, char *str,
|
|||||||
auth->add(auth, AUTH_RULE_EAP_TYPE, type);
|
auth->add(auth, AUTH_RULE_EAP_TYPE, type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (local && num)
|
if (!id)
|
||||||
{
|
{
|
||||||
snprintf(buf, sizeof(buf), "1%.10d%[email protected]", num, rnd);
|
if (local && num)
|
||||||
id = identification_create_from_string(buf);
|
{
|
||||||
}
|
snprintf(buf, sizeof(buf), "1%.10d%[email protected]",
|
||||||
else
|
num, rnd);
|
||||||
{
|
id = identification_create_from_string(buf);
|
||||||
id = identification_create_from_encoding(ID_ANY, chunk_empty);
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
id = identification_create_from_encoding(ID_ANY, chunk_empty);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -152,21 +188,24 @@ static void generate_auth_cfg(private_load_tester_config_t *this, char *str,
|
|||||||
}
|
}
|
||||||
/* certificate authentication, use distinguished names */
|
/* certificate authentication, use distinguished names */
|
||||||
class = AUTH_CLASS_PUBKEY;
|
class = AUTH_CLASS_PUBKEY;
|
||||||
if ((local && !num) || (!local && num))
|
if (!id)
|
||||||
{
|
{
|
||||||
id = identification_create_from_string(
|
if ((local && !num) || (!local && num))
|
||||||
"CN=srv, OU=load-test, O=strongSwan");
|
{
|
||||||
}
|
id = identification_create_from_string(
|
||||||
else if (local)
|
"CN=srv, OU=load-test, O=strongSwan");
|
||||||
{
|
}
|
||||||
snprintf(buf, sizeof(buf),
|
else if (local)
|
||||||
"CN=c%d-r%d, OU=load-test, O=strongSwan", num, rnd);
|
{
|
||||||
id = identification_create_from_string(buf);
|
snprintf(buf, sizeof(buf),
|
||||||
}
|
"CN=c%d-r%d, OU=load-test, O=strongSwan", num, rnd);
|
||||||
else
|
id = identification_create_from_string(buf);
|
||||||
{
|
}
|
||||||
id = identification_create_from_string(
|
else
|
||||||
"CN=*, OU=load-test, O=strongSwan");
|
{
|
||||||
|
id = identification_create_from_string(
|
||||||
|
"CN=*, OU=load-test, O=strongSwan");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
auth->add(auth, AUTH_RULE_AUTH_CLASS, class);
|
auth->add(auth, AUTH_RULE_AUTH_CLASS, class);
|
||||||
@@ -317,6 +356,10 @@ load_tester_config_t *load_tester_config_create()
|
|||||||
"charon.plugins.load-tester.initiator_auth", "pubkey");
|
"charon.plugins.load-tester.initiator_auth", "pubkey");
|
||||||
this->responder_auth = lib->settings->get_str(lib->settings,
|
this->responder_auth = lib->settings->get_str(lib->settings,
|
||||||
"charon.plugins.load-tester.responder_auth", "pubkey");
|
"charon.plugins.load-tester.responder_auth", "pubkey");
|
||||||
|
this->initiator_id = lib->settings->get_str(lib->settings,
|
||||||
|
"charon.plugins.load-tester.initiator_id", NULL);
|
||||||
|
this->responder_id = lib->settings->get_str(lib->settings,
|
||||||
|
"charon.plugins.load-tester.responder_id", NULL);
|
||||||
|
|
||||||
this->port = lib->settings->get_int(lib->settings,
|
this->port = lib->settings->get_int(lib->settings,
|
||||||
"charon.plugins.load-tester.dynamic_port", 0);
|
"charon.plugins.load-tester.dynamic_port", 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user