Skip to content

Commit

Permalink
nfd-status-http-server: change default port to 6380
Browse files Browse the repository at this point in the history
Change-Id: Ibccd79d04da346443ad17db9220940c488bc9873
  • Loading branch information
Pesa committed May 13, 2024
1 parent f568c5e commit 48108e0
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 43 deletions.
48 changes: 23 additions & 25 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,31 @@ RUN apt-get install -Uy --no-install-recommends \
ARG JOBS
ARG SOURCE_DATE_EPOCH
RUN --mount=rw,target=/src <<EOF
set -eux
cd /src
./waf configure \
--prefix=/usr \
--libdir=/usr/lib \
--sysconfdir=/etc \
--localstatedir=/var \
--sharedstatedir=/var \
--without-systemd
./waf build
./waf install
mkdir -p /deps/debian
touch /deps/debian/control
cd /deps
for binary in nfd nfdc nfd-autoreg; do
dpkg-shlibdeps --ignore-missing-info "/usr/bin/${binary}" -O \
| sed -n 's|^shlibs:Depends=||p' | sed 's| ([^)]*),\?||g' > "${binary}"
done
set -eux
cd /src
./waf configure \
--prefix=/usr \
--libdir=/usr/lib \
--sysconfdir=/etc \
--localstatedir=/var \
--sharedstatedir=/var \
--without-systemd
./waf build
./waf install
mkdir -p /deps/debian
touch /deps/debian/control
cd /deps
for binary in nfd nfdc; do
dpkg-shlibdeps --ignore-missing-info "/usr/bin/${binary}" -O \
| sed -n 's|^shlibs:Depends=||p' | sed 's| ([^)]*),\?||g' > "${binary}"
done
EOF


FROM ghcr.io/named-data/ndn-cxx-runtime:${NDN_CXX_VERSION} AS nfd-autoreg

COPY --link --from=build /usr/bin/nfd-autoreg /usr/bin/

RUN --mount=from=build,source=/deps,target=/deps \
apt-get install -Uy --no-install-recommends $(cat /deps/nfd-autoreg) \
&& apt-get distclean

ENV HOME=/config
VOLUME /config
VOLUME /run/nfd
Expand All @@ -53,15 +49,16 @@ COPY --link --from=build /usr/bin/nfd-status-http-server /usr/bin/
COPY --link --from=build /usr/share/ndn/ /usr/share/ndn/

RUN --mount=from=build,source=/deps,target=/deps \
apt-get install -Uy --no-install-recommends $(cat /deps/nfdc) \
apt-get install -Uy --no-install-recommends \
$(cat /deps/nfdc) \
python3 \
&& apt-get distclean

ENV HOME=/config
VOLUME /config
VOLUME /run/nfd

EXPOSE 8080/tcp
EXPOSE 6380/tcp

ENTRYPOINT ["/usr/bin/nfd-status-http-server", "--address", "0.0.0.0"]

Expand All @@ -73,7 +70,8 @@ COPY --link --from=build /usr/bin/nfd /usr/bin/
COPY --link --from=build /etc/ndn/nfd.conf.sample /config/nfd.conf

RUN --mount=from=build,source=/deps,target=/deps \
apt-get install -Uy --no-install-recommends $(cat /deps/nfd /deps/nfdc) \
apt-get install -Uy --no-install-recommends \
$(cat /deps/nfd /deps/nfdc) \
&& apt-get distclean

ENV HOME=/config
Expand Down
12 changes: 6 additions & 6 deletions docs/manpages/nfd-status-http-server.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Synopsis
Description
-----------

``nfd-status-http-server`` is a daemon that enables retrieval of NFD status via HTTP protocol.
``nfd-status-http-server`` is a daemon that enables the retrieval of NFD's status over HTTP.

Options
-------
Expand All @@ -21,7 +21,7 @@ Options
HTTP server IP address (default is 127.0.0.1).

``-p <PORT>``
HTTP server port number (default is 8080).
HTTP server port number (default is 6380).

``-r``
Enable HTTP robots to crawl (disabled by default).
Expand All @@ -32,10 +32,10 @@ Options
Examples
--------

Enable NFD HTTP status server on all IPv4 interfaces::
Start NFD's HTTP status server on all IPv4 interfaces, port 80 (requires root)::

nfd-status-http-server -p 80 -a 0.0.0.0
nfd-status-http-server -a 0.0.0.0 -p 80

Enable NFD HTTP status server on all IPv6 interfaces::
Start NFD's HTTP status server on all IPv6 interfaces, port 8000::

nfd-status-http-server -p 80 -a ::
nfd-status-http-server -a :: -p 8000
22 changes: 10 additions & 12 deletions tools/nfd-status-http-server.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
"""
Copyright (c) 2014-2023, Regents of the University of California,
Copyright (c) 2014-2024, Regents of the University of California,
Arizona Board of Regents,
Colorado State University,
University Pierre & Marie Curie, Sorbonne University,
Expand All @@ -23,9 +23,13 @@
NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
"""

import argparse
import ipaddress
import os
import socket
import subprocess
from http.server import SimpleHTTPRequestHandler, ThreadingHTTPServer
from urllib.parse import urlsplit
import argparse, ipaddress, os, socket, subprocess


class NfdStatusHandler(SimpleHTTPRequestHandler):
Expand Down Expand Up @@ -57,11 +61,7 @@ def __serve_report(self):
# add stylesheet processing instruction after the XML document type declaration
# (yes, this is a ugly hack)
if (pos := output.find(">") + 1) != 0:
xml = (
output[:pos]
+ '<?xml-stylesheet type="text/xsl" href="nfd-status.xsl"?>'
+ output[pos:]
)
xml = output[:pos] + '<?xml-stylesheet type="text/xsl" href="nfd-status.xsl"?>' + output[pos:]
self.send_response(200)
self.send_header("Content-Type", "text/xml; charset=UTF-8")
self.end_headers()
Expand Down Expand Up @@ -110,14 +110,12 @@ def port_number(arg, /):
parser.add_argument("-V", "--version", action="version", version="@VERSION@")
parser.add_argument("-a", "--address", default="127.0.0.1", type=ip_address, metavar="ADDR",
help="bind to this IP address (default: %(default)s)")
parser.add_argument("-p", "--port", default=8080, type=port_number,
parser.add_argument("-p", "--port", default=6380, type=port_number,
help="bind to this port number (default: %(default)s)")
parser.add_argument("-f", "--workdir", default="@DATAROOTDIR@/ndn", metavar="DIR",
help="server's working directory (default: %(default)s)")
parser.add_argument("-r", "--robots", action="store_true",
help="allow crawlers and other HTTP bots")
parser.add_argument("-v", "--verbose", action="store_true",
help="turn on verbose logging")
parser.add_argument("-r", "--robots", action="store_true", help="allow crawlers and other HTTP bots")
parser.add_argument("-v", "--verbose", action="store_true", help="turn on verbose logging")
args = parser.parse_args()

os.chdir(args.workdir)
Expand Down

0 comments on commit 48108e0

Please sign in to comment.