mirror of
https://gitlab.com/openconnect/ocserv.git
synced 2026-10-14 02:22:03 +08:00
simplify the input of IPv6 networks
The prefix is specified as part of the network.
This commit is contained in:
+1
-2
@@ -269,8 +269,7 @@ dns = 192.168.1.2
|
|||||||
#nbns = 192.168.1.3
|
#nbns = 192.168.1.3
|
||||||
|
|
||||||
# The IPv6 subnet that leases will be given from.
|
# The IPv6 subnet that leases will be given from.
|
||||||
#ipv6-network = fc00::
|
ipv6-network = fda9:4efe:7e3b:03ea::/64
|
||||||
#ipv6-prefix = 16
|
|
||||||
|
|
||||||
# The domains over which the provided DNS should be used. Use
|
# The domains over which the provided DNS should be used. Use
|
||||||
# multiple lines for multiple domains.
|
# multiple lines for multiple domains.
|
||||||
|
|||||||
@@ -367,6 +367,28 @@ static char *get_brackets_string2(void *pool, const char *str)
|
|||||||
return talloc_strndup(pool, p, len);
|
return talloc_strndup(pool, p, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Parses the string ::1/prefix, to return prefix
|
||||||
|
* and modify the string to contain the network only.
|
||||||
|
*/
|
||||||
|
unsigned extract_prefix(char *network)
|
||||||
|
{
|
||||||
|
char *p;
|
||||||
|
unsigned prefix;
|
||||||
|
|
||||||
|
if (network == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
p = strchr(network, '/');
|
||||||
|
|
||||||
|
if (p == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
prefix = atoi(p+1);
|
||||||
|
*p = 0;
|
||||||
|
|
||||||
|
return prefix;
|
||||||
|
}
|
||||||
|
|
||||||
const struct auth_mod_st *get_auth_mod(void)
|
const struct auth_mod_st *get_auth_mod(void)
|
||||||
{
|
{
|
||||||
return amod;
|
return amod;
|
||||||
@@ -646,7 +668,11 @@ unsigned force_cert_auth;
|
|||||||
|
|
||||||
READ_STRING("ipv6-network", config->network.ipv6);
|
READ_STRING("ipv6-network", config->network.ipv6);
|
||||||
|
|
||||||
|
prefix = extract_prefix(config->network.ipv6);
|
||||||
|
if (prefix == 0) {
|
||||||
READ_NUMERIC("ipv6-prefix", prefix);
|
READ_NUMERIC("ipv6-prefix", prefix);
|
||||||
|
}
|
||||||
|
|
||||||
if (prefix > 0) {
|
if (prefix > 0) {
|
||||||
config->network.ipv6_prefix = prefix;
|
config->network.ipv6_prefix = prefix;
|
||||||
|
|
||||||
|
|||||||
+2
-3
@@ -362,8 +362,7 @@ dns = 192.168.1.2
|
|||||||
#nbns = 192.168.1.3
|
#nbns = 192.168.1.3
|
||||||
|
|
||||||
# The IPv6 subnet that leases will be given from.
|
# The IPv6 subnet that leases will be given from.
|
||||||
#ipv6-network = fc00::
|
#ipv6-network = fda9:4efe:7e3b:03ea::/64
|
||||||
#ipv6-prefix = 16
|
|
||||||
|
|
||||||
# The domains over which the provided DNS should be used. Use
|
# The domains over which the provided DNS should be used. Use
|
||||||
# multiple lines for multiple domains.
|
# multiple lines for multiple domains.
|
||||||
@@ -421,7 +420,7 @@ route = 192.168.5.0/255.255.255.0
|
|||||||
# per group. Each file name on these directories must match the username
|
# per group. Each file name on these directories must match the username
|
||||||
# or the groupname.
|
# or the groupname.
|
||||||
# The options allowed in the configuration files are dns, nbns,
|
# The options allowed in the configuration files are dns, nbns,
|
||||||
# ipv?-network, ipv4-netmask, ipv6-prefix, rx/tx-per-sec, iroute, route,
|
# ipv?-network, ipv4-netmask, rx/tx-per-sec, iroute, route,
|
||||||
# net-priority, deny-roaming, no-udp, user-profile, require-cert, and cgroup.
|
# net-priority, deny-roaming, no-udp, user-profile, require-cert, and cgroup.
|
||||||
#
|
#
|
||||||
# Note that the 'iroute' option allows to add routes on the server
|
# Note that the 'iroute' option allows to add routes on the server
|
||||||
|
|||||||
@@ -204,7 +204,13 @@ unsigned prefix = 0;
|
|||||||
READ_RAW_STRING("ipv6-network", msg->ipv6_net);
|
READ_RAW_STRING("ipv6-network", msg->ipv6_net);
|
||||||
READ_RAW_STRING("ipv4-netmask", msg->ipv4_netmask);
|
READ_RAW_STRING("ipv4-netmask", msg->ipv4_netmask);
|
||||||
|
|
||||||
|
msg->ipv6_prefix = extract_prefix(msg->ipv6_net);
|
||||||
|
if (msg->ipv6_prefix == 0) {
|
||||||
READ_RAW_NUMERIC("ipv6-prefix", msg->ipv6_prefix, msg->has_ipv6_prefix);
|
READ_RAW_NUMERIC("ipv6-prefix", msg->ipv6_prefix, msg->has_ipv6_prefix);
|
||||||
|
} else {
|
||||||
|
msg->has_ipv6_prefix = 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (msg->has_ipv6_prefix != 0) {
|
if (msg->has_ipv6_prefix != 0) {
|
||||||
if (valid_ipv6_prefix(msg->ipv6_prefix) == 0) {
|
if (valid_ipv6_prefix(msg->ipv6_prefix) == 0) {
|
||||||
syslog(LOG_ERR, "unknown ipv6-prefix '%u' in %s", prefix, file);
|
syslog(LOG_ERR, "unknown ipv6-prefix '%u' in %s", prefix, file);
|
||||||
|
|||||||
@@ -317,6 +317,7 @@ struct main_server_st;
|
|||||||
|
|
||||||
#include <tun.h>
|
#include <tun.h>
|
||||||
|
|
||||||
|
unsigned extract_prefix(char *network);
|
||||||
char *human_addr2(const struct sockaddr *sa, socklen_t salen,
|
char *human_addr2(const struct sockaddr *sa, socklen_t salen,
|
||||||
void *buf, size_t buflen, unsigned full);
|
void *buf, size_t buflen, unsigned full);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user