Add a -version command-line switch to print the version

Fixes #2
This commit is contained in:
Frank Denis 2018-01-18 12:22:25 +01:00
parent 0e03f684b2
commit fd7838ee58
2 changed files with 9 additions and 1 deletions

View File

@ -4,6 +4,7 @@ import (
"errors"
"flag"
"fmt"
"os"
"strings"
"time"
@ -73,11 +74,16 @@ type BlockNameConfig struct {
}
func ConfigLoad(proxy *Proxy, svcFlag *string, config_file string) error {
version := flag.Bool("version", false, "prints current proxy version")
configFile := flag.String("config", "dnscrypt-proxy.toml", "path to the configuration file")
flag.Parse()
if *svcFlag == "stop" || *svcFlag == "uninstall" {
return nil
}
if *version {
fmt.Println(AppVersion)
os.Exit(0)
}
config := newConfig()
if _, err := toml.DecodeFile(*configFile, &config); err != nil {
return err

View File

@ -15,6 +15,8 @@ import (
"golang.org/x/crypto/curve25519"
)
const AppVersion = "2.0.0beta2"
type Proxy struct {
proxyPublicKey [32]byte
proxySecretKey [32]byte
@ -153,7 +155,7 @@ func (proxy *Proxy) StartProxy() {
}
liveServers, err := proxy.serversInfo.refresh(proxy)
if liveServers > 0 {
dlog.Noticef("dnscrypt-proxy is ready - live servers: %d", liveServers)
dlog.Noticef("dnscrypt-proxy %s is ready - live servers: %d", AppVersion, liveServers)
} else if err != nil {
dlog.Error(err)
dlog.Notice("dnscrypt-proxy is waiting for at least one server to be reachable")