Commit a8a06fd6 authored by Rob Swindell's avatar Rob Swindell 💬
Browse files

Over-overhaul of MQTT support

Each Synchronet server is now its own MQTT client. This means there's no
longer any MQTT logic in the Synchronet "hosts" (e.g. sbbscon.c, ctrl/*.cpp)
and none needed for SBBS NT services (they'll "just work" with MQTT).

This also means that just about everything (except for nodes, spam and hack)
is now published per-server (in the sbbs/BBS-ID/hostname/server/ topic branch)
and if you want aggregated totals or client lists, you'll have to do that in
your own MQTT client or dashboard.

I also removed the publishing of thread_count and socket_count topics as
they weren't universally supported across all servers and are of questionable
value. They can be added back later if determined to be useful.
parent 7da26d40
Pipeline #3587 passed with stage
in 6 minutes and 4 seconds
......@@ -582,7 +582,7 @@ bool sbbs_t::update_nodeterm(void)
,mouse_mode
,console
);
mqtt_pub_strval((struct startup*)startup, TOPIC_BBS, topic, str);
mqtt_pub_strval(mqtt, TOPIC_BBS, topic, str);
}
return result;
}
......
......@@ -171,7 +171,6 @@ static void thread_up(void* p, BOOL up, BOOL setuid)
threads++;
else if(threads>0)
threads--;
mqtt_thread_count((struct startup*)&MainForm->bbs_startup, TOPIC_HOST, threads);
ReleaseMutex(mutex);
}
......@@ -189,7 +188,6 @@ void socket_open(void* p, BOOL open)
sockets++;
else if(sockets>0)
sockets--;
mqtt_socket_count((struct startup*)&MainForm->bbs_startup, TOPIC_HOST, sockets);
ReleaseMutex(mutex);
}
......@@ -203,10 +201,8 @@ static void client_add(void* p, BOOL add)
if(add) {
clients++;
total_clients++;
mqtt_served_count((struct startup*)&MainForm->bbs_startup, TOPIC_HOST, total_clients);
} else if(clients>0)
clients--;
mqtt_client_count((struct startup*)&MainForm->bbs_startup, TOPIC_HOST, clients);
}
static void client_on(void* p, BOOL on, int sock, client_t* client, BOOL update)
......@@ -217,8 +213,6 @@ static void client_on(void* p, BOOL on, int sock, client_t* client, BOOL update)
static HANDLE mutex;
TListItem* Item;
mqtt_client_on((struct startup*)&MainForm->bbs_startup, on, sock, client, update);
if(!mutex)
mutex=CreateMutex(NULL,false,NULL);
WaitForSingleObject(mutex,INFINITE);
......@@ -338,7 +332,6 @@ static void bbs_set_state(void* p, enum server_state state)
{
TelnetForm->Status->Caption = server_state_str(state);
mqtt_server_state((struct startup*)&MainForm->bbs_startup, state);
switch(state) {
case SERVER_STOPPED:
MainForm->TelnetStart->Enabled=true;
......@@ -436,7 +429,6 @@ static void services_set_state(void* p, enum server_state state)
{
ServicesForm->Status->Caption = server_state_str(state);
mqtt_server_state((struct startup*)&MainForm->services_startup, state);
switch(state) {
case SERVER_STOPPED:
MainForm->ServicesStart->Enabled=true;
......@@ -503,7 +495,6 @@ static void mail_set_state(void* p, enum server_state state)
{
MailForm->Status->Caption = server_state_str(state);
mqtt_server_state((struct startup*)&MainForm->mail_startup, state);
switch(state) {
case SERVER_STOPPED:
MainForm->MailStart->Enabled=true;
......@@ -599,7 +590,6 @@ static void ftp_set_state(void* p, enum server_state state)
{
FtpForm->Status->Caption = server_state_str(state);
mqtt_server_state((struct startup*)&MainForm->ftp_startup, state);
switch(state) {
case SERVER_STOPPED:
MainForm->FtpStart->Enabled=true;
......@@ -668,7 +658,6 @@ static void web_set_state(void* p, enum server_state state)
{
WebForm->Status->Caption = server_state_str(state);
mqtt_server_state((struct startup*)&MainForm->web_startup, state);
switch(state) {
case SERVER_STOPPED:
MainForm->WebStart->Enabled=true;
......@@ -1054,7 +1043,6 @@ BOOL __fastcall TMainForm::servicesServiceEnabled(void)
//---------------------------------------------------------------------------
void __fastcall TMainForm::FormClose(TObject *Sender, TCloseAction &Action)
{
mqtt_terminating((struct startup*)&bbs_startup);
UpTimer->Enabled=false; /* Stop updating the status bar */
StatsTimer->Enabled=false;
......@@ -1083,14 +1071,12 @@ void __fastcall TMainForm::FormClose(TObject *Sender, TCloseAction &Action)
}
StatusBar->Panels->Items[STATUSBAR_LAST_PANEL]->Text="Closing...";
Application->ProcessMessages();
mqtt_terminating((struct startup*)&bbs_startup);
LogTimer->Enabled=false;
ServiceStatusTimer->Enabled=false;
NodeForm->Timer->Enabled=false;
ClientForm->Timer->Enabled=false;
mqtt_shutdown((struct startup*)&bbs_startup);
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::FormCloseQuery(TObject *Sender, bool &CanClose)
......@@ -1970,22 +1956,7 @@ void __fastcall TMainForm::StartupTimerTick(TObject *Sender)
StartupTimer->Interval = 2500; // Let 'em see the logo for a bit
StartupTimer->Enabled = true;
} else {
if(!bbsServiceEnabled()) {
bbs_startup.startup[SERVER_TERM] = (struct startup*)&bbs_startup;
bbs_startup.startup[SERVER_FTP] = (struct startup*)&ftp_startup;
bbs_startup.startup[SERVER_WEB] = (struct startup*)&web_startup;
bbs_startup.startup[SERVER_MAIL] = (struct startup*)&mail_startup;
bbs_startup.startup[SERVER_SERVICES] = (struct startup*)&services_startup;
mqtt_startup((struct startup*)&bbs_startup, &cfg, ver()
,/* lputs: */NULL
,/* shared_client_list: */TRUE);
ftp_startup.mqtt = bbs_startup.mqtt;
web_startup.mqtt = bbs_startup.mqtt;
mail_startup.mqtt = bbs_startup.mqtt;
services_startup.mqtt = bbs_startup.mqtt;
}
DisplayMainPanels(Sender);
mqtt_online((struct startup*)&bbs_startup);
}
Initialized=true;
}
......
......@@ -78,6 +78,7 @@ const char* server_abbrev = "ftp";
static ftp_startup_t* startup=NULL;
static scfg_t scfg;
static struct mqtt mqtt;
static struct xpms_set *ftp_set = NULL;
static protected_uint32_t active_clients;
static protected_uint32_t thread_count;
......@@ -127,6 +128,28 @@ BOOL dir_op(scfg_t* cfg, user_t* user, client_t* client, uint dirnum)
return is_user_dirop(cfg, dirnum, user, client);
}
static int lputs(int level, const char* str)
{
mqtt_lputs(&mqtt, TOPIC_SERVER, level, str);
if(level <= LOG_ERR) {
char errmsg[1024];
errorlog(&scfg, &mqtt, level, startup == NULL ? NULL : startup->host_name, str);
SAFEPRINTF2(errmsg, "%s %s", server_abbrev, str);
if(startup != NULL && startup->errormsg != NULL)
startup->errormsg(startup->cbdata, level, errmsg);
}
if(startup == NULL || startup->lputs == NULL || str == NULL || level > startup->log_level)
return 0;
#if defined(_WIN32)
if(IsBadCodePtr((FARPROC)startup->lputs))
return 0;
#endif
return startup->lputs(startup->cbdata,level,str);
}
#if defined(__GNUC__) // Catch printf-format errors with lprintf
static int lprintf(int level, const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
#endif
......@@ -140,25 +163,7 @@ static int lprintf(int level, const char *fmt, ...)
sbuf[sizeof(sbuf)-1]=0;
va_end(argptr);
if(level <= LOG_ERR) {
char errmsg[sizeof(sbuf)+16];
errorlog(&scfg, (struct startup*)startup, level, startup==NULL ? NULL:startup->host_name, sbuf);
SAFEPRINTF2(errmsg, "%s %s", server_abbrev, sbuf);
if(startup!=NULL && startup->errormsg!=NULL)
startup->errormsg(startup->cbdata,level,errmsg);
}
if(startup != NULL)
mqtt_lputs((struct startup*)startup, TOPIC_SERVER, level, sbuf);
if(startup==NULL || startup->lputs==NULL || level > startup->log_level)
return(0);
#if defined(_WIN32)
if(IsBadCodePtr((FARPROC)startup->lputs))
return(0);
#endif
return startup->lputs(startup->cbdata,level,sbuf);
return lputs(level, sbuf);
}
#ifdef _WINSOCKAPI_
......@@ -199,7 +204,7 @@ static void set_state(enum server_state state)
if(startup != NULL) {
if(startup->set_state != NULL)
startup->set_state(startup->cbdata, state);
mqtt_server_state((struct startup*)startup, state);
mqtt_server_state(&mqtt, state);
}
}
......@@ -209,7 +214,6 @@ static void update_clients(void)
uint32_t count = protected_uint32_value(active_clients);
if(startup->clients != NULL)
startup->clients(startup->cbdata, count);
mqtt_client_count((struct startup*)startup, TOPIC_SERVER, count);
}
}
......@@ -219,6 +223,7 @@ static void client_on(SOCKET sock, client_t* client, BOOL update)
listAddNodeData(&current_connections, client->addr, strlen(client->addr) + 1, sock, LAST_NODE);
if(startup!=NULL && startup->client_on!=NULL)
startup->client_on(startup->cbdata,TRUE,sock,client,update);
mqtt_client_on(&mqtt, TRUE, sock, client, update);
}
static void client_off(SOCKET sock)
......@@ -226,6 +231,7 @@ static void client_off(SOCKET sock)
listRemoveTaggedNode(&current_connections, sock, /* free_data */TRUE);
if(startup!=NULL && startup->client_on!=NULL)
startup->client_on(startup->cbdata,FALSE,sock,NULL,FALSE);
mqtt_client_on(&mqtt, FALSE, sock, NULL, FALSE);
}
static void thread_up(BOOL setuid)
......@@ -233,7 +239,6 @@ static void thread_up(BOOL setuid)
if(startup != NULL) {
if(startup->thread_up != NULL)
startup->thread_up(startup->cbdata,TRUE, setuid);
mqtt_thread_count((struct startup*)startup, TOPIC_SERVER, protected_uint32_value(thread_count));
}
}
......@@ -243,7 +248,6 @@ static int32_t thread_down(void)
if(startup != NULL) {
if(startup->thread_up != NULL)
startup->thread_up(startup->cbdata,FALSE, FALSE);
mqtt_thread_count((struct startup*)startup, TOPIC_SERVER, count);
}
return count;
}
......@@ -1726,7 +1730,7 @@ static BOOL ftp_hacklog(char* prot, char* user, char* text, char* host, union xp
PlaySound(startup->sound.hack, NULL, SND_ASYNC|SND_FILENAME);
#endif
return hacklog(&scfg, (struct startup*)startup, prot, user, text, host, addr);
return hacklog(&scfg, &mqtt, prot, user, text, host, addr);
}
/****************************************************************************/
......@@ -4888,6 +4892,8 @@ static void cleanup(int code, int line)
thread_down();
if(terminate_server || code)
lprintf(LOG_INFO,"#### FTP Server thread terminated (%lu clients served)", served);
set_state(SERVER_STOPPED);
mqtt_shutdown(&mqtt);
if(startup!=NULL && startup->terminated!=NULL)
startup->terminated(startup->cbdata,code);
}
......@@ -4955,8 +4961,6 @@ void ftp_server(void* arg)
}
set_state(SERVER_INIT);
mqtt_server_version((struct startup*)startup, ftp_ver());
uptime=0;
served=0;
startup->recycle_now=FALSE;
......@@ -5019,6 +5023,8 @@ void ftp_server(void* arg)
break;
}
mqtt_startup(&mqtt, &scfg, (struct startup*)startup, ftp_ver(), lputs);
if((t=checktime())!=0) { /* Check binary time */
lprintf(LOG_ERR,"!TIME PROBLEM (%ld)",t);
}
......@@ -5064,8 +5070,6 @@ void ftp_server(void* arg)
update_clients();
strlwr(scfg.sys_id); /* Use lower-case unix-looking System ID for group name */
/* open a socket and wait for a client */
ftp_set = xpms_create(startup->bind_retry_count, startup->bind_retry_delay, lprintf);
......@@ -5096,7 +5100,7 @@ void ftp_server(void* arg)
set_state(SERVER_READY);
lprintf(LOG_INFO,"FTP Server thread started");
mqtt_client_max((struct startup*)startup, startup->max_clients);
mqtt_client_max(&mqtt, startup->max_clients);
while(ftp_set!=NULL && !terminate_server) {
YIELD();
......@@ -5212,6 +5216,4 @@ void ftp_server(void* arg)
} while(!terminate_server);
protected_uint32_destroy(thread_count);
set_state(SERVER_STOPPED);
}
......@@ -20,12 +20,13 @@
****************************************************************************/
#include "sbbs.h"
#include "mqtt.h"
#include "git_branch.h"
#include "git_hash.h"
const char* log_line_ending = "\r\n";
extern "C" BOOL hacklog(scfg_t* cfg, struct startup* startup, const char* prot, const char* user, const char* text, const char* host, union xp_sockaddr* addr)
extern "C" BOOL hacklog(scfg_t* cfg, struct mqtt* mqtt, const char* prot, const char* user, const char* text, const char* host, union xp_sockaddr* addr)
{
char tstr[64];
char fname[MAX_PATH+1];
......@@ -54,12 +55,12 @@ extern "C" BOOL hacklog(scfg_t* cfg, struct startup* startup, const char* prot,
fputs(log_line_ending, fp);
fcloselog(fp);
if(startup != NULL) {
if(mqtt != NULL) {
char str[1024];
if(text == NULL)
text= "";
snprintf(str, sizeof(str), "%s\t%s\t%u\t%s\t%s\t%s", prot, user, inet_addrport(addr), host, ip, text);
mqtt_pub_strval(startup, TOPIC_HOST, "hack", str);
mqtt_pub_strval(mqtt, TOPIC_HOST, "hack", str);
}
return true;
......@@ -67,10 +68,10 @@ extern "C" BOOL hacklog(scfg_t* cfg, struct startup* startup, const char* prot,
BOOL sbbs_t::hacklog(const char* prot, const char* text)
{
return ::hacklog(&cfg, (struct startup*)startup, prot, useron.alias, text, client_name, &client_addr);
return ::hacklog(&cfg, mqtt, prot, useron.alias, text, client_name, &client_addr);
}
extern "C" BOOL spamlog(scfg_t* cfg, struct startup* startup, char* prot, char* action
extern "C" BOOL spamlog(scfg_t* cfg, struct mqtt* mqtt, char* prot, char* action
,char* reason, char* host, char* ip_addr
,char* to, char* from)
{
......@@ -110,18 +111,18 @@ extern "C" BOOL spamlog(scfg_t* cfg, struct startup* startup, char* prot, char*
fputs(log_line_ending, fp);
fcloselog(fp);
if(startup != NULL) {
if(mqtt != NULL) {
char str[1024];
if(reason == NULL)
reason = (char*)"";
snprintf(str, sizeof(str), "%s\t%s\t%s\t%s\t%s\t%s\t%s", prot, action, host, ip_addr, from, to_user, reason);
mqtt_pub_strval(startup, TOPIC_HOST, "spam", str);
mqtt_pub_strval(mqtt, TOPIC_HOST, "spam", str);
}
return true;
}
extern "C" int errorlog(scfg_t* cfg, struct startup* startup, int level, const char* host, const char* text)
extern "C" int errorlog(scfg_t* cfg, struct mqtt* mqtt, int level, const char* host, const char* text)
{
FILE* fp;
char buf[128];
......@@ -150,7 +151,7 @@ extern "C" int errorlog(scfg_t* cfg, struct startup* startup, int level, const c
SAFEPRINTF2(subject, "%s %sERROR occurred", host, level <= LOG_CRIT ? "CRITICAL " : "");
notify(cfg, cfg->node_erruser, subject, text);
}
mqtt_errormsg(startup, level, text);
mqtt_errormsg(mqtt, level, text);
return 0;
}
......
......@@ -145,7 +145,7 @@ void sbbs_t::badlogin(const char* user, const char* passwd, const char* protocol
count=loginFailure(startup->login_attempt_list, addr, protocol, user, passwd);
if(user!=NULL && startup->login_attempt.hack_threshold && count>=startup->login_attempt.hack_threshold) {
getnameinfo(&addr->addr, addr_len, host_name, sizeof(host_name), NULL, 0, NI_NAMEREQD);
::hacklog(&cfg, (struct startup*)startup, reason, user, passwd, host_name, addr);
::hacklog(&cfg, mqtt, reason, user, passwd, host_name, addr);
#ifdef _WIN32
if(startup->sound.hack[0] && !sound_muted(&cfg))
PlaySound(startup->sound.hack, NULL, SND_ASYNC|SND_FILENAME);
......
......@@ -94,6 +94,7 @@ static link_list_t current_logins;
static link_list_t current_connections;
static bool savemsg_mutex_created = false;
static pthread_mutex_t savemsg_mutex;
static struct mqtt mqtt;
static const char* servprot_smtp = "SMTP";
static const char* servprot_submission = "SMTP";
......@@ -176,6 +177,33 @@ typedef struct {
} \
} while(0)
static int lputs(int level, const char* str)
{
mqtt_lputs(&mqtt, TOPIC_SERVER, level, str);
if(level <= LOG_ERR) {
char errmsg[1024];
errorlog(&scfg, &mqtt, level, startup == NULL ? NULL : startup->host_name, str);
stats.errors++;
SAFEPRINTF2(errmsg, "%s %s", server_abbrev, str);
if(startup != NULL && startup->errormsg != NULL)
startup->errormsg(startup->cbdata, level, errmsg);
}
if(level <= LOG_CRIT)
stats.crit_errors++;
if(startup == NULL || startup->lputs == NULL || str == NULL || level > startup->log_level)
return 0;
#if defined(_WIN32)
if(IsBadCodePtr((FARPROC)startup->lputs))
return 0;
#endif
return startup->lputs(startup->cbdata,level,str);
}
#if defined(__GNUC__) // Catch printf-format errors with lprintf
static int lprintf(int level, const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
#endif
......@@ -189,29 +217,7 @@ static int lprintf(int level, const char *fmt, ...)
sbuf[sizeof(sbuf)-1]=0;
va_end(argptr);
if(level <= LOG_ERR) {
char errmsg[sizeof(sbuf)+16];
errorlog(&scfg, (struct startup*)startup, level, startup==NULL ? NULL:startup->host_name, sbuf), stats.errors++;
SAFEPRINTF2(errmsg, "%s %s", server_abbrev, sbuf);
if(startup!=NULL && startup->errormsg!=NULL)
startup->errormsg(startup->cbdata,level,errmsg);
}
if(level <= LOG_CRIT)
stats.crit_errors++;
if(startup != NULL)
mqtt_lputs((struct startup*)startup, TOPIC_SERVER, level, sbuf);
if(startup==NULL || startup->lputs==NULL || level > startup->log_level)
return(0);
#if defined(_WIN32)
if(IsBadCodePtr((FARPROC)startup->lputs))
return(0);
#endif
return(startup->lputs(startup->cbdata, level, condense_whitespace(sbuf)));
return lputs(level, condense_whitespace(sbuf));
}
#ifdef _WINSOCKAPI_
......@@ -251,7 +257,7 @@ static void set_state(enum server_state state)
if(startup != NULL) {
if(startup->set_state != NULL)
startup->set_state(startup->cbdata, state);
mqtt_server_state((struct startup*)startup, state);
mqtt_server_state(&mqtt, state);
}
}
......@@ -260,7 +266,6 @@ static void update_clients(void)
if(startup != NULL) {
if(startup->clients != NULL)
startup->clients(startup->cbdata,protected_uint32_value(active_clients)+active_sendmail);
mqtt_client_count((struct startup*)startup, TOPIC_SERVER, protected_uint32_value(active_clients));
}
}
......@@ -270,6 +275,7 @@ static void client_on(SOCKET sock, client_t* client, BOOL update)
listAddNodeData(&current_connections, client->addr, strlen(client->addr)+1, sock, LAST_NODE);
if(startup!=NULL && startup->client_on!=NULL)
startup->client_on(startup->cbdata,TRUE,sock,client,update);
mqtt_client_on(&mqtt, TRUE, sock, client, update);
}
static void client_off(SOCKET sock)
......@@ -277,6 +283,7 @@ static void client_off(SOCKET sock)
listRemoveTaggedNode(&current_connections, sock, /* free_data */TRUE);
if(startup!=NULL && startup->client_on!=NULL)
startup->client_on(startup->cbdata,FALSE,sock,NULL,FALSE);
mqtt_client_on(&mqtt, FALSE, sock, NULL, FALSE);
}
static void thread_up(BOOL setuid)
......@@ -284,7 +291,6 @@ static void thread_up(BOOL setuid)
if(startup != NULL) {
if(startup->thread_up != NULL)
startup->thread_up(startup->cbdata,TRUE,setuid);
mqtt_thread_count((struct startup*)startup, TOPIC_SERVER, protected_uint32_value(thread_count));
}
}
......@@ -294,7 +300,6 @@ static int32_t thread_down(void)
if(startup != NULL) {
if(startup->thread_up != NULL)
startup->thread_up(startup->cbdata,FALSE,FALSE);
mqtt_thread_count((struct startup*)startup, TOPIC_SERVER, count);
}
return count;
}
......@@ -312,8 +317,6 @@ void mail_open_socket(SOCKET sock, void* cb_protocol)
lprintf(LOG_ERR,"%04d %s !ERROR %s", sock, protocol, error);
stats.sockets++;
if(startup != NULL)
mqtt_socket_count((struct startup*)startup, TOPIC_SERVER, stats.sockets);
}
void mail_close_socket_cb(SOCKET sock, void* cb_protocol)
......@@ -321,8 +324,6 @@ void mail_close_socket_cb(SOCKET sock, void* cb_protocol)
if(startup!=NULL && startup->socket_open!=NULL)
startup->socket_open(startup->cbdata,FALSE);
stats.sockets--;
if(startup != NULL)
mqtt_socket_count((struct startup*)startup, TOPIC_SERVER, stats.sockets);
}
int mail_close_socket(SOCKET *sock, int *sess)
......@@ -341,8 +342,6 @@ int mail_close_socket(SOCKET *sock, int *sess)
if(startup!=NULL && startup->socket_open!=NULL)
startup->socket_open(startup->cbdata,FALSE);
stats.sockets--;
if(startup != NULL)
mqtt_socket_count((struct startup*)startup, TOPIC_SERVER, stats.sockets);
if(result!=0) {
if(ERROR_VALUE!=ENOTSOCK)
lprintf(LOG_WARNING,"%04d !ERROR %d closing socket",*sock, ERROR_VALUE);
......@@ -981,7 +980,7 @@ static void badlogin(SOCKET sock, CRYPT_SESSION sess, const char* prot, const ch
SAFEPRINTF(reason,"%s LOGIN", prot);
count=loginFailure(startup->login_attempt_list, addr, prot, user, passwd);
if(startup->login_attempt.hack_threshold && count>=startup->login_attempt.hack_threshold) {
hacklog(&scfg, (struct startup*)startup, reason, user, passwd, host, addr);
hacklog(&scfg, &mqtt, reason, user, passwd, host, addr);
#ifdef _WIN32
if(startup->sound.hack[0] && !sound_muted(&scfg))
PlaySound(startup->sound.hack, NULL, SND_ASYNC|SND_FILENAME);
......@@ -1916,7 +1915,7 @@ static BOOL chk_email_addr(SOCKET socket, const char* prot, char* p, char* host_
lprintf(LOG_NOTICE,"%04d %s [%s] !BLOCKED %s e-mail address: %s"
,socket, prot, host_ip, source, addr);
SAFEPRINTF2(tmp,"Blocked %s e-mail address: %s", source, addr);
spamlog(&scfg, (struct startup*)startup, (char*)prot, "REFUSED", tmp, host_name, host_ip, to, from);
spamlog(&scfg, &mqtt, (char*)prot, "REFUSED", tmp, host_name, host_ip, to, from);
return(FALSE);
}
......@@ -3112,7 +3111,7 @@ static void smtp_thread(void* arg)
,socket, client.protocol, dnsbl_ip, dnsbl, host_name, inet_ntoa(dnsbl_result));
if(startup->options&MAIL_OPT_DNSBL_REFUSE) {
SAFEPRINTF2(str,"Listed on %s as %s", dnsbl, inet_ntoa(dnsbl_result));
spamlog(&scfg, (struct startup*)startup, (char*)client.protocol, "SESSION REFUSED", str, host_name, dnsbl_ip, NULL, NULL);
spamlog(&scfg, &mqtt, (char*)client.protocol, "SESSION REFUSED", str, host_name, dnsbl_ip, NULL, NULL);
sockprintf(socket,client.protocol,session
,"550 Mail from %s refused due to listing at %s"
,dnsbl_ip, dnsbl);
......@@ -3238,7 +3237,7 @@ static void smtp_thread(void* arg)
lprintf(LOG_NOTICE,"%04d %s %s !FILTERING TWIT-LISTED SENDER: '%s' <%s> (%lu total)"
,socket, client.protocol, client_id, sender, sender_addr, ++stats.msgs_refused);
SAFEPRINTF2(tmp,"Twit-listed sender: '%s' <%s>", sender, sender_addr);
spamlog(&scfg, (struct startup*)startup, (char*)client.protocol, "REFUSED", tmp, host_name, host_ip, rcpt_addr, reverse_path);
spamlog(&scfg, &mqtt, (char*)client.protocol, "REFUSED", tmp, host_name, host_ip, rcpt_addr, reverse_path);
sockprintf(socket,client.protocol,session, "554 Sender not allowed.");
continue;
}
......@@ -3512,7 +3511,7 @@ static void smtp_thread(void* arg)
,socket, client.protocol, client_id, p, reverse_path, ++stats.msgs_refused);
SAFEPRINTF2(tmp,"Blocked subject (%s) from: %s"
,p, reverse_path);
spamlog(&scfg, (struct startup*)startup, (char*)client.protocol, "REFUSED"
spamlog(&scfg, &mqtt, (char*)client.protocol, "REFUSED"
,tmp, host_name, host_ip, rcpt_addr, reverse_path);
errmsg="554 Subject not allowed.";
smb_error=SMB_FAILURE;
......@@ -3615,7 +3614,7 @@ static void smtp_thread(void* arg)
}
if(startup->dnsbl_hdr[0] || startup->dnsbl_tag[0]) {
SAFEPRINTF2(str,"Listed on %s as %s", dnsbl, inet_ntoa(dnsbl_result));
spamlog(&scfg, (struct startup*)startup, (char*)client.protocol, "TAGGED", str, host_name, dnsbl_ip, rcpt_addr, reverse_path);
spamlog(&scfg, &mqtt, (char*)client.protocol, "TAGGED", str, host_name, dnsbl_ip, rcpt_addr, reverse_path);
}
}
if(dnsbl_recvhdr) /* DNSBL-listed IP found in Received header? */
......@@ -3804,7 +3803,7 @@ static void smtp_thread(void* arg)
);
lprintf(LOG_NOTICE,"%04d %s %s Message from %s %s", socket, client.protocol, client_id, sender_info, str);
if(!is_spam) {
spamlog(&scfg, (struct startup*)startup, (char*)client.protocol, "IGNORED"
spamlog(&scfg, &mqtt, (char*)client.protocol, "IGNORED"
,str, host_name, host_ip, rcpt_addr, reverse_path);
is_spam=TRUE;
}
......@@ -3849,7 +3848,7 @@ static void smtp_thread(void* arg)
SAFEPRINTF2(str,"Listed on %s as %s", dnsbl, inet_ntoa(dnsbl_result));
lprintf(LOG_NOTICE,"%04d %s %s !IGNORED MAIL from %s to <%s> from server: %s (%lu total)"
,socket, client.protocol, client_id, sender_info, rcpt_addr, str, ++stats.msgs_ignored);
spamlog(&scfg, (struct startup*)startup, (char*)client.protocol, "IGNORED"
spamlog(&scfg, &mqtt, (char*)client.protocol, "IGNORED"
,str, host_name, dnsbl_ip, rcpt_addr, reverse_path);
}
/* pretend we received it */
......@@ -4508,7 +4507,7 @@ static void smtp_thread(void* arg)
lprintf(LOG_NOTICE,"%04d %s %s !MAXIMUM RECIPIENTS (%d) REACHED"
,socket, client.protocol, client_id, startup->max_recipients);
SAFEPRINTF(tmp,"Maximum recipient count (%d)",startup->max_recipients);
spamlog(&scfg, (struct startup*)startup, (char*)client.protocol, "REFUSED", tmp
spamlog(&scfg, &mqtt, (char*)client.protocol, "REFUSED", tmp
,host_name, host_ip, rcpt_addr, reverse_path);
sockprintf(socket,client.protocol,session, "452 Too many recipients");
stats.msgs_refused++;
......@@ -4530,7 +4529,7 @@ static void smtp_thread(void* arg)
,socket, client.protocol, client_id, scfg.level_emailperday[relay_user.level], relay_user.number, relay_user.alias);