-
Notifications
You must be signed in to change notification settings - Fork 335
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ipoe_server: T6872: Add the ability to configure LUA scripts and user…
…name
- Loading branch information
1 parent
c6a097e
commit e8e72e2
Showing
3 changed files
with
56 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ | |
from vyos.accel_ppp_util import verify_accel_ppp_authentication | ||
from vyos import ConfigError | ||
from vyos import airbag | ||
|
||
airbag.enable() | ||
|
||
|
||
|
@@ -52,7 +53,9 @@ def get_config(config=None): | |
|
||
if dict_search('client_ip_pool', ipoe): | ||
# Multiple named pools require ordered values T5099 | ||
ipoe['ordered_named_pools'] = get_pools_in_order(dict_search('client_ip_pool', ipoe)) | ||
ipoe['ordered_named_pools'] = get_pools_in_order( | ||
dict_search('client_ip_pool', ipoe) | ||
) | ||
|
||
ipoe['server_type'] = 'ipoe' | ||
return ipoe | ||
|
@@ -68,11 +71,23 @@ def verify(ipoe): | |
for interface, iface_config in ipoe['interface'].items(): | ||
verify_interface_exists(ipoe, interface, warning_only=True) | ||
if 'client_subnet' in iface_config and 'vlan' in iface_config: | ||
raise ConfigError('Option "client-subnet" and "vlan" are mutually exclusive, ' | ||
'use "client-ip-pool" instead!') | ||
if 'vlan_mon' in iface_config and not 'vlan' in iface_config: | ||
raise ConfigError( | ||
'Options "client-subnet" and "vlan" are mutually exclusive, ' | ||
'use "client-ip-pool" instead!' | ||
) | ||
if 'vlan_mon' in iface_config and 'vlan' not in iface_config: | ||
raise ConfigError('Option "vlan-mon" requires "vlan" to be set!') | ||
|
||
if 'lua_username' in iface_config: | ||
if 'lua_file' not in ipoe: | ||
raise ConfigError( | ||
'Option "lua-username" requires "lua-file" to be set!' | ||
) | ||
if dict_search('authentication.mode', ipoe) != 'radius': | ||
raise ConfigError( | ||
'Can configure username with Lua script only for RADIUS authentication' | ||
) | ||
|
||
verify_accel_ppp_authentication(ipoe, local_users=False) | ||
verify_accel_ppp_ip_pool(ipoe) | ||
verify_accel_ppp_name_servers(ipoe) | ||
|
@@ -88,22 +103,26 @@ def generate(ipoe): | |
render(ipoe_conf, 'accel-ppp/ipoe.config.j2', ipoe) | ||
|
||
if dict_search('authentication.mode', ipoe) == 'local': | ||
render(ipoe_chap_secrets, 'accel-ppp/chap-secrets.ipoe.j2', | ||
ipoe, permission=0o640) | ||
render( | ||
ipoe_chap_secrets, 'accel-ppp/chap-secrets.ipoe.j2', ipoe, permission=0o640 | ||
) | ||
return None | ||
|
||
|
||
def apply(ipoe): | ||
systemd_service = '[email protected]' | ||
if ipoe == None: | ||
if ipoe is None: | ||
call(f'systemctl stop {systemd_service}') | ||
for file in [ipoe_conf, ipoe_chap_secrets]: | ||
if os.path.exists(file): | ||
os.unlink(file) | ||
|
||
return None | ||
|
||
call(f'systemctl reload-or-restart {systemd_service}') | ||
# Accel-pppd does not do soft-reload correctly. | ||
# Most of the changes require restarting the service | ||
call(f'systemctl restart {systemd_service}') | ||
|
||
|
||
if __name__ == '__main__': | ||
try: | ||
|