diff --git a/DMAPI/server_tools.dm b/DMAPI/server_tools.dm
index ea1172964d..9ff5b4ee28 100644
--- a/DMAPI/server_tools.dm
+++ b/DMAPI/server_tools.dm
@@ -98,6 +98,8 @@
#define SERVICE_REQUEST_WORLD_REBOOT "worldreboot"
#define SERVICE_REQUEST_API_VERSION "api_ver"
+#define SERVICE_RETURN_SUCCESS "SUCCESS"
+
/*
The MIT License
diff --git a/DMAPI/st_interface.dm b/DMAPI/st_interface.dm
index 727e7d3c8f..4bf3db1775 100644
--- a/DMAPI/st_interface.dm
+++ b/DMAPI/st_interface.dm
@@ -72,7 +72,7 @@ SERVER_TOOLS_DEFINE_AND_SET_GLOBAL(server_tools_api_compatible, FALSE)
switch(command)
if(SERVICE_CMD_API_COMPATIBLE)
SERVER_TOOLS_WRITE_GLOBAL(server_tools_api_compatible, TRUE)
- return "SUCCESS"
+ return SERVICE_RETURN_SUCCESS
if(SERVICE_CMD_HARD_REBOOT)
if(SERVER_TOOLS_READ_GLOBAL(reboot_mode) != REBOOT_MODE_HARD)
SERVER_TOOLS_WRITE_GLOBAL(reboot_mode, REBOOT_MODE_HARD)
@@ -88,7 +88,7 @@ SERVER_TOOLS_DEFINE_AND_SET_GLOBAL(server_tools_api_compatible, FALSE)
if(!istext(msg) || !msg)
return "No message set!"
SERVER_TOOLS_WORLD_ANNOUNCE(msg)
- return "SUCCESS"
+ return SERVICE_RETURN_SUCCESS
if(SERVICE_CMD_PLAYER_COUNT)
return "[SERVER_TOOLS_CLIENT_COUNT]"
if(SERVICE_CMD_LIST_CUSTOM)
@@ -96,7 +96,7 @@ SERVER_TOOLS_DEFINE_AND_SET_GLOBAL(server_tools_api_compatible, FALSE)
else
var/custom_command_result = HandleServiceCustomCommand(lowertext(command), params[SERVICE_CMD_PARAM_SENDER], params[SERVICE_CMD_PARAM_CUSTOM])
if(custom_command_result)
- return istext(custom_command_result) ? custom_command_result : "SUCCESS"
+ return istext(custom_command_result) ? custom_command_result : SERVICE_RETURN_SUCCESS
return "Unknown command: [command]"
/*
diff --git a/TGServerService/ServerInstance/DreamDaemon.cs b/TGServerService/ServerInstance/DreamDaemon.cs
index 9f68a48bb1..30145c5051 100644
--- a/TGServerService/ServerInstance/DreamDaemon.cs
+++ b/TGServerService/ServerInstance/DreamDaemon.cs
@@ -577,7 +577,7 @@ namespace TGServerService
GenCommsKey();
StartingSecurity = Config.Security;
- Proc.StartInfo.Arguments = String.Format("{0} -port {1} {5}-close -verbose -params \"server_service={3}&server_service_version={4}&server_instance={6}\" -{2} -public", DMB, Config.Port, SecurityWord(), serviceCommsKey, Version(), Config.Webclient ? "-webclient " : "", Config.Name);
+ Proc.StartInfo.Arguments = String.Format("{0} -port {1} {5}-close -verbose -params \"server_service={3}&server_service_version={4}&{6}={7}\" -{2} -public", DMB, Config.Port, SecurityWord(), serviceCommsKey, Version(), Config.Webclient ? "-webclient " : "", SPInstanceName, Config.Name);
UpdateInterfaceDll(true);
lock (topicLock)
{
diff --git a/TGServerService/ServerInstance/Interop.cs b/TGServerService/ServerInstance/Interop.cs
index 6ebf909035..e796527fec 100644
--- a/TGServerService/ServerInstance/Interop.cs
+++ b/TGServerService/ServerInstance/Interop.cs
@@ -24,13 +24,20 @@ namespace TGServerService
const int AllowedMajorAPIVersion = 1;
Version GameAPIVersion;
+ const string SPInstanceName = "server_instance";
+
//See code/modules/server_tools/server_tools.dm for command switch
const string SCHardReboot = "hard_reboot"; //requests that dreamdaemon restarts when the round ends
const string SCGracefulShutdown = "graceful_shutdown"; //requests that dreamdaemon stops when the round ends
const string SCWorldAnnounce = "world_announce"; //sends param 'message' to the world
const string SCListCustomCommands = "list_custom_commands"; //Get a list of commands supported by the server
const string SCAPICompat = "api_compat"; //Tells the server we understand each other
- const string SCPlayerCount = "client_count"; //Gets the number of connected clients
+ const string SCPlayerCount = "client_count"; //Gets the number of connected client
+
+ ///
+ /// String returned when a command completes successfully with no output
+ ///
+ const string SRetSuccess = "SUCCESS";
const string SRKillProcess = "killme";
const string SRIRCBroadcast = "irc";
diff --git a/TGServerService/Service.cs b/TGServerService/Service.cs
index 6ca622bae0..6c6f0c897d 100644
--- a/TGServerService/Service.cs
+++ b/TGServerService/Service.cs
@@ -63,6 +63,20 @@ namespace TGServerService
Run(ActiveService);
}
+ ///
+ /// Checks an for illegal characters
+ ///
+ /// The name to check
+ /// if contains no illegal characters, error message otherwise
+ static string CheckInstanceName(string instanceName)
+ {
+ char[] bannedCharacters = { ';', '&', '=', '%' };
+ foreach (var I in bannedCharacters)
+ if (instanceName.Contains(I.ToString()))
+ return "Instance names may not contain the following characters: ';', '&', '=', or '%'";
+ return null;
+ }
+
///
/// Sets up the service name. Do not add any more code due to the reasons outlined in
///
@@ -401,6 +415,9 @@ namespace TGServerService
///
public string CreateInstance(string Name, string path)
{
+ var res = CheckInstanceName(Name);
+ if (res != null)
+ return res;
if (File.Exists(path) || Directory.Exists(path))
return "Cannot create instance at pre-existing path!";
var Config = Properties.Settings.Default;
@@ -542,6 +559,9 @@ namespace TGServerService
{
if (name == new_name)
return null;
+ var res = CheckInstanceName(new_name);
+ if (res != null)
+ return res;
lock (this)
{
//we have to check em all anyway