2020-07-25 12:03:18 +00:00
|
|
|
/*
|
|
|
|
* This file is part of uIRCd. (https://git.redxen.eu/caskd/uIRCd)
|
|
|
|
* Copyright (c) 2019, 2020 Alex-David Denes
|
|
|
|
*
|
|
|
|
* uIRCd is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* uIRCd is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with uIRCd. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2020-12-17 00:27:30 +00:00
|
|
|
#include "channels.h"
|
2020-12-08 02:16:12 +00:00
|
|
|
#include "limits.h"
|
|
|
|
|
2021-01-02 14:12:13 +00:00
|
|
|
#include <stdbool.h> // bool
|
|
|
|
#include <sys/types.h> // size_t ssize_t socklen_t
|
2020-07-25 12:03:18 +00:00
|
|
|
|
2020-12-08 02:16:12 +00:00
|
|
|
#define UIRC_IRCV3
|
|
|
|
#define UIRC_HELPERS
|
2020-12-09 01:33:36 +00:00
|
|
|
#include <uirc/uirc.h> // Assm_mesg Assm_cmd...
|
2020-12-08 02:16:12 +00:00
|
|
|
|
|
|
|
#ifndef UIRCD_GUARD_CONNECTION
|
|
|
|
#define UIRCD_GUARD_CONNECTION
|
|
|
|
|
|
|
|
#define INIT_HARDFAIL -1
|
|
|
|
#define INIT_SOFTFAIL -2
|
2020-07-25 12:03:18 +00:00
|
|
|
|
2020-12-09 01:33:36 +00:00
|
|
|
#define CONN_ACTIVE 2
|
|
|
|
#define CONN_REGISTERED 1
|
|
|
|
#define CONN_PENDING 0
|
2020-10-02 12:38:11 +00:00
|
|
|
#define CONN_RECONNECTING -1
|
2020-12-09 01:33:36 +00:00
|
|
|
#define CONN_CLOSING -2
|
|
|
|
#define CONN_CLOSED -3
|
2020-08-01 17:45:14 +00:00
|
|
|
|
2020-12-20 23:53:56 +00:00
|
|
|
#define CHANNELMASK(STR) (strchr("#&+!", *STR) != NULL)
|
|
|
|
|
2020-12-08 02:16:12 +00:00
|
|
|
typedef struct {
|
2020-12-17 00:27:30 +00:00
|
|
|
char * address, *service, *quitmsg, *path;
|
|
|
|
time_t timeout;
|
2020-12-09 01:33:36 +00:00
|
|
|
} Connection_Data; // Session/Configuration data [persistent]
|
2020-12-08 22:20:42 +00:00
|
|
|
|
2020-12-08 02:16:12 +00:00
|
|
|
typedef struct {
|
2020-12-08 22:20:42 +00:00
|
|
|
char *nickname, *username, *realname, *password;
|
2020-12-09 01:33:36 +00:00
|
|
|
} Connection_User; // User information [persistent]
|
2020-12-08 22:20:42 +00:00
|
|
|
|
|
|
|
typedef struct {
|
2020-12-09 01:33:36 +00:00
|
|
|
time_t l_ping, l_pong, l_connect, l_message;
|
2020-12-17 00:27:30 +00:00
|
|
|
Channel* channels;
|
2020-12-08 22:20:42 +00:00
|
|
|
signed short state;
|
2020-12-09 01:33:36 +00:00
|
|
|
signed int reconinter;
|
|
|
|
bool active;
|
|
|
|
} Connection_Info; // Connection information [temporary]
|
2020-12-08 22:20:42 +00:00
|
|
|
|
2020-12-08 02:16:12 +00:00
|
|
|
typedef struct {
|
2020-12-09 01:33:36 +00:00
|
|
|
char buffer[UIRCD_LIMITS_LINE + 1];
|
2020-12-08 02:16:12 +00:00
|
|
|
size_t append_pos;
|
2020-12-09 01:33:36 +00:00
|
|
|
int fd;
|
2020-12-08 02:16:12 +00:00
|
|
|
} Buffer_Info;
|
2020-12-08 22:20:42 +00:00
|
|
|
|
2020-12-08 02:16:12 +00:00
|
|
|
typedef struct {
|
2020-12-08 22:20:42 +00:00
|
|
|
Connection_User user;
|
2020-12-08 02:16:12 +00:00
|
|
|
Connection_Data data;
|
2020-12-08 22:20:42 +00:00
|
|
|
Connection_Info info;
|
2020-12-08 02:16:12 +00:00
|
|
|
} Connection;
|
2020-08-20 17:51:43 +00:00
|
|
|
|
2020-12-20 23:53:56 +00:00
|
|
|
signed int init_connection(Connection* conn);
|
|
|
|
signed int get_msgchannel(IRC_Message* mesg);
|
|
|
|
int auto_msg_actions(IRC_Message* mesg, Connection* conn, Buffer_Info* buf);
|
|
|
|
int commit_channelist(Buffer_Info* buf, Connection* conn);
|
|
|
|
const char* get_categ(IRC_Message* mesg);
|
2020-10-02 12:38:11 +00:00
|
|
|
|
2020-12-08 02:16:12 +00:00
|
|
|
#endif /* UIRCD_GUARD_CONNECTION */
|
2020-12-08 22:20:42 +00:00
|
|
|
|