diff --git a/src/config.c b/src/config.c index 68a2ea227..8fe5cdbb7 100644 --- a/src/config.c +++ b/src/config.c @@ -216,6 +216,10 @@ void loadServerConfigFromString(char *config) { if ((server.protected_mode = yesnotoi(argv[1])) == -1) { err = "argument must be 'yes' or 'no'"; goto loaderr; } + } else if (!strcasecmp(argv[0],"gopher-enabled") && argc == 2) { + if ((server.gopher_enabled = yesnotoi(argv[1])) == -1) { + err = "argument must be 'yes' or 'no'"; goto loaderr; + } } else if (!strcasecmp(argv[0],"port") && argc == 2) { server.port = atoi(argv[1]); if (server.port < 0 || server.port > 65535) { @@ -1141,6 +1145,8 @@ void configSetCommand(client *c) { #endif } config_set_bool_field( "protected-mode",server.protected_mode) { + } config_set_bool_field( + "gopher-enabled",server.gopher_enabled) { } config_set_bool_field( "stop-writes-on-bgsave-error",server.stop_writes_on_bgsave_err) { } config_set_bool_field( @@ -1472,6 +1478,7 @@ void configGetCommand(client *c) { config_get_bool_field("activerehashing", server.activerehashing); config_get_bool_field("activedefrag", server.active_defrag_enabled); config_get_bool_field("protected-mode", server.protected_mode); + config_get_bool_field("gopher-enabled", server.gopher_enabled); config_get_bool_field("repl-disable-tcp-nodelay", server.repl_disable_tcp_nodelay); config_get_bool_field("repl-diskless-sync", @@ -2301,6 +2308,7 @@ int rewriteConfig(char *path) { rewriteConfigYesNoOption(state,"activerehashing",server.activerehashing,CONFIG_DEFAULT_ACTIVE_REHASHING); rewriteConfigYesNoOption(state,"activedefrag",server.active_defrag_enabled,CONFIG_DEFAULT_ACTIVE_DEFRAG); rewriteConfigYesNoOption(state,"protected-mode",server.protected_mode,CONFIG_DEFAULT_PROTECTED_MODE); + rewriteConfigYesNoOption(state,"gopher-enabled",server.gopher_enabled,CONFIG_DEFAULT_GOPHER_ENABLED); rewriteConfigClientoutputbufferlimitOption(state); rewriteConfigNumericalOption(state,"hz",server.config_hz,CONFIG_DEFAULT_HZ); rewriteConfigYesNoOption(state,"aof-rewrite-incremental-fsync",server.aof_rewrite_incremental_fsync,CONFIG_DEFAULT_AOF_REWRITE_INCREMENTAL_FSYNC); diff --git a/src/server.c b/src/server.c index 89e795042..fd9d856bd 100644 --- a/src/server.c +++ b/src/server.c @@ -2222,6 +2222,7 @@ void initServerConfig(void) { server.ipfd_count = 0; server.sofd = -1; server.protected_mode = CONFIG_DEFAULT_PROTECTED_MODE; + server.gopher_enabled = CONFIG_DEFAULT_GOPHER_ENABLED; server.dbnum = CONFIG_DEFAULT_DBNUM; server.verbosity = CONFIG_DEFAULT_VERBOSITY; server.maxidletime = CONFIG_DEFAULT_CLIENT_TIMEOUT; diff --git a/src/server.h b/src/server.h index 994952654..daa0b0047 100644 --- a/src/server.h +++ b/src/server.h @@ -121,6 +121,7 @@ typedef long long mstime_t; /* millisecond time type. */ #define CONFIG_DEFAULT_UNIX_SOCKET_PERM 0 #define CONFIG_DEFAULT_TCP_KEEPALIVE 300 #define CONFIG_DEFAULT_PROTECTED_MODE 1 +#define CONFIG_DEFAULT_GOPHER_ENABLED 0 #define CONFIG_DEFAULT_LOGFILE "" #define CONFIG_DEFAULT_SYSLOG_ENABLED 0 #define CONFIG_DEFAULT_STOP_WRITES_ON_BGSAVE_ERROR 1 @@ -1054,6 +1055,8 @@ struct redisServer { dict *migrate_cached_sockets;/* MIGRATE cached sockets */ uint64_t next_client_id; /* Next client unique ID. Incremental. */ int protected_mode; /* Don't accept external connections. */ + int gopher_enabled; /* If true the server will reply to gopher + queries. Will still serve RESP2 queries. */ /* RDB / AOF loading information */ int loading; /* We are loading data from disk if true */ off_t loading_total_bytes;