From 1ba14f3e52820e3cdfe46215bc675d071e798e23 Mon Sep 17 00:00:00 2001 From: Xinyu Ma Date: Mon, 11 Dec 2023 23:12:06 -0800 Subject: [PATCH] examples: Change Unix socket path See: https://redmine.named-data.net/issues/5304 --- src/ndn/platform/linux.py | 5 ++++- src/ndn/platform/osx.py | 5 ++++- src/ndn/platform/windows.py | 13 ++++++++++--- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/ndn/platform/linux.py b/src/ndn/platform/linux.py index 6b64f8c..367ff7d 100644 --- a/src/ndn/platform/linux.py +++ b/src/ndn/platform/linux.py @@ -28,7 +28,10 @@ def client_conf_paths(self): '/etc/ndn/client.conf'] def default_transport(self): - return 'unix:///run/nfd.sock' + if not os.path.exists('/run/nfd/nfd.sock') and os.path.exists('/run/nfd.sock'): + # Try to be compatible to old NFD + return 'unix:///run/nfd.sock' + return 'unix:///run/nfd/nfd.sock' def default_pib_scheme(self): return 'pib-sqlite3' diff --git a/src/ndn/platform/osx.py b/src/ndn/platform/osx.py index d480063..3780e01 100644 --- a/src/ndn/platform/osx.py +++ b/src/ndn/platform/osx.py @@ -121,7 +121,10 @@ def client_conf_paths(self): '/etc/ndn/client.conf'] def default_transport(self): - return 'unix:///var/run/nfd.sock' + if not os.path.exists('/var/run/nfd/nfd.sock') and os.path.exists('/var/run/nfd.sock'): + # Try to be compatible to old NFD + return 'unix:///var/run/nfd.sock' + return 'unix:///var/run/nfd/nfd.sock' def default_pib_scheme(self): return 'pib-sqlite3' diff --git a/src/ndn/platform/windows.py b/src/ndn/platform/windows.py index 09fc427..029584b 100644 --- a/src/ndn/platform/windows.py +++ b/src/ndn/platform/windows.py @@ -47,8 +47,10 @@ class Cng: NCRYPT_ECDSA_P521_ALGORITHM = BCRYPT_ECDSA_P521_ALGORITHM BCRYPT_OBJECT_LENGTH = c.c_wchar_p('ObjectLength') BCRYPT_HASH_LENGTH = c.c_wchar_p('HashDigestLength') - MS_PLATFORM_KEY_STORAGE_PROVIDER = c.c_wchar_p('Microsoft Platform Crypto Provider') - MS_KEY_STORAGE_PROVIDER = c.c_wchar_p('Microsoft Software Key Storage Provider') + MS_PLATFORM_KEY_STORAGE_PROVIDER = c.c_wchar_p( + 'Microsoft Platform Crypto Provider') + MS_KEY_STORAGE_PROVIDER = c.c_wchar_p( + 'Microsoft Software Key Storage Provider') BCRYPT_ECCPUBLIC_BLOB = c.c_wchar_p('ECCPUBLICBLOB') BCRYPT_ECCPRIVATE_BLOB = c.c_wchar_p('ECCPRIVATEBLOB') @@ -79,7 +81,12 @@ def client_conf_paths(self): def default_transport(self): # Note: %TEMP% won't be redirected even when the executable is a MSIX/MicrosoftStore app - return 'unix://' + os.path.expandvars(r'%TEMP%\nfd.sock') + oldPath = os.path.expandvars(r'%TEMP%\nfd.sock') + newPath = os.path.expandvars(r'%TEMP%\nfd\nfd.sock') + if not os.path.exists(newPath) and os.path.exists(oldPath): + # Try to be compatible to old NFD + return 'unix://' + oldPath + return 'unix://' + newPath def default_pib_scheme(self): return 'pib-sqlite3'