diff --git a/muxrpc/handlers/alias/plugin.go b/muxrpc/handlers/alias/plugin.go deleted file mode 100644 index 49cb2e44..00000000 --- a/muxrpc/handlers/alias/plugin.go +++ /dev/null @@ -1,20 +0,0 @@ -// SPDX-License-Identifier: MIT - -package alias - -import ( - "github.com/ssb-ngi-pointer/go-ssb-room/roomdb" - - kitlog "github.com/go-kit/kit/log" - - refs "go.mindeco.de/ssb-refs" -) - -func New(log kitlog.Logger, self refs.FeedRef, aliasDB roomdb.AliasService) Handler { - var h Handler - h.self = self - h.logger = log - h.db = aliasDB - - return h -} diff --git a/muxrpc/handlers/alias/register.go b/muxrpc/handlers/alias/register.go index 26055b41..4c569174 100644 --- a/muxrpc/handlers/alias/register.go +++ b/muxrpc/handlers/alias/register.go @@ -1,5 +1,6 @@ // SPDX-License-Identifier: MIT +// Package alias implements the muxrpc handlers for alias needs. package alias import ( @@ -18,6 +19,7 @@ import ( refs "go.mindeco.de/ssb-refs" ) +// Handler implements the muxrpc methods for alias registration and recvocation type Handler struct { logger kitlog.Logger self refs.FeedRef @@ -25,8 +27,22 @@ type Handler struct { db roomdb.AliasService } +// New returns a fresh alias muxrpc handler +func New(log kitlog.Logger, self refs.FeedRef, aliasDB roomdb.AliasService) Handler { + var h Handler + h.self = self + h.logger = log + h.db = aliasDB + + return h +} + const sigSuffix = ".sig.ed25519" +// Register is an async muxrpc method handler for registering aliases. +// It receives two string arguments over muxrpc (alias and signature), +// checks the signature confirmation is correct (for this room and signed by the key of theconnection) +// If it is valid, it registers the alias on the roomdb and returns true. If not it returns an error. func (h Handler) Register(ctx context.Context, req *muxrpc.Request) (interface{}, error) { var args []string diff --git a/roomsrv/init_handlers.go b/roomsrv/init_handlers.go index b80ce7fb..348e500b 100644 --- a/roomsrv/init_handlers.go +++ b/roomsrv/init_handlers.go @@ -13,6 +13,7 @@ import ( "github.com/ssb-ngi-pointer/go-ssb-room/muxrpc/handlers/whoami" ) +// instantiate and register the muxrpc handlers func (s *Server) initHandlers(aliasDB roomdb.AliasService) { // inistaniate handler packages whoami := whoami.New(s.Whoami()) diff --git a/roomsrv/init_network.go b/roomsrv/init_network.go index 997fc26e..9328a857 100644 --- a/roomsrv/init_network.go +++ b/roomsrv/init_network.go @@ -12,6 +12,7 @@ import ( "github.com/ssb-ngi-pointer/go-ssb-room/internal/network" ) +// opens the shs listener for TCP connections func (s *Server) initNetwork() error { // muxrpc handler creation and authoratization decider mkHandler := func(conn net.Conn) (muxrpc.Handler, error) { diff --git a/roomsrv/init_unixsock.go b/roomsrv/init_unixsock.go index db21ef8a..0a2b8469 100644 --- a/roomsrv/init_unixsock.go +++ b/roomsrv/init_unixsock.go @@ -25,6 +25,7 @@ func WithUNIXSocket(yes bool) Option { } } +// creates the UNIX socket file listener for local usage func (s *Server) initUnixSock() error { // this races because roomsrv might not be done with init yet // TODO: refactor network peer code and make unixsock implement that (those will be inited late anyway) diff --git a/roomsrv/server.go b/roomsrv/server.go index b5751fd4..33dc3750 100644 --- a/roomsrv/server.go +++ b/roomsrv/server.go @@ -1,5 +1,7 @@ // SPDX-License-Identifier: MIT +// Package roomsrv implements the muxrpc server for all the room related code. +// It ties the muxrpc/handlers packages and network listeners together. package roomsrv import ( diff --git a/web/handlers/admin/aliases.go b/web/handlers/admin/aliases.go index 81105eb3..e7997640 100644 --- a/web/handlers/admin/aliases.go +++ b/web/handlers/admin/aliases.go @@ -15,6 +15,8 @@ import ( weberrors "github.com/ssb-ngi-pointer/go-ssb-room/web/errors" ) +// aliasesHandler implements the managment endpoints for aliases (list and revoke), +// does light validation of the web arguments and passes them through to the roomdb. type aliasesHandler struct { r *render.Renderer diff --git a/web/handlers/admin/handler.go b/web/handlers/admin/handler.go index 05e2629f..2300dcf1 100644 --- a/web/handlers/admin/handler.go +++ b/web/handlers/admin/handler.go @@ -1,5 +1,7 @@ // SPDX-License-Identifier: MIT +// Package admin implements the dashboard for admins and moderators to change and control aspects of the room. +// Including aliases, allow/deny list managment, invites and settings of the room. package admin import ( @@ -18,6 +20,7 @@ import ( "github.com/ssb-ngi-pointer/go-ssb-room/roomstate" ) +// HTMLTemplates define the list of files the template system should load. var HTMLTemplates = []string{ "admin/dashboard.tmpl", "admin/menu.tmpl", diff --git a/web/handlers/aliases.go b/web/handlers/aliases.go index f4c399b4..12a2b8f8 100644 --- a/web/handlers/aliases.go +++ b/web/handlers/aliases.go @@ -15,6 +15,7 @@ import ( "github.com/ssb-ngi-pointer/go-ssb-room/roomdb" ) +// aliasHandler implements the public resolve endpoint for HTML and JSON requests. type aliasHandler struct { r *render.Renderer