summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--python/vyos/remote.py14
-rwxr-xr-xsrc/op_mode/ping.py7
-rwxr-xr-xsrc/op_mode/vpn_ike_sa.py4
3 files changed, 22 insertions, 3 deletions
diff --git a/python/vyos/remote.py b/python/vyos/remote.py
index c36b77630..05f739dc8 100644
--- a/python/vyos/remote.py
+++ b/python/vyos/remote.py
@@ -17,6 +17,7 @@ from ftplib import FTP
import os
import shutil
import socket
+import stat
import sys
import tempfile
import urllib.parse
@@ -152,7 +153,18 @@ def transfer_sftp(mode, local_path, hostname, remote_path,\
ssh.connect(hostname, port, username, password, sock=sock)
with ssh.open_sftp() as sftp:
if mode == 'upload':
- sftp.put(local_path, remote_path, callback=callback)
+ try:
+ # If the remote path is a directory, use the original filename.
+ if stat.S_ISDIR(sftp.stat(remote_path).st_mode):
+ path = os.path.join(remote_path, os.path.basename(local_path))
+ # A file exists at this destination. We're simply going to clobber it.
+ else:
+ path = remote_path
+ # This path doesn't point at any existing file. We can freely use this filename.
+ except IOError:
+ path = remote_path
+ finally:
+ sftp.put(local_path, path, callback=callback)
elif mode == 'download':
sftp.get(remote_path, local_path, callback=callback)
elif mode == 'size':
diff --git a/src/op_mode/ping.py b/src/op_mode/ping.py
index 29b430d53..924a889db 100755
--- a/src/op_mode/ping.py
+++ b/src/op_mode/ping.py
@@ -50,6 +50,11 @@ options = {
'type': '<seconds>',
'help': 'Number of seconds before ping exits'
},
+ 'do-not-fragment': {
+ 'ping': '{command} -M dont',
+ 'type': 'noarg',
+ 'help': 'Set DF-bit flag to 1 for no fragmentation'
+ },
'flood': {
'ping': 'sudo {command} -f',
'type': 'noarg',
@@ -227,4 +232,4 @@ if __name__ == '__main__':
# print(f'{command} {host}')
os.system(f'{command} {host}')
-
+ \ No newline at end of file
diff --git a/src/op_mode/vpn_ike_sa.py b/src/op_mode/vpn_ike_sa.py
index fe016da45..2a3fbf718 100755
--- a/src/op_mode/vpn_ike_sa.py
+++ b/src/op_mode/vpn_ike_sa.py
@@ -49,7 +49,9 @@ def ike_sa(peer, nat):
print('%-39s %-39s' % (remote_str, local_str))
state = 'up' if 'state' in sa and s(sa['state']) == 'ESTABLISHED' else 'down'
version = 'IKEv' + s(sa['version'])
- encryption = f'{s(sa["encr-alg"])}_{s(sa["encr-keysize"])}' if 'encr-alg' in sa else 'n/a'
+ encryption = f'{s(sa["encr-alg"])}' if 'encr-alg' in sa else 'n/a'
+ if 'encr-keysize' in sa:
+ encyption += '_' + s(sa["encr-keysize"])
integrity = s(sa['integ-alg']) if 'integ-alg' in sa else 'n/a'
dh_group = s(sa['dh-group']) if 'dh-group' in sa else 'n/a'
natt = 'yes' if 'nat-local' in sa and s(sa['nat-local']) == 'yes' else 'no'