Repository navigation
Expand file tree
/
Copy pathobsidian.h
More file actions
140 lines (120 loc) · 3.84 KB
/
Copy pathobsidian.h
File metadata and controls
140 lines (120 loc) · 3.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#ifndef OBSIDIAN_H
#define OBSIDIAN_H
// Includes
#include "unrealircd.h"
#include "sqlite3.h"
// Database files
#define OBSIDIAN_DB "../data/obsidian.db"
// Config
#define CONF_ACCOUNT_BLOCK "account-registration"
// Range allowed
#define MIN_ACCOUNT_NAME_LENGTH 1
#define MAX_ACCOUNT_NAME_LENGTH 200
#define MIN_PASSWORD_LENGTH 3
#define MAX_PASSWORD_LENGTH 200
// Commands
#define CMD_REGISTER "REGISTER"
#define CMD_LISTACC "LISTACC"
#define CMD_IDENTIFY "IDENTIFY"
#define CMD_LOGOUT "LOGOUT"
// Command functions
CMD_FUNC(register_account);
CMD_FUNC(list_accounts);
CMD_FUNC(cmd_identify);
CMD_FUNC(cmd_logout);
// RPC commands
RPC_CALL_FUNC(rpc_list_accounts);
RPC_CALL_FUNC(rpc_accounts_find);
// Events
EVENT(nick_enforce); // Enforce Guest nicks
// Capabilities
#define REGCAP_NAME "draft/account-registration"
// Hooks definitions
#define HOOKTYPE_ACCOUNT_REGISTER 150 // Custom hook to tell other modules about account registration
// Hooks
int authenticate_attempt(Client *client, int first, const char *param);
const char *saslmechs(Client *client);
// SASL definitions
#define SASL_TYPE_NONE 0
#define SASL_TYPE_PLAIN 1
#define SASL_TYPE_EXTERNAL 2
#define SASL_TYPE_ANONYMOUS 3 // logout
#define SASL_TYPE_SESSION_COOKIE 4
#define SASL_TYPE_OTP 5
#define GetSaslType(x) (moddata_client(x, sasl_md).i)
#define SetSaslType(x, y) do { moddata_client(x, sasl_md).i = y; } while (0)
#define DelSaslType(x) do { moddata_client(x, sasl_md).i = SASL_TYPE_NONE; } while (0)
// SASL MD serialization
void sat_free(ModData *m);
const char *sat_serialize(ModData *m);
void sat_unserialize(const char *str, ModData *m);
// Structs
// IRCv3 METADATA
typedef struct Metadata {
bool ircv3; // true if this is an IRCv3 metadata item;
char *key;
char *value;
struct Metadata *prev, *next;
} Metadata;
// List of online users who are logged into this account
typedef struct AccountMember {
Client *client;
struct AccountMember *next;
} AccountMember;
typedef struct Account {
long int id; // Unique ID, can be NULL if not used
char *name;
char *email;
char *password;
time_t time_registered;
int verified;
char **channels;
Metadata *metadata_head;
AccountMember *members;
} Account;
typedef struct AccountRegistrationConfStruct
{
int min_name_length;
int max_name_length;
int min_password_length;
int max_password_length;
int require_email;
int require_terms_acceptance;
int allow_username_changes;
int allow_password_changes;
int allow_email_changes;
char *guest_nick_format;
bool got_min_name_length;
bool got_max_name_length;
bool got_min_password_length;
bool got_max_password_length;
bool got_require_email;
bool got_require_terms_acceptance;
bool got_allow_username_changes;
bool got_allow_password_changes;
bool got_allow_email_changes;
bool got_guest_nick_format;
} AccountRegistrationConfStruct;
// Global variables
sqlite3 *db;
// Function declarations
int open_database(const char *filename);
void close_database();
int write_account_to_db(const Account *acc);
Account **read_accounts_from_db(const char *name);
Account *find_account(const char *name);
json_t* account2json(const Account *acc);
void free_account(Account *acc);
void free_metadata(Metadata *head);
Metadata* create_metadata(const char *key, const char *value);
void add_metadata(Account *acc, const char *key, const char *value);
TKL *my_find_tkl_nameban(const char *name);
const char *accreg_capability_parameter(Client *client);
int accreg_capability_visible(Client *client);
void set_accreg_conf(void);
void free_accreg_conf(void);
int accreg_configtest(ConfigFile *cf, ConfigEntry *ce, int type, int *errs);
int accreg_configposttest(int *errs);
int accreg_configrun(ConfigFile *cf, ConfigEntry *ce, int type);
char *convert_guest_nick_format(const char *format, Client *client);
#endif