Switch broadcast to MQTT
This commit is contained in:
parent
760fef49b2
commit
1684f8ab39
7
dist/config/bbs.ini
vendored
7
dist/config/bbs.ini
vendored
@ -25,9 +25,10 @@ SSH RSA Key = /home/andrew/MagickaBBS/keys/ssh_host_rsa_key
|
|||||||
Main AKA = 1:2/3.4
|
Main AKA = 1:2/3.4
|
||||||
QWK Name = MAGICKA
|
QWK Name = MAGICKA
|
||||||
QWK Max Messages = 5000
|
QWK Max Messages = 5000
|
||||||
Broadcast Enable = false
|
MQTT Enable = false
|
||||||
Broadcast Port = 2027
|
MQTT Port = 2027
|
||||||
Broadcast Address = 192.168.1.255
|
MQTT Address = localhost
|
||||||
|
MQTT Topic = MagickaBBS
|
||||||
IP Guard Enable = true
|
IP Guard Enable = true
|
||||||
IP Guard Timeout = 120
|
IP Guard Timeout = 120
|
||||||
IP Guard Tries = 4
|
IP Guard Tries = 4
|
||||||
|
@ -16,9 +16,9 @@
|
|||||||
|
|
||||||
## Install Prerequisites
|
## Install Prerequisites
|
||||||
|
|
||||||
Ensure you have git, c compiler, libsqlite3-dev, libreadline-dev, libssl-dev, libssh-dev libncurses5-dev, libmicrohttpd-dev, bash, libdbd-sqlite3-perl, gnu sed and gnu make
|
Ensure you have git, c compiler, libsqlite3-dev, libreadline-dev, libssl-dev, libssh-dev libncurses5-dev, libmicrohttpd-dev, libmosquitto-dev, bash, libdbd-sqlite3-perl, gnu sed and gnu make
|
||||||
|
|
||||||
sudo apt-get install build-essential libsqlite3-dev libreadline-dev git libssl-dev libssh-dev libncurses5-dev libmicrohttpd-dev libdbd-sqlite3-perl sed
|
sudo apt-get install build-essential libsqlite3-dev libreadline-dev git libssl-dev libssh-dev libncurses5-dev libmicrohttpd-dev libdbd-sqlite3-perl libmosquitto-dev sed
|
||||||
|
|
||||||
should work on debian and debian derivatives.
|
should work on debian and debian derivatives.
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.
|
|||||||
$(CC) -c -o $@ $< $(CFLAGS)
|
$(CC) -c -o $@ $< $(CFLAGS)
|
||||||
|
|
||||||
magicka: $(OBJ) ${LUA} ${JAMLIB} ${ZMODEM} ${JSMN} ${UUID}
|
magicka: $(OBJ) ${LUA} ${JAMLIB} ${ZMODEM} ${JSMN} ${UUID}
|
||||||
$(CC) -o ../magicka $^ $(CFLAGS) -L/usr/local/lib -lsqlite3 -lutil -lm -lssl -lcrypto -lssh -liconv
|
$(CC) -o ../magicka $^ $(CFLAGS) -L/usr/local/lib -lsqlite3 -lutil -lm -lssl -lcrypto -lssh -liconv -lmosquitto
|
||||||
|
|
||||||
magimail: $(JAMLIB)
|
magimail: $(JAMLIB)
|
||||||
cd ../utils/magimail && $(MAKE) freebsd
|
cd ../utils/magimail && $(MAKE) freebsd
|
||||||
|
@ -47,7 +47,7 @@ OBJ = ../deps/aha/aha.o ../deps/hashids/hashids.o inih/ini.o bbs.o main.o users
|
|||||||
$(CC) -c -o $@ $< $(CFLAGS)
|
$(CC) -c -o $@ $< $(CFLAGS)
|
||||||
|
|
||||||
magicka: $(OBJ) ${LUA} ${ZMODEM} ${JAMLIB} ${B64} ${JSMN} ${UUID}
|
magicka: $(OBJ) ${LUA} ${ZMODEM} ${JAMLIB} ${B64} ${JSMN} ${UUID}
|
||||||
$(CC) -o ../magicka $^ $(CFLAGS) -L/usr/local/lib -lsqlite3 -lutil -lm -lssl -lcrypto -lssh -liconv $(MICROHTTPD)
|
$(CC) -o ../magicka $^ $(CFLAGS) -L/usr/local/lib -lsqlite3 -lutil -lm -lssl -lcrypto -lssh -liconv -lmosquitto $(MICROHTTPD)
|
||||||
|
|
||||||
magimail: $(JAMLIB)
|
magimail: $(JAMLIB)
|
||||||
cd ../utils/magimail && $(MAKE) freebsd
|
cd ../utils/magimail && $(MAKE) freebsd
|
||||||
|
@ -42,7 +42,7 @@ OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o
|
|||||||
$(CC) -c -o $@ $< $(CFLAGS)
|
$(CC) -c -o $@ $< $(CFLAGS)
|
||||||
|
|
||||||
magicka: $(OBJ) ${LUA} ${ZMODEM} ${JAMLIB} ${JSMN} ${UUID}
|
magicka: $(OBJ) ${LUA} ${ZMODEM} ${JAMLIB} ${JSMN} ${UUID}
|
||||||
$(CC) -o ../magicka $^ $(CFLAGS) -L/usr/local/lib -lsqlite3 -lutil -lm -ldl -lssl -lcrypto -lssh
|
$(CC) -o ../magicka $^ $(CFLAGS) -L/usr/local/lib -lsqlite3 -lutil -lm -ldl -lssl -lcrypto -lssh -lmosquitto
|
||||||
|
|
||||||
magimail: $(JAMLIB)
|
magimail: $(JAMLIB)
|
||||||
cd ../utils/magimail && $(MAKE) linux
|
cd ../utils/magimail && $(MAKE) linux
|
||||||
|
@ -47,7 +47,7 @@ OBJ = ../deps/aha/aha.o ../deps/hashids/hashids.o inih/ini.o bbs.o main.o users
|
|||||||
$(CC) -c -o $@ $< $(CFLAGS)
|
$(CC) -c -o $@ $< $(CFLAGS)
|
||||||
|
|
||||||
magicka: $(OBJ) ${LUA} ${JAMLIB} ${ZMODEM} ${B64} ${JSMN} ${UUID}
|
magicka: $(OBJ) ${LUA} ${JAMLIB} ${ZMODEM} ${B64} ${JSMN} ${UUID}
|
||||||
$(CC) -o ../magicka $^ $(CFLAGS) -L/usr/local/lib -lsqlite3 -lutil -lm -ldl -lssl -lcrypto -lssh $(MICROHTTPD)
|
$(CC) -o ../magicka $^ $(CFLAGS) -L/usr/local/lib -lsqlite3 -lutil -lm -ldl -lssl -lcrypto -lssh -lmosquitto $(MICROHTTPD)
|
||||||
|
|
||||||
magimail: $(JAMLIB)
|
magimail: $(JAMLIB)
|
||||||
cd ../utils/magimail && $(MAKE) linux
|
cd ../utils/magimail && $(MAKE) linux
|
||||||
|
@ -42,7 +42,7 @@ OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o
|
|||||||
$(CC) -c -o $@ $< $(CFLAGS)
|
$(CC) -c -o $@ $< $(CFLAGS)
|
||||||
|
|
||||||
magicka: $(OBJ) ${LUA} ${ZMODEM} ${JAMLIB} ${JSMN} ${UUID}
|
magicka: $(OBJ) ${LUA} ${ZMODEM} ${JAMLIB} ${JSMN} ${UUID}
|
||||||
$(CC) -o ../magicka $^ $(CFLAGS) -R/usr/pkg/lib -L/usr/pkg/lib -lsqlite3 -lutil -lm -lssl -lcrypto -lssh -liconv
|
$(CC) -o ../magicka $^ $(CFLAGS) -R/usr/pkg/lib -L/usr/pkg/lib -lsqlite3 -lutil -lm -lssl -lcrypto -lssh -liconv -lmosquitto
|
||||||
|
|
||||||
magiedit: $(ODOORS)
|
magiedit: $(ODOORS)
|
||||||
cd ../utils/magiedit && $(MAKE)
|
cd ../utils/magiedit && $(MAKE)
|
||||||
|
@ -47,7 +47,7 @@ OBJ = ../deps/aha/aha.o ../deps/hashids/hashids.o inih/ini.o bbs.o main.o users
|
|||||||
$(CC) -c -o $@ $< $(CFLAGS)
|
$(CC) -c -o $@ $< $(CFLAGS)
|
||||||
|
|
||||||
magicka: $(OBJ) ${LUA} ${ZMODEM} ${JAMLIB} ${B64} ${JSMN} ${UUID}
|
magicka: $(OBJ) ${LUA} ${ZMODEM} ${JAMLIB} ${B64} ${JSMN} ${UUID}
|
||||||
$(CC) -o ../magicka $^ $(CFLAGS) -R/usr/pkg/lib -L/usr/pkg/lib -lsqlite3 -lutil -lm -lssl -lcrypto -lssh -liconv $(MICROHTTPD)
|
$(CC) -o ../magicka $^ $(CFLAGS) -R/usr/pkg/lib -L/usr/pkg/lib -lsqlite3 -lutil -lm -lssl -lcrypto -lssh -liconv -lmosquitto $(MICROHTTPD)
|
||||||
|
|
||||||
magiedit: $(ODOORS)
|
magiedit: $(ODOORS)
|
||||||
cd ../utils/magiedit && $(MAKE)
|
cd ../utils/magiedit && $(MAKE)
|
||||||
|
@ -42,7 +42,7 @@ OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o
|
|||||||
$(CC) -c -o $@ $< $(CFLAGS)
|
$(CC) -c -o $@ $< $(CFLAGS)
|
||||||
|
|
||||||
magicka: $(OBJ) ${LUA} ${ZMODEM} ${JAMLIB} ${JSMN} ${UUID}
|
magicka: $(OBJ) ${LUA} ${ZMODEM} ${JAMLIB} ${JSMN} ${UUID}
|
||||||
$(CC) -o ../magicka $^ $(CFLAGS) -L/usr/local/lib -lsqlite3 -lutil -lm -lssl -lcrypto -lssh -liconv
|
$(CC) -o ../magicka $^ $(CFLAGS) -L/usr/local/lib -lsqlite3 -lutil -lm -lssl -lcrypto -lssh -liconv -lmosquitto
|
||||||
|
|
||||||
magiedit: $(ODOORS)
|
magiedit: $(ODOORS)
|
||||||
cd ../utils/magiedit && $(MAKE)
|
cd ../utils/magiedit && $(MAKE)
|
||||||
|
@ -47,7 +47,7 @@ OBJ = ../deps/aha/aha.o ../deps/hashids/hashids.o inih/ini.o bbs.o main.o users
|
|||||||
$(CC) -c -o $@ $< $(CFLAGS)
|
$(CC) -c -o $@ $< $(CFLAGS)
|
||||||
|
|
||||||
magicka: $(OBJ) ${LUA} ${ZMODEM} ${JAMLIB} ${B64} ${JSMN} ${UUID}
|
magicka: $(OBJ) ${LUA} ${ZMODEM} ${JAMLIB} ${B64} ${JSMN} ${UUID}
|
||||||
$(CC) -o ../magicka $^ $(CFLAGS) -L/usr/local/lib -lsqlite3 -lutil -lm -lssl -lcrypto -lssh -liconv $(MICROHTTPD)
|
$(CC) -o ../magicka $^ $(CFLAGS) -L/usr/local/lib -lsqlite3 -lutil -lm -lssl -lcrypto -lssh -liconv -lmosquitto $(MICROHTTPD)
|
||||||
|
|
||||||
magiedit: $(ODOORS)
|
magiedit: $(ODOORS)
|
||||||
cd ../utils/magiedit && $(MAKE)
|
cd ../utils/magiedit && $(MAKE)
|
||||||
|
@ -43,7 +43,7 @@ $(UUID):
|
|||||||
$(CC) -c -o $@ $< $(CFLAGS)
|
$(CC) -c -o $@ $< $(CFLAGS)
|
||||||
|
|
||||||
magicka: $(OBJ) ${LUA} ${ZMODEM} ${JAMLIB} ${JSMN} ${UUID}
|
magicka: $(OBJ) ${LUA} ${ZMODEM} ${JAMLIB} ${JSMN} ${UUID}
|
||||||
$(CC) -o ../magicka $^ $(CFLAGS) -L/opt/local/lib -lsqlite3 -lutil -lm -ldl -lssl -lcrypto -lssh -liconv
|
$(CC) -o ../magicka $^ $(CFLAGS) -L/opt/local/lib -lsqlite3 -lutil -lm -ldl -lssl -lcrypto -lssh -liconv -lmosquitto
|
||||||
|
|
||||||
magimail: $(JAMLIB)
|
magimail: $(JAMLIB)
|
||||||
cd ../utils/magimail && $(MAKE) linux
|
cd ../utils/magimail && $(MAKE) linux
|
||||||
|
@ -47,7 +47,7 @@ OBJ = ../deps/aha/aha.o ../deps/hashids/hashids.o inih/ini.o bbs.o main.o users
|
|||||||
$(CC) -c -o $@ $< $(CFLAGS)
|
$(CC) -c -o $@ $< $(CFLAGS)
|
||||||
|
|
||||||
magicka: $(OBJ) ${LUA} ${ZMODEM} ${JAMLIB} ${B64} ${JSMN} ${UUID}
|
magicka: $(OBJ) ${LUA} ${ZMODEM} ${JAMLIB} ${B64} ${JSMN} ${UUID}
|
||||||
$(CC) -o ../magicka $^ $(CFLAGS) -L/opt/local/lib -lsqlite3 -lutil -lm -ldl -lssl -lcrypto -lssh -liconv $(MICROHTTPD)
|
$(CC) -o ../magicka $^ $(CFLAGS) -L/opt/local/lib -lsqlite3 -lutil -lm -ldl -lssl -lcrypto -lssh -liconv -lmosquitto $(MICROHTTPD)
|
||||||
|
|
||||||
magimail: $(JAMLIB)
|
magimail: $(JAMLIB)
|
||||||
cd ../utils/magimail && $(MAKE) linux
|
cd ../utils/magimail && $(MAKE) linux
|
||||||
|
@ -42,7 +42,7 @@ OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o
|
|||||||
$(CC) -c -o $@ $< $(CFLAGS)
|
$(CC) -c -o $@ $< $(CFLAGS)
|
||||||
|
|
||||||
magicka: $(OBJ) ${LUA} ${ZMODEM} ${JAMLIB} ${JSMN} ${UUID}
|
magicka: $(OBJ) ${LUA} ${ZMODEM} ${JAMLIB} ${JSMN} ${UUID}
|
||||||
$(CC) -o ../magicka $^ $(CFLAGS) -L/usr/local/lib -lsqlite3 -lm -ldl -lssl -lcrypto -lssh -lnsl -lsocket
|
$(CC) -o ../magicka $^ $(CFLAGS) -L/usr/local/lib -lsqlite3 -lm -ldl -lssl -lcrypto -lssh -lmosquitto -lnsl -lsocket
|
||||||
|
|
||||||
magimail: $(JAMLIB)
|
magimail: $(JAMLIB)
|
||||||
cd ../utils/magimail && $(MAKE) freebsd
|
cd ../utils/magimail && $(MAKE) freebsd
|
||||||
|
@ -47,7 +47,7 @@ OBJ = ../deps/aha/aha.o ../deps/hashids/hashids.o inih/ini.o bbs.o main.o users
|
|||||||
$(CC) -c -o $@ $< $(CFLAGS)
|
$(CC) -c -o $@ $< $(CFLAGS)
|
||||||
|
|
||||||
magicka: $(OBJ) ${LUA} ${JAMLIB} ${ZMODEM} ${B64} ${JSMN} ${UUID}
|
magicka: $(OBJ) ${LUA} ${JAMLIB} ${ZMODEM} ${B64} ${JSMN} ${UUID}
|
||||||
$(CC) -o ../magicka $^ $(CFLAGS) -L/usr/local/lib -lsqlite3 -lm -ldl -lssl -lcrypto -lssh $(MICROHTTPD) -lnsl -lsocket
|
$(CC) -o ../magicka $^ $(CFLAGS) -L/usr/local/lib -lsqlite3 -lm -ldl -lssl -lcrypto -lssh -lmosquitto $(MICROHTTPD) -lnsl -lsocket
|
||||||
|
|
||||||
magimail: $(JAMLIB)
|
magimail: $(JAMLIB)
|
||||||
cd ../utils/magimail && $(MAKE) freebsd
|
cd ../utils/magimail && $(MAKE) freebsd
|
||||||
|
79
src/bbs.c
79
src/bbs.c
@ -15,6 +15,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <iconv.h>
|
#include <iconv.h>
|
||||||
|
#include <mosquitto.h>
|
||||||
#include "bbs.h"
|
#include "bbs.h"
|
||||||
#include "lua/lua.h"
|
#include "lua/lua.h"
|
||||||
#include "lua/lualib.h"
|
#include "lua/lualib.h"
|
||||||
@ -34,6 +35,8 @@ int usertimeout;
|
|||||||
int timeoutpaused;
|
int timeoutpaused;
|
||||||
time_t userlaston;
|
time_t userlaston;
|
||||||
|
|
||||||
|
struct mosquitto *mosq = NULL;
|
||||||
|
|
||||||
char *ipaddress = NULL;
|
char *ipaddress = NULL;
|
||||||
|
|
||||||
void sigterm_handler2(int s)
|
void sigterm_handler2(int s)
|
||||||
@ -50,44 +53,14 @@ void sigint_handler(int s)
|
|||||||
// do nothing...
|
// do nothing...
|
||||||
}
|
}
|
||||||
void broadcast(char *mess, ...) {
|
void broadcast(char *mess, ...) {
|
||||||
char json[1024];
|
char buffer[PATH_MAX];
|
||||||
char buffer[512];
|
if (conf.broadcast_enable && conf.broadcast_port != 0 && conf.broadcast_address != NULL) {
|
||||||
struct sockaddr_in s;
|
|
||||||
int bcast_sock;
|
|
||||||
int broadcastEnable=1;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (conf.broadcast_enable && conf.broadcast_port > 1024 && conf.broadcast_port < 65536 && conf.broadcast_address != NULL) {
|
|
||||||
bcast_sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
|
||||||
ret=setsockopt(bcast_sock, SOL_SOCKET, SO_BROADCAST, &broadcastEnable, sizeof(broadcastEnable));
|
|
||||||
|
|
||||||
if (ret) {
|
|
||||||
dolog("broadcast: Couldn't set socket to broadcast mode");
|
|
||||||
close(bcast_sock);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
memset(&s, 0, sizeof(struct sockaddr_in));
|
|
||||||
|
|
||||||
s.sin_family=AF_INET;
|
|
||||||
s.sin_addr.s_addr = inet_addr(conf.broadcast_address);
|
|
||||||
s.sin_port = htons((unsigned short)conf.broadcast_port);
|
|
||||||
bind(bcast_sock, (struct sockaddr *)&s, sizeof(struct sockaddr_in));
|
|
||||||
|
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, mess);
|
va_start(ap, mess);
|
||||||
vsnprintf(buffer, 512, mess, ap);
|
vsnprintf(buffer, PATH_MAX, mess, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
snprintf(json, 1024, "{\"System\": \"%s\", \"Program\": \"MagickaBBS\", \"Message\": \"%s\"}", conf.bbs_name, buffer);
|
mosquitto_publish(mosq, NULL, (conf.broadcast_topic == NULL ? "MagickaBBS" : conf.broadcast_topic), strlen(buffer), buffer, 0, 0);
|
||||||
|
|
||||||
ret = sendto(bcast_sock, json, strlen(json) + 1, 0, (struct sockaddr *)&s, sizeof(struct sockaddr_in));
|
|
||||||
|
|
||||||
if (ret < 0) {
|
|
||||||
dolog("broadcast: Couldn't send broadcast");
|
|
||||||
}
|
|
||||||
close(bcast_sock);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -679,15 +652,25 @@ void s_readpass(char *buffer, int max) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void exit_bbs() {
|
void exit_bbs() {
|
||||||
char buffer[1024];
|
char buffer[PATH_MAX];
|
||||||
snprintf(buffer, 1024, "%s/nodeinuse.%d", conf.bbs_path, mynode);
|
|
||||||
|
snprintf(buffer, PATH_MAX, "%s/nodeinuse.%d", conf.bbs_path, mynode);
|
||||||
remove(buffer);
|
remove(buffer);
|
||||||
|
if (mosq != NULL) {
|
||||||
|
mosquitto_disconnect(mosq);
|
||||||
|
mosquitto_loop_stop(mosq, 0);
|
||||||
|
mosquitto_destroy(mosq);
|
||||||
|
mosquitto_lib_cleanup();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void disconnect(char *calledby) {
|
void disconnect(char *calledby) {
|
||||||
|
|
||||||
if (gUser != NULL) {
|
if (gUser != NULL) {
|
||||||
|
broadcast("USER: %s; NODE:%d; STATUS: disconnected.", gUser->loginname, mynode);
|
||||||
save_user(gUser);
|
save_user(gUser);
|
||||||
|
} else {
|
||||||
|
broadcast("USER: unknown; NODE:%d; STATUS: disconnected.", mynode);
|
||||||
}
|
}
|
||||||
dolog("Node %d disconnected (%s)", mynode, calledby);
|
dolog("Node %d disconnected (%s)", mynode, calledby);
|
||||||
|
|
||||||
@ -899,6 +882,24 @@ void runbbs_real(int socket, char *ip, int ssh) {
|
|||||||
int tries;
|
int tries;
|
||||||
int fno;
|
int fno;
|
||||||
|
|
||||||
|
// initialize mqtt
|
||||||
|
if (conf.broadcast_enable && conf.broadcast_address != NULL && conf.broadcast_port != 0) {
|
||||||
|
mosquitto_lib_init();
|
||||||
|
mosq = mosquitto_new(NULL, 1, NULL);
|
||||||
|
if (conf.broadcast_user != NULL && conf.broadcast_pass != NULL) {
|
||||||
|
mosquitto_username_pw_set(mosq, conf.broadcast_user, conf.broadcast_pass);
|
||||||
|
}
|
||||||
|
if(mosquitto_connect(mosq, conf.broadcast_address, conf.broadcast_port, 60)){
|
||||||
|
dolog("Unable to connect to MQTT server.");
|
||||||
|
conf.broadcast_enable = 0;
|
||||||
|
} else {
|
||||||
|
if (mosquitto_loop_start(mosq) != MOSQ_ERR_SUCCESS) {
|
||||||
|
dolog("Unable to start MQTT loop.");
|
||||||
|
conf.broadcast_enable = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
atexit(exit_bbs);
|
atexit(exit_bbs);
|
||||||
|
|
||||||
usertimeout = 10;
|
usertimeout = 10;
|
||||||
@ -947,7 +948,7 @@ void runbbs_real(int socket, char *ip, int ssh) {
|
|||||||
} else {
|
} else {
|
||||||
sshBBS = 1;
|
sshBBS = 1;
|
||||||
}
|
}
|
||||||
|
broadcast("USER: unknown; NODE:%d; STATUS: Logging in.", mynode);
|
||||||
s_printf("Magicka BBS v%d.%d (%s), Loading...\r\n", VERSION_MAJOR, VERSION_MINOR, VERSION_STR);
|
s_printf("Magicka BBS v%d.%d (%s), Loading...\r\n", VERSION_MAJOR, VERSION_MINOR, VERSION_STR);
|
||||||
|
|
||||||
// find out which node we are
|
// find out which node we are
|
||||||
@ -1101,7 +1102,7 @@ tryagain:
|
|||||||
|
|
||||||
// do post-login
|
// do post-login
|
||||||
dolog("%s logged in, on node %d", user->loginname, mynode);
|
dolog("%s logged in, on node %d", user->loginname, mynode);
|
||||||
broadcast("%s logged in, on node %d", user->loginname, mynode);
|
broadcast("USER: %s; NODE:%d; STATUS: Logged in.", user->loginname, mynode);
|
||||||
// check time left
|
// check time left
|
||||||
now = time(NULL);
|
now = time(NULL);
|
||||||
localtime_r(&now, &thetime);
|
localtime_r(&now, &thetime);
|
||||||
@ -1167,7 +1168,7 @@ tryagain:
|
|||||||
do_logout();
|
do_logout();
|
||||||
|
|
||||||
dolog("%s is logging out, on node %d", user->loginname, mynode);
|
dolog("%s is logging out, on node %d", user->loginname, mynode);
|
||||||
broadcast("%s is logging out, on node %d", user->loginname, mynode);
|
broadcast("USER: %s; NODE:%d; STATUS: Logging out.", user->loginname, mynode);
|
||||||
disconnect("Log out");
|
disconnect("Log out");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,6 +173,9 @@ struct bbs_config {
|
|||||||
int broadcast_enable;
|
int broadcast_enable;
|
||||||
int broadcast_port;
|
int broadcast_port;
|
||||||
char *broadcast_address;
|
char *broadcast_address;
|
||||||
|
char *broadcast_topic;
|
||||||
|
char *broadcast_user;
|
||||||
|
char *broadcast_pass;
|
||||||
|
|
||||||
int ipguard_enable;
|
int ipguard_enable;
|
||||||
int ipguard_timeout;
|
int ipguard_timeout;
|
||||||
|
15
src/main.c
15
src/main.c
@ -497,16 +497,22 @@ static int handler(void* user, const char* section, const char* name,
|
|||||||
conf->main_aka = parse_fido_addr(value);
|
conf->main_aka = parse_fido_addr(value);
|
||||||
} else if (strcasecmp(name, "qwk max messages") == 0) {
|
} else if (strcasecmp(name, "qwk max messages") == 0) {
|
||||||
conf->bwave_max_msgs = atoi(value);
|
conf->bwave_max_msgs = atoi(value);
|
||||||
} else if (strcasecmp(name, "broadcast enable") == 0) {
|
} else if (strcasecmp(name, "mqtt enable") == 0) {
|
||||||
if (strcasecmp(value, "true") == 0) {
|
if (strcasecmp(value, "true") == 0) {
|
||||||
conf->broadcast_enable = 1;
|
conf->broadcast_enable = 1;
|
||||||
} else {
|
} else {
|
||||||
conf->broadcast_enable = 0;
|
conf->broadcast_enable = 0;
|
||||||
}
|
}
|
||||||
} else if (strcasecmp(name, "broadcast port") == 0) {
|
} else if (strcasecmp(name, "mqtt port") == 0) {
|
||||||
conf->broadcast_port = atoi(value);
|
conf->broadcast_port = atoi(value);
|
||||||
} else if (strcasecmp(name, "broadcast address") == 0) {
|
} else if (strcasecmp(name, "mqtt address") == 0) {
|
||||||
conf->broadcast_address = strdup(value);
|
conf->broadcast_address = strdup(value);
|
||||||
|
} else if (strcasecmp(name, "mqtt topic") == 0) {
|
||||||
|
conf->broadcast_topic = strdup(value);
|
||||||
|
} else if (strcasecmp(name, "mqtt user") == 0) {
|
||||||
|
conf->broadcast_user = strdup(value);
|
||||||
|
} else if (strcasecmp(name, "mqtt pass") == 0) {
|
||||||
|
conf->broadcast_pass = strdup(value);
|
||||||
} else if (strcasecmp(name, "ip guard enable") == 0) {
|
} else if (strcasecmp(name, "ip guard enable") == 0) {
|
||||||
if (strcasecmp(value, "true") == 0) {
|
if (strcasecmp(value, "true") == 0) {
|
||||||
conf->ipguard_enable = 1;
|
conf->ipguard_enable = 1;
|
||||||
@ -1301,6 +1307,9 @@ int main(int argc, char **argv) {
|
|||||||
conf.broadcast_enable = 0;
|
conf.broadcast_enable = 0;
|
||||||
conf.broadcast_port = 0;
|
conf.broadcast_port = 0;
|
||||||
conf.broadcast_address = NULL;
|
conf.broadcast_address = NULL;
|
||||||
|
conf.broadcast_topic = NULL;
|
||||||
|
conf.broadcast_user = NULL;
|
||||||
|
conf.broadcast_pass = NULL;
|
||||||
conf.config_path = NULL;
|
conf.config_path = NULL;
|
||||||
conf.ipguard_enable = 0;
|
conf.ipguard_enable = 0;
|
||||||
conf.ipguard_tries = 4;
|
conf.ipguard_tries = 4;
|
||||||
|
37
src/menus.c
37
src/menus.c
@ -95,6 +95,8 @@ int menu_system(char *menufile) {
|
|||||||
char *msg;
|
char *msg;
|
||||||
|
|
||||||
dolog("%s is loading menu: %s", gUser->loginname, menufile);
|
dolog("%s is loading menu: %s", gUser->loginname, menufile);
|
||||||
|
broadcast("USER: %s; NODE:%d; STATUS: Browsing menu %s.", gUser->loginname, mynode, menufile);
|
||||||
|
|
||||||
|
|
||||||
if (menufile[0] == '/') {
|
if (menufile[0] == '/') {
|
||||||
snprintf(buffer, PATH_MAX, "%s.mnu", menufile);
|
snprintf(buffer, PATH_MAX, "%s.mnu", menufile);
|
||||||
@ -424,24 +426,31 @@ int menu_system(char *menufile) {
|
|||||||
free(menu);
|
free(menu);
|
||||||
return 0;
|
return 0;
|
||||||
case MENU_AUTOMESSAGE:
|
case MENU_AUTOMESSAGE:
|
||||||
|
broadcast("USER: %s; NODE:%d; STATUS: Viewing/Changing Automessage.", gUser->loginname, mynode);
|
||||||
automessage();
|
automessage();
|
||||||
break;
|
break;
|
||||||
case MENU_TEXTFILES:
|
case MENU_TEXTFILES:
|
||||||
|
broadcast("USER: %s; NODE:%d; STATUS: Browsing Textfiles.", gUser->loginname, mynode);
|
||||||
display_textfiles();
|
display_textfiles();
|
||||||
break;
|
break;
|
||||||
case MENU_CHATSYSTEM:
|
case MENU_CHATSYSTEM:
|
||||||
|
broadcast("USER: %s; NODE:%d; STATUS: In Chat System.", gUser->loginname, mynode);
|
||||||
chat_system(gUser);
|
chat_system(gUser);
|
||||||
break;
|
break;
|
||||||
case MENU_BBSLIST:
|
case MENU_BBSLIST:
|
||||||
|
broadcast("USER: %s; NODE:%d; STATUS: Browsing BBS List.", gUser->loginname, mynode);
|
||||||
bbs_list(gUser);
|
bbs_list(gUser);
|
||||||
break;
|
break;
|
||||||
case MENU_LISTUSERS:
|
case MENU_LISTUSERS:
|
||||||
|
broadcast("USER: %s; NODE:%d; STATUS: Browsing User List.", gUser->loginname, mynode);
|
||||||
list_users(gUser);
|
list_users(gUser);
|
||||||
break;
|
break;
|
||||||
case MENU_BULLETINS:
|
case MENU_BULLETINS:
|
||||||
|
broadcast("USER: %s; NODE:%d; STATUS: Reading Bulletins.", gUser->loginname, mynode);
|
||||||
display_bulletins();
|
display_bulletins();
|
||||||
break;
|
break;
|
||||||
case MENU_LAST10:
|
case MENU_LAST10:
|
||||||
|
broadcast("USER: %s; NODE:%d; STATUS: Viewing Last 10 Callers.", gUser->loginname, mynode);
|
||||||
display_last10_callers(gUser);
|
display_last10_callers(gUser);
|
||||||
break;
|
break;
|
||||||
case MENU_SETTINGS:
|
case MENU_SETTINGS:
|
||||||
@ -452,6 +461,7 @@ int menu_system(char *menufile) {
|
|||||||
for (m=0;m<conf.door_count;m++) {
|
for (m=0;m<conf.door_count;m++) {
|
||||||
if (strcasecmp(menu[i]->data[j], conf.doors[m]->name) == 0) {
|
if (strcasecmp(menu[i]->data[j], conf.doors[m]->name) == 0) {
|
||||||
dolog("%s launched door %s, on node %d", gUser->loginname, conf.doors[m]->name, mynode);
|
dolog("%s launched door %s, on node %d", gUser->loginname, conf.doors[m]->name, mynode);
|
||||||
|
broadcast("USER: %s; NODE:%d; STATUS: Executing Door %s.", gUser->loginname, mynode, conf.doors[m]->name);
|
||||||
rundoor(gUser, conf.doors[m]->command, conf.doors[m]->stdio, conf.doors[m]->codepage);
|
rundoor(gUser, conf.doors[m]->command, conf.doors[m]->stdio, conf.doors[m]->codepage);
|
||||||
dolog("%s returned from door %s, on node %d", gUser->loginname, conf.doors[m]->name, mynode);
|
dolog("%s returned from door %s, on node %d", gUser->loginname, conf.doors[m]->name, mynode);
|
||||||
break;
|
break;
|
||||||
@ -460,24 +470,31 @@ int menu_system(char *menufile) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MENU_MAILSCAN:
|
case MENU_MAILSCAN:
|
||||||
|
broadcast("USER: %s; NODE:%d; STATUS: Performing Mail Scan.", gUser->loginname, mynode);
|
||||||
mail_scan(gUser);
|
mail_scan(gUser);
|
||||||
break;
|
break;
|
||||||
case MENU_READMAIL:
|
case MENU_READMAIL:
|
||||||
|
broadcast("USER: %s; NODE:%d; STATUS: Reading Mail.", gUser->loginname, mynode);
|
||||||
read_mail(gUser);
|
read_mail(gUser);
|
||||||
break;
|
break;
|
||||||
case MENU_POSTMESSAGE:
|
case MENU_POSTMESSAGE:
|
||||||
|
broadcast("USER: %s; NODE:%d; STATUS: Posting a Message.", gUser->loginname, mynode);
|
||||||
post_message(gUser);
|
post_message(gUser);
|
||||||
break;
|
break;
|
||||||
case MENU_CHOOSEMAILCONF:
|
case MENU_CHOOSEMAILCONF:
|
||||||
|
broadcast("USER: %s; NODE:%d; STATUS: Choosing Mail Conference.", gUser->loginname, mynode);
|
||||||
choose_conference();
|
choose_conference();
|
||||||
break;
|
break;
|
||||||
case MENU_CHOOSEMAILAREA:
|
case MENU_CHOOSEMAILAREA:
|
||||||
|
broadcast("USER: %s; NODE:%d; STATUS: Choosing Mail Area.", gUser->loginname, mynode);
|
||||||
choose_area();
|
choose_area();
|
||||||
break;
|
break;
|
||||||
case MENU_SENDEMAIL:
|
case MENU_SENDEMAIL:
|
||||||
|
broadcast("USER: %s; NODE:%d; STATUS: Sending an Email.", gUser->loginname, mynode);
|
||||||
send_email(gUser);
|
send_email(gUser);
|
||||||
break;
|
break;
|
||||||
case MENU_LISTEMAIL:
|
case MENU_LISTEMAIL:
|
||||||
|
broadcast("USER: %s; NODE:%d; STATUS: Browsing their Emails.", gUser->loginname, mynode);
|
||||||
list_emails(gUser);
|
list_emails(gUser);
|
||||||
break;
|
break;
|
||||||
case MENU_NEXTMAILCONF:
|
case MENU_NEXTMAILCONF:
|
||||||
@ -493,28 +510,35 @@ int menu_system(char *menufile) {
|
|||||||
prev_mail_area(gUser);
|
prev_mail_area(gUser);
|
||||||
break;
|
break;
|
||||||
case MENU_BLUEWAVEDOWN:
|
case MENU_BLUEWAVEDOWN:
|
||||||
|
broadcast("USER: %s; NODE:%d; STATUS: Downloading Bluewave Packet.", gUser->loginname, mynode);
|
||||||
bwave_create_packet();
|
bwave_create_packet();
|
||||||
break;
|
break;
|
||||||
case MENU_BLUEWAVEUP:
|
case MENU_BLUEWAVEUP:
|
||||||
|
broadcast("USER: %s; NODE:%d; STATUS: Uploading Bluewave Packet.", gUser->loginname, mynode);
|
||||||
bwave_upload_reply();
|
bwave_upload_reply();
|
||||||
break;
|
break;
|
||||||
case MENU_CHOOSEFILEDIR:
|
case MENU_CHOOSEFILEDIR:
|
||||||
|
broadcast("USER: %s; NODE:%d; STATUS: Choosing a file directory.", gUser->loginname, mynode);
|
||||||
choose_directory();
|
choose_directory();
|
||||||
break;
|
break;
|
||||||
case MENU_CHOOSEFILESUB:
|
case MENU_CHOOSEFILESUB:
|
||||||
|
broadcast("USER: %s; NODE:%d; STATUS: Choosing a file sub-directory.", gUser->loginname, mynode);
|
||||||
choose_subdir();
|
choose_subdir();
|
||||||
break;
|
break;
|
||||||
case MENU_LISTFILES:
|
case MENU_LISTFILES:
|
||||||
|
broadcast("USER: %s; NODE:%d; STATUS: Browsing Files.", gUser->loginname, mynode);
|
||||||
list_files(gUser);
|
list_files(gUser);
|
||||||
break;
|
break;
|
||||||
case MENU_UPLOAD:
|
case MENU_UPLOAD:
|
||||||
if (gUser->sec_level >= conf.file_directories[gUser->cur_file_dir]->file_subs[gUser->cur_file_sub]->upload_sec_level) {
|
if (gUser->sec_level >= conf.file_directories[gUser->cur_file_dir]->file_subs[gUser->cur_file_sub]->upload_sec_level) {
|
||||||
|
broadcast("USER: %s; NODE:%d; STATUS: Uploading a File.", gUser->loginname, mynode);
|
||||||
upload(gUser);
|
upload(gUser);
|
||||||
} else {
|
} else {
|
||||||
s_printf(get_string(84));
|
s_printf(get_string(84));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MENU_DOWNLOAD:
|
case MENU_DOWNLOAD:
|
||||||
|
broadcast("USER: %s; NODE:%d; STATUS: Downloading Files.", gUser->loginname, mynode);
|
||||||
download(gUser);
|
download(gUser);
|
||||||
break;
|
break;
|
||||||
case MENU_CLEARTAGGEDFILES:
|
case MENU_CLEARTAGGEDFILES:
|
||||||
@ -536,12 +560,15 @@ int menu_system(char *menufile) {
|
|||||||
list_messages(gUser);
|
list_messages(gUser);
|
||||||
break;
|
break;
|
||||||
case MENU_DOSCRIPT:
|
case MENU_DOSCRIPT:
|
||||||
|
broadcast("USER: %s; NODE:%d; STATUS: Executing a script %s.", gUser->loginname, mynode, menu[i]->data[j]);
|
||||||
do_lua_script(menu[i]->data[j]);
|
do_lua_script(menu[i]->data[j]);
|
||||||
break;
|
break;
|
||||||
case MENU_SENDNODEMSG:
|
case MENU_SENDNODEMSG:
|
||||||
|
broadcast("USER: %s; NODE:%d; STATUS: Sending a node Message.", gUser->loginname, mynode);
|
||||||
send_node_msg();
|
send_node_msg();
|
||||||
break;
|
break;
|
||||||
case MENU_SUBUNSUBCONF:
|
case MENU_SUBUNSUBCONF:
|
||||||
|
broadcast("USER: %s; NODE:%d; STATUS: Subscribing to conferences.", gUser->loginname, mynode);
|
||||||
msg_conf_sub_bases();
|
msg_conf_sub_bases();
|
||||||
break;
|
break;
|
||||||
case MENU_RESETPOINTERS:
|
case MENU_RESETPOINTERS:
|
||||||
@ -577,13 +604,16 @@ int menu_system(char *menufile) {
|
|||||||
msgbase_reset_all_pointers(m);
|
msgbase_reset_all_pointers(m);
|
||||||
break;
|
break;
|
||||||
case MENU_FILESCAN:
|
case MENU_FILESCAN:
|
||||||
|
broadcast("USER: %s; NODE:%d; STATUS: Doing a filescan.", gUser->loginname, mynode);
|
||||||
file_scan();
|
file_scan();
|
||||||
break;
|
break;
|
||||||
case MENU_FULLMAILSCAN:
|
case MENU_FULLMAILSCAN:
|
||||||
if (menu[i]->data[j] != NULL) {
|
if (menu[i]->data[j] != NULL) {
|
||||||
if (strcasecmp(menu[i]->data[j], "PERSONAL") == 0) {
|
if (strcasecmp(menu[i]->data[j], "PERSONAL") == 0) {
|
||||||
|
broadcast("USER: %s; NODE:%d; STATUS: Scanning for personal mail.", gUser->loginname, mynode);
|
||||||
full_mail_scan_personal(gUser);
|
full_mail_scan_personal(gUser);
|
||||||
} else {
|
} else {
|
||||||
|
broadcast("USER: %s; NODE:%d; STATUS: Scanning all mail.", gUser->loginname, mynode);
|
||||||
full_mail_scan(gUser);
|
full_mail_scan(gUser);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -591,15 +621,18 @@ int menu_system(char *menufile) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MENU_FILESEARCH:
|
case MENU_FILESEARCH:
|
||||||
|
broadcast("USER: %s; NODE:%d; STATUS: Executing a filesearch.", gUser->loginname, mynode);
|
||||||
file_search();
|
file_search();
|
||||||
break;
|
break;
|
||||||
case MENU_DISPTXTFILE:
|
case MENU_DISPTXTFILE:
|
||||||
if (menu[i]->data[j] != NULL) {
|
if (menu[i]->data[j] != NULL) {
|
||||||
|
broadcast("USER: %s; NODE:%d; STATUS: Displaying Text File: %s.", gUser->loginname, mynode, menu[i]->data[j]);
|
||||||
s_displayansi_pause(menu[i]->data[j], 0);
|
s_displayansi_pause(menu[i]->data[j], 0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MENU_DISPTXTFILEPAUSE:
|
case MENU_DISPTXTFILEPAUSE:
|
||||||
if (menu[i]->data[j] != NULL) {
|
if (menu[i]->data[j] != NULL) {
|
||||||
|
broadcast("USER: %s; NODE:%d; STATUS: Displaying Text File: %s.", gUser->loginname, mynode, menu[i]->data[j]);
|
||||||
s_displayansi_pause(menu[i]->data[j], 1);
|
s_displayansi_pause(menu[i]->data[j], 1);
|
||||||
}
|
}
|
||||||
s_printf(get_string(6));
|
s_printf(get_string(6));
|
||||||
@ -609,12 +642,14 @@ int menu_system(char *menufile) {
|
|||||||
genurls();
|
genurls();
|
||||||
break;
|
break;
|
||||||
case MENU_NLBROWSER:
|
case MENU_NLBROWSER:
|
||||||
|
broadcast("USER: %s; NODE:%d; STATUS: Executing a filesearch.", gUser->loginname, mynode);
|
||||||
nl_browser();
|
nl_browser();
|
||||||
break;
|
break;
|
||||||
case MENU_SENDFEEDBACK:
|
case MENU_SENDFEEDBACK:
|
||||||
if (check_user(conf.sysop_name)) {
|
if (check_user(conf.sysop_name)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
broadcast("USER: %s; NODE:%d; STATUS: Sending feedback to Sysop.", gUser->loginname, mynode);
|
||||||
msg = external_editor(gUser, conf.sysop_name, gUser->loginname, NULL, 0, NULL, "Feedback", 1, 0);
|
msg = external_editor(gUser, conf.sysop_name, gUser->loginname, NULL, 0, NULL, "Feedback", 1, 0);
|
||||||
if (msg != NULL) {
|
if (msg != NULL) {
|
||||||
commit_email(conf.sysop_name, "Feedback", msg);
|
commit_email(conf.sysop_name, "Feedback", msg);
|
||||||
@ -622,9 +657,11 @@ int menu_system(char *menufile) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MENU_BLOGDISPLAY:
|
case MENU_BLOGDISPLAY:
|
||||||
|
broadcast("USER: %s; NODE:%d; STATUS: Displaying Blog.", gUser->loginname, mynode);
|
||||||
blog_display();
|
blog_display();
|
||||||
break;
|
break;
|
||||||
case MENU_BLOGWRITE:
|
case MENU_BLOGWRITE:
|
||||||
|
broadcast("USER: %s; NODE:%d; STATUS: Writing a Blog Entry.", gUser->loginname, mynode);
|
||||||
blog_write();
|
blog_write();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
Reference in New Issue
Block a user