Loading src/server/replay.c +9 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,8 @@ #include <rooms.h> #include <talker_privs.h> #include <ipc.h> #include <perms.h> #include <special.h> #include "servsock.h" #include "replay.h" Loading Loading @@ -185,6 +187,13 @@ void replay(ipc_connection_t *conn, ipc_message_t *msg) json_decref(j); continue; } if (store[idx]->head.type == IPC_WIZ) { if (s_wizchat(&user)) { /* we are a wiz, we see this */ msg_attach(store[idx], conn); } continue; } /* send them everything else */ if (store[idx]->head.dst) Loading src/server/servsock.c +41 −0 Original line number Diff line number Diff line Loading @@ -408,6 +408,14 @@ void process_msg(ipc_connection_t *conn, ipc_message_t *msg) if (msg->head.type == IPC_EVENT) { printf("Event message\n"); msg_attach_to_all(msg); ipcmsg_destroy(msg); return; } if (msg->head.type == IPC_WIZ) { printf("Wiz message\n"); msg_attach_to_perm(msg, PERM_WIZCHAT); ipcmsg_destroy(msg); return; } Loading @@ -415,6 +423,7 @@ void process_msg(ipc_connection_t *conn, ipc_message_t *msg) if (msg->head.dst == SYSTEM_USER) { printf("Broadcast message to system user %s\n", ipc_nametype(msg->head.type)); msg_attach_to_all(msg); ipcmsg_destroy(msg); return; } Loading Loading @@ -544,6 +553,38 @@ int msg_attach_to_userid(ipc_message_t *msg, uint32_t userposn) return found; } void msg_attach_to_perm(ipc_message_t *msg, perm_t perm) { int users_fd = userdb_open(O_RDONLY); struct user user; struct person *urec = &user.record; struct list_head *pos; if (users_fd < 0) return; list_for_each(pos, &connection_list) { ipc_connection_t *c = list_entry(pos, ipc_connection_t, list); if (c->state != IPCSTATE_VALID) continue; if (pread(users_fd, urec, sizeof(*urec), c->user) <= 0) continue; if (perm == PERM_WIZCHAT) { if (!s_wizchat(&user)) continue; } else if (perm == PERM_CHANGEINFO) { if (!s_changeinfo(&user)) continue; } /* person not on talker, just skip them */ if (!cm_test(&user, CM_ONCHAT)) continue; msg_attach(msg, c); printf("Restricted Broadcast to %s in %d\n", urec->name, urec->room); } close(users_fd); } /* attach messgae to outgoing queue */ void msg_attach(ipc_message_t *msg, ipc_connection_t *conn) { Loading src/server/servsock.h +7 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,12 @@ #define SERVSOCK_H #include <user.h> typedef enum { PERM_WIZCHAT, PERM_CHANGEINFO } perm_t; /* servsock.c */ int open_mainsock(uint16_t port); ipc_connection_t *add_connection(int fd); Loading @@ -14,6 +20,7 @@ void msg_attach_to_all(ipc_message_t *msg); int msg_attach_to_userid(ipc_message_t *msg, uint32_t userposn); int msg_attach_to_username(ipc_message_t *msg, const char *username); void msg_attach_to_channel(ipc_message_t *msg, int channel, const char * exclude); void msg_attach_to_perm(ipc_message_t *msg, perm_t perm); void msg_attach(ipc_message_t *msg, ipc_connection_t *conn); void migrate_old_folders(void); void init_server(void); Loading Loading
src/server/replay.c +9 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,8 @@ #include <rooms.h> #include <talker_privs.h> #include <ipc.h> #include <perms.h> #include <special.h> #include "servsock.h" #include "replay.h" Loading Loading @@ -185,6 +187,13 @@ void replay(ipc_connection_t *conn, ipc_message_t *msg) json_decref(j); continue; } if (store[idx]->head.type == IPC_WIZ) { if (s_wizchat(&user)) { /* we are a wiz, we see this */ msg_attach(store[idx], conn); } continue; } /* send them everything else */ if (store[idx]->head.dst) Loading
src/server/servsock.c +41 −0 Original line number Diff line number Diff line Loading @@ -408,6 +408,14 @@ void process_msg(ipc_connection_t *conn, ipc_message_t *msg) if (msg->head.type == IPC_EVENT) { printf("Event message\n"); msg_attach_to_all(msg); ipcmsg_destroy(msg); return; } if (msg->head.type == IPC_WIZ) { printf("Wiz message\n"); msg_attach_to_perm(msg, PERM_WIZCHAT); ipcmsg_destroy(msg); return; } Loading @@ -415,6 +423,7 @@ void process_msg(ipc_connection_t *conn, ipc_message_t *msg) if (msg->head.dst == SYSTEM_USER) { printf("Broadcast message to system user %s\n", ipc_nametype(msg->head.type)); msg_attach_to_all(msg); ipcmsg_destroy(msg); return; } Loading Loading @@ -544,6 +553,38 @@ int msg_attach_to_userid(ipc_message_t *msg, uint32_t userposn) return found; } void msg_attach_to_perm(ipc_message_t *msg, perm_t perm) { int users_fd = userdb_open(O_RDONLY); struct user user; struct person *urec = &user.record; struct list_head *pos; if (users_fd < 0) return; list_for_each(pos, &connection_list) { ipc_connection_t *c = list_entry(pos, ipc_connection_t, list); if (c->state != IPCSTATE_VALID) continue; if (pread(users_fd, urec, sizeof(*urec), c->user) <= 0) continue; if (perm == PERM_WIZCHAT) { if (!s_wizchat(&user)) continue; } else if (perm == PERM_CHANGEINFO) { if (!s_changeinfo(&user)) continue; } /* person not on talker, just skip them */ if (!cm_test(&user, CM_ONCHAT)) continue; msg_attach(msg, c); printf("Restricted Broadcast to %s in %d\n", urec->name, urec->room); } close(users_fd); } /* attach messgae to outgoing queue */ void msg_attach(ipc_message_t *msg, ipc_connection_t *conn) { Loading
src/server/servsock.h +7 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,12 @@ #define SERVSOCK_H #include <user.h> typedef enum { PERM_WIZCHAT, PERM_CHANGEINFO } perm_t; /* servsock.c */ int open_mainsock(uint16_t port); ipc_connection_t *add_connection(int fd); Loading @@ -14,6 +20,7 @@ void msg_attach_to_all(ipc_message_t *msg); int msg_attach_to_userid(ipc_message_t *msg, uint32_t userposn); int msg_attach_to_username(ipc_message_t *msg, const char *username); void msg_attach_to_channel(ipc_message_t *msg, int channel, const char * exclude); void msg_attach_to_perm(ipc_message_t *msg, perm_t perm); void msg_attach(ipc_message_t *msg, ipc_connection_t *conn); void migrate_old_folders(void); void init_server(void); Loading