Expire join codes on the setup's side, bind the join port to its address, trust the peer address

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ilker ManapandClaude Opus 5.5 committed 2026-10-04 10:16:53 +02:00
1 parent 27c49d0af9
commit 1f406247e4
4 files changed
+67 -15

No files matched your search

+6 -2
View File
@@ -4,6 +4,7 @@ import (
"context"
"fmt"
"io"
"net"
"net/mail"
"os"
"strings"
@@ -448,8 +449,11 @@ func (m *setupModel) startJoins() (tea.Cmd, bool) {
continue
}
if m.listener == nil {
l, err := joinpkg.Listen(fmt.Sprintf(":%d", joinpkg.DefaultPort),
fmt.Sprintf("%s:%d", m.thisAddr(), joinpkg.DefaultPort), time.Hour)
// On the address the codes name, not every interface: a code is
// a credential, and the port it is spent on need not face more
// than the network the machines join from.
addr := net.JoinHostPort(m.thisAddr(), fmt.Sprint(joinpkg.DefaultPort))
l, err := joinpkg.Listen(addr, addr, time.Hour)
if err != nil {
m.formErr = err.Error()
return nil, false