Support multiple CGI paths.
This commit is contained in:
parent
bec952c66a
commit
4681d3f971
2 changed files with 10 additions and 6 deletions
|
@ -14,7 +14,7 @@ type Config struct {
|
||||||
LogPath string
|
LogPath string
|
||||||
TempRedirects map[string]string
|
TempRedirects map[string]string
|
||||||
PermRedirects map[string]string
|
PermRedirects map[string]string
|
||||||
CGIPath string
|
CGIPaths []string
|
||||||
SCGIPaths map[string]string
|
SCGIPaths map[string]string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ func getConfig(filename string) (Config, error) {
|
||||||
config.LogPath = "molly.log"
|
config.LogPath = "molly.log"
|
||||||
config.TempRedirects = make(map[string]string)
|
config.TempRedirects = make(map[string]string)
|
||||||
config.PermRedirects = make(map[string]string)
|
config.PermRedirects = make(map[string]string)
|
||||||
config.CGIPath = "^/var/gemini/cgi-bin/"
|
config.CGIPaths = make([]string, 0)
|
||||||
config.SCGIPaths = make(map[string]string)
|
config.SCGIPaths = make(map[string]string)
|
||||||
|
|
||||||
// Return defaults if no filename given
|
// Return defaults if no filename given
|
||||||
|
|
12
handler.go
12
handler.go
|
@ -149,10 +149,14 @@ func handleGeminiRequest(conn net.Conn, config Config, logEntries chan LogEntry)
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this file is executable, get dynamic content
|
// If this file is executable, get dynamic content
|
||||||
inCGIPath, err := regexp.Match(config.CGIPath, []byte(path))
|
if info.Mode().Perm() & 0111 == 0111 {
|
||||||
if inCGIPath && info.Mode().Perm() & 0111 == 0111 {
|
for _, cgiPath := range(config.CGIPaths) {
|
||||||
handleCGI(config, path, URL, &log, conn)
|
inCGIPath, err := regexp.Match(cgiPath, []byte(path))
|
||||||
return
|
if err == nil && inCGIPath {
|
||||||
|
handleCGI(config, path, URL, &log, conn)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise, serve the file contents
|
// Otherwise, serve the file contents
|
||||||
|
|
Loading…
Reference in a new issue