mirror of
https://gitlab.com/openconnect/ocserv.git
synced 2026-02-10 16:57:00 +08:00
The route configuration directive accepts the keyword 'default'
In that case it will return a default route irrespective of any other route directives. That allows overriding existing routes with a default route for specific users and groups.
This commit is contained in:
@@ -171,6 +171,19 @@ udp_fd_fail:
|
||||
return -1;
|
||||
}
|
||||
|
||||
unsigned check_if_default_route(char **routes, unsigned routes_size)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
for (i=0;i<routes_size;i++) {
|
||||
if (strcmp(routes[i], "default") == 0 ||
|
||||
strcmp(routes[i], "0.0.0.0/0") == 0)
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Completes the VPN device information.
|
||||
*
|
||||
* Returns 0 on success.
|
||||
@@ -196,6 +209,9 @@ int complete_vpn_info(worker_st * ws, struct vpn_st *vinfo)
|
||||
if (ws->config->network.routes_size > 0)
|
||||
vinfo->routes = ws->config->network.routes;
|
||||
|
||||
if (check_if_default_route(vinfo->routes, vinfo->routes_size))
|
||||
ws->default_route = 1;
|
||||
|
||||
vinfo->ipv4_netmask = ws->config->network.ipv4_netmask;
|
||||
vinfo->ipv6_netmask = ws->config->network.ipv6_netmask;
|
||||
vinfo->ipv6_prefix = ws->config->network.ipv6_prefix;
|
||||
|
||||
Reference in New Issue
Block a user