Added built-in http server#511
Added built-in http server#511mgerhardy wants to merge 1 commit intoioquake:mainfrom mgerhardy:pr/ioq3-http
Conversation
|
You read my mind, I was literally thinking about doing this today but in the docker image. Not sure if it belongs in the engine package itself but it might. |
|
I thought so, too - but imo it's also great to give direct access to the engine data. It would allow for a web based rcon view or online stats generator and all kind of funny things. But I've just written it because I never know the maps that are available on my server and I also can't remember the names - I need the pictures ;) I also don't expect this to get merged, but as I said - others might find it useful and might extend it to be more useful. |
code/server/sv_http.c
Outdated
| } | ||
|
|
||
| static void HTTP_BodyHeader(char *buf, int size) { | ||
| // TODO: allow to customize stylesheet |
There was a problem hiding this comment.
As much as I would like the whole header to be an external 'template' file that can customized, I don't think it's really needed unless there is a lot of people requesting it.
code/server/sv_http.c
Outdated
| Q_strncpyz(imageName, "levelshots/unknownmap", sizeof(imageName)); | ||
| } | ||
|
|
||
| Com_sprintf(imgLine, sizeof(imgLine), "\t\t<h1>%s</h1>\n\t\t<div class=\"img\"><img width=\"320\" height=\"240\" alt=\"%s\" src=\"maps/%s\" /></div>\n", mapName, mapName, imageName); |
There was a problem hiding this comment.
Same comment as above with wanting this to be an external template.
|
|
||
| HTTP_MapsAddMap(outputBuffer, sizeof(outputBuffer), sv_mapname->string); | ||
|
|
||
| Q_strcat(outputBuffer, sizeof(outputBuffer), "<table><tr><th>cl</th><th>score</th><th>ping</th><th>name</th><th>address</th><th>rate</th><tr>"); |
There was a problem hiding this comment.
Same as above with the external template.
| ps = SV_GameClientNum(i); | ||
| s = NET_AdrToString(cl->netchan.remoteAddress); | ||
|
|
||
| Com_sprintf(buf, sizeof(buf), "<tr><td>%i</td><td>%i</td><td>%i</td><td>%s</td><td>%s</td><td>%i</td></tr>", |
There was a problem hiding this comment.
Same as above with the external template.
| if (listen(httpSocket, 5) < 0) { | ||
| closesocket(httpSocket); | ||
| httpSocket = INVALID_SOCKET; | ||
| return qfalse; |
There was a problem hiding this comment.
I see a couple inconsistencies with style on new lines before returns. I personally like a new line before a return, but as long as it consistent, it doesn't matter which way you do it.
|
the css stuff can now get customized by providing the file I've also added bearer token support - but please see the comments in the code about it. And you can specify the interface to bind to, now. |
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
|
Fixed a few valgrind reports - calling this done for now. |
|
This is the new PR #558 - I've deleted the repo by accident. |

This allows you to get a list of available maps on the server, get the status and download pk3s - might be useful for others.
pk3 download must get the
sv_allowDownloadand the download url configureddownloading works when talking to the
/pk3endpoint like this:curl http://localhost:8080/pk3/baseq3/my.pk3http://localhost:8080/statushttp://localhost:8080/mapshttp://localhost:8080/pk3/[...]Open / Maybe
http/style.css)