commit 1747f815f3f5dea7e2e27f5d44769d64de4f530e
parent 0e26ceb790adee16f641b71d6ebd86de8411cd69
Author: Martin Schanzenbach <schanzen@gnunet.org>
Date: Tue, 27 Oct 2026 12:14:52 +0100
use proper types
Diffstat:
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/pkg/taldir/taldir.go b/pkg/taldir/taldir.go
@@ -269,7 +269,9 @@ func (t *Taldir) getSingleEntry(w http.ResponseWriter, r *http.Request) {
hsAlias := saltHAlias(vars["h_alias"], t.Salt)
var err = t.DB.GetEntryByHsAlias(&entry, hsAlias)
if err == nil {
+ entryValidity := time.UnixMicro(entry.CreatedAt + entry.Duration)
w.Header().Set("Content-Type", "application/json")
+ w.Write(fmt.Appendf(make([]byte, 0), "{\"target_uri\": %s, \"valid_for\": { \"d_us\": %d }}", entry.TargetURI, time.Until(entryValidity).Microseconds()))
resp, _ := json.Marshal(entry)
w.Write(resp)
return
@@ -451,7 +453,7 @@ func (t *Taldir) validationRequest(w http.ResponseWriter, r *http.Request) {
if validation.TargetURI != "" {
entryValidFor = time.Until(time.UnixMicro(entry.CreatedAt + entry.Duration)).Microseconds()
}
- w.Write(fmt.Appendf(make([]byte, 0), "{\"valid_for\": %d}", entryValidFor))
+ w.Write(fmt.Appendf(make([]byte, 0), "{\"valid_for\": { \"d_us\": %d }}", entryValidFor))
w.WriteHeader(http.StatusOK)
}
@@ -556,7 +558,7 @@ func (t *Taldir) registerRequest(w http.ResponseWriter, r *http.Request) {
t.Logger.Logf(LogDebug, "Returning validity of entry")
w.WriteHeader(http.StatusOK)
w.Header().Set("Content-Type", "application/json")
- w.Write(fmt.Appendf(make([]byte, 0), "{\"valid_for\": %d}", time.Until(entryValidity).Microseconds()))
+ w.Write(fmt.Appendf(make([]byte, 0), "{\"valid_for\": { \"d_us\": %d }}", time.Until(entryValidity).Microseconds()))
return
}
}