fix: edge-control: per-caller attribution for register/deregister (#1094)
All checks were successful
ci/woodpecker/push/ci Pipeline was successful
ci/woodpecker/pr/ci Pipeline was successful
ci/woodpecker/pr/edge-subpath Pipeline was successful

- register.sh parses --as <tag> from forced-command argv, stores as
  registered_by in registry entries (defaults to "unknown")
- allocate_port() accepts optional registered_by parameter
- list output includes registered_by for each tunnel
- deregister response includes deregistered_by
- install.sh accepts --admin-tag <name> (defaults to "admin") and wires
  it into the forced-command entry as --as <tag>

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Claude 2026-04-20 19:29:15 +00:00
parent 3116293d8e
commit bba859f7cc
3 changed files with 39 additions and 7 deletions

View file

@ -54,13 +54,14 @@ _registry_write() {
}
# Allocate a port for a project
# Usage: allocate_port <project> <pubkey> <fqdn>
# Usage: allocate_port <project> <pubkey> <fqdn> [<registered_by>]
# Returns: port number on stdout
# Writes: registry.json with project entry
allocate_port() {
local project="$1"
local pubkey="$2"
local fqdn="$3"
local registered_by="${4:-unknown}"
_ensure_registry_dir
@ -116,11 +117,13 @@ allocate_port() {
--arg pubkey "$pubkey" \
--arg fqdn "$fqdn" \
--arg timestamp "$timestamp" \
--arg registered_by "$registered_by" \
'.projects[$project] = {
"port": $port,
"fqdn": $fqdn,
"pubkey": $pubkey,
"registered_at": $timestamp
"registered_at": $timestamp,
"registered_by": $registered_by
}')
_registry_write "$new_registry"
@ -184,7 +187,7 @@ list_ports() {
local registry
registry=$(_registry_read)
echo "$registry" | jq -r '.projects | to_entries | map({name: .key, port: .value.port, fqdn: .value.fqdn}) | .[] | @json' 2>/dev/null
echo "$registry" | jq -r '.projects | to_entries | map({name: .key, port: .value.port, fqdn: .value.fqdn, registered_by: (.value.registered_by // "unknown")}) | .[] | @json' 2>/dev/null
}
# Get full project info from registry