Skip to content

Commit 3e70ef5

Browse files
committed
CGI-Bin legacy support
1 parent 606f701 commit 3e70ef5

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ fpproxy.csr
44
Flashpoint Proxy.exe
55
Flashpoint Game Server.exe
66
fpProxy.exe
7-
testdata/htdocs
7+
testdata/htdocs
8+
testdata/cgi-bin

legacyServer.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,14 @@ func ServeLegacy(w http.ResponseWriter, r *http.Request) {
7676
}
7777
exactFilePaths = append(exactFilePaths, path.Join(serverSettings.LegacyHTDOCSPath, relPath))
7878

79+
// CGI bin for scripts
80+
if isScriptUrl(r.URL) {
81+
if hasQuery {
82+
exactFilePaths = append(exactFilePaths, path.Join(serverSettings.LegacyCGIBINPath, relPathWithQuery))
83+
}
84+
exactFilePaths = append(exactFilePaths, path.Join(serverSettings.LegacyCGIBINPath, relPath))
85+
}
86+
7987
// 2. Directory Index Files
8088
for _, ext := range serverSettings.ExtIndexTypes {
8189
for _, override := range serverSettings.LegacyOverridePaths {

legacyServer_test.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ var testServerSettings = ServerSettings{
3232
UseInfinityServer: false,
3333
InfinityServerURL: "https://infinity.unstable.life/Flashpoint/Legacy/htdocs/",
3434
LegacyHTDOCSPath: "",
35+
LegacyCGIBINPath: "",
3536
ExtScriptTypes: []string{
3637
"php",
3738
},
@@ -50,6 +51,17 @@ func setup(settings *ServerSettings) {
5051
}
5152
testServerSettings.LegacyHTDOCSPath = path.Join(cwd, "testdata", "htdocs")
5253
settings.LegacyHTDOCSPath = testServerSettings.LegacyHTDOCSPath
54+
testServerSettings.LegacyCGIBINPath = path.Join(cwd, "testdata", "cgi-bin")
55+
settings.LegacyCGIBINPath = testServerSettings.LegacyCGIBINPath
56+
// Create directories if missing
57+
err = os.MkdirAll(testServerSettings.LegacyHTDOCSPath, os.ModePerm)
58+
if err != nil {
59+
panic(err)
60+
}
61+
err = os.MkdirAll(testServerSettings.LegacyCGIBINPath, os.ModePerm)
62+
if err != nil {
63+
panic(err)
64+
}
5365
}
5466
// Cleanup and remake htdocs
5567
err := os.RemoveAll(testServerSettings.LegacyHTDOCSPath)
@@ -255,7 +267,7 @@ func TestServeLegacy200Script(t *testing.T) {
255267
// Write a test file
256268
testStr := "success"
257269
testData := []byte(fmt.Sprintf("<?php echo \"%s\"; ?>", testStr))
258-
testFile := path.Join(testServerSettings.LegacyHTDOCSPath, "example.com", "index.php")
270+
testFile := path.Join(testServerSettings.LegacyCGIBINPath, "example.com", "index.php")
259271
// Make directory path
260272
err := os.MkdirAll(path.Dir(testFile), os.ModePerm)
261273
if err != nil {

0 commit comments

Comments
 (0)