Fix the Master Server so it works

Instructions:
1. In SQL, create an account called "srb2_ms" @ "localhost" (or your hostname).
2. Grant the account full priviledges to "srb2_ms" (the database).
3. Compile, and run using the sh script provided.
That's all I'm telling you, I don't want this to become rampant.
This commit is contained in:
GoldenTails 2020-03-20 09:12:19 -05:00
parent 6f8dfb6fca
commit 5f85c72279
5 changed files with 41 additions and 34 deletions

View file

@ -1,4 +1,4 @@
/client /client
/server /server
/server.log /*.log
/*.o /*.o

View file

@ -140,8 +140,8 @@ typedef struct
char port[8]; char port[8];
char name[32]; char name[32];
INT32 room; 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 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; } ATTRPACK msg_server_t;
typedef struct typedef struct

View file

@ -5,9 +5,10 @@
# Get LSB functions # Get LSB functions
. /lib/lsb/init-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 SRB2MS_PORT=28900
# Check that the package is still installed # Check that the package is still installed
@ -15,11 +16,9 @@ SRB2MS_PORT=28900
case "$1" in case "$1" in
start) start)
log_begin_msg "Starting SRB2MS..." log_begin_msg "Starting SRB2MS...\n"
umask 002 umask 002
if start-stop-daemon --start \ if exec $SRB2MS $SRB2MS_PORT & then
--exec $SRB2MS \
-- $SRB2MS_PORT; then
log_end_msg 0 log_end_msg 0
else else
log_end_msg $? log_end_msg $?
@ -27,11 +26,11 @@ case "$1" in
;; ;;
stop) stop)
log_begin_msg "Stopping SRB2MS..." log_begin_msg "Stopping SRB2MS...\n"
if start-stop-daemon --stop --exec $SRB2MS; then if killall $SRB2MS -q & then
log_end_msg 0 log_end_msg 0
else else
log_end_msg $? log_end_msg $?
fi 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 exit 1
;; ;;
esac esac

View file

@ -86,7 +86,7 @@ typedef struct
//============================================================================= //=============================================================================
#define HOSTNAME "loopback" #define HOSTNAME "localhost"
#define USER "srb2_ms" #define USER "srb2_ms"
#define PASSWORD "gLRDRb7WgLRDRb7W" #define PASSWORD "gLRDRb7WgLRDRb7W"
#define DATABASE "srb2_ms" #define DATABASE "srb2_ms"
@ -841,6 +841,10 @@ static void addServer(int id, char *buffer, bool firstadd)
info->port[sizeof (info->port)-1] = '\0'; info->port[sizeof (info->port)-1] = '\0';
info->name[sizeof (info->name)-1] = '\0'; info->name[sizeof (info->name)-1] = '\0';
info->version[sizeof (info->version)-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 // retrieve the true ip of the server
strcpy(info->ip, server_socket.getClientIP(id)); strcpy(info->ip, server_socket.getClientIP(id));
//strcpy(info->port, server_socket.getClientPort(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) 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); exit(2);
} }

View file

@ -13,8 +13,8 @@ SET time_zone = "+00:00";
-- Database: `srb2ms` -- Database: `srb2ms`
-- --
CREATE DATABASE IF NOT EXISTS `srb2ms` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE DATABASE IF NOT EXISTS `srb2_ms` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
USE `srb2ms`; USE `srb2_ms`;
-- -------------------------------------------------------- -- --------------------------------------------------------
@ -25,8 +25,8 @@ USE `srb2ms`;
CREATE TABLE `ms_bans` ( CREATE TABLE `ms_bans` (
`bid` int(11) DEFAULT NULL, `bid` int(11) DEFAULT NULL,
`ipstart` int(11) DEFAULT NULL, `ipstart` int(10) unsigned DEFAULT NULL,
`ipend` int(11) DEFAULT NULL, `ipend` int(10) unsigned DEFAULT NULL,
`full_endtime` int(11) DEFAULT NULL, `full_endtime` int(11) DEFAULT NULL,
`permanent` tinyint(1) DEFAULT NULL, `permanent` tinyint(1) DEFAULT NULL,
`hostonly` 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` ( CREATE TABLE `ms_servers` (
`sid` int(11) NOT NULL, `sid` int(11) primary key AUTO_INCREMENT,
`name` text COLLATE utf8mb4_unicode_ci NOT NULL, `name` text COLLATE utf8mb4_unicode_ci NOT NULL,
`ip` 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, `version` text COLLATE utf8mb4_unicode_ci NOT NULL,
`timestamp` int(11) NOT NULL, `timestamp` int(11) NOT NULL DEFAULT 0,
`room` int(11) NOT NULL, `room` int(11) NOT NULL DEFAULT 0,
`key` text COLLATE utf8mb4_unicode_ci NOT NULL, `key` text COLLATE utf8mb4_unicode_ci NOT NULL,
`room_override` int(11) NOT NULL, `room_override` int(11) NOT NULL DEFAULT 0,
`upnow` tinyint(1) NOT NULL, `upnow` tinyint(1) NOT NULL DEFAULT 1,
`permanent` tinyint(1) NOT NULL, `permanent` tinyint(1) NOT NULL DEFAULT 0,
`delisted` tinyint(1) NOT NULL, `delisted` tinyint(1) NOT NULL DEFAULT 0,
`sticky` int(11) NOT NULL `sticky` int(11) NOT NULL DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- -------------------------------------------------------- -- --------------------------------------------------------
@ -85,16 +85,20 @@ CREATE TABLE `ms_servers` (
-- --
CREATE TABLE `ms_versions` ( CREATE TABLE `ms_versions` (
`mod_id` int(11) NOT NULL, `mod_id` int(10) unsigned primary key AUTO_INCREMENT,
`mod_version` int(11) NOT NULL `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; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --
-- Dumping data for table `ms_versions` -- Dumping data for table `ms_versions`
-- --
INSERT INTO `ms_versions` (`mod_id`, `mod_version`) VALUES INSERT INTO `ms_versions` (`mod_id`, `mod_version`, `mod_vstring`, `mod_codebase`, `mod_name`, `mod_url`) VALUES
(12, 25); (18, 42, 'v2.2.2', 205, 'SRB2 2.2', 'SRB2.org');
-- -------------------------------------------------------- -- --------------------------------------------------------