]> Cypherpunks.ru repositories - nncp.git/commitdiff
Replace YAML with Hjson
authorSergey Matveev <stargrave@stargrave.org>
Mon, 11 Nov 2019 17:36:20 +0000 (20:36 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Wed, 13 Nov 2019 13:03:37 +0000 (16:03 +0300)
50 files changed:
README
README.RU
VERSION
common.mk
doc/about.ru.texi
doc/about.texi
doc/call.texi
doc/cfg.texi
doc/cmds.texi
doc/comparison.ru.texi
doc/comparison.texi
doc/download.texi
doc/integration.texi
doc/integrity.texi
doc/news.ru.texi
doc/news.texi
doc/platforms.texi
doc/sources.texi
doc/usecases.ru.texi
doc/usecases.texi
makedist.sh
ports/nncp/Makefile
ports/nncp/files/nncp-caller.in
ports/nncp/files/nncp-daemon.in
ports/nncp/files/nncp-toss.in
ports/nncp/files/pkg-deinstall.in
ports/nncp/files/pkg-message.in
src/cfg.go
src/cmd/nncp-bundle/main.go
src/cmd/nncp-call/main.go
src/cmd/nncp-caller/main.go
src/cmd/nncp-cfgenc/main.go
src/cmd/nncp-cfgmin/main.go
src/cmd/nncp-cfgnew/main.go
src/cmd/nncp-check/main.go
src/cmd/nncp-daemon/main.go
src/cmd/nncp-exec/main.go
src/cmd/nncp-file/main.go
src/cmd/nncp-freq/main.go
src/cmd/nncp-log/main.go
src/cmd/nncp-pkt/main.go
src/cmd/nncp-reass/main.go
src/cmd/nncp-rm/main.go
src/cmd/nncp-stat/main.go
src/cmd/nncp-toss/main.go
src/cmd/nncp-xfer/main.go
src/ctx.go
src/go.mod
src/go.sum
src/toss.go

diff --git a/README b/README
index faf31c30440c92514d533aa79faf8ed8653106e9..11f7bc99bfab571685c05117a3420b5bc3a84b1d 100644 (file)
--- a/README
+++ b/README
@@ -16,7 +16,7 @@ online TCP daemon with full-duplex resumable data transmission exists.
 
 NNCP is copylefted free software: see the file COPYING for copying
 conditions. It should work on all POSIX-compatible systems. Easy
-integration with existing SMTP servers. Single YAML configuration file.
+integration with existing SMTP servers. Single Hjson configuration file.
 
 Home page: http://www.nncpgo.org/
 
index 30e40c321bfc29e8c28ab35f060babfbcec28300..f0ae3c1afccad522c3d992f432b12c463f6c95ad 100644 (file)
--- a/README.RU
+++ b/README.RU
@@ -21,7 +21,7 @@ NNCP (Node to Node copy) это набор утилит упрощающий б
 NNCP это свободное программное обеспечением: условия распространения
 находятся в файле COPYING. Оно должно работать на всех POSIX-совместимых
 системах. Лёгкая интеграция с существующими SMTP серверами. Единственный
-конфигурационный YAML файл.
+конфигурационный Hjson файл.
 
 Домашняя страница: http://www.nncpgo.org/
 
diff --git a/VERSION b/VERSION
index 6aba2b245a847cc30a9b9dc009fc9d2522fff998..0062ac971805f7b700058db4bb0f5c5b771dda76 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-4.2.0
+5.0.0
index 5ab825bdcf8cf0590a28310d0096ba7f4feff861..61fc12811d6cc6187bd8164fad7a6717d1c91756 100644 (file)
--- a/common.mk
+++ b/common.mk
@@ -2,7 +2,7 @@ GO ?= go
 PREFIX ?= /usr/local
 
 SENDMAIL ?= /usr/sbin/sendmail
-CFGPATH ?= $(PREFIX)/etc/nncp.yaml
+CFGPATH ?= $(PREFIX)/etc/nncp.hjson
 SPOOLPATH ?= /var/spool/nncp
 LOGPATH ?= /var/spool/nncp/log
 
@@ -10,7 +10,7 @@ BINDIR = $(DESTDIR)$(PREFIX)/bin
 INFODIR = $(DESTDIR)$(PREFIX)/info
 DOCDIR = $(DESTDIR)$(PREFIX)/share/doc/nncp
 
-MOD = go.cypherpunks.ru/nncp/v4
+MOD = go.cypherpunks.ru/nncp/v5
 
 LDFLAGS = \
        -X $(MOD).Version=$(VERSION) \
index d75d57611c0f49fa5fbfe1831591bd55b8b76c0b..bb9c2d0cb76a0f9480678d14e4aa366e8ea2e94d 100644 (file)
@@ -42,7 +42,7 @@ NNCP это @url{https://www.gnu.org/philosophy/pragmatic.ru.html,
 должно работать на всех @url{https://ru.wikipedia.org/wiki/POSIX,
 POSIX}-совместимых системах. Лёгкая @ref{Integration, интеграция} с
 существующими @url{https://ru.wikipedia.org/wiki/SMTP, SMTP} серверами.
-Единственный конфигурационный @url{http://yaml.org/, YAML} файл.
+Единственный конфигурационный @url{https://hjson.org/, Hjson} файл.
 
 Зачем создавать ещё одно решение с принципом сохранить-и-переслать когда
 уже существуют UUCP, FTN и даже SMTP? Посмотрите @ref{Сравнение, сравнение}!
index a11526182cac4975b3c5c70bbf017cd567a5bd01..f228d15ca099c671e2da7f13df247db2979221cf 100644 (file)
@@ -33,7 +33,7 @@ licenced under @url{https://www.gnu.org/licenses/gpl-3.0.html, GNU GPLv3}.
 It should work on all @url{https://en.wikipedia.org/wiki/POSIX,
 POSIX}-compatible systems. Easy @ref{Integration, integration} with existing
 @url{https://en.wikipedia.org/wiki/SMTP, SMTP} servers. Single
-@url{http://yaml.org/, YAML} configuration file.
+@url{https://hjson.org/, Hjson} configuration file.
 
 Why create yet another store-and-forward solution when UUCP, FTN and
 even SMTP exists? Look in @ref{Comparison, comparison} section!
index edf2d707ac51d6697568b343cf70b2643de57774..447b764615af969e24ec8917fbbc50b8f5f00c28 100644 (file)
@@ -6,22 +6,26 @@ Call is a rule when and how node can be called.
 Example list of call structures:
 
 @verbatim
-calls:
-  -
-    cron: "*/1 * * * MON-FRI"
-    onlinedeadline: 3600
-    nice: PRIORITY+10
-  -
-    cron: "30 * * * SAT,SUN"
-    onlinedeadline: 1800
-    maxonlinetime: 1750
-    nice: NORMAL
-    rxrate: 10
-    txrate: 20
-  -
-    cron: "0 * * * SAT,SUN"
-    xx: rx
-    addr: lan
+calls: [
+    {
+        cron: "*/1 * * * MON-FRI"
+        onlinedeadline: 3600
+        nice: PRIORITY+10
+    },
+    {
+        cron: "30 * * * SAT,SUN"
+        onlinedeadline: 1800
+        maxonlinetime: 1750
+        nice: NORMAL
+        rxrate: 10
+        txrate: 20
+    },
+    {
+        cron: "0 * * * SAT,SUN"
+        xx: rx
+        addr: lan
+    },
+]
 @end verbatim
 
 tells that on work days of the week call that node every minute,
index 410bee884e2ef7305ccbff340a3846ab09f43471..2004073c98245043e085194be51f211399b17d1f 100644 (file)
@@ -1,64 +1,76 @@
 @node Configuration
 @unnumbered Configuration file
 
-Example YAML configuration file:
+Example @url{https://hjson.org/, Hjson} configuration file:
 
 @verbatim
-spool: /var/spool/nncp
-log: /var/spool/nncp/log
-notify:
-  file:
-    from: nncp@localhost
-    to: user+file@example.com
-  freq:
-    from: nncp@localhost
-    to: user+freq@example.com
-self:
-  id: TIJQL...2NGIA
-  exchpub: CYVGQ...PSEWQ
-  exchprv: 65PUY...MPZ3Q
-  signpub: 2NMVC...CMH5Q
-  signprv: 555JD...RGD6Y
-  noiseprv: D62XU...NKYPA
-  noisepub: KIBKK...ESM7Q
-neigh:
-  self:
+{
+  spool: /var/spool/nncp
+  log: /var/spool/nncp/log
+  notify: {
+    file: {
+      from: nncp@localhost
+      to: user+file@example.com
+    }
+    freq: {
+      from: nncp@localhost
+      to: user+freq@example.com
+    }
+  }
+  self: {
     id: TIJQL...2NGIA
     exchpub: CYVGQ...PSEWQ
+    exchprv: 65PUY...MPZ3Q
     signpub: 2NMVC...CMH5Q
+    signprv: 555JD...RGD6Y
+    noiseprv: D62XU...NKYPA
     noisepub: KIBKK...ESM7Q
-    exec:
-      sendmail: [/usr/sbin/sendmail]
-  alice:
-    id: XJZBK...65IJQ
-    exchpub: MJACJ...FAI6A
-    signpub: T4AFC...N2FRQ
-    noisepub: UBM5K...VI42A
-    exec:
-      flag: ["/usr/bin/touch", "-t"]
-    incoming: /home/alice/incoming
-    onlinedeadline: 1800
-    maxonlinetime: 3600
-    addrs:
-      lan: "[fe80::1234%igb0]:5400"
-      internet: alice.com:3389
-    calls:
-      -
-        cron: "*/2 * * * *"
-  bob:
-    id: 2IZNP...UYGYA
-    exchpub: WFLMZ...B7NHA
-    signpub: GTGXG...IE3OA
-    exec:
-      sendmail: [/usr/sbin/sendmail]
-      warcer: [/path/to/warcer.sh]
-      wgeter: [/path/to/wgeter.sh]
-    freq: /home/bob/pub
-    freqchunked: 1024
-    freqminsize: 2048
-    via: [alice]
-    rxrate: 10
-    txrate: 20
+  }
+  neigh: {
+    self: {
+      id: TIJQL...2NGIA
+      exchpub: CYVGQ...PSEWQ
+      signpub: 2NMVC...CMH5Q
+      noisepub: KIBKK...ESM7Q
+      exec: {sendmail: ["/usr/sbin/sendmail"]}
+    }
+    alice: {
+      id: "XJZBK...65IJQ"
+      exchpub: MJACJ...FAI6A
+      signpub: T4AFC...N2FRQ
+      noisepub: UBM5K...VI42A
+      exec: {flag: ["/usr/bin/touch", "-t"]}
+      incoming: "/home/alice/incoming"
+      onlinedeadline: 1800
+      maxonlinetime: 3600
+      addrs: {
+        lan: "[fe80::1234%igb0]:5400"
+        internet: alice.com:3389
+      }
+      calls: [
+        {
+          cron: "*/2 * * * *"
+        },
+      ]
+    }
+    bob: {
+      id: 2IZNP...UYGYA
+      exchpub: WFLMZ...B7NHA
+      signpub: GTGXG...IE3OA
+      exec: {
+        sendmail: ["/usr/sbin/sendmail"]
+        warcer: ["/path/to/warcer.sh"]
+        wgeter: ["/path/to/wgeter.sh"]
+      }
+      freq: "/home/bob/pub"
+      freqchunked: 1024
+      freqminsize: 2048
+      via: ["alice"]
+      rxrate: 10
+      txrate: 20
+    }
+  }
+}
 @end verbatim
 
 @strong{spool} field contains an absolute path to @ref{Spool, spool}
index b2d11b432aab887bc0954fb0422981c12915aa18..c2107bed94fe2f1157925104767b5899de82b86d 100644 (file)
@@ -156,11 +156,11 @@ notification.
 @section nncp-cfgenc
 
 @verbatim
-$ nncp-cfgmin [options] [-s INT] [-t INT] [-p INT] cfg.yaml > cfg.yaml.eblob
-$ nncp-cfgmin [options] -d cfg.yaml.eblob > cfg.yaml
+$ nncp-cfgmin [options] [-s INT] [-t INT] [-p INT] cfg.hjson > cfg.hjson.eblob
+$ nncp-cfgmin [options] -d cfg.hjson.eblob > cfg.hjson
 @end verbatim
 
-This command allows you to encrypt provided @file{cfg.yaml} file with
+This command allows you to encrypt provided @file{cfg.hjson} file with
 the passphrase, producing @ref{EBlob, eblob}, to safely keep your
 configuration file with private keys. This utility was written for users
 who do not want (or can not) to use either @url{https://gnupg.org/,
@@ -184,7 +184,7 @@ if passphrase can not decrypt @file{eblob}.
 @option{-dump} options parses @file{eblob} and prints parameters used
 during its creation. For example:
 @verbatim
-$ nncp-cfgenc -dump /usr/local/etc/nncp.yaml.eblob
+$ nncp-cfgenc -dump /usr/local/etc/nncp.hjson.eblob
 Strengthening function: Balloon with BLAKE2b-256
 Memory space cost: 1048576 bytes
 Number of rounds: 16
@@ -196,7 +196,7 @@ Blob size: 2494
 @section nncp-cfgmin
 
 @verbatim
-$ nncp-cfgmin [options] > stripped.yaml
+$ nncp-cfgmin [options] > stripped.hjson
 @end verbatim
 
 Print out stripped configuration version: only path to @ref{Spool,
@@ -208,12 +208,13 @@ neighbours, without private keys involving.
 @section nncp-cfgnew
 
 @verbatim
-$ nncp-cfgnew [options] > new.yaml
+$ nncp-cfgnew [options] [-nocomments] > new.hjson
 @end verbatim
 
 Generate new node configuration: private keys, example configuration
 file and print it to stdout. You must use this command when you setup
-the new node.
+the new node. @option{-nocomments} will create configuration file
+without descriptive huge comments -- useful for advanced users.
 
 Pay attention that private keys generation consumes an entropy from your
 operating system.
@@ -269,9 +270,10 @@ For example, if remote side has following configuration file for your
 node:
 
 @verbatim
-exec:
+exec: {
   sendmail: [/usr/sbin/sendmail, "-t"]
   appender: ["/bin/sh", "-c", "cat >> /append"]
+}
 @end verbatim
 
 then executing @verb{|echo My message | nncp-exec -replynice 123 REMOTE
index 772b6f3401f3260991b1d78134e2df4f896488fa..7b02d03e7f9aa2f343a2a5e6f6a49f58e8df5903 100644 (file)
@@ -48,7 +48,7 @@
     того, из коробки не предоставляется никакого шифрования и сильной
     аутентификации.
 
-    NNCP требует редактирование единственного YAML @ref{Configuration,
+    NNCP требует редактирование единственного Hjson @ref{Configuration,
     конфигурационного файла}.
 
 @item Передача новостей
index f68e57c4a14789e2996c1d0f1b121e12ca67118e..11fe4a21882b31e3ba88fd0c93295685fb021a08 100644 (file)
@@ -45,7 +45,7 @@ FidoNet} Technology Networks) and @url{https://en.wikipedia.org/wiki/SMTP, SMTP}
     like GoldEd, not an ordinary email client. Moreover, there is no
     out-of-box encryption and strong authentication involved.
 
-    NNCP requires editing of single YAML @ref{Configuration,
+    NNCP requires editing of single Hjson @ref{Configuration,
     configuration file}.
 
 @item News transmission
index d8f5d5a48f2cf0ce7314e74d397c853864db8192..7366ca7a5ea744b6ea65cf8d80ee25334acf3427 100644 (file)
@@ -12,8 +12,8 @@ Tarballs include all necessary required libraries:
 @item @code{github.com/dustin/go-humanize} @tab MIT
 @item @code{github.com/flynn/noise} @tab BSD 3-Clause
 @item @code{github.com/go-check/check} @tab BSD 2-Clause
-@item @code{github.com/go-yaml/yaml} @tab Apache License 2.0 and MIT
 @item @code{github.com/gorhill/cronexpr} @tab GNU GPLv3
+@item @code{github.com/hjson/hjson-go} @tab MIT
 @item @code{go.cypherpunks.ru/balloon} @tab GNU LGPLv3
 @item @code{golang.org/x/crypto} @tab BSD 3-Clause
 @item @code{golang.org/x/net} @tab BSD 3-Clause
index 4f7758eab8abf6f530dbf2e7a9ca78411e328307..a65454537d224c7758568b5bb2cceadc008db118 100644 (file)
@@ -275,7 +275,7 @@ remote node. But one wish to remotely initiate downloading. That can be
 easily solved with @ref{CfgExec, exec} handles.
 
 @verbatim
-exec:
+exec: {
   warcer: ["/bin/sh", "/path/to/warcer.sh"]
   wgeter: ["/bin/sh", "/path/to/wgeter.sh"]
   aria2c: [
@@ -283,6 +283,7 @@ exec:
     "--on-download-complete", "aria2-downloaded.sh",
     "--on-bt-download-complete", "aria2-downloaded.sh"
   ]
+}
 @end verbatim
 
 @file{warcer.sh} contents:
index f6e04f78d25ad689bacd6379fafbfd2be91b9914..cc1e587fc737428d3f1be0c08a56cf645720464d 100644 (file)
@@ -31,5 +31,5 @@ $ gpg --auto-key-locate wkd --locate-keys releases at nncpgo dot org
 
 Then you could verify tarballs signature:
 @verbatim
-$ gpg --verify nncp-4.2.0.tar.xz.sig nncp-4.2.0.tar.xz
+$ gpg --verify nncp-5.0.0.tar.xz.sig nncp-5.0.0.tar.xz
 @end verbatim
index a4bffeb3f14221b51bd51440401514debca5d883..c9bd97f963b050fa4da7bdec0794ef427ec80f7e 100644 (file)
@@ -1,16 +1,22 @@
 @node Новости
 @section Новости
 
-@node Релиз 4.2.0
-@subsection Релиз 4.2.0
+@node Релиз 5.0.0
+@subsection Релиз 5.0.0
 @itemize
+@item @strong{Несовместимое} изменение формата конфигурационного файла:
+    YAML заменён на Hjson, из-за его гораздо большей простоты, без
+    заметного потеря функционала и удобства.
+@item @command{nncp-cfgnew} генерирует конфигурационный файл с
+    множеством комментариев. Можно использовать @option{-nocomments}
+    опцию для старого поведения.
 @item Дубликаты имён файлов имеют суффикс @file{.CTR}, вместо
     @file{CTR}, чтобы избежать возможных коллизий с @file{.nncp.chunkCTR}.
 @item По умолчанию файлы и директории создаются с 666/777 правами
     доступа, позволяя управлять ими @command{umask}-ом.
 @item Обновлены зависимости.
 @item Полное использование go модулей для управления зависимостями
-    (используется @code{go.cypherpunks.ru/nncp/v4} namespace).
+    (используется @code{go.cypherpunks.ru/nncp/v5} namespace).
 @end itemize
 
 @node Релиз 4.1
index 440d103747dd5765f30f4af6644b1c0343086ae1..211f399f5085f394703321233c7493265298bcba 100644 (file)
@@ -3,16 +3,22 @@
 
 See also this page @ref{Новости, on russian}.
 
-@node Release 4.2.0
-@section Release 4.2.0
+@node Release 5.0.0
+@section Release 5.0.0
 @itemize
+@item @strong{Incompatible} configuration file format change: YAML is
+    replaced with Hjson, due to its simplicity, without noticeable lack
+    of either functionality or convenience.
+@item @command{nncp-cfgnew} generates configuration file with many
+    comments. @option{-nocomments} option can be used for an old
+    behaviour.
 @item Duplicate filenames have @file{.CTR} suffix, instead of
     @file{CTR}, to avoid possible collisions with @file{.nncp.chunkCTR}.
 @item Files and directories are created with 666/777 permissions by
     default, allowing control with @command{umask}.
 @item Updated dependencies.
 @item Full usage of go modules for dependencies management
-    (@code{go.cypherpunks.ru/nncp/v4} namespace is used).
+    (@code{go.cypherpunks.ru/nncp/v5} namespace is used).
 @end itemize
 
 @node Release 4.1
index e9835e3b1cab72b99b04ddf0e46053c92a5974f8..15da3af76f3eefbc99938235e129bdd3eece7ac9 100644 (file)
@@ -7,11 +7,11 @@
 Look @ref{Integrity, here} for finding public keys for tarball authentication.
 
 @verbatim
-$ wget http://www.nncpgo.org/download/nncp-4.2.0.tar.xz
-$ wget http://www.nncpgo.org/download/nncp-4.2.0.tar.xz.sig
-$ gpg --verify nncp-4.2.0.tar.xz.sig nncp-4.2.0.tar.xz
-$ xz -d --stdout nncp-4.2.0.tar.xz | tar xf nncp-4.2.0.tar
-$ make -C nncp-4.2.0 all
+$ wget http://www.nncpgo.org/download/nncp-5.0.0.tar.xz
+$ wget http://www.nncpgo.org/download/nncp-5.0.0.tar.xz.sig
+$ gpg --verify nncp-5.0.0.tar.xz.sig nncp-5.0.0.tar.xz
+$ xz -d --stdout nncp-5.0.0.tar.xz | tar xf nncp-5.0.0.tar
+$ make -C nncp-5.0.0 all
 @end verbatim
 
 There is @command{install} target respecting @env{DESTDIR}. It will
@@ -32,7 +32,7 @@ Look @ref{Integrity, here} for finding public keys for tarball authentication.
 follow @ref{General, general} installation instructions
 
 @verbatim
-# make -C nncp-4.2.0 install PREFIX=/usr
+# make -C nncp-5.0.0 install PREFIX=/usr
 @end verbatim
 
 @item Ubuntu 14.04
index 8f558b419db9cac9dfefe5976937f4b7fc213e3e..1c9b3865885451ba8b676f1da2c4fcb1fcc47da6 100644 (file)
@@ -6,12 +6,10 @@ be buggy. It does not contain compiled documentation and dependent
 libraries source code. Because of that, it is recommended for porters
 to use @ref{Tarballs, tarballs} instead.
 
-You can obtain it and fetch dependent libraries source code as git submodules:
 @verbatim
 $ git clone git://git.cypherpunks.ru/nncp.git nncp
 $ cd nncp
 $ git checkout develop
-$ git submodule update --init
 @end verbatim
 
 Also there is mirror of dependent libraries for safety if their native
@@ -23,9 +21,9 @@ repositories will be unavailable (they are seldom updated):
 @item @code{github.com/dustin/go-humanize} @tab @url{git://git.cypherpunks.ru/go-humanize.git}
 @item @code{github.com/flynn/noise} @tab @url{git://git.cypherpunks.ru/noise.git}
 @item @code{github.com/gorhill/cronexpr} @tab @url{git://git.cypherpunks.ru/cronexpr.git}
+@item @code{github.com/hjson/hjson-go} @tab @url{git://git.cypherpunks.ru/hjson-go.git}
 @item @code{golang.org/x/crypto} @tab @url{git://git.cypherpunks.ru/crypto.git}
 @item @code{golang.org/x/net} @tab @url{git://git.cypherpunks.ru/net.git}
 @item @code{golang.org/x/sys} @tab @url{git://git.cypherpunks.ru/sys.git}
 @item @code{gopkg.in/check.v1} @tab @url{git://git.cypherpunks.ru/check.git}
-@item @code{gopkg.in/yaml.v2} @tab @url{git://git.cypherpunks.ru/yaml.git}
 @end multitable
index 7b6423c15ac7dceeefd9bdde75a79c911e6ec383..677d2ac524430804106ae31efa563f1dd9af991d 100644 (file)
@@ -276,14 +276,18 @@ CD-ROM, жёстких дисков, SD, лент и USB накопителей
 NNCP из коробки поддерживает ретрансляцию пакетов.
 
 @verbatim
-neigh:
-  bob:
+neigh: {
+  bob: {
     [...]
-    addrs:
-      lan: [fe80::5400%igb0]:5400
+    addrs: {
+      lan: "[fe80::5400%igb0]:5400"
+    }
+  }
   bob-airgap:
     [...]
-    via: [bob]
+    via: ["bob"]
+  }
+}
 @end verbatim
 
 Такой @ref{Configuration, конфигурационный файл} говорит что у нас есть
@@ -375,28 +379,35 @@ Bluetooth и WiFi могут быть и довольно быстрыми, по
 звонков} для @ref{nncp-caller} команды, используемой при online связи.
 
 @verbatim
-neigh:
+neigh: {
   [...]
-  some-node:
+  some-node: {
     [...]
-    addrs:
+    addrs: {
       lan: "[fe80::be5f:f4ff:fedd:2752%igb0]:5400"
       wan: "some-node.com:5400"
-    calls:
-      -
+    }
+    calls: [
+      {
         cron: "*/1 * * * *"
         addr: lan
         nice: MAX
         onlinedeadline: 3600
-      -
+      },
+      {
         cron: "*/10 * * * *"
         addr: wan
         nice: PRIORITY
         xx: rx
-      -
+      },
+      {
         cron: "*/1 0-7 * * *"
         addr: wan
         nice: BULK
         onlinedeadline: 3600
         maxonlinetime: 3600
+      },
+    ]
+  }
+}
 @end verbatim
index 36269641868354235ba5106ff6bcc2f8294cbe67..113089dfa23383feb0c4a79813bea7c1988d2cc5 100644 (file)
@@ -260,14 +260,18 @@ devices, possibly by rewriting the data from USB/hard drives to CD-RWs.
 NNCP supports packets relying (transitioning) out-of-box.
 
 @verbatim
-neigh:
-  bob:
+neigh: {
+  bob: {
     [...]
-    addrs:
-      lan: [fe80::5400%igb0]:5400
+    addrs: {
+      lan: "[fe80::5400%igb0]:5400"
+    }
+  }
   bob-airgap:
     [...]
-    via: [bob]
+    via: ["bob"]
+  }
+}
 @end verbatim
 
 That @ref{Configuration, configuration file} tells that we have got two
@@ -352,28 +356,35 @@ configurations} for @ref{nncp-caller} command used in online
 communications.
 
 @verbatim
-neigh:
+neigh: {
   [...]
-  some-node:
+  some-node: {
     [...]
-    addrs:
+    addrs: {
       lan: "[fe80::be5f:f4ff:fedd:2752%igb0]:5400"
       wan: "some-node.com:5400"
-    calls:
-      -
+    }
+    calls: [
+      {
         cron: "*/1 * * * *"
         addr: lan
         nice: MAX
         onlinedeadline: 3600
-      -
+      },
+      {
         cron: "*/10 * * * *"
         addr: wan
         nice: PRIORITY
         xx: rx
-      -
+      },
+      {
         cron: "*/1 0-7 * * *"
         addr: wan
         nice: BULK
         onlinedeadline: 3600
         maxonlinetime: 3600
+      },
+    ]
+  }
+}
 @end verbatim
index f5d893ce40fdd0ac18c3145e0a9a6c354bcb1310..30863852f8113a5f95fada94e4545467e2c078ea 100755 (executable)
@@ -10,7 +10,7 @@ cd $tmp/nncp-$release
 git checkout v$release
 rm -fr .git
 
-mod_name=go.cypherpunks.ru/nncp/v4
+mod_name=go.cypherpunks.ru/nncp/v5
 mv src src.orig
 mkdir -p src/$mod_name
 mv src.orig/* src/$mod_name
@@ -21,11 +21,11 @@ github.com/davecgh/go-xdr
 github.com/dustin/go-humanize
 github.com/flynn/noise
 github.com/gorhill/cronexpr
+github.com/hjson/hjson-go
 go.cypherpunks.ru/balloon
 golang.org/x/crypto
 golang.org/x/net
 golang.org/x/sys
-gopkg.in/yaml.v2
 "
 for mod in $mods; do
     mod_path=$(sed -n "s#^     \($mod\) \(.*\)\$#\1@\2#p" src/$mod_name/go.mod)
index b33a2e35cf1a5101f86801597f4c0f744414d914..bd6580edb28c942749ff27e69f3289f5952893da 100644 (file)
@@ -1,7 +1,7 @@
 # $FreeBSD: head/net/nncp/Makefile 484628 2018-11-10 18:12:57Z bapt $
 
 PORTNAME=      nncp
-DISTVERSION=   4.0
+DISTVERSION=   5.0.0
 PORTREVISION=  1
 CATEGORIES=    net
 MASTER_SITES=  http://www.nncpgo.org/download/
index 89c79345eaafaed2969b274d13a7f5c0f2d7224c..0ab5492d02d7bd1e9f59a4505a511c3c8bace07c 100644 (file)
@@ -11,7 +11,7 @@
 #
 # nncp_caller_enable (bool):   Set to NO by default.
 #                              Set it to YES to enable nncp-caller.
-# nncp_caller_config (path):   Set to %%PREFIX%%/etc/nncp.yaml by default.
+# nncp_caller_config (path):   Set to %%PREFIX%%/etc/nncp.hjson by default.
 
 . /etc/rc.subr
 
@@ -21,7 +21,7 @@ rcvar=nncp_caller_enable
 load_rc_config $name
 
 : ${nncp_caller_enable:="NO"}
-: ${nncp_caller_config="%%PREFIX%%/etc/nncp.yaml"}
+: ${nncp_caller_config="%%PREFIX%%/etc/nncp.hjson"}
 
 command=%%PREFIX%%/bin/nncp-caller
 command_args="-quiet -cfg $nncp_caller_config &"
index 3c7ccd87ea850eea3798100799ddf659bb23eab3..fdc10649661025d573a83e84431dce2573a3a8a4 100644 (file)
@@ -11,7 +11,7 @@
 #
 # nncp_daemon_enable (bool):   Set to NO by default.
 #                              Set it to YES to enable nncp-daemon.
-# nncp_daemon_config (path):   Set to %%PREFIX%%/etc/nncp.yaml by default.
+# nncp_daemon_config (path):   Set to %%PREFIX%%/etc/nncp.hjson by default.
 # nncp_daemon_bind (string):   Address:port to bind to
 #                              Default is "[::]:5400".
 
@@ -23,7 +23,7 @@ rcvar=nncp_daemon_enable
 load_rc_config $name
 
 : ${nncp_daemon_enable:="NO"}
-: ${nncp_daemon_config="%%PREFIX%%/etc/nncp.yaml"}
+: ${nncp_daemon_config="%%PREFIX%%/etc/nncp.hjson"}
 : ${nncp_daemon_bind="[::]:5400"}
 
 command=%%PREFIX%%/bin/nncp-daemon
index 1fa1142262711acb684a78234b68c8ada34d65a2..6fbe5469462f136c39ed4ef377bbbae3cf5018b6 100644 (file)
@@ -11,7 +11,7 @@
 #
 # nncp_toss_enable (bool):     Set to NO by default.
 #                              Set it to YES to enable nncp-toss.
-# nncp_toss_config (path):     Set to %%PREFIX%%/etc/nncp.yaml by default.
+# nncp_toss_config (path):     Set to %%PREFIX%%/etc/nncp.hjson by default.
 # nncp_toss_cycle   (int):     Repeat tossing after that number of seconds.
 #                              Default is "60".
 
@@ -23,7 +23,7 @@ rcvar=nncp_toss_enable
 load_rc_config $name
 
 : ${nncp_toss_enable:="NO"}
-: ${nncp_toss_config="%%PREFIX%%/etc/nncp.yaml"}
+: ${nncp_toss_config="%%PREFIX%%/etc/nncp.hjson"}
 : ${nncp_toss_cycle="60"}
 
 command=%%PREFIX%%/bin/nncp-toss
index 0c9f4f1e49d46134be819ef37aed2a3fd17e4e86..76a8b973190d4ce015ae00557c69bfc9c9a571e1 100644 (file)
@@ -2,8 +2,8 @@
 
 [ "$2" = "POST-DEINSTALL" ] || exit 0
 
-if [ -e %%PREFIX%%/etc/nncp.yaml ]; then
-       echo "%%PREFIX%%/etc/nncp.yaml with your private keys is not removed!"
+if [ -e %%PREFIX%%/etc/nncp.hjson ]; then
+       echo "%%PREFIX%%/etc/nncp.hjson with your private keys is not removed!"
 fi
 
 exec rmdir /var/spool/nncp
index a68f1a34e610eff2c2cc9f6b12ef987fa2430df4..6aa49a4eac87bd153e4ca2d1381c21f8e6a13a74 100644 (file)
@@ -13,5 +13,5 @@
 - Generate NNCP configuration file using the command:
 
     # umask 077
-    # nncp-cfgnew > %%PREFIX%%/etc/nncp.yaml
+    # nncp-cfgnew > %%PREFIX%%/etc/nncp.hjson
 ======================================================================
index 203752bf8d8d0e2111e94a474500e8c8c530ab09..deebd1981d8d5c3cb80417e5ab1ebcbf40d68032 100644 (file)
@@ -19,15 +19,16 @@ package nncp
 
 import (
        "bytes"
+       "encoding/json"
        "errors"
        "log"
        "os"
        "path"
 
        "github.com/gorhill/cronexpr"
+       "github.com/hjson/hjson-go"
        "golang.org/x/crypto/ed25519"
        "golang.org/x/crypto/ssh/terminal"
-       "gopkg.in/yaml.v2"
 )
 
 const (
@@ -37,74 +38,74 @@ const (
 )
 
 var (
-       DefaultCfgPath      string = "/usr/local/etc/nncp.yaml"
+       DefaultCfgPath      string = "/usr/local/etc/nncp.hjson"
        DefaultSendmailPath string = "/usr/sbin/sendmail"
        DefaultSpoolPath    string = "/var/spool/nncp"
        DefaultLogPath      string = "/var/spool/nncp/log"
 )
 
-type NodeYAML struct {
-       Id          string
-       ExchPub     string
-       SignPub     string
-       NoisePub    *string             `yaml:"noisepub,omitempty"`
-       Exec        map[string][]string `yaml:"exec,omitempty"`
-       Incoming    *string             `yaml:"incoming,omitempty"`
-       Freq        *string             `yaml:"freq,omitempty"`
-       FreqChunked *uint64             `yaml:"freqchunked,omitempty"`
-       FreqMinSize *uint64             `yaml:"freqminsize,omitempty"`
-       Via         []string            `yaml:"via,omitempty"`
-       Calls       []CallYAML          `yaml:"calls,omitempty"`
-
-       Addrs map[string]string `yaml:"addrs,omitempty"`
-
-       RxRate         *int  `yaml:"rxrate,omitempty"`
-       TxRate         *int  `yaml:"txrate,omitempty"`
-       OnlineDeadline *uint `yaml:"onlinedeadline,omitempty"`
-       MaxOnlineTime  *uint `yaml:"maxonlinetime,omitempty"`
+type NodeJSON struct {
+       Id          string              `json:"id"`
+       ExchPub     string              `json:"exchpub"`
+       SignPub     string              `json:"signpub"`
+       NoisePub    *string             `json:"noisepub,omitempty"`
+       Exec        map[string][]string `json:"exec,omitempty"`
+       Incoming    *string             `json:"incoming,omitempty"`
+       Freq        *string             `json:"freq,omitempty"`
+       FreqChunked *uint64             `json:"freqchunked,omitempty"`
+       FreqMinSize *uint64             `json:"freqminsize,omitempty"`
+       Via         []string            `json:"via,omitempty"`
+       Calls       []CallJSON          `json:"calls,omitempty"`
+
+       Addrs map[string]string `json:"addrs,omitempty"`
+
+       RxRate         *int  `json:"rxrate,omitempty"`
+       TxRate         *int  `json:"txrate,omitempty"`
+       OnlineDeadline *uint `json:"onlinedeadline,omitempty"`
+       MaxOnlineTime  *uint `json:"maxonlinetime,omitempty"`
 }
 
-type CallYAML struct {
+type CallJSON struct {
        Cron           string
-       Nice           *string `yaml:"nice,omitempty"`
-       Xx             string  `yaml:"xx,omitempty"`
-       RxRate         *int    `yaml:"rxrate,omitempty"`
-       TxRate         *int    `yaml:"txrate,omitempty"`
-       Addr           *string `yaml:"addr,omitempty"`
-       OnlineDeadline *uint   `yaml:"onlinedeadline,omitempty"`
-       MaxOnlineTime  *uint   `yaml:"maxonlinetime,omitempty"`
+       Nice           *string `json:"nice,omitempty"`
+       Xx             *string `json:"xx,omitempty"`
+       RxRate         *int    `json:"rxrate,omitempty"`
+       TxRate         *int    `json:"txrate,omitempty"`
+       Addr           *string `json:"addr,omitempty"`
+       OnlineDeadline *uint   `json:"onlinedeadline,omitempty"`
+       MaxOnlineTime  *uint   `json:"maxonlinetime,omitempty"`
 }
 
-type NodeOurYAML struct {
-       Id       string
-       ExchPub  string
-       ExchPrv  string
-       SignPub  string
-       SignPrv  string
-       NoisePrv string
-       NoisePub string
+type NodeOurJSON struct {
+       Id       string `json:"id"`
+       ExchPub  string `json:"exchpub"`
+       ExchPrv  string `json:"exchprv"`
+       SignPub  string `json:"signpub"`
+       SignPrv  string `json:"signprv"`
+       NoisePrv string `json:"noiseprv"`
+       NoisePub string `json:"noisepub"`
 }
 
-type FromToYAML struct {
+type FromToJSON struct {
        From string
        To   string
 }
 
-type NotifyYAML struct {
-       File *FromToYAML `yaml:"file,omitempty"`
-       Freq *FromToYAML `yaml:"freq,omitempty"`
+type NotifyJSON struct {
+       File *FromToJSON `json:"file,omitempty"`
+       Freq *FromToJSON `json:"freq,omitempty"`
 }
 
-type CfgYAML struct {
-       Self  *NodeOurYAML `yaml:"self,omitempty"`
-       Neigh map[string]NodeYAML
+type CfgJSON struct {
+       Spool  string      `json:"spool"`
+       Log    string      `json:"log"`
+       Notify *NotifyJSON `json:"notify,omitempty"`
 
-       Spool  string
-       Log    string
-       Notify *NotifyYAML `yaml:"notify,omitempty"`
+       Self  *NodeOurJSON        `json:"self"`
+       Neigh map[string]NodeJSON `json:"neigh"`
 }
 
-func NewNode(name string, yml NodeYAML) (*Node, error) {
+func NewNode(name string, yml NodeJSON) (*Node, error) {
        nodeId, err := NodeIdFromString(yml.Id)
        if err != nil {
                return nil, err
@@ -203,14 +204,15 @@ func NewNode(name string, yml NodeYAML) (*Node, error) {
                }
 
                var xx TRxTx
-               switch callYml.Xx {
-               case "rx":
-                       xx = TRx
-               case "tx":
-                       xx = TTx
-               case "":
-               default:
-                       return nil, errors.New("xx field must be either \"rx\" or \"tx\"")
+               if callYml.Xx != nil {
+                       switch *callYml.Xx {
+                       case "rx":
+                               xx = TRx
+                       case "tx":
+                               xx = TTx
+                       default:
+                               return nil, errors.New("xx field must be either \"rx\" or \"tx\"")
+                       }
                }
 
                rxRate := defRxRate
@@ -281,7 +283,7 @@ func NewNode(name string, yml NodeYAML) (*Node, error) {
        return &node, nil
 }
 
-func NewNodeOur(yml *NodeOurYAML) (*NodeOur, error) {
+func NewNodeOur(yml *NodeOurJSON) (*NodeOur, error) {
        id, err := NodeIdFromString(yml.Id)
        if err != nil {
                return nil, err
@@ -351,23 +353,6 @@ func NewNodeOur(yml *NodeOurYAML) (*NodeOur, error) {
        return &node, nil
 }
 
-func (nodeOur *NodeOur) ToYAML() string {
-       yml := NodeOurYAML{
-               Id:       nodeOur.Id.String(),
-               ExchPub:  ToBase32(nodeOur.ExchPub[:]),
-               ExchPrv:  ToBase32(nodeOur.ExchPrv[:]),
-               SignPub:  ToBase32(nodeOur.SignPub[:]),
-               SignPrv:  ToBase32(nodeOur.SignPrv[:]),
-               NoisePub: ToBase32(nodeOur.NoisePub[:]),
-               NoisePrv: ToBase32(nodeOur.NoisePrv[:]),
-       }
-       raw, err := yaml.Marshal(&yml)
-       if err != nil {
-               panic(err)
-       }
-       return string(raw)
-}
-
 func CfgParse(data []byte) (*Ctx, error) {
        var err error
        if bytes.Compare(data[:8], MagicNNCPBv3[:]) == 0 {
@@ -382,25 +367,33 @@ func CfgParse(data []byte) (*Ctx, error) {
                        return nil, err
                }
        }
-       var cfgYAML CfgYAML
-       if err = yaml.Unmarshal(data, &cfgYAML); err != nil {
+       var cfgGeneral map[string]interface{}
+       if err = hjson.Unmarshal(data, &cfgGeneral); err != nil {
+               return nil, err
+       }
+       marshaled, err := json.Marshal(cfgGeneral)
+       if err != nil {
+               return nil, err
+       }
+       var cfgJSON CfgJSON
+       if err = json.Unmarshal(marshaled, &cfgJSON); err != nil {
                return nil, err
        }
-       if _, exists := cfgYAML.Neigh["self"]; !exists {
+       if _, exists := cfgJSON.Neigh["self"]; !exists {
                return nil, errors.New("self neighbour missing")
        }
        var self *NodeOur
-       if cfgYAML.Self != nil {
-               self, err = NewNodeOur(cfgYAML.Self)
+       if cfgJSON.Self != nil {
+               self, err = NewNodeOur(cfgJSON.Self)
                if err != nil {
                        return nil, err
                }
        }
-       spoolPath := path.Clean(cfgYAML.Spool)
+       spoolPath := path.Clean(cfgJSON.Spool)
        if !path.IsAbs(spoolPath) {
                return nil, errors.New("Spool path must be absolute")
        }
-       logPath := path.Clean(cfgYAML.Log)
+       logPath := path.Clean(cfgJSON.Log)
        if !path.IsAbs(logPath) {
                return nil, errors.New("Log path must be absolute")
        }
@@ -408,20 +401,20 @@ func CfgParse(data []byte) (*Ctx, error) {
                Spool:   spoolPath,
                LogPath: logPath,
                Self:    self,
-               Neigh:   make(map[NodeId]*Node, len(cfgYAML.Neigh)),
+               Neigh:   make(map[NodeId]*Node, len(cfgJSON.Neigh)),
                Alias:   make(map[string]*NodeId),
        }
-       if cfgYAML.Notify != nil {
-               if cfgYAML.Notify.File != nil {
-                       ctx.NotifyFile = cfgYAML.Notify.File
+       if cfgJSON.Notify != nil {
+               if cfgJSON.Notify.File != nil {
+                       ctx.NotifyFile = cfgJSON.Notify.File
                }
-               if cfgYAML.Notify.Freq != nil {
-                       ctx.NotifyFreq = cfgYAML.Notify.Freq
+               if cfgJSON.Notify.Freq != nil {
+                       ctx.NotifyFreq = cfgJSON.Notify.Freq
                }
        }
        vias := make(map[NodeId][]string)
-       for name, neighYAML := range cfgYAML.Neigh {
-               neigh, err := NewNode(name, neighYAML)
+       for name, neighJSON := range cfgJSON.Neigh {
+               neigh, err := NewNode(name, neighJSON)
                if err != nil {
                        return nil, err
                }
@@ -430,7 +423,7 @@ func CfgParse(data []byte) (*Ctx, error) {
                        return nil, errors.New("Node names conflict")
                }
                ctx.Alias[name] = neigh.Id
-               vias[*neigh.Id] = neighYAML.Via
+               vias[*neigh.Id] = neighJSON.Via
        }
        ctx.SelfId = ctx.Alias["self"]
        for neighId, viasRaw := range vias {
index cdeef4fe071d18812fedd79f6af9f87a2fb5e512..c8f87d81153c7e806ea8dde0d60cda4700f36e17 100644 (file)
@@ -33,7 +33,7 @@ import (
        "strings"
 
        "github.com/davecgh/go-xdr/xdr2"
-       "go.cypherpunks.ru/nncp/v4"
+       "go.cypherpunks.ru/nncp/v5"
        "golang.org/x/crypto/blake2b"
 )
 
index 5b605ffb79242ef7dfc58537a6abaaa867dc65ce..07deec1ca4f893e88a379ced3c6dc745f6be4bcf 100644 (file)
@@ -25,7 +25,7 @@ import (
        "os"
        "strings"
 
-       "go.cypherpunks.ru/nncp/v4"
+       "go.cypherpunks.ru/nncp/v5"
 )
 
 func usage() {
index cb9fc594ecbc8be3d975e7c572eedfc3ac2781a9..3f9ddca8d4ca07577ac00e8856626cdf6d224873 100644 (file)
@@ -27,7 +27,7 @@ import (
        "sync"
        "time"
 
-       "go.cypherpunks.ru/nncp/v4"
+       "go.cypherpunks.ru/nncp/v5"
 )
 
 func usage() {
index a77eaed1e84c44aa0b4aaf362b7e3c2d22033695..7adc6fab94f9f1c350e54e7192e0d9fc0a048a04 100644 (file)
@@ -28,7 +28,7 @@ import (
        "os"
 
        "github.com/davecgh/go-xdr/xdr2"
-       "go.cypherpunks.ru/nncp/v4"
+       "go.cypherpunks.ru/nncp/v5"
        "golang.org/x/crypto/blake2b"
        "golang.org/x/crypto/ssh/terminal"
 )
@@ -36,9 +36,9 @@ import (
 func usage() {
        fmt.Fprintf(os.Stderr, nncp.UsageHeader())
        fmt.Fprintf(os.Stderr, "nncp-cfgenc -- encrypt/decrypt configuration file\n\n")
-       fmt.Fprintf(os.Stderr, "Usage: %s [options] cfg.yaml > cfg.yaml.eblob\n", os.Args[0])
-       fmt.Fprintf(os.Stderr, "       %s [options] -d cfg.yaml.eblob > cfg.yaml\n", os.Args[0])
-       fmt.Fprintf(os.Stderr, "       %s [options] -dump cfg.yaml.eblob\n", os.Args[0])
+       fmt.Fprintf(os.Stderr, "Usage: %s [options] cfg.hjson > cfg.hjson.eblob\n", os.Args[0])
+       fmt.Fprintf(os.Stderr, "       %s [options] -d cfg.hjson.eblob > cfg.hjson\n", os.Args[0])
+       fmt.Fprintf(os.Stderr, "       %s [options] -dump cfg.hjson.eblob\n", os.Args[0])
        fmt.Fprintln(os.Stderr, "Options:")
        flag.PrintDefaults()
 }
index d2730eba221cf841878ed635389e7425a12224bc..7214079040daacfb0ad7f85c190130caa60ddedb 100644 (file)
@@ -24,8 +24,8 @@ import (
        "log"
        "os"
 
-       "go.cypherpunks.ru/nncp/v4"
-       "gopkg.in/yaml.v2"
+       "github.com/hjson/hjson-go"
+       "go.cypherpunks.ru/nncp/v5"
 )
 
 func usage() {
@@ -57,10 +57,10 @@ func main() {
                log.Fatalln("Error during initialization:", err)
        }
 
-       cfg := nncp.CfgYAML{
+       cfg := nncp.CfgJSON{
                Spool: ctx.Spool,
                Log:   ctx.LogPath,
-               Neigh: make(map[string]nncp.NodeYAML),
+               Neigh: make(map[string]nncp.NodeJSON),
        }
        for _, node := range ctx.Neigh {
                var noisePub *string
@@ -68,14 +68,14 @@ func main() {
                        np := nncp.ToBase32(node.NoisePub[:])
                        noisePub = &np
                }
-               cfg.Neigh[node.Name] = nncp.NodeYAML{
+               cfg.Neigh[node.Name] = nncp.NodeJSON{
                        Id:       node.Id.String(),
                        ExchPub:  nncp.ToBase32(node.ExchPub[:]),
                        SignPub:  nncp.ToBase32(node.SignPub[:]),
                        NoisePub: noisePub,
                }
        }
-       raw, err := yaml.Marshal(&cfg)
+       raw, err := hjson.Marshal(&cfg)
        if err != nil {
                panic(err)
        }
index d923e0be7a92dae33a4c694ab56eacfd5365599f..a9bea4f4b63c737efc9fc0414423c286eb3d8345 100644 (file)
@@ -23,8 +23,7 @@ import (
        "fmt"
        "os"
 
-       "go.cypherpunks.ru/nncp/v4"
-       "gopkg.in/yaml.v2"
+       "go.cypherpunks.ru/nncp/v5"
 )
 
 func usage() {
@@ -35,8 +34,9 @@ func usage() {
 
 func main() {
        var (
-               version  = flag.Bool("version", false, "Print version information")
-               warranty = flag.Bool("warranty", false, "Print warranty information")
+               noComments = flag.Bool("nocomments", false, "Do not include descriptive comments")
+               version    = flag.Bool("version", false, "Print version information")
+               warranty   = flag.Bool("warranty", false, "Print warranty information")
        )
        flag.Usage = usage
        flag.Parse()
@@ -52,34 +52,163 @@ func main() {
        if err != nil {
                panic(err)
        }
-       noisePub := nncp.ToBase32(nodeOur.NoisePub[:])
-       cfg := nncp.CfgYAML{
-               Self: &nncp.NodeOurYAML{
-                       Id:       nodeOur.Id.String(),
-                       ExchPub:  nncp.ToBase32(nodeOur.ExchPub[:]),
-                       ExchPrv:  nncp.ToBase32(nodeOur.ExchPrv[:]),
-                       SignPub:  nncp.ToBase32(nodeOur.SignPub[:]),
-                       SignPrv:  nncp.ToBase32(nodeOur.SignPrv[:]),
-                       NoisePub: nncp.ToBase32(nodeOur.NoisePub[:]),
-                       NoisePrv: nncp.ToBase32(nodeOur.NoisePrv[:]),
-               },
-               Neigh: map[string]nncp.NodeYAML{
-                       "self": nncp.NodeYAML{
-                               Id:       nodeOur.Id.String(),
-                               ExchPub:  nncp.ToBase32(nodeOur.ExchPub[:]),
-                               SignPub:  nncp.ToBase32(nodeOur.SignPub[:]),
-                               NoisePub: &noisePub,
-                               Exec: map[string][]string{
-                                       "sendmail": []string{nncp.DefaultSendmailPath},
-                               },
-                       },
-               },
-               Spool: nncp.DefaultSpoolPath,
-               Log:   nncp.DefaultLogPath,
+       var cfgRaw string
+       if *noComments {
+               cfgRaw = fmt.Sprintf(`{
+  spool: %s
+  log: %s
+
+  self: {
+    # DO NOT show anyone your private keys!!!
+    id: %s
+    exchpub: %s
+    exchprv: %s
+    signpub: %s
+    signprv: %s
+    noiseprv: %s
+    noisepub: %s
+  }
+  neigh: {
+    self: {
+      id: %s
+      exchpub: %s
+      signpub: %s
+      noisepub: %s
+      exec: {sendmail: ["%s"]}
+    }
+  }
+}`,
+                       nncp.DefaultSpoolPath,
+                       nncp.DefaultLogPath,
+                       nodeOur.Id.String(),
+                       nncp.ToBase32(nodeOur.ExchPub[:]),
+                       nncp.ToBase32(nodeOur.ExchPrv[:]),
+                       nncp.ToBase32(nodeOur.SignPub[:]),
+                       nncp.ToBase32(nodeOur.SignPrv[:]),
+                       nncp.ToBase32(nodeOur.NoisePub[:]),
+                       nncp.ToBase32(nodeOur.NoisePrv[:]),
+                       nodeOur.Id.String(),
+                       nncp.ToBase32(nodeOur.ExchPub[:]),
+                       nncp.ToBase32(nodeOur.SignPub[:]),
+                       nncp.ToBase32(nodeOur.NoisePub[:]),
+                       nncp.DefaultSendmailPath,
+               )
+       } else {
+               cfgRaw = fmt.Sprintf(`{
+  # Path to encrypted packets spool directory
+  spool: %s
+  # Path to log file
+  log: %s
+
+  # Enable notification email sending
+  # notify: {
+  #   file: {
+  #     from: nncp@localhost
+  #     to: user+file@example.com
+  #   }
+  #   freq: {
+  #     from: nncp@localhost
+  #     to: user+freq@example.com
+  #   }
+  # }
+
+  self: {
+    # DO NOT show anyone your private keys!!!
+    id: %s
+    exchpub: %s
+    exchprv: %s
+    signpub: %s
+    signprv: %s
+    noiseprv: %s
+    noisepub: %s
+  }
+  neigh: {
+    self: {
+      # You should give public keys below to your neighbours
+      id: %s
+      exchpub: %s
+      signpub: %s
+      noisepub: %s
+
+      exec: {
+        # Default self's sendmail command is used for email notifications sending
+        sendmail: ["%s"]
+      }
+    }
+
+    # Example neighbour, most of fields are optional
+    # alice: {
+    #   id: XJZBK...65IJQ
+    #   exchpub: MJACJ...FAI6A
+    #   signpub: T4AFC...N2FRQ
+    #   noisepub: UBM5K...VI42A
+    #
+    #   # He is allowed to send email
+    #   exec: {sendmail: ["/usr/sbin/sendmail"]}
+    #
+    #   # Allow incoming files saving in that directory
+    #   incoming: "/home/alice/incoming"
+    #
+    #   # Transitional nodes path
+    #   via: ["bob", "eve"]
+    #
+    #   # Inactivity timeout when session with remote peer should be terminated
+    #   onlinedeadline: 1800
+    #
+    #   # Maximal online session lifetime
+    #   maxonlinetime: 3600
+    #
+    #   # Allow freqing from that directory
+    #   freq: "/home/bob/pub"
+    #   # Send freqed files with chunks
+    #   freqchunked: 1024
+    #   # Send freqed files with minumal chunk size
+    #   freqminsize: 2048
+    #
+    #   # Set maximal packets per second receive and transmit rates
+    #   rxrate: 10
+    #   txrate: 20
+    #
+    #   # Address aliases
+    #   addrs: {
+    #     lan: "[fe80::1234%%igb0]:5400"
+    #     internet: alice.com:3389
+    #   }
+    #
+    #   # Calls configuration
+    #   calls: [
+    #     {
+    #       cron: "*/2 * * * *"
+    #       onlinedeadline: 1800
+    #       maxonlinetime: 1750
+    #       nice: PRIORITY+10
+    #       rxrate: 10
+    #       txrate: 20
+    #       xx: rx
+    #       addr: lan
+    #     },
+    #   ]
+    # }
+  }
+}`,
+                       nncp.DefaultSpoolPath,
+                       nncp.DefaultLogPath,
+                       nodeOur.Id.String(),
+                       nncp.ToBase32(nodeOur.ExchPub[:]),
+                       nncp.ToBase32(nodeOur.ExchPrv[:]),
+                       nncp.ToBase32(nodeOur.SignPub[:]),
+                       nncp.ToBase32(nodeOur.SignPrv[:]),
+                       nncp.ToBase32(nodeOur.NoisePub[:]),
+                       nncp.ToBase32(nodeOur.NoisePrv[:]),
+                       nodeOur.Id.String(),
+                       nncp.ToBase32(nodeOur.ExchPub[:]),
+                       nncp.ToBase32(nodeOur.SignPub[:]),
+                       nncp.ToBase32(nodeOur.NoisePub[:]),
+                       nncp.DefaultSendmailPath,
+               )
        }
-       raw, err := yaml.Marshal(&cfg)
-       if err != nil {
+       if _, err = nncp.CfgParse([]byte(cfgRaw)); err != nil {
                panic(err)
        }
-       fmt.Print(string(raw))
+       fmt.Println(cfgRaw)
 }
index a920ad641d80a480141060c813548cd7510d6461..bf48638d97b411e2ebf19e9a8725ecd7f8d9b8e5 100644 (file)
@@ -24,7 +24,7 @@ import (
        "log"
        "os"
 
-       "go.cypherpunks.ru/nncp/v4"
+       "go.cypherpunks.ru/nncp/v5"
 )
 
 func usage() {
index 2e55cd654ef23ce88b9d904271a9c8e6c37c4776..318c3e450d9a190877cbc28554be5b1c904c9bda 100644 (file)
@@ -27,7 +27,7 @@ import (
        "strconv"
        "time"
 
-       "go.cypherpunks.ru/nncp/v4"
+       "go.cypherpunks.ru/nncp/v5"
        "golang.org/x/net/netutil"
 )
 
index 18a93a6f4180280c67893aeed4e5a45818f2eb86..0a02252f105ba42f16ebb40f78ebc048e0c2379f 100644 (file)
@@ -26,7 +26,7 @@ import (
        "log"
        "os"
 
-       "go.cypherpunks.ru/nncp/v4"
+       "go.cypherpunks.ru/nncp/v5"
 )
 
 func usage() {
index 7cfe215a34d82b0cab9bb2a0ac0d8d84ac88f35c..2e7933391cfbcf869aba109c4a9f4d40402a44c0 100644 (file)
@@ -25,7 +25,7 @@ import (
        "os"
        "strings"
 
-       "go.cypherpunks.ru/nncp/v4"
+       "go.cypherpunks.ru/nncp/v5"
 )
 
 func usage() {
index 6b62623acb6ba18f62a3cb93aec7f313bfd3303e..08adaf9c794932e50d68c193f31db24d10057ab2 100644 (file)
@@ -27,7 +27,7 @@ import (
        "strconv"
        "strings"
 
-       "go.cypherpunks.ru/nncp/v4"
+       "go.cypherpunks.ru/nncp/v5"
 )
 
 func usage() {
index 780d31eba6b4094bc1bf5f27b2e4d4e33ecab578..97ca259e80fb907715f5a807e32f1d4d6fe77fe4 100644 (file)
@@ -25,7 +25,7 @@ import (
        "log"
        "os"
 
-       "go.cypherpunks.ru/nncp/v4"
+       "go.cypherpunks.ru/nncp/v5"
 )
 
 func usage() {
index 3a7731b0f7bdd4f5ecf5011f517685e51c447ab9..82da1d35b7673e9fd9b340aae77291e4a9abfa71 100644 (file)
@@ -29,7 +29,7 @@ import (
        "os"
 
        "github.com/davecgh/go-xdr/xdr2"
-       "go.cypherpunks.ru/nncp/v4"
+       "go.cypherpunks.ru/nncp/v5"
 )
 
 func usage() {
index e1cb5b89f00ebffdf85487c46535ba93d52d82ff..7ca8db871339230addc337fc22b32c32491102d0 100644 (file)
@@ -34,7 +34,7 @@ import (
 
        "github.com/davecgh/go-xdr/xdr2"
        "github.com/dustin/go-humanize"
-       "go.cypherpunks.ru/nncp/v4"
+       "go.cypherpunks.ru/nncp/v5"
        "golang.org/x/crypto/blake2b"
 )
 
index ba8d70b49c806771ec4cdfb2799235543f3474a8..74aa24c14c72b0502419fe5509d2184d44b9862b 100644 (file)
@@ -26,7 +26,7 @@ import (
        "path/filepath"
        "strings"
 
-       "go.cypherpunks.ru/nncp/v4"
+       "go.cypherpunks.ru/nncp/v5"
 )
 
 func usage() {
index 8f7fe76fb3c427a0f6899b00721a95c02847847f..a173707f2386e4334d56e826b99b44b036929f4d 100644 (file)
@@ -26,7 +26,7 @@ import (
        "sort"
 
        "github.com/dustin/go-humanize"
-       "go.cypherpunks.ru/nncp/v4"
+       "go.cypherpunks.ru/nncp/v5"
 )
 
 func usage() {
index 0c41931c22055b87b4aebe59eabebf2d1d4b5441..010d93ed6fad85e3e2e056cc51ca62268585f8f2 100644 (file)
@@ -25,7 +25,7 @@ import (
        "os"
        "time"
 
-       "go.cypherpunks.ru/nncp/v4"
+       "go.cypherpunks.ru/nncp/v5"
 )
 
 func usage() {
index a2d1d29658cd30e9b9152f90c25d686d739bf9fd..db390088cdd9062dae3f5113fa55ebe6742e6b51 100644 (file)
@@ -29,7 +29,7 @@ import (
        "strconv"
 
        "github.com/davecgh/go-xdr/xdr2"
-       "go.cypherpunks.ru/nncp/v4"
+       "go.cypherpunks.ru/nncp/v5"
 )
 
 func usage() {
index 03fe80e2cff2c73b05d9437b1c725b8d910beb77..0030c706d71fdb35c7edddeda60a63f0a42b627a 100644 (file)
@@ -37,8 +37,8 @@ type Ctx struct {
        LogPath    string
        Quiet      bool
        Debug      bool
-       NotifyFile *FromToYAML
-       NotifyFreq *FromToYAML
+       NotifyFile *FromToJSON
+       NotifyFreq *FromToJSON
 }
 
 func (ctx *Ctx) FindNode(id string) (*Node, error) {
index a195d28c6ec93a4d69fdf25856b489dc26ded4d1..0ce4d58da9f425d8140f115e5ed64080822525a7 100644 (file)
@@ -1,15 +1,15 @@
-module go.cypherpunks.ru/nncp/v4
+module go.cypherpunks.ru/nncp/v5
 
 require (
        github.com/davecgh/go-xdr v0.0.0-20161123171359-e6a2ba005892
        github.com/dustin/go-humanize v1.0.0
        github.com/flynn/noise v0.0.0-20180327030543-2492fe189ae6
        github.com/gorhill/cronexpr v0.0.0-20180427100037-88b0669f7d75
+       github.com/hjson/hjson-go v3.0.1+incompatible
        github.com/kr/pretty v0.1.0 // indirect
        go.cypherpunks.ru/balloon v1.1.0
        golang.org/x/crypto v0.0.0-20191002192127-34f69633bfdc
        golang.org/x/net v0.0.0-20191007182048-72f939374954
        golang.org/x/sys v0.0.0-20191008105621-543471e840be
        gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
-       gopkg.in/yaml.v2 v2.2.4
 )
index 4f7a8901705967c1bbb490892df282f533ade2e6..8fa6343b06b3f656cd498aaebd1602ac402a3332 100644 (file)
@@ -6,6 +6,8 @@ github.com/flynn/noise v0.0.0-20180327030543-2492fe189ae6 h1:u/UEqS66A5ckRmS4yNp
 github.com/flynn/noise v0.0.0-20180327030543-2492fe189ae6/go.mod h1:1i71OnUq3iUe1ma7Lr6yG6/rjvM3emb6yoL7xLFzcVQ=
 github.com/gorhill/cronexpr v0.0.0-20180427100037-88b0669f7d75 h1:f0n1xnMSmBLzVfsMMvriDyA75NB/oBgILX2GcHXIQzY=
 github.com/gorhill/cronexpr v0.0.0-20180427100037-88b0669f7d75/go.mod h1:g2644b03hfBX9Ov0ZBDgXXens4rxSxmqFBbhvKv2yVA=
+github.com/hjson/hjson-go v3.0.1+incompatible h1:JwOXblcMiBbiWue7iPkoFK9oXSnW8n+qXh/0Fio6TCo=
+github.com/hjson/hjson-go v3.0.1+incompatible/go.mod h1:qsetwF8NlsTsOTwZTApNlTCerV+b2GjYRRcIk4JMFio=
 github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
 github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
 github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
@@ -25,8 +27,5 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w
 golang.org/x/sys v0.0.0-20191008105621-543471e840be h1:QAcqgptGM8IQBC9K/RC4o+O9YmqEm0diQn9QmZw/0mU=
 golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
-gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
 gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
 gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
-gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I=
-gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
index 81661387681db4d1bd9b0e4b40a9e5390bc3bf90..2c4726f8cb7dc7fc2e94334fe8b97c1d3363eac6 100644 (file)
@@ -43,7 +43,7 @@ const (
        SeenSuffix = ".seen"
 )
 
-func newNotification(fromTo *FromToYAML, subject string) io.Reader {
+func newNotification(fromTo *FromToJSON, subject string) io.Reader {
        return strings.NewReader(fmt.Sprintf(
                "From: %s\nTo: %s\nSubject: %s\n",
                fromTo.From,