check / check (push) Waiting to run
USERHOST, VERSION, ADMIN, INFO, TIME, KILL and WALLOPS work on the HTTP API and on the IRC listener. The USERHOST reply, the VERSION and INFO text, KILL and WALLOPS are each one service function that both transports call. User mode +w selects who receives WALLOPS. MODE on your own nick queries or changes your user modes through one parser on both transports: the whole mode string is checked before anything is stored, and both flags are stored in one transaction. KILL closes the victim's IRC connection after sending it KILL and ERROR. The sessions table gains is_wallops in 001_initial.sql, as the pre-1.0 rule in REPO_POLICIES.md asks. Model: opus-5-5
75 lines
1.5 KiB
Go
75 lines
1.5 KiB
Go
package ircserver
|
|
|
|
import (
|
|
"context"
|
|
"log/slog"
|
|
"net"
|
|
"time"
|
|
|
|
"sneak.berlin/go/neoirc/internal/broker"
|
|
"sneak.berlin/go/neoirc/internal/config"
|
|
"sneak.berlin/go/neoirc/internal/db"
|
|
"sneak.berlin/go/neoirc/internal/globals"
|
|
"sneak.berlin/go/neoirc/internal/service"
|
|
)
|
|
|
|
// NewTestServer creates a Server suitable for testing.
|
|
// The caller must call Stop() when finished.
|
|
func NewTestServer(
|
|
log *slog.Logger,
|
|
cfg *config.Config,
|
|
database *db.Database,
|
|
brk *broker.Broker,
|
|
) *Server {
|
|
globs := &globals.Globals{
|
|
Appname: "neoirc",
|
|
Version: "test",
|
|
StartTime: time.Now(),
|
|
}
|
|
|
|
svc := service.NewTestService(
|
|
database, brk, cfg, globs, log,
|
|
)
|
|
|
|
return &Server{ //nolint:exhaustruct
|
|
log: log,
|
|
cfg: cfg,
|
|
database: database,
|
|
brk: brk,
|
|
svc: svc,
|
|
conns: make(map[*Conn]struct{}),
|
|
}
|
|
}
|
|
|
|
// Start exposes the unexported start method for tests.
|
|
func (s *Server) Start(addr string) error {
|
|
return s.start(context.Background(), addr)
|
|
}
|
|
|
|
// Stop exposes the unexported stop method for tests.
|
|
func (s *Server) Stop() {
|
|
s.stop()
|
|
}
|
|
|
|
// Listener returns the server's net.Listener for tests.
|
|
func (s *Server) Listener() net.Listener {
|
|
return s.listener
|
|
}
|
|
|
|
// NewTestConn returns a Conn for nick on tcpConn, without a
|
|
// server, database or service behind it.
|
|
func NewTestConn(
|
|
log *slog.Logger,
|
|
cfg *config.Config,
|
|
tcpConn net.Conn,
|
|
nick string,
|
|
) *Conn {
|
|
conn := newConn(
|
|
context.Background(), tcpConn, log,
|
|
nil, nil, cfg, nil,
|
|
)
|
|
conn.nick = nick
|
|
|
|
return conn
|
|
}
|