mirror of
https://github.com/ioquake/ioq3.git
synced 2025-05-30 00:20:59 +00:00
Added built-in http server
this allows you to get a list of available maps on the server, get the status and download pk3s pk3 download must get the sv_allowDownload and the download url configured downloading works when talking to the /pk3 endpoint like this: curl http://localhost:8080/pk3/baseq3/my.pk3
This commit is contained in:
parent
6d74896557
commit
6e4e8622ea
5 changed files with 1211 additions and 2 deletions
9
Makefile
9
Makefile
|
@ -199,6 +199,10 @@ ifndef USE_VOIP
|
|||
USE_VOIP=1
|
||||
endif
|
||||
|
||||
ifndef USE_HTTP_SERVER
|
||||
USE_HTTP_SERVER=0
|
||||
endif
|
||||
|
||||
ifndef USE_FREETYPE
|
||||
USE_FREETYPE=0
|
||||
endif
|
||||
|
@ -1114,6 +1118,10 @@ ifeq ($(USE_CURL),1)
|
|||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(USE_HTTP_SERVER),1)
|
||||
SERVER_CFLAGS += -DUSE_HTTP_SERVER
|
||||
endif
|
||||
|
||||
ifeq ($(USE_VOIP),1)
|
||||
CLIENT_CFLAGS += -DUSE_VOIP
|
||||
SERVER_CFLAGS += -DUSE_VOIP
|
||||
|
@ -2300,6 +2308,7 @@ Q3DOBJ = \
|
|||
$(B)/ded/sv_client.o \
|
||||
$(B)/ded/sv_ccmds.o \
|
||||
$(B)/ded/sv_game.o \
|
||||
$(B)/ded/sv_http.o \
|
||||
$(B)/ded/sv_init.o \
|
||||
$(B)/ded/sv_main.o \
|
||||
$(B)/ded/sv_net_chan.o \
|
||||
|
|
|
@ -269,7 +269,7 @@ static struct addrinfo *SearchAddrInfo(struct addrinfo *hints, sa_family_t famil
|
|||
Sys_StringToSockaddr
|
||||
=============
|
||||
*/
|
||||
static qboolean Sys_StringToSockaddr(const char *s, struct sockaddr *sadr, int sadr_len, sa_family_t family)
|
||||
qboolean Sys_StringToSockaddr(const char *s, struct sockaddr *sadr, int sadr_len, sa_family_t family)
|
||||
{
|
||||
struct addrinfo hints;
|
||||
struct addrinfo *res = NULL;
|
||||
|
|
1169
code/server/sv_http.c
Normal file
1169
code/server/sv_http.c
Normal file
File diff suppressed because it is too large
Load diff
|
@ -22,6 +22,13 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
|
||||
#include "server.h"
|
||||
|
||||
#ifdef USE_HTTP_SERVER
|
||||
extern cvar_t *sv_httpServerPort;
|
||||
extern cvar_t *sv_httpServerIP;
|
||||
extern cvar_t *sv_httpServerBearer;
|
||||
extern qboolean SV_HTTPServerInit(void);
|
||||
extern void SV_HTTPServerShutdown(void);
|
||||
#endif
|
||||
|
||||
/*
|
||||
===============
|
||||
|
@ -655,6 +662,11 @@ void SV_Init (void)
|
|||
sv_voip = Cvar_Get("sv_voip", "1", CVAR_LATCH);
|
||||
Cvar_CheckRange(sv_voip, 0, 1, qtrue);
|
||||
sv_voipProtocol = Cvar_Get("sv_voipProtocol", sv_voip->integer ? "opus" : "", CVAR_SYSTEMINFO | CVAR_ROM );
|
||||
#endif
|
||||
#ifdef USE_HTTP_SERVER
|
||||
sv_httpServerPort = Cvar_Get("sv_httpServerPort", "8080", CVAR_SYSTEMINFO | CVAR_INIT | CVAR_ARCHIVE);
|
||||
sv_httpServerIP = Cvar_Get("sv_httpServerIP", "0.0.0.0", CVAR_INIT | CVAR_ARCHIVE);
|
||||
sv_httpServerBearer = Cvar_Get("sv_httpServerBearer", "", CVAR_ARCHIVE);
|
||||
#endif
|
||||
Cvar_Get ("sv_paks", "", CVAR_SYSTEMINFO | CVAR_ROM );
|
||||
Cvar_Get ("sv_pakNames", "", CVAR_SYSTEMINFO | CVAR_ROM );
|
||||
|
@ -693,9 +705,15 @@ void SV_Init (void)
|
|||
|
||||
// init the botlib here because we need the pre-compiler in the UI
|
||||
SV_BotInitBotLib();
|
||||
|
||||
|
||||
// Load saved bans
|
||||
Cbuf_AddText("rehashbans\n");
|
||||
|
||||
#ifdef USE_HTTP_SERVER
|
||||
if (!SV_HTTPServerInit()) {
|
||||
Com_Printf("Failed to init http server\n");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -779,5 +797,9 @@ void SV_Shutdown( char *finalmsg ) {
|
|||
// disconnect any local clients
|
||||
if( sv_killserver->integer != 2 )
|
||||
CL_Disconnect( qfalse );
|
||||
|
||||
#ifdef USE_HTTP_SERVER
|
||||
SV_HTTPServerShutdown();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,10 @@ cvar_t *sv_voip;
|
|||
cvar_t *sv_voipProtocol;
|
||||
#endif
|
||||
|
||||
#ifdef USE_HTTP_SERVER
|
||||
extern void HTTP_Frame(void);
|
||||
#endif
|
||||
|
||||
serverStatic_t svs; // persistant server info
|
||||
server_t sv; // local server
|
||||
vm_t *gvm = NULL; // game virtual machine
|
||||
|
@ -1068,6 +1072,11 @@ void SV_Frame( int msec ) {
|
|||
return;
|
||||
}
|
||||
|
||||
#ifdef USE_HTTP_SERVER
|
||||
// a map must be running in dedicated server mode
|
||||
HTTP_Frame();
|
||||
#endif
|
||||
|
||||
// allow pause if only the local client is connected
|
||||
if ( SV_CheckPaused() ) {
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue