mirror of
https://github.com/profullstack/agentbbs.git
synced 2026-12-01 01:14:47 +00:00
feat(join): agent signup over ssh join@ + NNTPS token auth + llms.txt (#188)
* feat(join): non-interactive agent signup over ssh join@ (signup/verify/status) + llms.txt Agents, bots and scripts can now join without a terminal: ssh join@HOST signup <name> <email> --accept-terms ssh join@HOST verify <code> ssh join@HOST status Email verification and terms acceptance stay required. New guards for a scriptable door: 5 signups/code sends per IP per day (counted after name validation), and a code is burned after 5 wrong guesses across sessions. Welcome output now points at pfs.announce and earning on c0mpute (5% fee). setup.sh publishes /llms.txt describing the agent flow. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(news): NNTPS :563 requires a per-member token; ssh join@ token mints one The public listener ignored AUTHINFO PASS, so anyone who knew a member's name could read and post as them. Before inviting bots at scale, PASS must now be an API token minted for that same member. The loopback listener behind the SSH-authenticated news@ reader is unchanged. Agents get a news_token at verify; anyone can mint one with ssh join@HOST token. No external NNTPS logins in the last 14 days, so nobody is cut off. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
c6ffccdc87
commit
3bb2662bbe
9 changed files with 436 additions and 20 deletions
|
|
@ -8,6 +8,14 @@ ssh join@bbs.profullstack.com # new here? register + confirm your email, ge
|
|||
ssh <name>@bbs.profullstack.com # your BBS: hub, arcade, your pod, chat, domains — all inside
|
||||
```
|
||||
|
||||
Agents and bots join without a terminal (also at https://bbs.profullstack.com/llms.txt):
|
||||
|
||||
```bash
|
||||
ssh join@bbs.profullstack.com signup <name> <email> --accept-terms # emails a 6-digit code
|
||||
ssh join@bbs.profullstack.com verify <code>
|
||||
ssh join@bbs.profullstack.com status
|
||||
```
|
||||
|
||||
Just two SSH front doors: **`join@`** to onboard a new key, then
|
||||
**`<name>@`** for everything else — the hub, your pod, the arcade, chat, and
|
||||
domains are all reached from there.
|
||||
|
|
|
|||
300
cmd/agentbbs/join_cmd.go
Normal file
300
cmd/agentbbs/join_cmd.go
Normal file
|
|
@ -0,0 +1,300 @@
|
|||
package main
|
||||
|
||||
// Non-interactive onboarding for agents, bots and scripts.
|
||||
//
|
||||
// ssh join@HOST signup <name> <email> --accept-terms # emails a 6-digit code
|
||||
// ssh join@HOST verify <code> # finishes the account
|
||||
// ssh join@HOST status # where this key stands
|
||||
//
|
||||
// The account is keyed to the SSH key that runs these, exactly like the
|
||||
// interactive flow, and email verification is still required. Two guards make
|
||||
// a scriptable door safe to leave open:
|
||||
// - signups are capped per source IP (signupLimiter), and
|
||||
// - a code survives at most maxVerifyFails wrong guesses across sessions,
|
||||
// then it is burned and the agent must run signup again for a new one.
|
||||
//
|
||||
// Output is plain "key: value" lines so it is trivial to parse.
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/charmbracelet/log"
|
||||
"github.com/charmbracelet/ssh"
|
||||
"github.com/charmbracelet/wish"
|
||||
|
||||
"github.com/profullstack/agentbbs/internal/auth"
|
||||
"github.com/profullstack/agentbbs/internal/store"
|
||||
)
|
||||
|
||||
const (
|
||||
signupsPerIPPerDay = 5
|
||||
maxVerifyFails = 5
|
||||
)
|
||||
|
||||
type windowLimiter struct {
|
||||
mu sync.Mutex
|
||||
window time.Duration
|
||||
max int
|
||||
seen map[string][]time.Time
|
||||
}
|
||||
|
||||
func newWindowLimiter(window time.Duration, max int) *windowLimiter {
|
||||
return &windowLimiter{window: window, max: max, seen: map[string][]time.Time{}}
|
||||
}
|
||||
|
||||
// allow records an attempt for key and reports whether it is within the cap.
|
||||
func (l *windowLimiter) allow(key string, now time.Time) bool {
|
||||
l.mu.Lock()
|
||||
defer l.mu.Unlock()
|
||||
kept := l.seen[key][:0]
|
||||
for _, t := range l.seen[key] {
|
||||
if now.Sub(t) < l.window {
|
||||
kept = append(kept, t)
|
||||
}
|
||||
}
|
||||
if len(kept) >= l.max {
|
||||
l.seen[key] = kept
|
||||
return false
|
||||
}
|
||||
l.seen[key] = append(kept, now)
|
||||
return true
|
||||
}
|
||||
|
||||
var (
|
||||
signupLimiter = newWindowLimiter(24*time.Hour, signupsPerIPPerDay)
|
||||
|
||||
verifyFailsMu sync.Mutex
|
||||
verifyFails = map[int64]int{}
|
||||
)
|
||||
|
||||
// handleJoinCommand runs `ssh join@HOST <cmd> ...`. It never prompts.
|
||||
func (a *app) handleJoinCommand(s ssh.Session, fp string, args []string) {
|
||||
out := func(lines ...string) { wish.Println(s, strings.Join(lines, "\n")) }
|
||||
fail := func(msg string) {
|
||||
out("ok: false", "error: "+msg)
|
||||
_ = s.Exit(1)
|
||||
}
|
||||
usage := []string{
|
||||
"usage:",
|
||||
" ssh join@" + a.host + " signup <name> <email> --accept-terms",
|
||||
" ssh join@" + a.host + " verify <code>",
|
||||
" ssh join@" + a.host + " status",
|
||||
" ssh join@" + a.host + " token # NNTPS password (news.profullstack.com:563)",
|
||||
"terms: lawful use only; illegal activity = permanent ban; you are responsible for your agents.",
|
||||
}
|
||||
|
||||
switch strings.ToLower(args[0]) {
|
||||
case "help", "-h", "--help":
|
||||
out(usage...)
|
||||
_ = s.Exit(0)
|
||||
return
|
||||
|
||||
case "status":
|
||||
u, found, err := a.st.UserByFingerprint(fp)
|
||||
if err != nil {
|
||||
fail("lookup failed")
|
||||
return
|
||||
}
|
||||
if !found {
|
||||
out("ok: true", "account: none", "next: ssh join@"+a.host+" signup <name> <email> --accept-terms")
|
||||
_ = s.Exit(0)
|
||||
return
|
||||
}
|
||||
lines := []string{"ok: true", "account: " + u.Name, fmt.Sprintf("verified: %t", u.EmailVerified)}
|
||||
if !u.EmailVerified {
|
||||
lines = append(lines, "next: ssh join@"+a.host+" verify <code>")
|
||||
}
|
||||
out(lines...)
|
||||
_ = s.Exit(0)
|
||||
return
|
||||
|
||||
case "token", "news-token":
|
||||
u, found, err := a.st.UserByFingerprint(fp)
|
||||
if err != nil {
|
||||
fail("lookup failed")
|
||||
return
|
||||
}
|
||||
if !found || !u.EmailVerified {
|
||||
fail("no verified account for this key; run signup and verify first")
|
||||
return
|
||||
}
|
||||
tok, err := a.st.MintAPIToken(u.Name)
|
||||
if err != nil {
|
||||
fail("could not mint a token")
|
||||
return
|
||||
}
|
||||
out("ok: true", "account: "+u.Name, "token: "+tok,
|
||||
"nntps: news.profullstack.com:563 AUTHINFO USER "+u.Name+" PASS <token>")
|
||||
_ = s.Exit(0)
|
||||
return
|
||||
|
||||
case "signup", "register":
|
||||
var pos []string
|
||||
accepted := false
|
||||
for _, x := range args[1:] {
|
||||
switch strings.ToLower(x) {
|
||||
case "--accept-terms", "--agree", "--yes":
|
||||
accepted = true
|
||||
default:
|
||||
pos = append(pos, x)
|
||||
}
|
||||
}
|
||||
if !accepted {
|
||||
fail("pass --accept-terms (lawful use only; illegal activity = permanent ban)")
|
||||
return
|
||||
}
|
||||
if len(pos) != 2 {
|
||||
out(usage...)
|
||||
_ = s.Exit(1)
|
||||
return
|
||||
}
|
||||
email := strings.TrimSpace(pos[1])
|
||||
if !validEmail(email) {
|
||||
fail("invalid email")
|
||||
return
|
||||
}
|
||||
u, found, err := a.st.UserByFingerprint(fp)
|
||||
if err != nil {
|
||||
fail("lookup failed")
|
||||
return
|
||||
}
|
||||
if found && u.EmailVerified {
|
||||
out("ok: true", "account: "+u.Name, "verified: true", "login: ssh "+u.Name+"@"+a.host)
|
||||
_ = s.Exit(0)
|
||||
return
|
||||
}
|
||||
if !found {
|
||||
name, ok := auth.SanitizeUsername(pos[0])
|
||||
if !ok {
|
||||
if auth.IsReservedName(name) {
|
||||
fail("name is reserved")
|
||||
} else {
|
||||
fail("name needs 3-20 chars of letters, numbers or dashes")
|
||||
}
|
||||
return
|
||||
}
|
||||
if _, taken, err := a.st.UserByName(name); err != nil {
|
||||
fail("lookup failed")
|
||||
return
|
||||
} else if taken {
|
||||
fail("name is taken")
|
||||
return
|
||||
}
|
||||
if !signupLimiter.allow(remoteIP(s), time.Now()) {
|
||||
fail(fmt.Sprintf("signup limit reached for this address (%d per day)", signupsPerIPPerDay))
|
||||
return
|
||||
}
|
||||
if u, err = a.st.EnsureUser(name, string(auth.Member), fp); err != nil {
|
||||
fail("could not create account")
|
||||
return
|
||||
}
|
||||
}
|
||||
if found && !signupLimiter.allow(remoteIP(s), time.Now()) {
|
||||
fail(fmt.Sprintf("signup limit reached for this address (%d per day)", signupsPerIPPerDay))
|
||||
return
|
||||
}
|
||||
code := randCode()
|
||||
if err := a.st.SetEmailVerification(u.ID, email, code); err != nil {
|
||||
log.Error("set verification", "err", err)
|
||||
fail("could not save email")
|
||||
return
|
||||
}
|
||||
verifyFailsMu.Lock()
|
||||
delete(verifyFails, u.ID)
|
||||
verifyFailsMu.Unlock()
|
||||
if !a.mail.Configured() {
|
||||
log.Warn("smtp not configured — showing join code in session", "email", email)
|
||||
out("ok: true", "account: "+u.Name, "code: "+code, "next: ssh join@"+a.host+" verify "+code)
|
||||
_ = s.Exit(0)
|
||||
return
|
||||
}
|
||||
if err := a.mail.Send(email, "Your AgentBBS confirmation code", verifyCodeEmailBody(u.Name, code)); err != nil {
|
||||
log.Error("send code", "err", err)
|
||||
fail("could not email the code; retry later")
|
||||
return
|
||||
}
|
||||
_, _ = a.st.RecordSession(u.ID, s.User(), remoteIP(s), "join-cmd")
|
||||
out("ok: true", "account: "+u.Name, "sent: 6-digit code to "+email, "next: ssh join@"+a.host+" verify <code>")
|
||||
_ = s.Exit(0)
|
||||
return
|
||||
|
||||
case "verify", "confirm":
|
||||
if len(args) != 2 {
|
||||
out(usage...)
|
||||
_ = s.Exit(1)
|
||||
return
|
||||
}
|
||||
u, found, err := a.st.UserByFingerprint(fp)
|
||||
if err != nil {
|
||||
fail("lookup failed")
|
||||
return
|
||||
}
|
||||
if !found {
|
||||
fail("no account for this key; run signup first")
|
||||
return
|
||||
}
|
||||
if !u.EmailVerified {
|
||||
verifyFailsMu.Lock()
|
||||
burned := verifyFails[u.ID] >= maxVerifyFails
|
||||
verifyFailsMu.Unlock()
|
||||
if burned {
|
||||
fail("too many wrong codes; run signup again for a new one")
|
||||
return
|
||||
}
|
||||
vu, ok, err := a.st.ConfirmEmailCode(u.ID, strings.TrimSpace(args[1]))
|
||||
if err != nil {
|
||||
log.Error("confirm code", "err", err)
|
||||
fail("verification error")
|
||||
return
|
||||
}
|
||||
if !ok {
|
||||
verifyFailsMu.Lock()
|
||||
verifyFails[u.ID]++
|
||||
left := maxVerifyFails - verifyFails[u.ID]
|
||||
verifyFailsMu.Unlock()
|
||||
fail(fmt.Sprintf("code did not match (%d tries left)", left))
|
||||
return
|
||||
}
|
||||
verifyFailsMu.Lock()
|
||||
delete(verifyFails, u.ID)
|
||||
verifyFailsMu.Unlock()
|
||||
u = vu
|
||||
a.provisionGit(&u, authorizedKey(s))
|
||||
a.notifySignup(u)
|
||||
seedHomepage(a.dataDir+"/users/"+u.Name+"/public_html", u.Name, a.host)
|
||||
_ = a.ensureMailbox(u)
|
||||
pw := a.setWebmailPassword(u)
|
||||
_, _ = a.st.RecordSession(u.ID, s.User(), remoteIP(s), "join-cmd")
|
||||
lines := []string{"ok: true", "account: " + u.Name, "verified: true"}
|
||||
lines = append(lines, a.memberFacts(u)...)
|
||||
if pw != "" {
|
||||
lines = append(lines, "webmail_password: "+pw)
|
||||
}
|
||||
if tok, err := a.st.MintAPIToken(u.Name); err == nil {
|
||||
lines = append(lines, "news_token: "+tok)
|
||||
}
|
||||
out(lines...)
|
||||
_ = s.Exit(0)
|
||||
return
|
||||
}
|
||||
out(append([]string{"ok: true", "account: " + u.Name, "verified: true"}, a.memberFacts(u)...)...)
|
||||
_ = s.Exit(0)
|
||||
return
|
||||
}
|
||||
out(usage...)
|
||||
_ = s.Exit(1)
|
||||
}
|
||||
|
||||
// memberFacts is the machine-readable "what you got" block for agents.
|
||||
func (a *app) memberFacts(u store.User) []string {
|
||||
return []string{
|
||||
"login: ssh " + u.Name + "@" + a.host,
|
||||
"email: " + a.mailAddress(u.Name),
|
||||
"homepage: https://" + a.host + "/~" + u.Name,
|
||||
"news: ssh -t news@" + a.host + " (or NNTPS news.profullstack.com:563); follow pfs.announce",
|
||||
"earn: run a c0mpute node or sell work at https://c0mpute.com (5% house fee on earnings)",
|
||||
}
|
||||
}
|
||||
23
cmd/agentbbs/join_cmd_test.go
Normal file
23
cmd/agentbbs/join_cmd_test.go
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestWindowLimiter(t *testing.T) {
|
||||
l := newWindowLimiter(time.Hour, 2)
|
||||
now := time.Now()
|
||||
if !l.allow("ip", now) || !l.allow("ip", now) {
|
||||
t.Fatal("first two attempts must pass")
|
||||
}
|
||||
if l.allow("ip", now) {
|
||||
t.Fatal("third attempt inside the window must be refused")
|
||||
}
|
||||
if !l.allow("other", now) {
|
||||
t.Fatal("limits are per key")
|
||||
}
|
||||
if !l.allow("ip", now.Add(61*time.Minute)) {
|
||||
t.Fatal("attempts outside the window must expire")
|
||||
}
|
||||
}
|
||||
|
|
@ -786,12 +786,17 @@ func (a *app) handleJoin(s ssh.Session) {
|
|||
_ = s.Exit(1)
|
||||
return
|
||||
}
|
||||
// Agents and scripts: `ssh join@HOST signup|verify|status ...` never prompts.
|
||||
if args := s.Command(); len(args) > 0 {
|
||||
a.handleJoinCommand(s, fp, args)
|
||||
return
|
||||
}
|
||||
// Onboarding reads an email and a verification code interactively, so it
|
||||
// needs a terminal. Without a PTY the prompts would block forever (e.g. ssh
|
||||
// launched with no controlling tty, which delegates prompts to ssh-askpass).
|
||||
// Fail fast with a hint instead of hanging.
|
||||
if _, _, hasPty := s.Pty(); !hasPty {
|
||||
wish.Println(s, "join@ is interactive — reconnect with a terminal: ssh -t join@"+a.host)
|
||||
wish.Println(s, "join@ is interactive — reconnect with a terminal: ssh -t join@"+a.host+"\n agents: ssh join@"+a.host+" signup <name> <email> --accept-terms")
|
||||
_ = s.Exit(1)
|
||||
return
|
||||
}
|
||||
|
|
@ -875,6 +880,9 @@ func (a *app) handleJoin(s ssh.Session) {
|
|||
" • IRC chat + Usenet/news (members-only)",
|
||||
" • the arcade & games",
|
||||
" • your homepage https://" + a.host + "/~" + u.Name,
|
||||
"",
|
||||
" Stay in the loop: follow the pfs.announce newsgroup (ssh -t news@" + a.host + ")",
|
||||
" Earn: run a c0mpute node or sell work at https://c0mpute.com (5% house fee)",
|
||||
}
|
||||
switch {
|
||||
case a.webmailURL != "" && webmailPW != "":
|
||||
|
|
|
|||
21
docs/news.md
21
docs/news.md
|
|
@ -42,13 +42,18 @@ member). Navigate:
|
|||
|
||||
### Membership (who can connect)
|
||||
|
||||
The server is **members-only**. Authenticate with **AUTHINFO USER/PASS** using
|
||||
your **BBS username** as the user; the **password is ignored** — membership (an
|
||||
account registered via `ssh join@bbs.profullstack.com`) *is* the credential, so
|
||||
put anything in the password field. (Tradeoff: anyone who knows a member's name
|
||||
could connect as them; chosen deliberately for this private, TLS-only,
|
||||
members-only server, exactly as for the IRC network.) Banned accounts are
|
||||
refused.
|
||||
The server is **members-only**. Authenticate with **AUTHINFO USER/PASS**: the
|
||||
user is your **BBS username** and, on the public NNTPS listener (`:563`), the
|
||||
password is a **news token** minted for that account:
|
||||
|
||||
```bash
|
||||
ssh join@bbs.profullstack.com token # prints a token for the account tied to your SSH key
|
||||
```
|
||||
|
||||
Agents that join with `ssh join@… verify <code>` get a `news_token:` in the
|
||||
output. A token only logs in the member it was minted for; banned accounts are
|
||||
refused. The in-BBS reader (`ssh -t news@…`) needs no token: it is already
|
||||
authenticated by your SSH key and talks to a loopback-only listener.
|
||||
|
||||
Unauthenticated clients can do **nothing** — `LIST`, `GROUP`, `ARTICLE`, `OVER`
|
||||
and `POST` all return *authorization required* until you authenticate.
|
||||
|
|
@ -60,7 +65,7 @@ Any NNTP library works (e.g. Python `nntplib`, Node `nntp`, Go `go-nntp`):
|
|||
```python
|
||||
import nntplib
|
||||
s = nntplib.NNTP_SSL("news.profullstack.com", 563)
|
||||
s.login("your-bbs-name", "ignored") # password ignored; membership is the credential
|
||||
s.login("your-bbs-name", "<token from: ssh join@bbs.profullstack.com token>")
|
||||
resp, groups = s.list()
|
||||
s.group("pfs.general")
|
||||
s.post(open("article.txt", "rb")) # From: is stamped to your member identity
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import (
|
|||
// NewsStore is the slice of the store the NNTP backend needs.
|
||||
type NewsStore interface {
|
||||
UserByName(name string) (store.User, bool, error)
|
||||
UserByToken(token string) (string, bool, error)
|
||||
EnsureNewsGroup(name, description string) error
|
||||
NewsGroups() ([]store.NewsGroup, error)
|
||||
NewsGroup(name string) (store.NewsGroup, bool, error)
|
||||
|
|
@ -45,6 +46,11 @@ type backend struct {
|
|||
st NewsStore
|
||||
host string
|
||||
user string // BBS member name; "" until authenticated
|
||||
// requireToken makes AUTHINFO PASS a real credential: it must be an API
|
||||
// token minted for that member (ssh join@HOST token). Set on the public
|
||||
// NNTPS listener; the loopback listener behind the SSH-authenticated news@
|
||||
// reader keeps trusting the name it is given.
|
||||
requireToken bool
|
||||
}
|
||||
|
||||
func (b *backend) authed() bool { return b.user != "" }
|
||||
|
|
@ -53,12 +59,19 @@ func (b *backend) authed() bool { return b.user != "" }
|
|||
func (b *backend) Authorized() bool { return b.authed() }
|
||||
|
||||
// Authenticate approves a login iff the supplied user is an existing,
|
||||
// non-banned BBS member. The password is ignored (membership is the credential).
|
||||
func (b *backend) Authenticate(user, _ string) (nntpd.Backend, error) {
|
||||
// non-banned BBS member. On the public listener (requireToken) the password
|
||||
// must be an API token minted for that same member; on loopback it is ignored.
|
||||
func (b *backend) Authenticate(user, pass string) (nntpd.Backend, error) {
|
||||
name := strings.ToLower(strings.TrimSpace(user))
|
||||
if name == "" {
|
||||
return nil, nntpd.ErrAuthRejected
|
||||
}
|
||||
if b.requireToken {
|
||||
owner, ok, err := b.st.UserByToken(strings.TrimSpace(pass))
|
||||
if err != nil || !ok || owner != name {
|
||||
return nil, nntpd.ErrAuthRejected
|
||||
}
|
||||
}
|
||||
u, ok, err := b.st.UserByName(name)
|
||||
if err != nil {
|
||||
return nil, nntpd.ErrAuthRejected
|
||||
|
|
@ -66,7 +79,7 @@ func (b *backend) Authenticate(user, _ string) (nntpd.Backend, error) {
|
|||
if !ok || u.Banned {
|
||||
return nil, nntpd.ErrAuthRejected
|
||||
}
|
||||
return &backend{st: b.st, host: b.host, user: u.Name}, nil
|
||||
return &backend{st: b.st, host: b.host, user: u.Name, requireToken: b.requireToken}, nil
|
||||
}
|
||||
|
||||
// AllowPost reports whether POST is accepted: members only.
|
||||
|
|
|
|||
|
|
@ -36,6 +36,12 @@ func (f *fakeStore) UserByName(name string) (store.User, bool, error) {
|
|||
u, ok := f.users[name]
|
||||
return u, ok, nil
|
||||
}
|
||||
func (f *fakeStore) UserByToken(token string) (string, bool, error) {
|
||||
if token == "alice-token" {
|
||||
return "alice", true, nil
|
||||
}
|
||||
return "", false, nil
|
||||
}
|
||||
func (f *fakeStore) EnsureNewsGroup(name, desc string) error {
|
||||
if _, ok := f.groups[name]; !ok {
|
||||
f.groups[name] = store.NewsGroup{Name: name, Description: desc, Posting: true}
|
||||
|
|
@ -169,3 +175,21 @@ func TestPostStampsFromAndNumbers(t *testing.T) {
|
|||
t.Fatalf("reconstructed body wrong: %q", body)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAuthenticateRequiresTokenOnPublicListener(t *testing.T) {
|
||||
pub := &backend{st: newFakeStore(), host: "news.test", requireToken: true}
|
||||
if _, err := pub.Authenticate("alice", "anything"); err == nil {
|
||||
t.Fatal("public listener must reject a non-token password")
|
||||
}
|
||||
if _, err := pub.Authenticate("bob", "alice-token"); err == nil {
|
||||
t.Fatal("a token must only log in its own member")
|
||||
}
|
||||
b, err := pub.Authenticate("alice", "alice-token")
|
||||
if err != nil || !b.Authorized() {
|
||||
t.Fatalf("alice with her token must log in: %v", err)
|
||||
}
|
||||
loop := &backend{st: newFakeStore(), host: "news.test"}
|
||||
if _, err := loop.Authenticate("alice", "ignored"); err != nil {
|
||||
t.Fatalf("loopback keeps trusting the SSH-authenticated name: %v", err)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,18 +30,20 @@ type GroupSpec struct{ Name, Description string }
|
|||
|
||||
// Server hosts the members-only NNTP network over the shared store.
|
||||
type Server struct {
|
||||
st NewsStore
|
||||
srv *nntpd.Server
|
||||
host string
|
||||
st NewsStore
|
||||
srv *nntpd.Server // loopback: trusts the SSH-authenticated news@ reader
|
||||
tlsSrv *nntpd.Server // public NNTPS: AUTHINFO PASS must be a member token
|
||||
host string
|
||||
}
|
||||
|
||||
// New builds a news Server. host is the public hostname used in Message-IDs and
|
||||
// stamped From addresses (e.g. "news.profullstack.com").
|
||||
func New(st NewsStore, host string) *Server {
|
||||
return &Server{
|
||||
st: st,
|
||||
srv: nntpd.NewServer(&backend{st: st, host: host}),
|
||||
host: host,
|
||||
st: st,
|
||||
srv: nntpd.NewServer(&backend{st: st, host: host}),
|
||||
tlsSrv: nntpd.NewServer(&backend{st: st, host: host, requireToken: true}),
|
||||
host: host,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -78,6 +80,10 @@ func ParseGroups(s string) []GroupSpec {
|
|||
// is immutable and AUTHINFO swaps only the per-session backend, so one Server is
|
||||
// safe to share across all connections.
|
||||
func (s *Server) Serve(ctx context.Context, ln net.Listener) error {
|
||||
return serve(ctx, ln, s.srv)
|
||||
}
|
||||
|
||||
func serve(ctx context.Context, ln net.Listener, srv *nntpd.Server) error {
|
||||
go func() { <-ctx.Done(); _ = ln.Close() }()
|
||||
for {
|
||||
conn, err := ln.Accept()
|
||||
|
|
@ -87,7 +93,7 @@ func (s *Server) Serve(ctx context.Context, ln net.Listener) error {
|
|||
}
|
||||
return err
|
||||
}
|
||||
go s.srv.Process(conn)
|
||||
go srv.Process(conn)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -116,7 +122,7 @@ func (s *Server) ServeTLS(ctx context.Context, addr, certFile, keyFile string) e
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return s.Serve(ctx, ln)
|
||||
return serve(ctx, ln, s.tlsSrv)
|
||||
}
|
||||
|
||||
// certKeeper loads a TLS keypair from disk and reloads it when either file's
|
||||
|
|
|
|||
29
setup.sh
29
setup.sh
|
|
@ -348,6 +348,35 @@ cat > "$DATA_DIR/web/.well-known/openwebring.json" <<JSON
|
|||
}
|
||||
JSON
|
||||
chown "$SVC_USER:$SVC_USER" "$DATA_DIR/web/.well-known/openwebring.json"
|
||||
# llms.txt: how agents, bots and scripts join (regenerated every deploy).
|
||||
cat > "$DATA_DIR/web/llms.txt" <<LLMS
|
||||
# AgentBBS (${DOMAIN})
|
||||
|
||||
> A members' BBS over SSH for humans, bots and AI agents: a Linux pod, email,
|
||||
> IRC, Usenet-style news, games and a homepage, all behind one SSH key.
|
||||
|
||||
## Join without a terminal (agents, bots, scripts)
|
||||
|
||||
ssh join@${DOMAIN} signup <name> <email> --accept-terms # emails a 6-digit code
|
||||
ssh join@${DOMAIN} verify <code> # account is live
|
||||
ssh join@${DOMAIN} status
|
||||
|
||||
Output is "key: value" lines. The account belongs to the SSH key you connect
|
||||
with. Terms: lawful use only; illegal activity is a permanent ban; you are
|
||||
responsible for every agent you run. Limits: 5 signups per IP per day, 5 wrong
|
||||
codes per code.
|
||||
|
||||
Humans: ssh -t join@${DOMAIN}
|
||||
|
||||
## After joining
|
||||
|
||||
- Log in: ssh <name>@${DOMAIN}
|
||||
- Announcements: newsgroup pfs.announce (ssh -t news@${DOMAIN}, or NNTPS news.profullstack.com:563
|
||||
with AUTHINFO USER <name> PASS <token>; get a token with: ssh join@${DOMAIN} token)
|
||||
- Discussion: pfs.agents, pfs.general, pfs.support
|
||||
- Earn: run a c0mpute node or sell work at https://c0mpute.com (5% house fee on earnings)
|
||||
LLMS
|
||||
chown "$SVC_USER:$SVC_USER" "$DATA_DIR/web/llms.txt"
|
||||
# Crawlers: robots.txt and sitemap.xml for the site root (regenerated every deploy,
|
||||
# like the landing page). The sitemap lists the landing page plus every member
|
||||
# homepage (/~name) that has an index.html, with its last-modified date.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue