]> jfr.im git - irc/evilnet/x3.git/blame - src/nickserv.h
make sure commands always reply from the same nick you /msgd
[irc/evilnet/x3.git] / src / nickserv.h
CommitLineData
d76ed9a9 1/* nickserv.h - Nick/authentiction service
2 * Copyright 2000-2004 srvx Development Team
3 *
83ff05c3 4 * This file is part of x3.
d76ed9a9 5 *
d0f04f71 6 * x3 is free software; you can redistribute it and/or modify
d76ed9a9 7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with srvx; if not, write to the Free Software Foundation,
18 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
19 */
20
21#ifndef _nickserv_h
22#define _nickserv_h
23
24#include "hash.h" /* for NICKLEN, etc., and common.h */
25struct svccmd;
26
a32da4c7 27#define NICKSERV_HANDLE_LEN ACCOUNTLEN
d76ed9a9 28#define COOKIELEN 10
29
30/* HI_FLAG_* go into handle_info.flags */
31#define HI_FLAG_OPER_SUSPENDED 0x00000001
32#define HI_FLAG_USE_PRIVMSG 0x00000002
33#define HI_FLAG_SUPPORT_HELPER 0x00000004
34#define HI_FLAG_HELPING 0x00000008
35#define HI_FLAG_SUSPENDED 0x00000010
36#define HI_FLAG_MIRC_COLOR 0x00000020
37#define HI_FLAG_FROZEN 0x00000040
38#define HI_FLAG_NODELETE 0x00000080
39#define HI_FLAG_NETWORK_HELPER 0x00000100
40#define HI_FLAG_BOT 0x00000200
7fdb7639 41#define HI_FLAG_AUTOHIDE 0x00000400
0b587959 42#define HI_FLAG_ADVANCED 0x00000800
d76ed9a9 43/* Flag characters for the above. First char is LSB, etc. */
7fdb7639 44#define HANDLE_FLAGS "SphgscfnHbx"
d76ed9a9 45
46/* HI_STYLE_* go into handle_info.userlist_style */
338a82b5 47#define HI_STYLE_NORMAL 'n'
48#define HI_STYLE_CLEAN 'c'
49#define HI_STYLE_ADVANCED 'a'
d9896a83 50#define HI_STYLE_CLASSIC 'k'
d76ed9a9 51
52#define HI_DEFAULT_FLAGS (HI_FLAG_MIRC_COLOR)
338a82b5 53
54/* This is overridden by conf file */
55#define HI_DEFAULT_STYLE HI_STYLE_NORMAL
d76ed9a9 56
57#define HANDLE_FLAGGED(hi, tok) ((hi)->flags & HI_FLAG_##tok)
58#define HANDLE_SET_FLAG(hi, tok) ((hi)->flags |= HI_FLAG_##tok)
59#define HANDLE_TOGGLE_FLAG(hi, tok) ((hi)->flags ^= HI_FLAG_##tok)
60#define HANDLE_CLEAR_FLAG(hi, tok) ((hi)->flags &= ~HI_FLAG_##tok)
61
62#define IsSupportHelper(user) (user->handle_info && HANDLE_FLAGGED(user->handle_info, SUPPORT_HELPER))
63#define IsNetworkHelper(user) (user->handle_info && HANDLE_FLAGGED(user->handle_info, NETWORK_HELPER))
64#define IsHelper(user) (IsSupportHelper(user) || IsNetworkHelper(user))
65#define IsHelping(user) (user->handle_info && HANDLE_FLAGGED(user->handle_info, HELPING))
66#define IsStaff(user) (IsOper(user) || IsSupportHelper(user) || IsNetworkHelper(user))
67#define IsBot(user) (user->handle_info && HANDLE_FLAGGED(user->handle_info, BOT))
68
69enum cookie_type {
70 ACTIVATION,
71 PASSWORD_CHANGE,
72 EMAIL_CHANGE,
73 ALLOWAUTH
74};
75
76struct handle_cookie {
77 struct handle_info *hi;
78 char *data;
79 enum cookie_type type;
80 time_t expires;
81 char cookie[COOKIELEN+1];
82};
83
2362161a 84struct handle_note {
85 char setter[NICKSERV_HANDLE_LEN+1];
86 time_t date;
87 char note[1];
88};
89
d76ed9a9 90struct handle_info {
91 struct nick_info *nicks;
92 struct string_list *masks;
5177fd21 93 struct string_list *ignores;
d76ed9a9 94 struct userNode *users;
95 struct userData *channels;
96 struct handle_cookie *cookie;
2362161a 97 struct handle_note *note;
d76ed9a9 98 struct language *language;
99 char *email_addr;
100 char *epithet;
101 char *infoline;
102 char *handle;
103 char *fakehost;
104#ifdef WITH_PROTOCOL_BAHAMUT
105 unsigned long id;
106#endif
107 time_t registered;
108 time_t lastseen;
109 unsigned short flags;
110 unsigned short opserv_level;
111 unsigned short screen_width;
112 unsigned short table_width;
113 unsigned char userlist_style;
114 unsigned char announcements;
115 unsigned char maxlogins;
116 char passwd[MD5_CRYPT_LENGTH+1];
117 char last_quit_host[USERLEN+HOSTLEN+2];
118};
119
120struct nick_info {
121 struct handle_info *owner;
122 struct nick_info *next; /* next nick owned by same handle */
123 char nick[NICKLEN+1];
124};
125
126struct handle_info_list {
127 unsigned int used, size;
128 struct handle_info **list;
129 char *tag; /* e.g. email address */
130};
131
132extern const char *handle_flags;
133
134void init_nickserv(const char *nick);
135struct handle_info *get_handle_info(const char *handle);
136struct handle_info *smart_get_handle_info(struct userNode *service, struct userNode *user, const char *name);
137int oper_try_set_access(struct userNode *user, struct userNode *bot, struct handle_info *target, unsigned int new_level);
c092fcad 138int oper_outranks(struct svccmd *cmd, struct userNode *user, struct handle_info *hi);
d76ed9a9 139struct nick_info *get_nick_info(const char *nick);
140struct modeNode *find_handle_in_channel(struct chanNode *channel, struct handle_info *handle, struct userNode *except);
141int nickserv_modify_handle_flags(struct userNode *user, struct userNode *bot, const char *str, unsigned long *add, unsigned long *remove);
142int oper_has_access(struct userNode *user, struct userNode *bot, unsigned int min_level, unsigned int quiet);
143void nickserv_show_oper_accounts(struct userNode *user, struct svccmd *cmd);
144
c092fcad 145struct handle_info *get_victim_oper(struct svccmd *cmd, struct userNode *user, const char *target);
b21e2cfe 146struct handle_info *loc_auth(char *handle, char *password);
d9cd0e9d 147
ec311f39 148typedef void (*user_mode_func_t)(struct userNode *user, const char *mode_change);
149void reg_user_mode_func(user_mode_func_t func);
150typedef void (*channel_mode_func_t)(struct userNode *who, struct chanNode *channel, char **mode, unsigned int argc);
151void reg_channel_mode_func(channel_mode_func_t func);
152
d76ed9a9 153/* auth_funcs are called when a user gets a new handle_info. They are
154 * called *after* user->handle_info has been updated. */
155typedef void (*auth_func_t)(struct userNode *user, struct handle_info *old_handle);
156void reg_auth_func(auth_func_t func);
157
158/* Called just after a handle is renamed. */
159typedef void (*handle_rename_func_t)(struct handle_info *handle, const char *old_handle);
160void reg_handle_rename_func(handle_rename_func_t func);
161
162/* unreg_funcs are called right before a handle is unregistered.
163 * `user' is the person who caused the handle to be unregistered (either a
164 * client authed to the handle, or an oper). */
165typedef void (*unreg_func_t)(struct userNode *user, struct handle_info *handle);
166void reg_unreg_func(unreg_func_t func);
167
168/* Called just before a handle is merged */
169typedef void (*handle_merge_func_t)(struct userNode *user, struct handle_info *handle_to, struct handle_info *handle_from);
170void reg_handle_merge_func(handle_merge_func_t);
171
172/* Called after an allowauth. handle is null if allowauth authorization was
173 * removed */
174typedef void (*allowauth_func_t)(struct userNode *user, struct userNode *target, struct handle_info *handle);
175void reg_allowauth_func(allowauth_func_t func);
176
177/* Called when an auth attempt fails because of a bad password */
178typedef void (*failpw_func_t)(struct userNode *user, struct handle_info *handle);
179void reg_failpw_func(failpw_func_t func);
180
3fdd6a74 181void send_func_list(struct userNode *user);
182
d76ed9a9 183#endif