taler-mailbox

Service for asynchronous wallet-to-wallet payment messages
Log | Files | Refs | Submodules | README | LICENSE

commit e3c4651871b31c363f6b3f1d448f13848843463f
parent 53509e925d29424b7c3c872afabda473ae6aabce
Author: Martin Schanzenbach <schanzen@gnunet.org>
Date:   Sat, 21 Mar 2026 09:54:14 +0100

fix CLI options

Diffstat:
MMakefile.in | 16++++++++++++----
Mcmd/mailbox-config/main.go | 13++++++++++++-
Mcmd/mailbox-dbinit/main.go | 12++++++++++++
Mcmd/mailbox-server/main.go | 15+++++++++++----
Mcmd/mailbox-server/main_test.go | 2+-
Mconfigure | 2+-
Mdebian/changelog | 5+++++
Mdebian/taler-mailbox.service | 2+-
Mpkg/rest/db.go | 2+-
9 files changed, 56 insertions(+), 13 deletions(-)

diff --git a/Makefile.in b/Makefile.in @@ -6,7 +6,7 @@ LT_VERSION="1:1:0" GITVER=`git describe --tags | sed 's/v//'` server: - ${GO} build -ldflags "-X main.ltversion=${LT_VERSION} -X main.version=${VERSION} -X main.mailboxdatahome=${TALER_MAILBOX_HOME} -X main.mailboxconfdir=${TALER_MAILBOX_CONFDIR}" -o taler-mailbox ./cmd/mailbox-server + ${GO} build -ldflags "-X main.ltversion=${LT_VERSION} -X main.version=${VERSION} -X main.mailboxdatahome=${TALER_MAILBOX_HOME} -X main.mailboxconfdir=${TALER_MAILBOX_CONFDIR}" -o taler-mailbox-httpd ./cmd/mailbox-server tools: ${GO} build -ldflags "-X main.ltversion=${LT_VERSION} -X main.version=${VERSION} -X main.mailboxdatahome=${TALER_MAILBOX_HOME} -X main.mailboxconfdir=${TALER_MAILBOX_CONFDIR}" -o taler-mailbox-config ./cmd/mailbox-config @@ -18,7 +18,7 @@ tools: install: server -mkdir -p ${DESTDIR}${bindir} -mkdir -p ${DESTDIR}${TALER_MAILBOX_HOME} - install ./taler-mailbox ${DESTDIR}${bindir} + install ./taler-mailbox-httpd ${DESTDIR}${bindir} install ./taler-mailbox-dbinit ${DESTDIR}${bindir} install ./taler-mailbox-config ${DESTDIR}${bindir} chmod +x ./contrib/taler-mailbox-dbconfig @@ -26,11 +26,19 @@ install: server cp -r ./sql ${DESTDIR}${TALER_MAILBOX_HOME}/ cp mailbox.conf.example ${DESTDIR}${TALER_MAILBOX_HOME} -mkdir -p ${DESTDIR}${mandir}/man1 + -mkdir -p ${DESTDIR}${mandir}/man5 cp doc/man/taler-mailbox.1 ${DESTDIR}${mandir}/man1/ + cp doc/man/taler-mailbox-config.1 ${DESTDIR}${mandir}/man1/ + cp doc/man/taler-mailbox-httpd.1 ${DESTDIR}${mandir}/man1/ + cp doc/man/taler-mailbox-dbinit.1 ${DESTDIR}${mandir}/man1/ + cp doc/man/mailbox.conf.5 ${DESTDIR}${mandir}/man5/ uninstall: - $(RM) ${DESTDIR}${bindir}/taler-mailbox* - ${RM} -r ${DESTDIR}${TALER_MAILBOX_HOME} + -$(RM) ${DESTDIR}${bindir}/taler-mailbox* + -${RM} -r ${DESTDIR}${TALER_MAILBOX_HOME} + -${RM} -r ${DESTDIR}${mandir}/man1/taler-mailbox* + -${RM} -r ${DESTDIR}${mandir}/man5/mailbox* + check: ${GO} test ./cmd/mailbox-server diff --git a/cmd/mailbox-config/main.go b/cmd/mailbox-config/main.go @@ -21,8 +21,10 @@ package main import ( "flag" "fmt" + "log" "os" "path" + "path/filepath" "rsc.io/getopt" @@ -33,7 +35,6 @@ var ( version string mailboxdatahome string mailboxconfdir string - verbose bool // FIXME do something with this? ) func printHelp() { @@ -88,12 +89,22 @@ func main() { getopt.Alias("c", "config") var helpFlag = flag.Bool("h", false, "Print help") getopt.Alias("h", "help") + var versionFlag = flag.Bool("v", false, "Print version") + getopt.Alias("v", "version") getopt.Parse() if *helpFlag { printHelp() return } + if *versionFlag { + fullName, err := os.Executable() + if err != nil { + log.Panic(err) + } + fmt.Printf("%s %s", filepath.Base(fullName), version) + return + } cfgfile := path.Join(mailboxconfdir, "mailbox.conf") if len(*cfgFlag) != 0 { cfg, err = ini.Load(*cfgFlag) diff --git a/cmd/mailbox-dbinit/main.go b/cmd/mailbox-dbinit/main.go @@ -25,6 +25,7 @@ import ( "log" "os" "path" + "path/filepath" "strings" _ "github.com/lib/pq" @@ -37,6 +38,7 @@ import ( var ( mailboxdatahome string mailboxconfdir string + version string ) func printHelp() { @@ -54,12 +56,22 @@ func main() { getopt.Alias("c", "config") var helpFlag = flag.Bool("h", false, "Print help") getopt.Alias("h", "help") + var versionFlag = flag.Bool("v", false, "Print version") + getopt.Alias("v", "version") getopt.Parse() if *helpFlag { printHelp() return } + if *versionFlag { + fullName, err := os.Executable() + if err != nil { + log.Panic(err) + } + fmt.Printf("%s %s", filepath.Base(fullName), version) + return + } cfgfile := path.Join(mailboxconfdir, "mailbox.conf") if len(*cfgFlag) != 0 { cfg, err = ini.Load(*cfgFlag) diff --git a/cmd/mailbox-server/main.go b/cmd/mailbox-server/main.go @@ -26,6 +26,7 @@ import ( "net/http" "os" "path" + "path/filepath" "gopkg.in/ini.v1" @@ -41,7 +42,6 @@ var ( version string mailboxdatahome string mailboxconfdir string - verbose bool ) func handleRequests(m *mailbox.Mailbox) { @@ -62,8 +62,8 @@ func main() { // FIXME use flags loglevelStringOpt := flag.String("L", "INFO", "Log level to use. DEBUG, INFO, WARNING or ERROR") getopt.Alias("L", "loglevel") - var verboseFlag = flag.Bool("v", false, "Verbose") - getopt.Alias("v", "verbose") + var versionFlag = flag.Bool("v", false, "Print version") + getopt.Alias("v", "version") var helpFlag = flag.Bool("h", false, "Print help") getopt.Alias("h", "help") @@ -72,11 +72,18 @@ func main() { printHelp() return } + if *versionFlag { + fullName, err := os.Executable() + if err != nil { + log.Panic(err) + } + fmt.Printf("%s %s", filepath.Base(fullName), version) + return + } cfgfile := path.Join(mailboxconfdir, "mailbox.conf") if len(*cfgFlag) != 0 { cfgfile = *cfgFlag } - verbose = *verboseFlag loglevel := mailbox.LogInfo for loglevelNum, loglevelString := range mailbox.LoglevelStringMap { if loglevelString == *loglevelStringOpt { diff --git a/cmd/mailbox-server/main_test.go b/cmd/mailbox-server/main_test.go @@ -295,7 +295,7 @@ func createMailboxMetadata(encKey []byte, signKey []byte, info string) mailbox.M } func createMailboxRegistrationMessage(encKey []byte, md mailbox.MailboxMetadata) mailbox.MailboxRegistrationRequest { - var msg mailbox.MailboxRegistrationRequest + var msg mailbox.MailboxRegistrationRequest msg.MailboxMetadata = md expNbo := make([]byte, 8) binary.BigEndian.PutUint64(expNbo, msg.MailboxMetadata.Expiration.Seconds) diff --git a/configure b/configure @@ -1,7 +1,7 @@ #!/bin/sh pkg_name="taler-mailbox" -pkg_version="1.3.2" +pkg_version="1.5.0" pkg_default_features="" pkg_optional_features="" pkg_optional_dependencies="" diff --git a/debian/changelog b/debian/changelog @@ -1,3 +1,8 @@ +taler-mailbox (1.5.0) UNRELEASED; urgency=medium + + [ Martin Schanzenbach ] + * Bump version + taler-mailbox (1.3.1) UNRELEASED; urgency=medium [ Martin Schanzenbach ] diff --git a/debian/taler-mailbox.service b/debian/taler-mailbox.service @@ -9,7 +9,7 @@ Restart=always RestartSec=1s RestartPreventExitStatus=9 RuntimeMaxSec=3600s -ExecStart=/usr/bin/taler-mailbox -c /etc/taler-mailbox/taler-mailbox.conf +ExecStart=/usr/bin/taler-mailbox -c /etc/taler-mailbox/mailbox.conf [Install] WantedBy=multi-user.target diff --git a/pkg/rest/db.go b/pkg/rest/db.go @@ -21,8 +21,8 @@ package mailbox import ( "context" "database/sql" - _ "github.com/lib/pq" "errors" + _ "github.com/lib/pq" "time" )