]> Sergey Matveev's repositories - godlighty.git/commitdiff
Move domain-specific things to separate directory
authorSergey Matveev <stargrave@stargrave.org>
Mon, 4 Oct 2021 09:21:46 +0000 (12:21 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Mon, 4 Oct 2021 10:34:12 +0000 (13:34 +0300)
19 files changed:
cmd/godlighty/main.go
doc/index.texi
godlighty.do
rc/cfg [new symlink]
rc/cgi.go
rc/cryptoanarchy.ru.go [deleted file]
rc/example.cfg/blog.stargrave.org.go [moved from rc/blog.stargrave.org.go with 52% similarity]
rc/example.cfg/git.go [moved from rc/git.go with 84% similarity]
rc/example.cfg/go.go [new file with mode: 0644]
rc/example.cfg/if.mirror.cypherpunks.ru.go [moved from rc/if.mirror.cypherpunks.ru.go with 96% similarity]
rc/example.cfg/lists.cypherpunks.ru.go [new file with mode: 0644]
rc/example.cfg/proxied-host.go [moved from rc/proxied-host.go with 98% similarity]
rc/example.cfg/root.go [moved from rc/root.go with 93% similarity]
rc/example.cfg/static.go [moved from rc/static.go with 52% similarity]
rc/example.cfg/tls.go [new file with mode: 0644]
rc/go.go [deleted file]
rc/lists.cypherpunks.ru.go [deleted file]
rc/redirect.go
rc/tls.go [deleted file]

index 46c5d87cc7efb916ca853ac545ded532aff6f256..22f0c22131a4e235315d8998c9f1069df854379c 100644 (file)
@@ -34,7 +34,7 @@ import (
        "golang.org/x/net/netutil"
 
        "go.stargrave.org/godlighty"
-       _ "go.stargrave.org/godlighty/rc"
+       _ "go.stargrave.org/godlighty/rc/cfg"
 )
 
 const MaxConns = 128
index bbc53e7be031cf9d6ed92f81b870c754b8823e26..3923ab9c8b6edd53c0d7031aa7d8238bcdb03c16 100644 (file)
@@ -64,7 +64,7 @@ Hosts["example.com"] = &godlighty.HostCfg{
     },
     DirList: true,
     WebDAV: true,
-    MIMEOverride: map[string]string{
+    MIMEs: map[string]string{
         ".special": "text/x-special-type",
     },
 }
index 046dc1161165d4b002428940d91c92fa55dd7a16..ba66eda63b400d02c980ecb201096f37a597a6e4 100644 (file)
@@ -1,2 +1,2 @@
-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
diff --git a/rc/cfg b/rc/cfg
new file mode 120000 (symlink)
index 0000000..2681394
--- /dev/null
+++ b/rc/cfg
@@ -0,0 +1 @@
+example.cfg
\ No newline at end of file
index 18011d9977493652de1a407efb94abe978247c2f..42363e3d03d63c746bd8a0aa51dbd2dcbf420531 100644 (file)
--- a/rc/cgi.go
+++ b/rc/cgi.go
@@ -25,7 +25,7 @@ import (
        "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",
diff --git a/rc/cryptoanarchy.ru.go b/rc/cryptoanarchy.ru.go
deleted file mode 100644 (file)
index 81c85d5..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-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
-                       },
-               },
-       }
-}
similarity index 52%
rename from rc/blog.stargrave.org.go
rename to rc/example.cfg/blog.stargrave.org.go
index af005d5ab0901aa9e8b256a27de505f224c1d93c..22ce4a4a52ec57ea3556b1818dc2b17fa7d8ef59 100644 (file)
@@ -1,21 +1,4 @@
-/*
-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"
@@ -24,6 +7,7 @@ import (
        "strings"
 
        "go.stargrave.org/godlighty"
+       "go.stargrave.org/godlighty/rc"
 )
 
 func init() {
@@ -45,7 +29,7 @@ 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"},
similarity index 84%
rename from rc/git.go
rename to rc/example.cfg/git.go
index 65498b162810697f7495abfee2e5f966c349f9de..1e955ed7323e465c38f07901e0df314339a9e599 100644 (file)
--- a/rc/git.go
@@ -1,10 +1,11 @@
-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) {
@@ -13,13 +14,13 @@ 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{
@@ -38,7 +39,7 @@ func addGitRepoCfg(host, root, gitwebCfg 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},
                                        })
diff --git a/rc/example.cfg/go.go b/rc/example.cfg/go.go
new file mode 100644 (file)
index 0000000..6d905d3
--- /dev/null
@@ -0,0 +1,20 @@
+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")
+}
similarity index 96%
rename from rc/if.mirror.cypherpunks.ru.go
rename to rc/example.cfg/if.mirror.cypherpunks.ru.go
index dad2b39bf3b7acbf05d948d5d622034f1f3ada63..1e1a1dab04179b7497edea54e57ca237e109af04 100644 (file)
@@ -1,4 +1,4 @@
-package rc
+package cfg
 
 import "go.stargrave.org/godlighty"
 
diff --git a/rc/example.cfg/lists.cypherpunks.ru.go b/rc/example.cfg/lists.cypherpunks.ru.go
new file mode 100644 (file)
index 0000000..20b2e63
--- /dev/null
@@ -0,0 +1,29 @@
+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
+                       },
+               },
+       }
+}
similarity index 98%
rename from rc/proxied-host.go
rename to rc/example.cfg/proxied-host.go
index 8877007ad0dfc08a2329908793ee58cb646d6061..1ad0db6a0bda6bf39f1e8c539ae167e9c7a7af6e 100644 (file)
@@ -1,4 +1,4 @@
-package rc
+package cfg
 
 import (
        "fmt"
similarity index 93%
rename from rc/root.go
rename to rc/example.cfg/root.go
index 6151aa273835d9af01f71a5c5726e264cd17a4c4..e20228e23e8fcd56f46b048918a02985d0bfc370 100644 (file)
@@ -1,4 +1,4 @@
-package rc
+package cfg
 
 import "path"
 
similarity index 52%
rename from rc/static.go
rename to rc/example.cfg/static.go
index 89142a8ead44e289a177b53a89c046b3e929c529..f1559c8281ca7fd681eb9beb13ffada727074252 100644 (file)
@@ -1,21 +1,4 @@
-/*
-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"
@@ -44,6 +27,7 @@ func addStaticWebDAVedDir(host, root string) {
        godlighty.Hosts[host].WebDAV = true
 }
 
+
 func init() {
        addStaticCfg("www.stargrave.org", "stargrave.org")
 
diff --git a/rc/example.cfg/tls.go b/rc/example.cfg/tls.go
new file mode 100644 (file)
index 0000000..1a4cd7b
--- /dev/null
@@ -0,0 +1,15 @@
+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,
+       }
+}
diff --git a/rc/go.go b/rc/go.go
deleted file mode 100644 (file)
index e4b0d8e..0000000
--- a/rc/go.go
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
-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")
-}
diff --git a/rc/lists.cypherpunks.ru.go b/rc/lists.cypherpunks.ru.go
deleted file mode 100644 (file)
index 31e8148..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
-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
-                       },
-               },
-       }
-}
index 86a62107d090580353d3956e509721cc7fbe9862..ecbdbfb98c048b9daecb27d579aa2dca50b98eb5 100644 (file)
@@ -22,7 +22,7 @@ import (
        "net/http"
 )
 
-func redirect(
+func Redirect(
        host string,
        w http.ResponseWriter, r *http.Request,
        to string, status int,
diff --git a/rc/tls.go b/rc/tls.go
deleted file mode 100644 (file)
index faf5473..0000000
--- a/rc/tls.go
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
-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,
-       }
-}