Lindenii Project Forge
config: Add git.socket for git2d
// SPDX-License-Identifier: AGPL-3.0-only // SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org> package main import ( "bufio" "context" "errors" "os" "github.com/jackc/pgx/v5/pgxpool" "go.lindenii.runxiyu.org/lindenii-common/scfg" ) // config holds the global configuration used by this instance. There is // currently no synchronization mechanism, so it must not be modified after // request handlers are spawned. var config struct { HTTP struct { Net string `scfg:"net"` Addr string `scfg:"addr"` CookieExpiry int `scfg:"cookie_expiry"` Root string `scfg:"root"` ReadTimeout uint32 `scfg:"read_timeout"` WriteTimeout uint32 `scfg:"write_timeout"` IdleTimeout uint32 `scfg:"idle_timeout"` ReverseProxy bool `scfg:"reverse_proxy"` } `scfg:"http"` Hooks struct { Socket string `scfg:"socket"` Execs string `scfg:"execs"` } `scfg:"hooks"` LMTP struct { Socket string `scfg:"socket"` Domain string `scfg:"domain"` MaxSize int64 `scfg:"max_size"` WriteTimeout uint32 `scfg:"write_timeout"` ReadTimeout uint32 `scfg:"read_timeout"` } `scfg:"lmtp"` Git struct { RepoDir string `scfg:"repo_dir"`
Socket string `scfg:"socket"`
} `scfg:"git"` SSH struct { Net string `scfg:"net"` Addr string `scfg:"addr"` Key string `scfg:"key"` Root string `scfg:"root"` } `scfg:"ssh"` IRC struct { Net string `scfg:"net"` Addr string `scfg:"addr"` TLS bool `scfg:"tls"` SendQ uint `scfg:"sendq"` Nick string `scfg:"nick"` User string `scfg:"user"` Gecos string `scfg:"gecos"` } `scfg:"irc"` General struct { Title string `scfg:"title"` } `scfg:"general"` DB struct { Type string `scfg:"type"` Conn string `scfg:"conn"` } `scfg:"db"` } // loadConfig loads a configuration file from the specified path and unmarshals // it to the global [config] struct. This may race with concurrent reads from // [config]; additional synchronization is necessary if the configuration is to // be made reloadable. // // TODO: Currently, it returns an error when the user specifies any unknown // configuration patterns, but silently ignores fields in the [config] struct // that is not present in the user's configuration file. We would prefer the // exact opposite behavior. func loadConfig(path string) (err error) { var configFile *os.File if configFile, err = os.Open(path); err != nil { return err } defer configFile.Close() decoder := scfg.NewDecoder(bufio.NewReader(configFile)) if err = decoder.Decode(&config); err != nil { return err } if config.DB.Type != "postgres" { return errors.New("unsupported database type") } if database, err = pgxpool.New(context.Background(), config.DB.Conn); err != nil { return err } globalData["forge_title"] = config.General.Title return nil }
http { # What network transport should we listen on? # Examples: tcp tcp4 tcp6 unix net tcp # What address to listen on? # Examples for net tcp*: 127.0.0.1:8080 :80 # Example for unix: /var/run/lindenii/forge/http.sock addr /var/run/lindenii/forge/http.sock # How many seconds should cookies be remembered before they are purged? cookie_expiry 604800 # What is the canonical URL of the web root? root https://forge.example.org # General HTTP server context timeout settings. It's recommended to # set them slightly higher than usual as Git operations over large # repos may take a long time. read_timeout 120 write_timeout 1800 idle_timeout 120 # Are we running behind a reverse proxy? If so, we will trust # X-Forwarded-For headers. reverse_proxy true } irc { tls true net tcp addr irc.runxiyu.org:6697 sendq 6000 nick forge-test user forge gecos "Lindenii Forge Test" } git {
# Where should newly-created Git repositories be stored?
repo_dir /var/lib/lindenii/forge/repos
# Where should git2d listen on? socket /var/run/lindenii/forge/git2d.sock
} ssh { # What network transport should we listen on? # This should be "tcp" in almost all cases. net tcp # What address to listen on? addr :22 # What is the path to the SSH host key? Generate it with ssh-keygen. # The key must have an empty password. key /etc/lindenii/ssh_host_ed25519_key # What is the canonical SSH URL? root ssh://forge.example.org } general { title "Test Forge" } db { # What type of database are we connecting to? # Currently only "postgres" is supported. type postgres # What is the connection string? conn postgresql:///lindenii-forge?host=/var/run/postgresql } hooks { # On which UNIX domain socket should we listen for hook callbacks on? socket /var/run/lindenii/forge/hooks.sock # Where should hook executables be put? execs /usr/libexec/lindenii/forge/hooks } lmtp { # On which UNIX domain socket should we listen for LMTP on? socket /var/run/lindenii/forge/lmtp.sock # What's the maximum acceptable message size? max_size 1000000 # What is our domainpart? domain forge.example.org # General timeouts read_timeout 300 write_timeout 300 }
.\" SPDX-License-Identifier: AGPL-3.0-only .\" SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org> .Dd March 30, 2025 .Dt LINDENII-FORGE 5 .Os Lindenii Forge .Sh NAME .Nm lindenii-forge.scfg .Nd configuration file for Lindenii Forge .Sh DESCRIPTION .Nm describes the configuration for .Xr lindenii-forge 1 instance using the scfg format. .Pp Each directive consists of a name followed by zero or more parameters. Directives may also introduce blocks of subdirectives using braces. .Pp Comments begin with .Sq # and extend to the end of the line. .Sh DIRECTIVES .Bl -tag -width Ds .It Ic http Configures the ingress HTTP server. .Bl -tag -width Ds .It Ic net Network type to listen on (e.g., .Dq tcp , .Dq tcp4 , .Dq unix ) . .It Ic addr Address to listen on (e.g., .Dq :8080 or .Dq /var/run/lindenii/forge/http.sock ) . .It Ic cookie_expiry How long (in seconds) to keep session cookies. .It Ic root Canonical root URL of the web interface (e.g., .Dq https://forge.example.org ) . .It Ic read_timeout , write_timeout , idle_timeout Timeouts, in seconds, for the general HTTP server context. .It Ic reverse_proxy Boolean indicating whether to trust X-Forwarded-For headers. .El .It Ic ssh Configures the SSH server. .Bl -tag -width Ds .It Ic net Network type to listen on .Dq ( tcp is recommended). .It Ic addr Address to listen on (e.g., .Dq :22 ) . .It Ic key Path to the SSH host key (must be passwordless). .It Ic root Canonical SSH URL prefix (e.g., .Dq ssh://forge.example.org ) . .El .It Ic git Configures Git repository storage. .Bl -tag -width Ds .It Ic repo_dir Filesystem path under which new repositories are stored.
.It Ic socket Filesystem path for the socket listened on by .Xr lindenii-forge-git2d 1
.El .It Ic db Configures database connection. .Bl -tag -width Ds .It Ic type Database type (currently must be .Dq postgres ) . .It Ic conn Connection string, e.g., .Dq postgresql:///lindenii-forge?host=/var/run/postgresql . .El .It Ic general Miscellaneous settings. .Bl -tag -width Ds .It Ic title A user-facing name for the instance. .El .It Ic hooks Configures Git hook communication with the forge daemon. .Bl -tag -width Ds .It Ic socket Path to a UNIX domain socket for receiving hook events. .It Ic execs Directory where Git hook executables are stored. .El .It Ic irc Optional configuration for IRC presence. .Bl -tag -width Ds .It Ic tls Boolean indicating whether to use TLS. .It Ic net , addr Network type and address (e.g., .Dq tcp , .Dq irc.example.org:6697 ) . .It Ic sendq Maximum send queue size. .It Ic nick , user , gecos Identity fields for the IRC connection. .El .It Ic lmtp Configuration for the LMTP/MX component. You may wish to refer to .Xr forge-mail 5 for information on configuring your SMTP server. .Bl -tag -width Ds .It Ic socket The path to the UNIX domain socket to listen on. .It Ic max_size The maximum acceptable ingress message size. .It Ic domain The domain-part of our LMTP server. .It Ic read_timeout , write_timeout General timeouts for LMTP connections. .El .El .Sh FILES .Bl -tag -width Ds .It Pa /etc/lindenii/forge.scfg Default path to the configuration file. .El .Sh SEE ALSO .Xr lindenii-forge 1 , .Xr lindenii-forge-hookc 1 , .Lk https://git.sr.ht/~emersion/scfg scfg .Sh AUTHORS .An Runxi Yu Aq Mt https://runxiyu.org .An Test_User Aq Mt hax@runxiyu.org