mirror of
https://github.com/D-Modem/login.git
synced 2026-11-28 12:28:07 -08:00
The program is dmodem-login (like dmodemd and dmodem-ari), the Go module github.com/D-Modem/login, the site d-modem.github.io/login. Its files, units, sockets, PAM service, pppd plugin, environment (DMODEM_LOGIN_*) and nftables tables follow. An old installation keeps working: - make install puts a modemmenu link to dmodem-login, and a modemmenu.so link to the plugin, which also takes its old modemmenu-socket option - the default configuration, users file, state_dir and PAM service fall back to modemmenu's when only those are there (config.Legacy) docs/rename.md (Simplified Technical English) lists the new names and what an old installation must change (the -serve socket, the units, the /etc/modemmenu files, the old nftables tables). CI's bbs job moves a bbs that still imports github.com/D-Modem/menu to the new path. The pppd plugin builds clean with -Wall -Wextra on GCC and Clang. COMMERCIAL-LICENSE.md and CONTRIBUTING.md (legal text) are not changed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B82eRTD8BSptdpaUWGcs65
132 lines
3.3 KiB
Go
132 lines
3.3 KiB
Go
// Copyright (C) 2026 D-Modem Authors
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
// Command confref writes docs/reference.md, the configuration reference:
|
|
// every section and key of dmodem-login.conf, with the help, the sample's
|
|
// value and the other values the sample shows, all read from the comments
|
|
// of samples/dmodem-login.conf.sample. From the repository's root:
|
|
//
|
|
// go run ./tools/confref
|
|
//
|
|
// TestSampleHasEveryKey (cmd/dmodem-login/reference_test.go) keeps the sample complete: a key
|
|
// the code reads that the sample doesn't show fails it.
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"log"
|
|
"os"
|
|
"strings"
|
|
|
|
"github.com/D-Modem/login/internal/confdoc"
|
|
)
|
|
|
|
type kind = confdoc.Kind
|
|
|
|
func header(k *kind) string {
|
|
if k.Named {
|
|
return "[" + k.Name + " NAME]"
|
|
}
|
|
return "[" + k.Name + "]"
|
|
}
|
|
|
|
func anchor(k *kind) string {
|
|
return strings.ToLower(strings.ReplaceAll(strings.Trim(header(k), "[]"), " ", "-"))
|
|
}
|
|
|
|
func cell(s string) string {
|
|
s = strings.ReplaceAll(s, "|", `\|`)
|
|
s = strings.ReplaceAll(s, "<", "<")
|
|
return strings.Join(strings.Fields(s), " ")
|
|
}
|
|
|
|
func code(s string) string {
|
|
s = strings.ReplaceAll(s, "|", `\|`)
|
|
if strings.Contains(s, "`") {
|
|
return "`` " + s + " ``"
|
|
}
|
|
return "`" + s + "`"
|
|
}
|
|
|
|
func prose(s string) string {
|
|
s = strings.TrimSpace(s)
|
|
if s != "" && !strings.HasSuffix(s, ".") && !strings.HasSuffix(s, ")") && !strings.HasSuffix(s, ":") {
|
|
s += "."
|
|
}
|
|
return s
|
|
}
|
|
|
|
func reference(kinds []*kind) string {
|
|
var b strings.Builder
|
|
b.WriteString(`<!-- Made by go run ./tools/confref from samples/dmodem-login.conf.sample: edit the sample, not this page. -->
|
|
|
|
# Configuration reference
|
|
|
|
Every section and key of dmodem-login.conf, from the comments in
|
|
[dmodem-login.conf.sample](https://github.com/D-Modem/login/blob/main/samples/dmodem-login.conf.sample).
|
|
**Sample** is the value the sample sets (or shows, commented out);
|
|
[Configuration](configuration.md) explains the file and its sections in
|
|
full.
|
|
|
|
| section | what it is |
|
|
|---|---|
|
|
`)
|
|
for _, k := range kinds {
|
|
help := k.Help
|
|
if i := strings.Index(help, ". "); i >= 0 {
|
|
help = help[:i+1]
|
|
}
|
|
fmt.Fprintf(&b, "| [`%s`](#%s) | %s |\n", header(k), anchor(k), cell(prose(help)))
|
|
}
|
|
for _, k := range kinds {
|
|
fmt.Fprintf(&b, "\n## `%s`\n\n", header(k))
|
|
if k.Help != "" {
|
|
b.WriteString(prose(k.Help) + "\n\n")
|
|
}
|
|
if k.Named {
|
|
b.WriteString("There may be any number of these, each with its own NAME.\n\n")
|
|
}
|
|
if k.Free != "" {
|
|
fmt.Fprintf(&b, "Each key is %s.\n", k.Free)
|
|
}
|
|
if len(k.Keys) == 0 {
|
|
continue
|
|
}
|
|
b.WriteString("| key | sample | what it does |\n|---|---|---|\n")
|
|
for _, x := range k.Keys {
|
|
help := prose(x.Help)
|
|
if help == "" {
|
|
help = "See the section above."
|
|
}
|
|
if len(x.Examples) > 0 {
|
|
var ex []string
|
|
for _, e := range x.Examples {
|
|
ex = append(ex, code(e))
|
|
}
|
|
help += " Also: " + strings.Join(ex, ", ") + "."
|
|
}
|
|
v := ""
|
|
if x.Value != "" {
|
|
v = code(x.Value)
|
|
}
|
|
fmt.Fprintf(&b, "| `%s` | %s | %s |\n", x.Name, v, cell(help))
|
|
}
|
|
}
|
|
b.WriteString("\n**See also:** [Configuration](configuration.md)\n")
|
|
return b.String()
|
|
}
|
|
|
|
func main() {
|
|
sample, err := os.ReadFile("samples/dmodem-login.conf.sample")
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
out := "docs/reference.md"
|
|
if len(os.Args) > 1 {
|
|
out = os.Args[1]
|
|
}
|
|
if err := os.WriteFile(out, []byte(reference(confdoc.Parse(string(sample)))), 0o644); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|