mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-24 13:21:20 +00:00
Merge remote-tracking branch 'origin/master' into next
This commit is contained in:
commit
484b8e2c06
5 changed files with 50 additions and 43 deletions
4
tools/masterserver/.gitignore
vendored
4
tools/masterserver/.gitignore
vendored
|
@ -1,4 +1,4 @@
|
|||
/client
|
||||
/server
|
||||
/server.log
|
||||
/*.o
|
||||
/*.log
|
||||
/*.o
|
|
@ -140,8 +140,8 @@ typedef struct
|
|||
char port[8];
|
||||
char name[32];
|
||||
INT32 room;
|
||||
char key[32]; // Secret key for linking dedicated servers to accounts
|
||||
char version[8]; // format is: x.yy.z (like 1.30.2 or 1.31)
|
||||
char key[32]; // Secret key for linking dedicated servers to accounts
|
||||
} ATTRPACK msg_server_t;
|
||||
|
||||
typedef struct
|
||||
|
|
|
@ -5,9 +5,10 @@
|
|||
|
||||
# Get LSB functions
|
||||
. /lib/lsb/init-functions
|
||||
. /etc/default/rcS
|
||||
#. /etc/default/rcS
|
||||
|
||||
SRB2MS=/usr/local/bin/masterserver
|
||||
#SRB2MS=/usr/local/bin/masterserver
|
||||
SRB2MS=./server
|
||||
SRB2MS_PORT=28900
|
||||
|
||||
# Check that the package is still installed
|
||||
|
@ -15,11 +16,9 @@ SRB2MS_PORT=28900
|
|||
|
||||
case "$1" in
|
||||
start)
|
||||
log_begin_msg "Starting SRB2MS..."
|
||||
log_begin_msg "Starting SRB2MS...\n"
|
||||
umask 002
|
||||
if start-stop-daemon --start \
|
||||
--exec $SRB2MS \
|
||||
-- $SRB2MS_PORT; then
|
||||
if exec $SRB2MS $SRB2MS_PORT & then
|
||||
log_end_msg 0
|
||||
else
|
||||
log_end_msg $?
|
||||
|
@ -27,11 +26,11 @@ case "$1" in
|
|||
;;
|
||||
|
||||
stop)
|
||||
log_begin_msg "Stopping SRB2MS..."
|
||||
if start-stop-daemon --stop --exec $SRB2MS; then
|
||||
log_end_msg 0
|
||||
log_begin_msg "Stopping SRB2MS...\n"
|
||||
if killall $SRB2MS -q & then
|
||||
log_end_msg 0
|
||||
else
|
||||
log_end_msg $?
|
||||
log_end_msg $?
|
||||
fi
|
||||
;;
|
||||
|
||||
|
@ -40,7 +39,7 @@ case "$1" in
|
|||
;;
|
||||
|
||||
*)
|
||||
e cho "Usage: /etc/init.d/masterserver {start|stop|restart|force-reload}"
|
||||
echo "Usage: $0 {start|stop|restart|force-reload}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
|
|
@ -86,7 +86,7 @@ typedef struct
|
|||
|
||||
//=============================================================================
|
||||
|
||||
#define HOSTNAME "loopback"
|
||||
#define HOSTNAME "localhost"
|
||||
#define USER "srb2_ms"
|
||||
#define PASSWORD "gLRDRb7WgLRDRb7W"
|
||||
#define DATABASE "srb2_ms"
|
||||
|
@ -291,17 +291,17 @@ void MySQL_AddServer(const char *ip, const char *port, const char *name, const c
|
|||
char checkquery[500];
|
||||
char updatequery[5000];
|
||||
char queryp1[5000] = "INSERT INTO `ms_servers` (`name`,`ip`,`port`,`version`,`timestamp`,`room`,`key`) VALUES ('%s','%s','%s','%s','%ld','%d','%s')";
|
||||
char checkqueryp1[500] = "SELECT room_override FROM `ms_servers` WHERE `ip` = '%s'";
|
||||
char checkqueryp1[500] = "SELECT room_override FROM `ms_servers` WHERE `ip` = '%s' AND `port` = '%s'";
|
||||
char updatequeryp1[5000];
|
||||
if(firstadd)
|
||||
{
|
||||
logPrintf(logfile, "First add.\n");
|
||||
strcpy(updatequeryp1, "UPDATE `ms_servers` SET `name` = '%s', `port` = '%s', `version` = '%s', timestamp = '%ld', upnow = '1', `room` = '%d', `delisted` = '0', `key` = '%s' WHERE `ip` = '%s'");
|
||||
strcpy(updatequeryp1, "UPDATE `ms_servers` SET `name` = '%s', `port` = '%s', `version` = '%s', timestamp = '%ld', upnow = '1', `room` = '%d', `delisted` = '0', `key` = '%s' WHERE `ip` = '%s' AND `port` = '%s'");
|
||||
}
|
||||
else
|
||||
{
|
||||
logPrintf(logfile, "Update ping.\n");
|
||||
strcpy(updatequeryp1, "UPDATE `ms_servers` SET `name` = '%s', `port` = '%s', `version` = '%s', timestamp = '%ld', upnow = '1', `room` = '%d', `key` = '%s' WHERE `ip` = '%s' AND `delisted` = '0'");
|
||||
strcpy(updatequeryp1, "UPDATE `ms_servers` SET `name` = '%s', `port` = '%s', `version` = '%s', timestamp = '%ld', upnow = '1', `room` = '%d', `key` = '%s' WHERE `ip` = '%s' AND `port` = '%s' AND `delisted` = '0'");
|
||||
}
|
||||
MySQL_Conn(false);
|
||||
mysql_real_escape_string(conn, escapedName, name, (unsigned long)strlen(name));
|
||||
|
@ -314,10 +314,10 @@ void MySQL_AddServer(const char *ip, const char *port, const char *name, const c
|
|||
logPrintf(errorfile, "IP %s tried to use the private room %d! THIS SHOULD NOT HAPPEN\n", ip, room);
|
||||
return;
|
||||
}
|
||||
sprintf(checkquery, checkqueryp1, ip);
|
||||
sprintf(checkquery, checkqueryp1, ip, port);
|
||||
time_t timestamp;
|
||||
timestamp = time (NULL);
|
||||
logPrintf(logfile, "Checking for existing servers in table with the same IP...\n");
|
||||
logPrintf(logfile, "Checking for existing servers in table with the same IP and port...\n");
|
||||
logPrintf(mysqlfile, "Executing MySQL Query: %s\n", checkquery);
|
||||
if(mysql_query(conn, checkquery)) {
|
||||
logPrintf(errorfile, "MYSQL ERROR: %s\n", mysql_error(conn));
|
||||
|
@ -341,9 +341,9 @@ void MySQL_AddServer(const char *ip, const char *port, const char *name, const c
|
|||
if(atoi(row[0]) != 0)
|
||||
room = atoi(row[0]);
|
||||
mysql_free_result(res);
|
||||
logPrintf(logfile, "Server's IP already exists, so let's just update it instead...\n");
|
||||
logPrintf(logfile, "Server's IP and port already exists, so let's just update it instead...\n");
|
||||
logPrintf(logfile, "Updating Server Data for %s\n", ip);
|
||||
sprintf(updatequery, updatequeryp1, escapedName, escapedPort, escapedVersion, timestamp, room, escapedKey, ip);
|
||||
sprintf(updatequery, updatequeryp1, escapedName, escapedPort, escapedVersion, timestamp, room, escapedKey, ip, port);
|
||||
logPrintf(mysqlfile, "Executing MySQL Query: %s\n", updatequery);
|
||||
if(mysql_query(conn, updatequery)) {
|
||||
logPrintf(errorfile, "MYSQL ERROR: %s\n", mysql_error(conn));
|
||||
|
@ -619,10 +619,10 @@ void MySQL_ListServServers(UINT32 id, UINT32 type, const char *ip) {
|
|||
void MySQL_RemoveServer(char *ip, char *port, char *name, char *version) {
|
||||
char escapedName[255];
|
||||
char updatequery[5000];
|
||||
char updatequeryp1[5000] = "UPDATE `ms_servers` SET upnow = '0' WHERE `ip` = '%s' AND `permanent` = '0'";
|
||||
char updatequeryp1[5000] = "UPDATE `ms_servers` SET upnow = '0' WHERE `ip` = '%s' AND `port` = '%s' AND `permanent` = '0'";
|
||||
MySQL_Conn(false);
|
||||
mysql_real_escape_string(conn, escapedName, name, (unsigned long)strlen(name));
|
||||
sprintf(updatequery, updatequeryp1, ip);
|
||||
sprintf(updatequery, updatequeryp1, ip, port);
|
||||
logPrintf(mysqlfile, "Executing MySQL Query: %s\n", updatequery);
|
||||
if(mysql_query(conn, updatequery)) {
|
||||
logPrintf(errorfile, "MYSQL ERROR: %s\n", mysql_error(conn));
|
||||
|
@ -841,6 +841,10 @@ static void addServer(int id, char *buffer, bool firstadd)
|
|||
info->port[sizeof (info->port)-1] = '\0';
|
||||
info->name[sizeof (info->name)-1] = '\0';
|
||||
info->version[sizeof (info->version)-1] = '\0';
|
||||
|
||||
logPrintf(logfile, "addServer(): Version = \"%s\"\n", info->version);
|
||||
logPrintf(logfile, "addServer(): Key = \"%s\"\n", info->key);
|
||||
|
||||
// retrieve the true ip of the server
|
||||
strcpy(info->ip, server_socket.getClientIP(id));
|
||||
//strcpy(info->port, server_socket.getClientPort(id));
|
||||
|
@ -995,7 +999,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
if (server_socket.listen(argv[1]) < 0)
|
||||
{
|
||||
fprintf(stderr, "Error while initializing the server\n");
|
||||
fprintf(stderr, "Error while initializing the server; port being used! Try killing the other Master Server.\n");
|
||||
exit(2);
|
||||
}
|
||||
|
||||
|
|
|
@ -13,8 +13,8 @@ SET time_zone = "+00:00";
|
|||
-- Database: `srb2ms`
|
||||
--
|
||||
|
||||
CREATE DATABASE IF NOT EXISTS `srb2ms` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
|
||||
USE `srb2ms`;
|
||||
CREATE DATABASE IF NOT EXISTS `srb2_ms` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
|
||||
USE `srb2_ms`;
|
||||
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
@ -25,8 +25,8 @@ USE `srb2ms`;
|
|||
|
||||
CREATE TABLE `ms_bans` (
|
||||
`bid` int(11) DEFAULT NULL,
|
||||
`ipstart` int(11) DEFAULT NULL,
|
||||
`ipend` int(11) DEFAULT NULL,
|
||||
`ipstart` int(10) unsigned DEFAULT NULL,
|
||||
`ipend` int(10) unsigned DEFAULT NULL,
|
||||
`full_endtime` int(11) DEFAULT NULL,
|
||||
`permanent` tinyint(1) DEFAULT NULL,
|
||||
`hostonly` tinyint(1) DEFAULT NULL,
|
||||
|
@ -63,19 +63,19 @@ INSERT INTO `ms_rooms` (`room_id`, `title`, `motd`, `visible`, `order`, `private
|
|||
--
|
||||
|
||||
CREATE TABLE `ms_servers` (
|
||||
`sid` int(11) NOT NULL,
|
||||
`sid` int(11) primary key AUTO_INCREMENT,
|
||||
`name` text COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`ip` text COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`port` int(11) NOT NULL,
|
||||
`port` int(11) NOT NULL DEFAULT 5029,
|
||||
`version` text COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`timestamp` int(11) NOT NULL,
|
||||
`room` int(11) NOT NULL,
|
||||
`timestamp` int(11) NOT NULL DEFAULT 0,
|
||||
`room` int(11) NOT NULL DEFAULT 0,
|
||||
`key` text COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`room_override` int(11) NOT NULL,
|
||||
`upnow` tinyint(1) NOT NULL,
|
||||
`permanent` tinyint(1) NOT NULL,
|
||||
`delisted` tinyint(1) NOT NULL,
|
||||
`sticky` int(11) NOT NULL
|
||||
`room_override` int(11) NOT NULL DEFAULT 0,
|
||||
`upnow` tinyint(1) NOT NULL DEFAULT 1,
|
||||
`permanent` tinyint(1) NOT NULL DEFAULT 0,
|
||||
`delisted` tinyint(1) NOT NULL DEFAULT 0,
|
||||
`sticky` int(11) NOT NULL DEFAULT 0
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
@ -85,16 +85,20 @@ CREATE TABLE `ms_servers` (
|
|||
--
|
||||
|
||||
CREATE TABLE `ms_versions` (
|
||||
`mod_id` int(11) NOT NULL,
|
||||
`mod_version` int(11) NOT NULL
|
||||
`mod_id` int(10) unsigned primary key AUTO_INCREMENT,
|
||||
`mod_version` int(10) unsigned NOT NULL DEFAULT 1,
|
||||
`mod_vstring` varchar(45) NOT NULL DEFAULT 'v1.0',
|
||||
`mod_codebase` int(10) unsigned NOT NULL DEFAULT 205,
|
||||
`mod_name` varchar(255) NOT NULL DEFAULT 'Default MOD Name',
|
||||
`mod_url` text NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
--
|
||||
-- Dumping data for table `ms_versions`
|
||||
--
|
||||
|
||||
INSERT INTO `ms_versions` (`mod_id`, `mod_version`) VALUES
|
||||
(12, 25);
|
||||
INSERT INTO `ms_versions` (`mod_id`, `mod_version`, `mod_vstring`, `mod_codebase`, `mod_name`, `mod_url`) VALUES
|
||||
(18, 42, 'v2.2.2', 205, 'SRB2 2.2', 'SRB2.org');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
|
@ -114,4 +118,4 @@ COMMIT;
|
|||
|
||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
Loading…
Reference in a new issue