Add containerization and make this bad boy work on Windows and MacOS
This commit is contained in:
@@ -2,14 +2,11 @@ INCS=-Isrc/include -I../hm_base/src/include -I/usr/include/json-c/
|
||||
LIB_PATH=-L../hm_base/lib
|
||||
LIB=-lhmbase -lm -lev -ljson-c -lcouchbase
|
||||
|
||||
all: base mods
|
||||
$(CC) -g -DMOD_$(mod) $(INCS) $(LIB_PATH) src/*.c $(LIB) -o hm_lobbyserver
|
||||
all: base
|
||||
$(CC) -g $(INCS) $(LIB_PATH) src/*.c $(LIB) -o hm_lobbyserver
|
||||
|
||||
base:
|
||||
$(MAKE) -C ../hm_base target=lobby
|
||||
|
||||
mods:
|
||||
cd script/ && python main.py
|
||||
|
||||
clean:
|
||||
rm hm_lobbyserver
|
||||
|
||||
@@ -1,7 +1,2 @@
|
||||
# hm_lobbyserver
|
||||
|
||||
hearthmod lobby server
|
||||
|
||||
# This is not a standalone project!
|
||||
|
||||
[hm_lobbyserver](https://github.com/farb3yonddriv3n/hm_lobbyserver) is part of [hearthmod software stack](https://github.com/hearthmod/hearthmod)
|
||||
|
||||
Executable
BIN
Binary file not shown.
@@ -1,37 +0,0 @@
|
||||
try:
|
||||
import couchbase
|
||||
from couchbase.bucket import Bucket
|
||||
from couchbase.views.iterator import View
|
||||
except:
|
||||
import couchbase_ffi
|
||||
from couchbase_ffi.bucket import Bucket
|
||||
from couchbase_ffi.views.iterator import View
|
||||
|
||||
cb = Bucket('couchbase://localhost/hbs', password='aci')
|
||||
|
||||
def prepare_mods():
|
||||
l = []
|
||||
for result in View(cb, "dev_mods", "mods"):
|
||||
l.append({ "url": result.value["url"], "name": result.value["name"] })
|
||||
|
||||
out = '#ifndef MODS_H_\n'
|
||||
out += '#define MODS_H_\n\n'
|
||||
|
||||
for i in l:
|
||||
out += '#ifdef MOD_%s\n' % i['url'].upper()
|
||||
out += '#define MOD_NAME "%s"\n' % i['name']
|
||||
out += '#define MOD_URL "%s"\n' % i['url']
|
||||
out += '#endif // MOD_%s\n\n' % i['url']
|
||||
|
||||
out += '#endif'
|
||||
|
||||
f = open("../src/include/mods.h", "w")
|
||||
f.write(out)
|
||||
f.close()
|
||||
|
||||
f = open("../../hm_gameserver/src/include/mods.h", "w")
|
||||
f.write(out)
|
||||
f.close()
|
||||
|
||||
if __name__ == '__main__':
|
||||
prepare_mods()
|
||||
@@ -25,7 +25,6 @@
|
||||
#define HM_LOBBYSERVER
|
||||
|
||||
#include <hmbase.h>
|
||||
#include <mods.h>
|
||||
|
||||
#include <client.h>
|
||||
|
||||
@@ -39,8 +38,6 @@ void login_reply(struct conn_client_s *cs, int error)
|
||||
json_object_object_add(obj, "type", json_object_new_int(CLIENT_LOGIN));
|
||||
json_object_object_add(obj, "error", json_object_new_int(error));
|
||||
json_object_object_add(obj, "secret", json_object_new_string(cs->login.secret));
|
||||
json_object_object_add(obj, "mod_name", json_object_new_string(MOD_NAME));
|
||||
json_object_object_add(obj, "mod_url", json_object_new_string(MOD_URL));
|
||||
const char *str = json_object_get_string(obj);
|
||||
|
||||
hm_send(cs, str, strlen(str));
|
||||
@@ -99,9 +96,9 @@ void client_login_2(struct cbop_s *cbop)
|
||||
cbop->data = cs;
|
||||
|
||||
char k1[128];
|
||||
snprintf(k1, sizeof(k1), "u:deck_%s_%s", MOD_URL, cs->login.secret);
|
||||
CBGQ_V0(0, k1, strlen(k1), client_login_3, 0, 0);
|
||||
return;
|
||||
snprintf(k1, sizeof(k1), "u:deck_%s", cs->login.secret);
|
||||
CBGQ_V0(0, k1, strlen(k1), client_login_3, 0, 0)
|
||||
return;
|
||||
} else {
|
||||
hm_log(LOG_DEBUG, cs->log, "{Client}: passwords do not match %s %s", cs->login.pass, v);
|
||||
free(cbop);
|
||||
@@ -164,8 +161,8 @@ void client_login(struct conn_client_s *cs, const char *buf, int len)
|
||||
cbop = malloc(sizeof(*cbop));
|
||||
memset(cbop, 0, sizeof(*cbop));
|
||||
cbop->data = cs;
|
||||
CBGQ_V0(0, k, strlen(k), client_login_2, 0, 0);
|
||||
CBGQ_V0(0, k, strlen(k), client_login_2, 0, 0)
|
||||
|
||||
json_object_put(obj);
|
||||
json_object_put(obj);
|
||||
json_tokener_free(tok);
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ int step22_7(char *dst, int ndst);
|
||||
int step22_8(char *dst, int ndst);
|
||||
|
||||
int step22_9_1(char *dst, int ndst, int iplen);
|
||||
int step22_9_2(char *dst, int ndst, int port);
|
||||
int step22_9_2(char *dst, int ndst);
|
||||
int step22_9_ip(char *dst, int ndst, const char *ip, const int iplen);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -44,7 +44,6 @@ static struct ev_loop *loop;
|
||||
|
||||
char ip[32];
|
||||
int iplen = 0;
|
||||
int gameserver_port = 0;
|
||||
|
||||
void dump_binary(char *buf, int len)
|
||||
{
|
||||
@@ -550,7 +549,7 @@ void start_game(struct conn_client_s *p1, struct conn_client_s *p2, const int ga
|
||||
t += step22_8(out + t, sizeof(buf2) - t);
|
||||
t += step22_9_1(out + t, sizeof(buf2) - t, iplen);
|
||||
t += step22_9_ip(out + t, sizeof(buf2) - t, ip, iplen);
|
||||
t += step22_9_2(out + t, sizeof(buf2) - t, gameserver_port);
|
||||
t += step22_9_2(out + t, sizeof(buf2) - t);
|
||||
|
||||
t = 0;
|
||||
out = buf2;
|
||||
@@ -565,7 +564,7 @@ void start_game(struct conn_client_s *p1, struct conn_client_s *p2, const int ga
|
||||
t += step22_8(out + t, sizeof(buf2) - t);
|
||||
t += step22_9_1(out + t, sizeof(buf2) - t, iplen);
|
||||
t += step22_9_ip(out + t, sizeof(buf2) - t, ip, iplen);
|
||||
t += step22_9_2(out + t, sizeof(buf2) - t, gameserver_port);
|
||||
t += step22_9_2(out + t, sizeof(buf2) - t);
|
||||
|
||||
memcpy(buf1 + 1343 + (iplen - 14), p1->token, p1->ntoken);
|
||||
memcpy(buf2 + 1343 + (iplen - 14), p2->token, p2->ntoken);
|
||||
@@ -793,17 +792,9 @@ int main(int argc, char **argv)
|
||||
snprintf(ip, sizeof(ip), "%s", argv[i] + 13);
|
||||
iplen = strlen(ip);
|
||||
}
|
||||
|
||||
if(strlen(argv[i]) > 18 && memcmp(argv[i], "--gameserver_port=", 18) == 0) {
|
||||
char gp[32];
|
||||
snprintf(gp, sizeof(gp), "%s", argv[i] + 18);
|
||||
gameserver_port = atoi(gp);
|
||||
}
|
||||
}
|
||||
|
||||
assert(iplen != 0);
|
||||
// gameserver port number must occupy exactly 2 protobuf bytes
|
||||
assert(gameserver_port > (1 << 10) && gameserver_port < (1 << 14));
|
||||
/* assert(iplen != 0); */
|
||||
|
||||
if(daemon == 0) {
|
||||
hm_log_open(&l, NULL, LOG_DEBUG);
|
||||
@@ -811,7 +802,7 @@ int main(int argc, char **argv)
|
||||
daemonize();
|
||||
}
|
||||
|
||||
hm_log(LOG_DEBUG, &l, "Associated with gameserver [%s:%d]", ip, gameserver_port);
|
||||
hm_log(LOG_DEBUG, &l, "Associated with gameserver [%s]%d", ip, iplen);
|
||||
|
||||
loop = ev_default_loop(0);
|
||||
pool = hm_create_pool(&l);
|
||||
|
||||
@@ -135,19 +135,9 @@ int step22_9_1(char *dst, int ndst, int iplen) {
|
||||
return 205;
|
||||
}
|
||||
|
||||
int step22_9_2(char *dst, int ndst, int port) {
|
||||
const char src[185] = { 0x18, 0x8C, 0x1D, 0x22, 0x06, 0x45, 0x6A, 0x63, 0x44, 0x65, 0x49, 0x2A, 0x13, 0x0A, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x12, 0x08, 0x2A, 0x06, 0x32, 0x30, 0x38, 0x38, 0x39, 0x31, 0x2A, 0x0D, 0x0A, 0x04, 0x67, 0x61, 0x6D, 0x65, 0x12, 0x05, 0x18, 0xAA, 0x80, 0xC4, 0x06, 0x2A, 0x0C, 0x0A, 0x06, 0x70, 0x6C, 0x61, 0x79, 0x65, 0x72, 0x12, 0x02, 0x18, 0x01, 0x2A, 0x0B, 0x0A, 0x02, 0x69, 0x64, 0x12, 0x05, 0x18, 0xB2, 0xB0, 0xAA, 0x1C, 0x2A, 0x0F, 0x0A, 0x09, 0x72, 0x65, 0x73, 0x75, 0x6D, 0x61, 0x62, 0x6C, 0x65, 0x12, 0x02, 0x10, 0x01, 0x2A, 0x1E, 0x0A, 0x12, 0x73, 0x70, 0x65, 0x63, 0x74, 0x61, 0x74, 0x6F, 0x72, 0x5F, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6F, 0x72, 0x64, 0x12, 0x08, 0x2A, 0x06, 0x6F, 0x44, 0x69, 0x70, 0x49, 0x66, 0x4A, 0x0A, 0x08, 0x95, 0xA5, 0x67, 0x10, 0xE9, 0xE6, 0xAC, 0xB9, 0x05, 0x52, 0x15, 0x0A, 0x05, 0x0D, 0x93, 0x71, 0x0E, 0x1A, 0x12, 0x0C, 0x0D, 0x67, 0x39, 0xAB, 0x04, 0x15, 0x47, 0x43, 0x54, 0x57, 0x18, 0x02, };
|
||||
char *ptr = (char *)&src[1];
|
||||
write_uint(&ptr, ptr + 2, port);
|
||||
|
||||
if(ndst >= 158) {
|
||||
memcpy(dst, src, 158);
|
||||
} else {
|
||||
abort();
|
||||
}
|
||||
|
||||
return 158;
|
||||
}
|
||||
int step22_9_2(char *dst, int ndst) {const char src[185] = { 0x18, 0x8C, 0x1D, 0x22, 0x06, 0x45, 0x6A, 0x63, 0x44, 0x65, 0x49, 0x2A, 0x13, 0x0A, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x12, 0x08, 0x2A, 0x06, 0x32, 0x30, 0x38, 0x38, 0x39, 0x31, 0x2A, 0x0D, 0x0A, 0x04, 0x67, 0x61, 0x6D, 0x65, 0x12, 0x05, 0x18, 0xAA, 0x80, 0xC4, 0x06, 0x2A, 0x0C, 0x0A, 0x06, 0x70, 0x6C, 0x61, 0x79, 0x65, 0x72, 0x12, 0x02, 0x18, 0x01, 0x2A, 0x0B, 0x0A, 0x02, 0x69, 0x64, 0x12, 0x05, 0x18, 0xB2, 0xB0, 0xAA, 0x1C, 0x2A, 0x0F, 0x0A, 0x09, 0x72, 0x65, 0x73, 0x75, 0x6D, 0x61, 0x62, 0x6C, 0x65, 0x12, 0x02, 0x10, 0x01, 0x2A, 0x1E, 0x0A, 0x12, 0x73, 0x70, 0x65, 0x63, 0x74, 0x61, 0x74, 0x6F, 0x72, 0x5F, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6F, 0x72, 0x64, 0x12, 0x08, 0x2A, 0x06, 0x6F, 0x44, 0x69, 0x70, 0x49, 0x66, 0x4A, 0x0A, 0x08, 0x95, 0xA5, 0x67, 0x10, 0xE9, 0xE6, 0xAC, 0xB9, 0x05, 0x52, 0x15, 0x0A, 0x05, 0x0D, 0x93, 0x71, 0x0E, 0x1A, 0x12, 0x0C, 0x0D, 0x67, 0x39, 0xAB, 0x04, 0x15, 0x47, 0x43, 0x54, 0x57, 0x18, 0x02, };
|
||||
if(ndst >= 158) { memcpy(dst, src, 158); } else { abort(); }
|
||||
return 158;}
|
||||
|
||||
int step22_9_ip(char *dst, int ndst, const char *ip, const int iplen)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user