feat: add metadata handling and add app visibility options

Kim committed Nov 15, 2025 at 12:16 UTC 702787ec07443509e4efa363751e8b1d0150c544
4 files changed +24 -17
cmd/demo-app/main.go
+2 -11
@@ -92,22 +92,13 @@ func runDemo() error {
92 }
93 defer client.Close()
94
95 - // Derive tags slice from comma-separated flag
96 - var tags []string
97 - for _, t := range strings.Split(flagTags, ",") {
98 - t = strings.TrimSpace(t)
99 - if t != "" {
100 - tags = append(tags, t)
101 - }
102 - }
103 -
104 - // 3) Register lease and obtain a net.Listener that accepts relayed connections
95 + // 3) Register lease
96 listener, err := client.Listen(
97 cred,
98 flagName,
99 []string{"http/1.1"},
100 sdk.WithDescription(flagDesc),
110 - sdk.WithTags(tags),
101 + sdk.WithTags(strings.Split(flagTags, ",")),
102 sdk.WithOwner(flagOwner),
103 sdk.WithHide(flagHide),
104 )
cmd/relay-server/static/index.html
+9 -1
@@ -109,7 +109,15 @@
109 >{{.LastSeenISO}}</time
110 ><br />Active ~{{.LastSeen}} ago
111 </div>
112 - <div class="muted idtext" style="margin-top: auto">{{.Peer}}</div>
112 + <div class="muted idtext" style="margin-top: auto">
113 + <div>
114 + <strong>Lease ID:</strong>
115 + <span class="mono">{{.Peer}}</span>
116 + </div>
117 + {{if .Description}}<div><strong>Description:</strong> {{.Description}}</div>{{end}}
118 + {{if .Tags}}<div><strong>Tags:</strong> {{.Tags}}</div>{{end}}
119 + {{if .Owner}}<div><strong>Owner:</strong> {{.Owner}}</div>{{end}}
120 + </div>
121 </a>
122 {{else}}
123 <article class="card">
cmd/relay-server/view.go
+12 -4
@@ -15,6 +15,7 @@ import (
15
16 "gosuda.org/portal/portal"
17 "gosuda.org/portal/portal/utils/wsstream"
18 + "gosuda.org/portal/sdk"
19 )
20
21 //go:embed static
@@ -169,6 +170,9 @@ type leaseRow struct {
170 Link string
171 StaleRed bool
172 Hide bool
173 + Description string
174 + Tags string
175 + Owner string
176 }
177
178 type adminPageData struct {
@@ -194,11 +198,12 @@ func convertLeaseEntriesToRows(serv *portal.RelayServer) []leaseRow {
198 lease := leaseEntry.Lease
199 identityID := string(lease.Identity.Id)
200
197 - // Metadata parsing and hide check
198 - var meta struct {
199 - Hide bool `json:"hide"`
200 - }
201 + // Metadata parsing
202 + var meta sdk.Metadata
203 _ = json.Unmarshal([]byte(lease.Metadata), &meta)
204 + if meta.Hide {
205 + continue
206 + }
207
208 // Calculate TTL
209 ttl := time.Until(leaseEntry.Expires)
@@ -280,6 +285,9 @@ func convertLeaseEntriesToRows(serv *portal.RelayServer) []leaseRow {
285 Link: link,
286 StaleRed: !connected && since >= 15*time.Second,
287 Hide: meta.Hide,
288 + Description: strings.TrimSpace(meta.Description),
289 + Tags: strings.Join(meta.Tags, ", "),
290 + Owner: strings.TrimSpace(meta.Owner),
291 }
292
293 rows = append(rows, row)
portal/handlers.go
+1 -1
@@ -78,7 +78,7 @@ func (g *RelayServer) handleLeaseUpdateRequest(ctx *StreamContext, packet *rdver
78 log.Debug().
79 Str("lease_id", leaseID).
80 Str("lease_name", req.Lease.Name).
81 - RawJSON("metadata", []byte(req.Lease.Metadata)).
81 + Str("metadata", req.Lease.Metadata).
82 Int64("connection_id", ctx.ConnectionID).
83 Msg("[RelayServer] Lease update completed successfully")
84 } else {