charon-cmd: Make local host configurable
This allows preferring a particular address family (via 0.0.0.0 or ::) or even a specific local address.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Tobias Brunner
|
||||
* Copyright (C) 2013-2026 Tobias Brunner
|
||||
* Copyright (C) 2013 Martin Willi
|
||||
*
|
||||
* Copyright (C) secunet Security Networks AG
|
||||
@@ -102,6 +102,11 @@ struct private_cmd_connection_t {
|
||||
*/
|
||||
char *host;
|
||||
|
||||
/**
|
||||
* Hostname to connect from
|
||||
*/
|
||||
char *host_local;
|
||||
|
||||
/**
|
||||
* Server identity, or NULL to use host
|
||||
*/
|
||||
@@ -150,7 +155,7 @@ static peer_cfg_t* create_peer_cfg(private_cmd_connection_t *this)
|
||||
peer_cfg_t *peer_cfg;
|
||||
proposal_t *proposal;
|
||||
ike_cfg_create_t ike = {
|
||||
.local = "%any",
|
||||
.local = this->host_local ?: "%any",
|
||||
.remote = this->host,
|
||||
.remote_port = IKEV2_UDP_PORT,
|
||||
.fragmentation = FRAGMENTATION_YES,
|
||||
@@ -502,6 +507,9 @@ METHOD(cmd_connection_t, handle, bool,
|
||||
case CMD_OPT_HOST:
|
||||
this->host = arg;
|
||||
break;
|
||||
case CMD_OPT_HOST_LOCAL:
|
||||
this->host_local = arg;
|
||||
break;
|
||||
case CMD_OPT_REMOTE_IDENTITY:
|
||||
this->server = arg;
|
||||
break;
|
||||
|
||||
@@ -31,6 +31,8 @@ cmd_option_t cmd_options[CMD_OPT_COUNT] = {
|
||||
"set the default log level (-1..4, default: 1)", {}},
|
||||
{ CMD_OPT_HOST, "host", required_argument, "hostname",
|
||||
"DNS name or address to connect to", {}},
|
||||
{ CMD_OPT_HOST_LOCAL, "host-local", required_argument, "hostname",
|
||||
"DNS name or address to connect from (default: %any)", {}},
|
||||
{ CMD_OPT_IDENTITY, "identity", required_argument, "identity",
|
||||
"identity the client uses for the IKE exchange", {}},
|
||||
{ CMD_OPT_EAP_IDENTITY, "eap-identity", required_argument, "eap-identity",
|
||||
|
||||
@@ -34,6 +34,7 @@ enum cmd_option_type_t {
|
||||
CMD_OPT_VERSION,
|
||||
CMD_OPT_DEBUG,
|
||||
CMD_OPT_HOST,
|
||||
CMD_OPT_HOST_LOCAL,
|
||||
CMD_OPT_IDENTITY,
|
||||
CMD_OPT_EAP_IDENTITY,
|
||||
CMD_OPT_XAUTH_USER,
|
||||
|
||||
Reference in New Issue
Block a user