]> Cypherpunks.ru repositories - govpn.git/commitdiff
Use YAML instead of JSON for server configuration file
authorSergey Matveev <stargrave@stargrave.org>
Sun, 10 Jan 2016 12:45:55 +0000 (15:45 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Sun, 10 Jan 2016 13:37:22 +0000 (16:37 +0300)
Signed-off-by: Sergey Matveev <stargrave@stargrave.org>
15 files changed:
.gitmodules
VERSION
doc/about.ru.texi
doc/about.texi
doc/example.texi
doc/installation.texi
doc/news.texi
doc/server.texi
doc/sources.texi
src/github.com/go-yaml/yaml [new submodule]
src/govpn/cmd/govpn-server/conf.go
src/govpn/cmd/govpn-server/main.go
src/govpn/conf.go
utils/makedist.sh
utils/newclient.sh

index ffbe4428c4b4ad35b59057f4f46ed0a0ed81ca90..27bf6b5f55b2e0bc11f7ca0365b936886f011aba 100644 (file)
@@ -13,3 +13,6 @@
 [submodule "src/github.com/dchest/blake2b"]
        path = src/github.com/dchest/blake2b
        url = https://github.com/dchest/blake2b.git
+[submodule "src/github.com/go-yaml/yaml"]
+       path = src/github.com/go-yaml/yaml
+       url = https://github.com/go-yaml/yaml.git
diff --git a/VERSION b/VERSION
index 819e07a22435f1e8efcbdd1d1c062deef0e501b1..a75b92f1ed766132f8e6b71376143c6a7111021a 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-5.0
+5.1
index 2797a6317b75e5d7ed9b4ebe97c1d62e1eb25375..12910b5f36ef6ed3483f6ae08eff2febba9c95f5 100644 (file)
@@ -66,6 +66,8 @@ A-EKE (Diffie-Hellman Augmented Encrypted Key Exchange)).
 статистики} о подключённых клиентах в режиме реального времени в
 @url{http://json.org/, JSON} формате.
 @item
+Сервер конфигурируется используя @url{http://yaml.org/, YAML} файл.
+@item
 Написан на языке @url{https://golang.org/, Go} с простым кодом,
 ориентированным на лёгкость чтения и анализа.
 @item
index 03b5c8966a526ed880bd34b780282128e253b874..ded06b642e2267f876cc66bcb4209c04ed176701 100644 (file)
@@ -60,6 +60,8 @@ Optional built-in HTTP-server for retrieving real-time
 @ref{Stats, statistics} information about known connected peers in
 @url{http://json.org/, JSON} format.
 @item
+Server is configured through the @url{http://yaml.org/, YAML} file.
+@item
 Written on @url{https://golang.org/, Go} programming language with
 simple code that can be read and reviewed.
 @item
index c2936a61414fb66484e3fd461f5d2c107f293355..f4f80f4bafebaf3bb22ab21a241252f15f4872cc 100644 (file)
@@ -24,13 +24,12 @@ client% ./utils/newclient.sh Alice
 Enter passphrase:
 Your client verifier is: $argon2d$m=4096,t=128,p=1$bwR5VjeCYIQaa8SeaI3rqg
 
-Place the following JSON configuration entry on the server's side:
+Place the following YAML configuration entry on the server's side:
 
-    "Alice": {
-        "up": "/path/to/up.sh",
-        "iface": "or TAP interface name",
-        "verifier": "$argon2d$m=4096,t=128,p=1$bwR5VjeCYIQaa8SeaI3rqg$KCNIqfS4DGsBTtVytamAzcISgrlEWvNxan1UfBrFu10"
-    }
+    Alice:
+        up: /path/to/up.sh
+        iface: or TAP interface name
+        verifier: $argon2d$m=4096,t=128,p=1$bwR5VjeCYIQaa8SeaI3rqg$KCNIqfS4DGsBTtVytamAzcISgrlEWvNxan1UfBrFu10
 
 Verifier was generated with:
 
@@ -38,16 +37,13 @@ Verifier was generated with:
     govpn-verifier -key /tmp/passphrase
 @end verbatim
 
-@strong{Prepare the server}. Add this entry to @code{peers.json}
+@strong{Prepare the server}. Add this entry to @code{peers.yaml}
 configuration file:
 
 @verbatim
-{
-    "Alice": {
-        "iface": "tap10",
-        "verifier": "$argon2d$m=4096,t=128,p=1$bwR5VjeCYIQaa8SeaI3rqg$KCNIqfS4DGsBTtVytamAzcISgrlEWvNxan1UfBrFu10"
-    }
-}
+Alice:
+    iface: tap10
+    verifier: $argon2d$m=4096,t=128,p=1$bwR5VjeCYIQaa8SeaI3rqg$KCNIqfS4DGsBTtVytamAzcISgrlEWvNxan1UfBrFu10
 @end verbatim
 
 @strong{Prepare network on GNU/Linux IPv4 server}:
index d8d958767c619ac06f1c608ee156bcdb6c9ad4bb..d32f4cfb621ecad465622945dedd94b68e1a1b3d 100644 (file)
@@ -22,11 +22,12 @@ Included required libraries:
 
 @multitable @columnfractions .40 .20 .40
 @headitem Library @tab Platform @tab Licence
-@item @code{golang.org/x/crypto} @tab All @tab BSD 3-Clause
 @item @code{github.com/agl/ed25519} @tab All @tab BSD 3-Clause
+@item @code{github.com/bigeagle/water} @tab GNU/Linux @tab BSD 3-Clause
 @item @code{github.com/dchest/blake2b} @tab All @tab CC0 1.0
+@item @code{github.com/go-yaml/yaml} @tab All @tab LGPLv3 and MIT
 @item @code{github.com/magical/argon2} @tab All @tab BSD 2-Clause
-@item @code{github.com/bigeagle/water} @tab GNU/Linux @tab BSD 3-Clause
+@item @code{golang.org/x/crypto} @tab All @tab BSD 3-Clause
 @end multitable
 
 Get @ref{Tarballs, the tarball}, check its
index 4086a79f4c92271fd9a2a28b0fc2f8362b0ea47e..b1781ce4b2dfe312650707219af7d5fa8b7b8545 100644 (file)
@@ -3,6 +3,12 @@
 
 @table @strong
 
+@item Release 5.1
+@itemize
+@item Server is configured using @url{http://yaml.org/, YAML} file. It
+is very convenient to have comments and templates, comparing to JSON.
+@end itemize
+
 @item Release 5.0
 @itemize
 @item New optional @ref{Encless, encryptionless mode} of operation.
index 2668b1da962e543b09dddba3e37a16d0ed233a35..0882ff2d3ea62315c7dc1a6475f3237ab38a872c 100644 (file)
@@ -14,32 +14,27 @@ following ones:
 Address (@code{host:port} format) we must bind to.
 
 @item -conf
-Path to JSON file with the configuration.
+Path to YAML file with the configuration.
 
 @item -proxy
 Start trivial HTTP @ref{Proxy} server on specified @emph{host:port}.
 
 @end table
 
-Configuration file is JSON file with following example structure:
+Configuration file is YAML file with following example structure:
 
 @verbatim
-{
-  "stargrave": {                        <-- Peer human readable name
-    "iface": "tap10",                   <-- OPTIONAL TAP interface name
-    "mtu": 1514,                        <-- OPTIONAL overriden MTU
-    "up": "./stargrave-up.sh",          <-- OPTIONAL up-script
-    "down": "./stargrave-down.sh",      <-- OPTIONAL down-script
-    "timeout": 60,                      <-- OPTIONAL overriden timeout
-    "noise": true,                      <-- OPTIONAL noise enabler
-                                            (default: false)
-    "cpr": 64,                          <-- OPTIONAL constant packet
-                                            rate in KiB/sec
-    "encless": false,                   <-- OPTIONAL Encryptionless mode
-    "verifier": "$argon2d..."           <-- verifier received from client
-  },
-  [...]
-}
+stargrave: {                        <-- Peer human readable name
+    iface: tap10                    <-- OPTIONAL TAP interface name
+    mtu: 1514                       <-- OPTIONAL overriden MTU
+    up: ./stargrave-up.sh           <-- OPTIONAL up-script
+    down: ./stargrave-down.sh       <-- OPTIONAL down-script
+    timeout: 60                     <-- OPTIONAL overriden timeout
+    noise: No                       <-- OPTIONAL noise enabler
+    cpr: 64                         <-- OPTIONAL constant packet rate, KiB/sec
+    encless: No                     <-- OPTIONAL Encryptionless mode
+    verifier: $argon2d...           <-- verifier received from client
+[...]
 @end verbatim
 
 At least one of either @code{iface} or @code{up} must be specified. If
@@ -68,12 +63,23 @@ creation:
 [...]
 Your client verifier is: $argon2d$m=4096,t=128,p=1$bwR5VjeCYIQaa8SeaI3rqg
 
-Place the following JSON configuration entry on the server's side:
+Place the following YAML configuration entry on the server's side:
 
-    "Alice": {
-        "up": "/path/to/up.sh",
-        "iface": "or TAP interface name",
-        "verifier": "$argon2d$m=4096,t=128,p=1$bwR5VjeCYIQaa8SeaI3rqg$KCNIqfS4DGsBTtVytamAzcISgrlEWvNxan1UfBrFu10"
-    }
-[...]
+    Alice:
+        up: /path/to/up.sh
+        iface: or TAP interface name
+        verifier: $argon2d$m=4096,t=128,p=1$bwR5VjeCYIQaa8SeaI3rqg$KCNIqfS4DGsBTtVytamAzcISgrlEWvNxan1UfBrFu10
+@end verbatim
+
+Example configuration file:
+@verbatim
+stargrave:
+    iface: tap0
+    verifier: $argon2d$m=4096,t=128,p=1$VMirzcshcHuG2V4jhUsEjw$X5fC07L8k61h3S1Oro/rC76+m0oGDTA9Bq+aWJ1uOgY
+slow:
+    iface: tap1
+    encless: Yes
+    mtu: 9000
+    cpr: 384
+    verifier: $argon2d$m=4096,t=128,p=1$YbIA5garDqCOhtI/2EZVNg$gOo5vcEGynmpeepNscwclicfZsWxzgYFRLbgG21EZ1U
 @end verbatim
index f2dd06dc22290660624a3fba18b0da58f3479e5c..862fa86dfeb057c8ea4ae58f97a91736bafe2ffd 100644 (file)
@@ -26,6 +26,7 @@ repositories will be unavailable (they are seldom updated):
 @item @code{github.com/agl/ed25519} @tab @url{git://git.cypherpunks.ru/ed25519.git}
 @item @code{github.com/bigeagle/water} @tab @url{git://git.cypherpunks.ru/water.git}
 @item @code{github.com/dchest/blake2b} @tab @url{git://git.cypherpunks.ru/blake2b.git}
+@item @code{github.com/go-yaml/yaml} @tab @url{git://git.cypherpunks.ru/yaml.git}
 @item @code{github.com/magical/argon2} @tab @url{git://git.cypherpunks.ru/argon2.git}
 @item @code{golang.org/x/crypto} @tab @url{git://git.cypherpunks.ru/crypto.git}
 @end multitable
diff --git a/src/github.com/go-yaml/yaml b/src/github.com/go-yaml/yaml
new file mode 160000 (submodule)
index 0000000..f7716cb
--- /dev/null
@@ -0,0 +1 @@
+Subproject commit f7716cbe52baa25d2e9b0d0da546fcf909fc16b4
index 36681078b565978fab4731b26aaf51a66d05b541..00fa7c851e5b109bbecc4b0b4db8f449341f953d 100644 (file)
@@ -19,12 +19,13 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 package main
 
 import (
-       "encoding/json"
        "errors"
        "io/ioutil"
        "log"
        "time"
 
+       "github.com/go-yaml/yaml"
+
        "govpn"
 )
 
@@ -43,7 +44,7 @@ func confRead() (*map[govpn.PeerId]*govpn.PeerConf, error) {
                return nil, err
        }
        confsRaw := new(map[string]govpn.PeerConf)
-       err = json.Unmarshal(data, confsRaw)
+       err = yaml.Unmarshal(data, confsRaw)
        if err != nil {
                return nil, err
        }
index 9a73b25da3acb78a2832182d175750c53c97c340..e7abfdf19b94d0a3ffc1c07ca63bfa46f3c5e509 100644 (file)
@@ -33,7 +33,7 @@ import (
 var (
        bindAddr = flag.String("bind", "[::]:1194", "Bind to address")
        proto    = flag.String("proto", "udp", "Protocol to use: udp, tcp or all")
-       confPath = flag.String("conf", "peers.json", "Path to configuration JSON")
+       confPath = flag.String("conf", "peers.yaml", "Path to configuration YAML")
        stats    = flag.String("stats", "", "Enable stats retrieving on host:port")
        proxy    = flag.String("proxy", "", "Enable HTTP proxy on host:port")
        egdPath  = flag.String("egd", "", "Optional path to EGD socket")
index 4cb2f15fd5c7905e7f65dd88732fc25bf7eaf04b..0639475254d8be37b091ee28c653ca502e9d810b 100644 (file)
@@ -25,21 +25,21 @@ import (
 )
 
 type PeerConf struct {
-       Id          *PeerId       `json:"-"`
-       Name        string        `json:"name"`
-       Iface       string        `json:"iface"`
-       MTU         int           `json:"mtu"`
-       Up          string        `json:"up"`
-       Down        string        `json:"down"`
-       TimeoutInt  int           `json:"timeout"`
-       Timeout     time.Duration `json:"-"`
-       Noise       bool          `json:"noise"`
-       CPR         int           `json:"cpr"`
-       Encless     bool          `json:"encless"`
-       VerifierRaw string        `json:"verifier"`
+       Id          *PeerId       `yaml:"-"`
+       Name        string        `yaml:"name"`
+       Iface       string        `yaml:"iface"`
+       MTU         int           `yaml:"mtu"`
+       Up          string        `yaml:"up"`
+       Down        string        `yaml:"down"`
+       TimeoutInt  int           `yaml:"timeout"`
+       Timeout     time.Duration `yaml:"-"`
+       Noise       bool          `yaml:"noise"`
+       CPR         int           `yaml:"cpr"`
+       Encless     bool          `yaml:"encless"`
+       VerifierRaw string        `yaml:"verifier"`
 
        // This is passphrase verifier
-       Verifier *Verifier
+       Verifier *Verifier `yaml:"-"`
        // This field exists only on client's side
-       DSAPriv *[ed25519.PrivateKeySize]byte `json:"-"`
+       DSAPriv *[ed25519.PrivateKeySize]byte `yaml:"-"`
 }
index cf819eceafe3460110d516368b93c90f357a9a5c..3c5ce99b78416e1b2d3764212c229a56dd024a7f 100755 (executable)
@@ -8,7 +8,15 @@ release=$1
 [ -n "$release" ]
 
 git clone . $tmp/govpn-$release
-for repo in src/github.com/bigeagle/water src/github.com/agl/ed25519 src/github.com/magical/argon2 src/github.com/dchest/blake2b src/golang.org/x/crypto; do
+repos="
+    src/github.com/bigeagle/water
+    src/github.com/agl/ed25519
+    src/github.com/magical/argon2
+    src/github.com/dchest/blake2b
+    src/golang.org/x/crypto
+    src/github.com/go-yaml/yaml
+"
+for repo in $repos; do
     git clone $repo $tmp/govpn-$release/$repo
 done
 cd $tmp/govpn-$release
index 2c2a811e49aeb5863ecc763d9b4aa56d94ac4ea4..44c7ef5e977c044a369a26ad1c1ce185dcaad996 100755 (executable)
@@ -6,7 +6,7 @@ PATH=$PATH:.
     cat <<EOF
 Example script for creating new user peer for GoVPN.
 It asks for passphrase, generates verifier and shows you example
-JSON entry for server configuration.
+YAML entry for server configuration.
 
 Usage: $0 <username>
 EOF
@@ -26,13 +26,12 @@ echo
 cat <<EOF
 Your client verifier is: $verifierC
 
-Place the following JSON configuration entry on the server's side:
+Place the following YAML configuration entry on the server's side:
 
-    "$username": {
-        "up": "/path/to/up.sh",
-        "iface": "or TAP interface name",
-        "verifier": "$verifierS"
-    }
+    $username:
+        up: /path/to/up.sh
+        iface: or TAP interface name
+        verifier: $verifierS
 
 Verifier was generated with: