"golang.org/x/net/netutil"
"go.stargrave.org/godlighty"
- _ "go.stargrave.org/godlighty/rc"
+ _ "go.stargrave.org/godlighty/rc/cfg"
)
const MaxConns = 128
},
DirList: true,
WebDAV: true,
- MIMEOverride: map[string]string{
+ MIMEs: map[string]string{
".special": "text/x-special-type",
},
}
-redo-ifchange cmd/godlighty/*.go *.go go.* rc/*.go rc/mime/*
+redo-ifchange cmd/godlighty/*.go *.go go.* rc/*.go rc/mime/* rc/cfg/*.go
${GO:-go} build -o $3 -ldflags=-s ./cmd/godlighty
--- /dev/null
+example.cfg
\ No newline at end of file
"go.stargrave.org/godlighty"
)
-func runCGIAndLog(host string, w http.ResponseWriter, r *http.Request, h *cgi.Handler) {
+func RunCGIAndLog(host string, w http.ResponseWriter, r *http.Request, h *cgi.Handler) {
wc := &godlighty.CountResponseWriter{ResponseWriter: w}
h.ServeHTTP(wc, r)
fmt.Printf("%s %s \"%s %s %s\" %d %d \"%s\"\n",
+++ /dev/null
-package rc
-
-import (
- "net/http"
-
- "go.stargrave.org/godlighty"
-)
-
-func init() {
- host := "www.cryptoanarchy.ru"
- godlighty.Hosts[host] = &godlighty.HostCfg{
- Hooks: []godlighty.Hook{
- func(w http.ResponseWriter, r *http.Request) bool {
- redirect(
- host, w, r,
- "//www.cypherpunks.ru/Manifesto-cryptoanarchist.html",
- http.StatusMovedPermanently,
- )
- return true
- },
- },
- }
-}
-/*
-godlighty -- highly-customizable HTTP, HTTP/2, HTTPS server
-Copyright (C) 2021 Sergey Matveev <stargrave@stargrave.org>
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, version 3 of the License.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-package rc
+package cfg
import (
"net/http"
"strings"
"go.stargrave.org/godlighty"
+ "go.stargrave.org/godlighty/rc"
)
func init() {
return false
}
r.URL.Path = strings.TrimPrefix(r.URL.Path, "/"+t)
- runCGIAndLog(host, w, r, &cgi.Handler{
+ rc.RunCGIAndLog(host, w, r, &cgi.Handler{
Path: "/home/sgblog/sgblog",
Dir: "/var/empty",
Env: []string{"SGBLOG_CFG=/home/sgblog/" + t + ".hjson"},
-package rc
+package cfg
import (
"net/http"
"net/http/cgi"
"go.stargrave.org/godlighty"
+ "go.stargrave.org/godlighty/rc"
)
func addGitRepoCfg(host, root, gitwebCfg string) {
Hooks: []godlighty.Hook{
func(w http.ResponseWriter, r *http.Request) bool {
if r.URL.Path == "/" {
- redirect(host, w, r, "//"+host+"/", http.StatusMovedPermanently)
+ rc.Redirect(host, w, r, "//"+host+"/", http.StatusMovedPermanently)
return true
}
return false
},
func(w http.ResponseWriter, r *http.Request) bool {
- runCGIAndLog(host, w, r, &cgi.Handler{
+ rc.RunCGIAndLog(host, w, r, &cgi.Handler{
Path: "/usr/local/libexec/git-core/git-http-backend",
Dir: "/var/empty",
Env: []string{
Hooks: []godlighty.Hook{
func(w http.ResponseWriter, r *http.Request) bool {
if r.URL.Path == "/" {
- runCGIAndLog(host, w, r, &cgi.Handler{
+ rc.RunCGIAndLog(host, w, r, &cgi.Handler{
Path: "/usr/local/share/gitweb/gitweb.cgi",
Env: []string{"GITWEB_CONFIG=" + gitwebCfg},
})
--- /dev/null
+package cfg
+
+import (
+ "path"
+
+ "go.stargrave.org/godlighty"
+)
+
+func addGoRepoCfg(host string) {
+ godlighty.Hosts[host] = &godlighty.HostCfg{
+ Root: path.Join(WWW, host),
+ TLS: newTLSCfg(host),
+ MIMEs: map[string]string{"": "text/html"},
+ }
+}
+
+func init() {
+ addGoRepoCfg("go.cypherpunks.ru")
+ addGoRepoCfg("go.stargrave.org")
+}
-package rc
+package cfg
import "go.stargrave.org/godlighty"
--- /dev/null
+package cfg
+
+import (
+ "net/http"
+ "path"
+ "strings"
+
+ "go.stargrave.org/godlighty"
+)
+
+func init() {
+ host := "lists.cypherpunks.ru"
+ godlighty.Hosts[host] = &godlighty.HostCfg{
+ Root: path.Join(WWW, host),
+ TLS: newTLSCfg(host),
+ Hooks: []godlighty.Hook{
+ func(w http.ResponseWriter, r *http.Request) bool {
+ if strings.HasPrefix(r.URL.Path, "/archive/") {
+ r.URL.Path = strings.TrimPrefix(r.URL.Path, "/archive")
+ godlighty.MainHandler.Handle(w, r, host, &godlighty.HostCfg{
+ Root: "/home/mlmmj/archive",
+ })
+ return true
+ }
+ return false
+ },
+ },
+ }
+}
-package rc
+package cfg
import (
"fmt"
-package rc
+package cfg
import "path"
-/*
-godlighty -- highly-customizable HTTP, HTTP/2, HTTPS server
-Copyright (C) 2021 Sergey Matveev <stargrave@stargrave.org>
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, version 3 of the License.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-package rc
+package cfg
import (
"path"
godlighty.Hosts[host].WebDAV = true
}
+
func init() {
addStaticCfg("www.stargrave.org", "stargrave.org")
--- /dev/null
+package cfg
+
+import (
+ "path"
+
+ "go.stargrave.org/godlighty"
+)
+
+func newTLSCfg(host string) *godlighty.TLSCfg {
+ return &godlighty.TLSCfg{
+ Cert: path.Join(Etc, host+".pem"),
+ Key: path.Join(Etc, host+".pem"),
+ CACert: CACert,
+ }
+}
+++ /dev/null
-/*
-godlighty -- highly-customizable HTTP, HTTP/2, HTTPS server
-Copyright (C) 2021 Sergey Matveev <stargrave@stargrave.org>
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, version 3 of the License.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-package rc
-
-import (
- "path"
-
- "go.stargrave.org/godlighty"
-)
-
-func addGoRepoCfg(host string) {
- godlighty.Hosts[host] = &godlighty.HostCfg{
- Root: path.Join(WWW, host),
- TLS: newTLSCfg(host),
- MIMEs: map[string]string{"": "text/html"},
- }
-}
-
-func init() {
- addGoRepoCfg("go.cypherpunks.ru")
- addGoRepoCfg("go.stargrave.org")
-}
+++ /dev/null
-/*
-godlighty -- highly-customizable HTTP, HTTP/2, HTTPS server
-Copyright (C) 2021 Sergey Matveev <stargrave@stargrave.org>
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, version 3 of the License.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-package rc
-
-import (
- "net/http"
- "path"
- "strings"
-
- "go.stargrave.org/godlighty"
-)
-
-func init() {
- host := "lists.cypherpunks.ru"
- godlighty.Hosts[host] = &godlighty.HostCfg{
- Root: path.Join(WWW, host),
- TLS: newTLSCfg(host),
- Hooks: []godlighty.Hook{
- func(w http.ResponseWriter, r *http.Request) bool {
- if strings.HasPrefix(r.URL.Path, "/archive/") {
- r.URL.Path = strings.TrimPrefix(r.URL.Path, "/archive")
- godlighty.MainHandler.Handle(w, r, host, &godlighty.HostCfg{
- Root: "/home/mlmmj/archive",
- })
- return true
- }
- return false
- },
- },
- }
-}
"net/http"
)
-func redirect(
+func Redirect(
host string,
w http.ResponseWriter, r *http.Request,
to string, status int,
+++ /dev/null
-/*
-godlighty -- highly-customizable HTTP, HTTP/2, HTTPS server
-Copyright (C) 2021 Sergey Matveev <stargrave@stargrave.org>
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, version 3 of the License.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-package rc
-
-import (
- "path"
-
- "go.stargrave.org/godlighty"
-)
-
-func newTLSCfg(host string) *godlighty.TLSCfg {
- return &godlighty.TLSCfg{
- Cert: path.Join(Etc, host+".pem"),
- Key: path.Join(Etc, host+".pem"),
- CACert: CACert,
- }
-}