Skip to content

Commit

Permalink
Update "SET SERVERPREFS" command to enable or disable the https tunne…
Browse files Browse the repository at this point in the history
…ling for FileMaker Pro and FileMaker Go (#47)
  • Loading branch information
matsuo committed Jan 4, 2025
1 parent 4958fdc commit 51ac411
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Features
- FileMaker Admin API PKI Authentication
- View and change the settings for the persistent cache (for FileMaker Server 2024)
- View and change the setting for blocking new users (for FileMaker Server 2024)
- View the HTTPS tunneling setting for FileMaker Pro and FileMaker Go (for FileMaker Server 2024 (21.1))
- View and change the HTTPS tunneling setting for FileMaker Pro and FileMaker Go (for FileMaker Server 2024 (21.1))
- View and change the "Only open last opened databases" setting (for FileMaker Server 2024 (21.1))

Supported Servers
Expand Down
53 changes: 50 additions & 3 deletions fmcsadmin.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ type blockNewUsersConfigInfo struct {
BlockNewUsersEnabled bool `json:"blockNewUsers"`
}

type enableHttpProtocolNetworkConfigInfo struct {
EnableHttpProtocolNetwork bool `json:"enableHTTPSTunneling"`
}

type phpConfigInfo struct {
Enabled bool `json:"enabled"`
CharacterEncoding string `json:"characterEncoding"`
Expand Down Expand Up @@ -178,6 +182,7 @@ type params struct {
syncpersistcache string
databaseserverautorestart string
blocknewusersenabled string
enablehttpprotocolnetwork string
onlyopenlastopeneddatabases string
characterencoding string
errormessagelanguage string
Expand Down Expand Up @@ -2039,6 +2044,7 @@ func (c *cli) Run(args []string) int {
case "authenticatedstream", "parallelbackupenabled":
case "persistcacheenabled", "syncpersistcache", "databaseserverautorestart":
case "blocknewusersenabled":
case "enablehttpprotocolnetwork":
case "onlyopenlastopeneddatabases":
default:
exitStatus = 10001
Expand Down Expand Up @@ -2133,9 +2139,10 @@ func (c *cli) Run(args []string) int {
syncPersistCache := results[9]
databaseServerAutoRestart := results[10]
blockNewUsersEnabled := results[11]
onlyOpenLastOpenedDatabases := results[12]
enableHttpProtocolNetwork := results[12]
onlyOpenLastOpenedDatabases := results[13]

if results[0] != "" || results[1] != "" || results[2] != "" || results[3] != "" || startupRestorationEnabled != "" || secureFilesOnlyFlag != "" || results[6] != "" || parallelBackupEnabled != "" || persistCacheEnabled != "" || syncPersistCache != "" || databaseServerAutoRestart != "" || blockNewUsersEnabled != "" || results[12] != "" {
if results[0] != "" || results[1] != "" || results[2] != "" || results[3] != "" || startupRestorationEnabled != "" || secureFilesOnlyFlag != "" || results[6] != "" || parallelBackupEnabled != "" || persistCacheEnabled != "" || syncPersistCache != "" || databaseServerAutoRestart != "" || blockNewUsersEnabled != "" || enableHttpProtocolNetwork != "" || onlyOpenLastOpenedDatabases != "" {
if results[0] == "" {
cacheSize = settings[0]
} else {
Expand Down Expand Up @@ -2252,6 +2259,12 @@ func (c *cli) Run(args []string) int {
} else {
exitStatus = 3
}
case "enablehttpprotocolnetwork":
if version >= 21.1 {
printOptions = append(printOptions, "enablehttpprotocolnetwork")
} else {
exitStatus = 3
}
case "onlyopenlastopeneddatabases":
if version >= 21.1 {
printOptions = append(printOptions, "onlyopenlastopeneddatabases")
Expand Down Expand Up @@ -2288,11 +2301,12 @@ func (c *cli) Run(args []string) int {
printOptions = append(printOptions, "blocknewusersenabled")
}
if version >= 21.1 {
printOptions = append(printOptions, "enablehttpprotocolnetwork")
printOptions = append(printOptions, "onlyopenlastopeneddatabases")
}
}
if exitStatus == 0 {
if results[0] != "" || results[1] != "" || results[2] != "" || results[3] != "" || results[4] != "" || results[12] != "" {
if results[0] != "" || results[1] != "" || results[2] != "" || results[3] != "" || results[4] != "" || results[13] != "" {
u.Path = path.Join(getAPIBasePath(), "server", "config", "general")
exitStatus, _, _ = sendRequest("PATCH", u.String(), token, params{
command: "set",
Expand Down Expand Up @@ -2402,6 +2416,19 @@ func (c *cli) Run(args []string) int {
}
}

if results[12] != "" {
// for Claris FileMaker Server 21.1.1 or later
if version >= 21.1 {
u.Path = path.Join(getAPIBasePath(), "fmclients", "httpstunneling")
exitStatus, _, _ = sendRequest("PATCH", u.String(), token, params{command: "set", enablehttpprotocolnetwork: enableHttpProtocolNetwork})
if exitStatus != 0 {
exitStatus = 10001
}
} else {
exitStatus = 3
}
}

u.Path = path.Join(getAPIBasePath(), "server", "config", "general")
settingResults, exitStatus = getServerGeneralConfigurations(u.String(), token, printOptions)
if restartMessageFlag {
Expand Down Expand Up @@ -2750,6 +2777,7 @@ func parseServerConfigurationSettings(str []string) ([]string, int) {
syncPersistCache := ""
databaseServerAutoRestart := ""
blockNewUsersEnabled := ""
enableHttpProtocolNetwork := ""
onlyOpenLastOpenedDatabases := ""

for i := 0; i < len(str); i++ {
Expand Down Expand Up @@ -2842,6 +2870,14 @@ func parseServerConfigurationSettings(str []string) ([]string, int) {
} else {
blockNewUsersEnabled = "false"
}
} else if regexp.MustCompile(`enablehttpprotocolnetwork=(.*)`).Match([]byte(val)) {
if strings.ToLower(str[i]) == "enablehttpprotocolnetwork=" {
exitStatus = 10001
} else if strings.ToLower(str[i]) == "enablehttpprotocolnetwork=true" || (regexp.MustCompile(`enablehttpprotocolnetwork=([+|-])?(\d)+`).Match([]byte(str[i])) && str[i] != "enablehttpprotocolnetwork=0" && str[i] != "enablehttpprotocolnetwork=+0" && str[i] != "enablehttpprotocolnetwork=-0") {
enableHttpProtocolNetwork = "true"
} else {
enableHttpProtocolNetwork = "false"
}
} else if regexp.MustCompile(`onlyopenlastopeneddatabases=(.*)`).Match([]byte(val)) {
if strings.ToLower(str[i]) == "onlyopenlastopeneddatabases=" {
exitStatus = 10001
Expand All @@ -2867,6 +2903,7 @@ func parseServerConfigurationSettings(str []string) ([]string, int) {
results = append(results, syncPersistCache)
results = append(results, databaseServerAutoRestart)
results = append(results, blockNewUsersEnabled)
results = append(results, enableHttpProtocolNetwork)
results = append(results, onlyOpenLastOpenedDatabases)

return results, exitStatus
Expand Down Expand Up @@ -4790,6 +4827,16 @@ func sendRequest(method string, urlString string, token string, p params) (int,
blocknewusersenabled,
}
jsonStr, _ = json.Marshal(d)
} else if strings.HasSuffix(urlString, "/fmclients/httpstunneling") {
// for Claris FileMaker Server 21.1.1 or later
enablehttpprotocolnetwork := false
if p.enablehttpprotocolnetwork == "true" {
enablehttpprotocolnetwork = true
}
d := enableHttpProtocolNetworkConfigInfo{
enablehttpprotocolnetwork,
}
jsonStr, _ = json.Marshal(d)
} else if strings.HasSuffix(urlString, "/server/config/general") && p.onlyopenlastopeneddatabases != "" {
// for Claris FileMaker Server 21.1.1 or later
onlyopenlastopeneddatabases := false
Expand Down
2 changes: 2 additions & 0 deletions fmcsadmin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1640,6 +1640,8 @@ func TestGetFlags(t *testing.T) {
* fmcsadmin set serverprefs DatabaseServerAutoRestart=true
* fmcsadmin set serverprefs BlockNewUsersEnabled=false
* fmcsadmin set serverprefs BlockNewUsersEnabled=true
* fmcsadmin set serverprefs EnableHttpProtocolNetwork=false
* fmcsadmin set serverprefs EnableHttpProtocolNetwork=true
* fmcsadmin set serverprefs OnlyOpenLastOpenedDatabases=false
* fmcsadmin set serverprefs OnlyOpenLastOpenedDatabases=true
* fmcsadmin --fqdn example.jp set serverconfig hostedfiles=125 scriptsessions=100
Expand Down
1 change: 1 addition & 0 deletions release-notes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Version: 2.3.0-dev (in development)
- Update "GET SERVERPREFS" command to view the "Only open last opened databases" setting. (Usage: "fmcsadmin get serverprefs OnlyOpenLastOpenedDatabases")
- Update "SET SERVERPREFS" command to open only the databases that were opened when the database server was last shut down. (Usage: "fmcsadmin set serverprefs OnlyOpenLastOpenedDatabases=true")
- Update "GET SERVERPREFS" command to get the https tunneling setting for FileMaker Pro and FileMaker Go. (Usage: "fmcsadmin get serverprefs EnableHttpProtocolNetwork")
- Update "SET SERVERPREFS" command to enable or disable the https tunneling for FileMaker Pro and FileMaker Go. (Usage: "fmcsadmin set serverprefs EnableHttpProtocolNetwork=true")
- Built with Go 1.23.
- [INFO] Drop support for Claris FileMaker Server 19.6.
- [INFO] Drop support for macOS Monterey 12.
Expand Down

0 comments on commit 51ac411

Please sign in to comment.