summaryrefslogtreecommitdiff
path: root/python/vyos/interfaces.py
diff options
context:
space:
mode:
authorThomas Mangin <thomas.mangin@exa.net.uk>2020-03-30 18:05:40 +0100
committerThomas Mangin <thomas.mangin@exa.net.uk>2020-03-31 16:59:55 +0100
commit10f31524db1623bf115f88c3a432b5c37522d2e4 (patch)
tree92c09e4947c2ee15b93cc6e3034e4626f7a63ac2 /python/vyos/interfaces.py
parent05e79a4bb2137ee3ea563ced7f64b033c41eb438 (diff)
downloadvyos-1x-10f31524db1623bf115f88c3a432b5c37522d2e4.tar.gz
vyos-1x-10f31524db1623bf115f88c3a432b5c37522d2e4.zip
ifconfig: T2057: centralise wireguard code
Some left over wireguard code was left in the interface.py file. The code was moved into the wireguard.py file and the now empty interface.py file removed as no longer holdin any code.
Diffstat (limited to 'python/vyos/interfaces.py')
-rw-r--r--python/vyos/interfaces.py65
1 files changed, 0 insertions, 65 deletions
diff --git a/python/vyos/interfaces.py b/python/vyos/interfaces.py
deleted file mode 100644
index 4697c0acc..000000000
--- a/python/vyos/interfaces.py
+++ /dev/null
@@ -1,65 +0,0 @@
-# Copyright 2018 VyOS maintainers and contributors <maintainers@vyos.io>
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library. If not, see <http://www.gnu.org/licenses/>.
-
-import re
-import json
-
-from vyos.ifconfig import Interface
-import subprocess
-import netifaces
-
-
-def wireguard_dump():
- """Dump wireguard data in a python friendly way."""
- last_device=None
- output = {}
-
- # Dump wireguard connection data
- _f = subprocess.check_output(["wg", "show", "all", "dump"]).decode()
- for line in _f.split('\n'):
- if not line:
- # Skip empty lines and last line
- continue
- items = line.split('\t')
-
- if last_device != items[0]:
- # We are currently entering a new node
- device, private_key, public_key, listen_port, fw_mark = items
- last_device = device
-
- output[device] = {
- 'private_key': None if private_key == '(none)' else private_key,
- 'public_key': None if public_key == '(none)' else public_key,
- 'listen_port': int(listen_port),
- 'fw_mark': None if fw_mark == 'off' else int(fw_mark),
- 'peers': {},
- }
- else:
- # We are entering a peer
- device, public_key, preshared_key, endpoint, allowed_ips, latest_handshake, transfer_rx, transfer_tx, persistent_keepalive = items
- if allowed_ips == '(none)':
- allowed_ips = []
- else:
- allowed_ips = allowed_ips.split('\t')
- output[device]['peers'][public_key] = {
- 'preshared_key': None if preshared_key == '(none)' else preshared_key,
- 'endpoint': None if endpoint == '(none)' else endpoint,
- 'allowed_ips': allowed_ips,
- 'latest_handshake': None if latest_handshake == '0' else int(latest_handshake),
- 'transfer_rx': int(transfer_rx),
- 'transfer_tx': int(transfer_tx),
- 'persistent_keepalive': None if persistent_keepalive == 'off' else int(persistent_keepalive),
- }
- return output