Finishing bundle
Change-Id: I276c9e76ab46a69b1388eb2ce4b6919b0f5ab7d6
diff --git a/make-deps.sh b/make-deps.sh
index 244d0f8..b54cd9d 100755
--- a/make-deps.sh
+++ b/make-deps.sh
@@ -14,6 +14,30 @@
git clone ${GIT}/ndn-cxx build/ndn-cxx
pushd build/ndn-cxx
git checkout ${NDN_CXX_COMMIT}
+
+patch -p1 <<EOF
+diff --git a/src/transport/unix-transport.cpp b/src/transport/unix-transport.cpp
+index 59c00ae..aa67b24 100644
+--- a/src/transport/unix-transport.cpp
++++ b/src/transport/unix-transport.cpp
+@@ -74,7 +74,7 @@ UnixTransport::getDefaultSocketName(const ConfigFile& config)
+ }
+
+ // Assume the default nfd.sock location.
+- return "/var/run/nfd.sock";
++ return "/tmp/nfd.sock";
+ }
+
+ shared_ptr<UnixTransport>
+@@ -135,4 +135,4 @@ UnixTransport::resume()
+
+ }
+
+-#endif // _WIN32
+\ No newline at end of file
++#endif // _WIN32
+EOF
+
./waf configure --prefix="${path}/build/deps"
./waf build
./waf install
@@ -31,3 +55,6 @@
./waf build
./waf install
popd
+
+PKG_CONFIG_PATH="${path}/build/deps/lib/pkgconfig:${PKG_CONFIG_PATH}" \
+ ./waf configure
diff --git a/make-osx-bundle.py b/make-osx-bundle.py
index 8df5b41..00ac760 100755
--- a/make-osx-bundle.py
+++ b/make-osx-bundle.py
@@ -221,87 +221,113 @@
return
- def copy_qt_plugins(self):
+ def copy_etc(self, rsrcs):
'''
- Copy over any needed Qt plugins.
+ Copy needed config files into our bundle.
'''
+ print ' * Copying needed config files'
+ rsrcpath = os.path.join(self.bundle, 'Contents', 'etc')
+ if not os.path.exists(rsrcpath):
+ os.mkdir(rsrcpath)
- print ' * Copying Qt and preparing plugins'
+ # Copy resources already in the bundle
+ for rsrc in rsrcs:
+ b = os.path.basename(rsrc)
+ if os.path.isdir(rsrc):
+ shutil.copytree(rsrc, os.path.join(rsrcpath, b), symlinks=True)
+ elif os.path.isfile(rsrc):
+ shutil.copy(rsrc, os.path.join(rsrcpath, b))
- src = os.popen('qmake -query QT_INSTALL_PLUGINS').read().strip()
- dst = os.path.join(self.bundle, 'Contents', 'QtPlugins')
- shutil.copytree(src, dst, symlinks=False)
+ return
+ # def copy_qt_plugins(self):
+ # '''
+ # Copy over any needed Qt plugins.
+ # '''
- top = dst
- files = {}
+ # print ' * Copying Qt and preparing plugins'
- def cb(arg, dirname, fnames):
- if dirname == top:
- return
- files[os.path.basename(dirname)] = fnames
+ # src = os.popen('qmake -query QT_INSTALL_PLUGINS').read().strip()
+ # dst = os.path.join(self.bundle, 'Contents', 'QtPlugins')
+ # shutil.copytree(src, dst, symlinks=False)
- os.path.walk(top, cb, None)
+ # top = dst
+ # files = {}
- exclude = ( 'phonon_backend', 'designer', 'script' )
+ # def cb(arg, dirname, fnames):
+ # if dirname == top:
+ # return
+ # files[os.path.basename(dirname)] = fnames
- for dir, files in files.items():
- absdir = dst + '/' + dir
- if dir in exclude:
- shutil.rmtree(absdir)
- continue
- for file in files:
- abs = absdir + '/' + file
- if file.endswith('_debug.dylib'):
- os.remove(abs)
- else:
- os.system('install_name_tool -id "%s" "%s"' % (file, abs))
- self.handle_binary_libs(abs)
+ # os.path.walk(top, cb, None)
+ # exclude = ( 'phonon_backend', 'designer', 'script' )
+
+ # for dir, files in files.items():
+ # absdir = dst + '/' + dir
+ # if dir in exclude:
+ # shutil.rmtree(absdir)
+ # continue
+ # for file in files:
+ # abs = absdir + '/' + file
+ # if file.endswith('_debug.dylib'):
+ # os.remove(abs)
+ # else:
+ # os.system('install_name_tool -id "%s" "%s"' % (file, abs))
+ # self.handle_binary_libs(abs)
+
+ def macdeployqt(self):
+ Popen(['macdeployqt', self.bundle, '-qmldir=src', '-executable=%s' % self.binary]).communicate()
+
def copy_ndn_deps(self, path):
'''
Copy over NDN dependencies (NFD and related apps)
'''
print ' * Copying NDN dependencies'
- src = path
- dst = os.path.join(self.bundle, 'Contents', 'Resources', 'platform')
+ src = os.path.join(path, 'bin')
+ dst = os.path.join(self.bundle, 'Contents', 'Platform')
shutil.copytree(src, dst, symlinks=False)
- top = dst
- files = {}
-
- def cb(arg, dirname, fnames):
- if dirname == top:
- return
- files[dirname] = fnames
-
- os.path.walk(top, cb, None)
-
- # Cleanup debug folders stuff
- excludeDirs = ['include', 'pkgconfig']
- excludeFiles = ['libndn-cxx.dylib', 'nfd-start', 'nfd-stop']
-
- for dir, files in files.items():
- basename = os.path.basename(dir)
- if basename in excludeDirs:
- shutil.rmtree(dir)
- continue
+ for subdir, dirs, files in os.walk(dst):
for file in files:
- if file in excludeFiles:
- abs = dir + '/' + file
- os.remove(abs)
-
- top = dst
- files = {}
-
- os.path.walk(top, cb, None)
+ abs = subdir + "/" + file
+ self.handle_binary_libs(abs)
- for dir, files in files.items():
- for file in files:
- abs = dir + '/' + file
- type = Popen(['file', '-b', abs], stdout=PIPE).communicate()[0].strip()
- if type.startswith('Mach-O'):
- self.handle_binary_libs(abs)
+ # top = dst
+ # files = {}
+
+ # def cb(arg, dirname, fnames):
+ # if dirname == top:
+ # return
+ # files[dirname] = fnames
+
+ # os.path.walk(top, cb, None)
+
+ # # Cleanup debug folders stuff
+ # excludeDirs = ['include', 'pkgconfig', 'lib'] # lib already processed
+ # excludeFiles = ['libndn-cxx.dylib', 'nfd-start', 'nfd-stop']
+
+ # for dir, files in files.items():
+ # basename = os.path.basename(dir)
+ # if basename in excludeDirs:
+ # shutil.rmtree(dir)
+ # continue
+ # for file in files:
+ # if file in excludeFiles:
+ # abs = dir + '/' + file
+ # os.remove(abs)
+
+ # top = dst
+ # files = {}
+
+ # os.path.walk(top, cb, None)
+
+ # for dir, files in files.items():
+ # for file in files:
+ # abs = dir + '/' + file
+ # type = Popen(['file', '-b', abs], stdout=PIPE).communicate()[0].strip()
+ # if type.startswith('Mach-O'):
+ # self.handle_binary_libs(abs)
def set_min_macosx_version(self, version):
@@ -416,11 +442,13 @@
# Do the finishing touches to our Application bundle before release
shutil.rmtree('build/%s/NDN.app' % (MIN_SUPPORTED_VERSION), ignore_errors=True)
a = AppBundle('build/%s/NDN.app' % (MIN_SUPPORTED_VERSION), ver, 'build/NFD Control Center.app')
- a.copy_qt_plugins()
- a.handle_libs()
+ # a.copy_qt_plugins()
+ # a.handle_libs()
a.copy_ndn_deps("build/deps")
- a.copy_resources(['qt.conf'])
+ # a.copy_resources(['qt.conf'])
+ a.copy_etc(['nfd.conf'])
a.set_min_macosx_version('%s.0' % MIN_SUPPORTED_VERSION)
+ a.macdeployqt()
a.done()
# Sign our binaries, etc.
diff --git a/nfd.conf b/nfd.conf
new file mode 100644
index 0000000..a517020
--- /dev/null
+++ b/nfd.conf
@@ -0,0 +1,334 @@
+; The general section contains settings of nfd process.
+general
+{
+ ; Specify a user and/or group for NFD to drop privileges to
+ ; when not performing privileged tasks. NFD does not drop
+ ; privileges by default.
+
+ ; user ndn-user
+ ; group ndn-user
+}
+
+log
+{
+ ; default_level specifies the logging level for modules
+ ; that are not explicitly named. All debugging levels
+ ; listed above the selected value are enabled.
+ ;
+ ; Valid values:
+ ;
+ ; NONE ; no messages
+ ; ERROR ; error messages
+ ; WARN ; warning messages
+ ; INFO ; informational messages (default)
+ ; DEBUG ; debugging messages
+ ; TRACE ; trace messages (most verbose)
+ ; ALL ; all messages
+
+ default_level INFO
+
+ ; You may override default_level by assigning a logging level
+ ; to the desired module name. Module names can be found in two ways:
+ ;
+ ; Run:
+ ; nfd --modules
+ ;
+ ; Or look for NFD_LOG_INIT(<module name>) statements in .cpp files
+ ;
+ ; Example module-level settings:
+ ;
+ ; FibManager DEBUG
+ ; Forwarder INFO
+}
+
+; The tables section configures the CS, PIT, FIB, Strategy Choice, and Measurements
+tables
+{
+
+ ; ContentStore size limit in number of packets
+ ; default is 65536, about 500MB with 8KB packet size
+ cs_max_packets 65536
+
+ ; Set the forwarding strategy for the specified prefixes:
+ ; <prefix> <strategy>
+ strategy_choice
+ {
+ / /localhost/nfd/strategy/best-route
+ /localhost /localhost/nfd/strategy/multicast
+ /localhost/nfd /localhost/nfd/strategy/best-route
+ /ndn/broadcast /localhost/nfd/strategy/multicast
+ }
+
+ ; Declare network region names
+ ; These are used for mobility support. An Interest carrying a Link object is
+ ; assumed to have reached the producer region if any delegation name in the
+ ; Link object is a prefix of any region name.
+ network_region
+ {
+ ; /example/region1
+ ; /example/region2
+ }
+}
+
+; The face_system section defines what faces and channels are created.
+face_system
+{
+ ; The unix section contains settings of Unix stream faces and channels.
+ ; Unix channel is always listening; delete unix section to disable
+ ; Unix stream faces and channels.
+ ;
+ ; The ndn-cxx library expects unix:///var/run/nfd.sock
+ ; to be used as the default transport option. Please change
+ ; the "transport" field in client.conf to an appropriate tcp4 FaceUri
+ ; if you need to disable unix sockets.
+ unix
+ {
+ path /tmp/nfd.sock ; Unix stream listener path
+ }
+
+ ; The tcp section contains settings of TCP faces and channels.
+ tcp
+ {
+ listen yes ; set to 'no' to disable TCP listener, default 'yes'
+ port 6363 ; TCP listener port number
+ enable_v4 yes ; set to 'no' to disable IPv4 channels, default 'yes'
+ enable_v6 yes ; set to 'no' to disable IPv6 channels, default 'yes'
+ }
+
+ ; The udp section contains settings of UDP faces and channels.
+ ; UDP channel is always listening; delete udp section to disable UDP
+ udp
+ {
+ port 6363 ; UDP unicast port number
+ enable_v4 yes ; set to 'no' to disable IPv4 channels, default 'yes'
+ enable_v6 yes ; set to 'no' to disable IPv6 channels, default 'yes'
+
+ ; idle time (seconds) before closing a UDP unicast face, the actual timeout would be
+ ; anywhere within [idle_timeout, 2*idle_timeout), default is 600
+ idle_timeout 600
+
+ keep_alive_interval 25; interval (seconds) between keep-alive refreshes
+
+ ; UDP multicast settings
+ ; NFD creates one UDP multicast face per NIC
+ ;
+ ; In multi-homed Linux machines these settings will NOT work without
+ ; root or settings the appropriate permissions:
+ ;
+ ; sudo setcap cap_net_raw=eip /full/path/nfd
+ ;
+ mcast yes ; set to 'no' to disable UDP multicast, default 'yes'
+ mcast_port 56363 ; UDP multicast port number
+ mcast_group 224.0.23.170 ; UDP multicast group (IPv4 only)
+ }
+
+ ; The ether section contains settings of Ethernet faces and channels.
+ ; These settings will NOT work without root or setting the appropriate
+ ; permissions:
+ ;
+ ; sudo setcap cap_net_raw,cap_net_admin=eip /full/path/nfd
+ ;
+ ; You may need to install a package to use setcap:
+ ;
+ ; **Ubuntu:**
+ ;
+ ; sudo apt-get install libcap2-bin
+ ;
+ ; **Mac OS X:**
+ ;
+ ; curl https://bugs.wireshark.org/bugzilla/attachment.cgi?id=3373 -o ChmodBPF.tar.gz
+ ; tar zxvf ChmodBPF.tar.gz
+ ; open ChmodBPF/Install\ ChmodBPF.app
+ ;
+ ; or manually:
+ ;
+ ; sudo chgrp admin /dev/bpf*
+ ; sudo chmod g+rw /dev/bpf*
+
+ ; ether
+ ; {
+ ; ; Ethernet multicast settings
+ ; ; NFD creates one Ethernet multicast face per NIC
+ ;
+ ; mcast yes ; set to 'no' to disable Ethernet multicast, default 'yes'
+ ; mcast_group 01:00:5E:00:17:AA ; Ethernet multicast group
+ ; }
+
+ ; The websocket section contains settings of WebSocket faces and channels.
+
+ websocket
+ {
+ listen yes ; set to 'no' to disable WebSocket listener, default 'yes'
+ port 9696 ; WebSocket listener port number
+ enable_v4 yes ; set to 'no' to disable listening on IPv4 socket, default 'yes'
+ enable_v6 yes ; set to 'no' to disable listening on IPv6 socket, default 'yes'
+ }
+}
+
+; The authorizations section grants privileges to authorized keys.
+authorizations
+{
+ ; An authorize section grants privileges to a NDN certificate.
+ authorize
+ {
+ ; If you do not already have NDN certificate, you can generate
+ ; one with the following commands.
+ ;
+ ; 1. Generate and install a self-signed identity certificate:
+ ;
+ ; ndnsec-keygen /`whoami` | ndnsec-install-cert -
+ ;
+ ; Note that the argument to ndnsec-key will be the identity name of the
+ ; new key (in this case, /your-username). Identities are hierarchical NDN
+ ; names and may have multiple components (e.g. `/ndn/ucla/edu/alice`).
+ ; You may create additional keys and identities as you see fit.
+ ;
+ ; 2. Dump the NDN certificate to a file:
+ ;
+ ; sudo mkdir -p /Users/cawka/Devel/ndn/NFD-Control-Center/build/deps/etc/ndn/keys/
+ ; ndnsec-cert-dump -i /`whoami` > default.ndncert
+ ; sudo mv default.ndncert /Users/cawka/Devel/ndn/NFD-Control-Center/build/deps/etc/ndn/keys/default.ndncert
+ ;
+ ; The "certfile" field below specifies the default key directory for
+ ; your machine. You may move your newly created key to the location it
+ ; specifies or path.
+
+ ; certfile keys/default.ndncert ; NDN identity certificate file
+ certfile any ; "any" authorizes command interests signed under any certificate,
+ ; i.e., no actual validation.
+ privileges ; set of privileges granted to this identity
+ {
+ faces
+ fib
+ strategy-choice
+ }
+ }
+
+ ; You may have multiple authorize sections that specify additional
+ ; certificates and their privileges.
+
+ ; authorize
+ ; {
+ ; certfile keys/this_cert_does_not_exist.ndncert
+ ; authorize
+ ; privileges
+ ; {
+ ; faces
+ ; }
+ ; }
+}
+
+rib
+{
+ ; The following localhost_security allows anyone to register routing entries in local RIB
+ localhost_security
+ {
+ trust-anchor
+ {
+ type any
+ }
+ }
+
+ ; localhop_security should be enabled when NFD runs on a hub.
+ ; "/localhop/nfd/fib" command prefix will be disabled when localhop_security section is missing.
+ ; localhop_security
+ ; {
+ ; ; This section defines the trust model for NFD RIB Management. It consists of rules and
+ ; ; trust-anchors, which are briefly defined in this file. For more information refer to
+ ; ; manpage of ndn-validator.conf:
+ ; ;
+ ; ; man ndn-validator.conf
+ ; ;
+ ; ; A trust-anchor is a pre-trusted certificate. This can be any certificate that is the
+ ; ; root of certification chain (e.g., NDN testbed root certificate) or an existing
+ ; ; default system certificate `default.ndncert`.
+ ; ;
+ ; ; A rule defines conditions a valid packet MUST have. A packet must satisfy one of the
+ ; ; rules defined here. A rule can be broken into two parts: matching & checking. A packet
+ ; ; will be matched against rules from the first to the last until a matched rule is
+ ; ; encountered. The matched rule will be used to check the packet. If a packet does not
+ ; ; match any rule, it will be treated as invalid. The matching part of a rule consists
+ ; ; of `for` and `filter` sections. They collectively define which packets can be checked
+ ; ; with this rule. `for` defines packet type (data or interest) and `filter` defines
+ ; ; conditions on other properties of a packet. Right now, you can only define conditions
+ ; ; on packet name, and you can only specify ONLY ONE filter for packet name. The
+ ; ; checking part of a rule consists of `checker`, which defines the conditions that a
+ ; ; VALID packet MUST have. See comments in checker section for more details.
+ ;
+ ; rule
+ ; {
+ ; id "NRD Prefix Registration Command Rule"
+ ; for interest ; rule for Interests (to validate CommandInterests)
+ ; filter
+ ; {
+ ; type name ; condition on interest name (w/o signature)
+ ; regex ^[<localhop><localhost>]<nfd><rib>[<register><unregister>]<>$ ; prefix before
+ ; ; timestamp
+ ; }
+ ; checker
+ ; {
+ ; type customized
+ ; sig-type rsa-sha256 ; interest must have a rsa-sha256 signature
+ ; key-locator
+ ; {
+ ; type name ; key locator must be the certificate name of the
+ ; ; signing key
+ ; regex ^[^<KEY>]*<KEY><>*<ksk-.*><ID-CERT>$
+ ; }
+ ; }
+ ; }
+ ; rule
+ ; {
+ ; id "NDN Testbed Hierarchy Rule"
+ ; for data ; rule for Data (to validate NDN certificates)
+ ; filter
+ ; {
+ ; type name ; condition on data name
+ ; regex ^[^<KEY>]*<KEY><>*<ksk-.*><ID-CERT><>$
+ ; }
+ ; checker
+ ; {
+ ; type hierarchical ; the certificate name of the signing key and
+ ; ; the data name must follow the hierarchical model
+ ; sig-type rsa-sha256 ; data must have a rsa-sha256 signature
+ ; }
+ ; }
+ ; trust-anchor
+ ; {
+ ; type file
+ ; file-name keys/default.ndncert ; the file name, by default this file should be placed in the
+ ; ; same folder as this config file.
+ ; }
+ ; ; trust-anchor ; Can be repeated multiple times to specify multiple trust anchors
+ ; ; {
+ ; ; type file
+ ; ; file-name keys/ndn-testbed.ndncert
+ ; ; }
+ ; }
+
+ ; The following localhop_security should be enabled when NFD runs on a hub,
+ ; which accepts all remote registrations and is a short-term solution.
+ ; localhop_security
+ ; {
+ ; trust-anchor
+ ; {
+ ; type any
+ ; }
+ ; }
+
+ auto_prefix_propagate
+ {
+ cost 15 ; forwarding cost of prefix registered on remote router
+ timeout 10000 ; timeout (in milliseconds) of prefix registration command for propagation
+
+ refresh_interval 300 ; interval (in seconds) before refreshing the propagation
+ ; This setting should be less than face_system.udp.idle_time,
+ ; so that the face is kept alive on the remote router.
+
+ base_retry_wait 50 ; base wait time (in seconds) before retrying propagation
+ max_retry_wait 3600 ; maximum wait time (in seconds) before retrying propagation
+ ; for consequent retries, the wait time before each retry is calculated based on the back-off
+ ; policy. Initially, the wait time is set to base_retry_wait, then it will be doubled for every
+ ; retry unless beyond the max_retry_wait, in which case max_retry_wait is set as the wait time.
+ }
+}
diff --git a/res/ndn b/res/ndn
index 5803fbe..ec05781 100755
--- a/res/ndn
+++ b/res/ndn
@@ -10,4 +10,4 @@
exit 1
fi
-/Applications/NDN.app/Contents/Resources/platform/bin/"$@"
+/Applications/NDN.app/Contents/Platform/"$@"
diff --git a/src/main.cpp b/src/main.cpp
index ad4dcf0..0dbbfd2 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -73,6 +73,7 @@
}
catch (const std::exception&e) {
emit m_tray.nfdActivityUpdate(false);
+ m_face.shutdown();
#ifdef BOOST_THREAD_USES_CHRONO
boost::this_thread::sleep_for(retryTimeout);
#else
diff --git a/src/tray-menu.cpp b/src/tray-menu.cpp
index 2a1b32a..9aa0d8b 100644
--- a/src/tray-menu.cpp
+++ b/src/tray-menu.cpp
@@ -13,7 +13,7 @@
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License along with NFD
+ * You should have received a copy of the GNU General Public License along with NFD
* Control Center, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
@@ -53,7 +53,6 @@
#endif
, m_entryQuit(new QAction("Quit", m_menu))
, m_keyViewerDialog(new ncc::KeyViewerDialog)
-
{
connect(m_entryPref, SIGNAL(triggered()), this, SIGNAL(showApp()));
connect(m_entrySec, SIGNAL(triggered()), m_keyViewerDialog, SLOT(present()));
@@ -131,29 +130,33 @@
void
TrayMenu::startNfd()
{
+#ifdef OSX_BUILD
+ QProcess* proc = new QProcess();
+ connect(proc, SIGNAL(finished(int)), proc, SLOT(deleteLater()));
+ proc->startDetached((QCoreApplication::applicationDirPath().toStdString() + "/../Platform/nfd").c_str(),
+ QStringList()
+ << "--config"
+ << (QCoreApplication::applicationDirPath().toStdString() + "/../etc/nfd.conf").c_str());
+// #endif
// QProcess * proc = new QProcess();
-// connect(proc,SIGNAL(finished(int)), proc, SLOT(deleteLater()));
+// connect(proc, SIGNAL(finished(int)), proc, SLOT(deleteLater()));
// #ifdef __linux__
// proc->start("gksudo", QStringList() << NFD_START_COMMAND);
// #else
// proc->start("osascript", QStringList()
// << "-e"
// << "do shell script \"" NFD_START_COMMAND "\" with administrator privileges");
-// #endif
+#endif
}
void
TrayMenu::stopNfd()
{
-// QProcess * proc = new QProcess();
-// connect(proc,SIGNAL(finished(int)), proc, SLOT(deleteLater()));
-// #ifdef __linux__
-// proc->start("gksudo", QStringList() << NFD_STOP_COMMAND);
-// #else
-// proc->start("osascript", QStringList()
-// << "-e"
-// << "do shell script \"" NFD_STOP_COMMAND "\" with administrator privileges");
-// #endif
+#ifdef OSX_BUILD
+ QProcess* proc = new QProcess();
+ connect(proc, SIGNAL(finished(int)), proc, SLOT(deleteLater()));
+ proc->startDetached("killall", QStringList() << "nfd");
+#endif
}
Q_INVOKABLE void
@@ -245,18 +248,6 @@
kAuthorizationFlagDefaults,
(char**)args.data(), NULL);
- // QVector<char *> args;
- // QVector<QByteArray> utf8Args;
- // for (const QString &argument : arguments) {
- // utf8Args.push_back(argument.toUtf8());
- // args.push_back(utf8Args.last().data());
- // }
- // args.push_back(0);
-
- // const QByteArray utf8Program = program.toUtf8();
- // status = AuthorizationExecuteWithPrivileges(authorizationRef, utf8Program.data(),
- // kAuthorizationFlagDefaults, args.data(), 0);
-
AuthorizationFree(authorizationRef, kAuthorizationFlagDestroyRights);
#endif
}