Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build and publish Docker images #257

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/examples/servinit.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ if (= $rehashing 0) [
// servertype 3 // type of server, 1 = private (does not register with masterserver), 2 = public, 3 = dedicated
// serveruprate 0 // maximum upload speed; cmdline: -suN
// serverip "127.0.0.1" // host which server binds to; cmdline: -siN
// serverpublicip "127.0.0.1" // host the server advertises to the master server (useful if behind NAT, e.g., in Docker); cmdline: -sjN
// servermaster "master.blue-nebula.org" // host server tries to use as master by default; cmdline: -smS
// serverport 28801 // port which server binds to (you must open this port [UDP] and this plus one, default 28801 and 28802); cmdline: -spN
// servermasterport 28800 // master server port which server *connects* to; cmdline: -saN
Expand Down
10 changes: 0 additions & 10 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,6 @@ COPY data/ /blue-nebula/data

COPY CMakeLists.txt /blue-nebula/
COPY README.md /blue-nebula/
COPY docker/serverip.patch /serverip.patch

RUN git apply < /serverip.patch && \
ls -al && \
mkdir build && \
cd build && \
# TODO: server-only build configuration
cmake .. -DCMAKE_BUILD_TYPE=Release -G Ninja -DCMAKE_INSTALL_PREFIX=/blue-nebula/install -DBUILD_CLIENT=OFF && \
ninja -v && \
ninja install


# next, we convert the example server config to a template
Expand Down
20 changes: 0 additions & 20 deletions docker/serverip.patch
voidanix marked this conversation as resolved.
Outdated
Show resolved Hide resolved

This file was deleted.

18 changes: 16 additions & 2 deletions src/engine/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ VAR(0, serveruprate, 0, 0, VAR_MAX);
VAR(0, serverport, 1, SERVER_PORT, VAR_MAX);
VAR(0, serverlanport, 0, LAN_PORT, VAR_MAX);
SVAR(0, serverip, "");
SVAR(0, serverpublicip, "");

bool filterword(char *src, const char *list)
{
Expand Down Expand Up @@ -1415,10 +1416,22 @@ void changeservertype()
void setupserver()
{
server::changemap(load && *load ? load : NULL);
if(!servertype) return;

if (servertype <= 0) {
return;
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Useless semicolon here.


setupmaster();

conoutf("loading server (%s:%d)..", *serverip ? serverip : "*", serverport);
if(setupserversockets() && verbose) conoutf("game server started");
if (*serverpublicip != '\0') {
conoutf("public server IP is %s", serverpublicip);
}

if(setupserversockets() && verbose) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style:

Suggested change
if(setupserversockets() && verbose) {
if (setupserversockets() && verbose) {

conoutf("game server started");
}

#ifndef STANDALONE
if(servertype >= 3) serverloop();
#endif
Expand Down Expand Up @@ -1470,6 +1483,7 @@ bool serveroption(char *opt)
{
case 'u': setvar("serveruprate", atoi(opt+3)); return true;
case 'i': setsvar("serverip", opt+3); return true;
case 'j': setsvar("serverpublicip", opt+3); return true;
case 'm': setsvar("servermaster", opt+3); return true;
case 'l': load = opt+3; return true;
case 's': setvar("servertype", atoi(opt+3)); return true;
Expand Down
11 changes: 10 additions & 1 deletion src/game/auth.h
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,16 @@ namespace auth
conoutf("Updating master server");
// the position of the 0 was used to signalize support for the global stats system, which has been removed
// to retain compatibility, we just send a 0, pretending it was simply disabled by the administrator
requestmasterf("server %d %s %d %s 0 %s\n", serverport, *serverip ? serverip : "*", CUR_VERSION, escapestring(limitstring(G(serverdesc), MAXSDESCLEN+1)), escapestring(versionbranch));
char* advertisedIp;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style again: specify the pointer with char* advertisedIp; to make it consistent with the code below.

if (*serverpublicip != '\0') {
advertisedIp = serverpublicip;
} else if (*serverip != '\0') {
advertisedIp = serverip;
} else {
advertisedIp = "*";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bn/src/game/auth.h:447:32: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
  447 |                 advertisedIp = "*";
      |                                ^~~

Consider const-ifying

}

requestmasterf("server %d %s %d %s 0 %s\n", serverport, advertisedIp, CUR_VERSION, escapestring(limitstring(G(serverdesc), MAXSDESCLEN+1)), escapestring(versionbranch));
}
reqserverauth();
}
Expand Down
1 change: 1 addition & 0 deletions src/game/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7321,6 +7321,7 @@ namespace server
{
case 'P': setsvar("adminpass", &arg[3]); return true;
case 'k': setsvar("serverpass", &arg[3]); return true;
case 'j': setsvar("serverpublicip", &arg[3]); return true;
default: break;
}
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/shared/iengine.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ extern int verbose, curtime, lastmillis, totalmillis, timescale, paused;
extern uint totalsecs;
extern time_t clocktime, currenttime, clockoffset;
extern int servertype, serverport, serverlanport, servermasterport;
extern char *servermaster, *serverip;
extern char *servermaster, *serverip, *serverpublicip;
#ifdef STANDALONE
#define ifserver(x) if(x)
#define ifnserver(x) if(x)
Expand Down