Compare commits
3 Commits
2824b8da7e
...
d69feeef12
Author | SHA1 | Date | |
---|---|---|---|
|
d69feeef12 | ||
|
d19099eb3c | ||
|
99a1244e46 |
2
COPYING
2
COPYING
@ -1,4 +1,4 @@
|
|||||||
bip copyright 2004 2005 Arnaud Cornet and Loïc Gomez, is released under the
|
BIP copyright 2004-2024 Arnaud Cornet and Loïc Gomez, is released under the
|
||||||
terms of the GNU GPL, License that you can find below.
|
terms of the GNU GPL, License that you can find below.
|
||||||
|
|
||||||
Specific permission is granted for the GPLed code in this distribution to
|
Specific permission is granted for the GPLed code in this distribution to
|
||||||
|
27
README
27
README
@ -19,6 +19,9 @@ Table of contents :
|
|||||||
A. Connecting your client(s)
|
A. Connecting your client(s)
|
||||||
B. Backlog and flood control
|
B. Backlog and flood control
|
||||||
C. Multiple users and ident issues
|
C. Multiple users and ident issues
|
||||||
|
V. The Team
|
||||||
|
A. Authors
|
||||||
|
B. Contributors for code, reviews, hosting, ...
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -218,7 +221,25 @@ IV. USING BIP
|
|||||||
ip address.
|
ip address.
|
||||||
|
|
||||||
|
|
||||||
|
V. THE TEAM
|
||||||
|
|
||||||
|
A. Authors
|
||||||
|
|
||||||
|
- Arnaud Cornet <nohar@t1r.net>
|
||||||
|
- Loïc Gomez <bip@animanova.fr>
|
||||||
|
|
||||||
|
B. Contributors for code, reviews, hosting, ...
|
||||||
|
|
||||||
|
nohar Arnaud Cornet <nohar@t1r.net>
|
||||||
|
Kyoshiro Loïc Gomez <bip@animanova.fr>
|
||||||
|
pilou Pierre-Louis Bonicoli
|
||||||
|
Duck Marc Dequènes <Duck@DuckCorp.org>
|
||||||
|
YS Yannick Schaus
|
||||||
|
Unit 193 <unit193@debian.org>
|
||||||
|
|
||||||
|
If you have contributed to BIP IRC Proxy one way or the other and don't
|
||||||
|
appear in that list, please file a bug on the tracker or even better,
|
||||||
|
a pull request.
|
||||||
|
|
||||||
|
|
||||||
Happy ircing!
|
Happy ircing!
|
||||||
|
|
||||||
-- Arnaud Cornet <nohar@t1r.net> and Loïc Gomez <opensource@kyoshiro.org>
|
|
||||||
|
|
||||||
|
91
src/bip.c
91
src/bip.c
@ -67,6 +67,7 @@ void conf_die(bip_t *bip, char *fmt, ...);
|
|||||||
static char *get_tuple_pvalue(list_t *tuple_l, int lex);
|
static char *get_tuple_pvalue(list_t *tuple_l, int lex);
|
||||||
void bip_notify(struct link_client *ic, char *fmt, ...);
|
void bip_notify(struct link_client *ic, char *fmt, ...);
|
||||||
void adm_list_connections(struct link_client *ic, struct bipuser *bu);
|
void adm_list_connections(struct link_client *ic, struct bipuser *bu);
|
||||||
|
struct link *find_link(const char *link_name, struct bipuser *bu);
|
||||||
void free_conf(list_t *l);
|
void free_conf(list_t *l);
|
||||||
|
|
||||||
|
|
||||||
@ -373,6 +374,45 @@ static int add_network(bip_t *bip, list_t *data)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void adm_bip_jump(struct link_client *ic, const char *conn_name,
|
||||||
|
int reset_timer)
|
||||||
|
{
|
||||||
|
struct link *lnk;
|
||||||
|
if (conn_name) {
|
||||||
|
lnk = find_link(conn_name, LINK(ic)->user);
|
||||||
|
if (!lnk) {
|
||||||
|
bip_notify(ic, "-- Cannot find connection named %s",
|
||||||
|
conn_name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
goto do_the_jump;
|
||||||
|
} else {
|
||||||
|
lnk = LINK(ic);
|
||||||
|
}
|
||||||
|
|
||||||
|
do_the_jump:
|
||||||
|
if (!lnk->l_server) {
|
||||||
|
if (reset_timer) {
|
||||||
|
lnk->recon_timer = 0;
|
||||||
|
bip_notify(ic,
|
||||||
|
"-- %s is not connected, "
|
||||||
|
"timer has been reset, please wait",
|
||||||
|
conn_name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int timer = (lnk->recon_timer ? lnk->recon_timer : 0);
|
||||||
|
bip_notify(ic,
|
||||||
|
"-- %s is not connected, "
|
||||||
|
"please wait for reconnect (%ds)",
|
||||||
|
conn_name, timer);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
WRITE_LINE1(CONN(lnk->l_server), NULL, "QUIT", "jumpin' jumpin'");
|
||||||
|
connection_close(CONN(lnk->l_server));
|
||||||
|
bip_notify(ic, "-- Jumping to next server on %s", conn_name);
|
||||||
|
}
|
||||||
|
|
||||||
void adm_bip_delconn(bip_t *bip, struct link_client *ic, const char *conn_name)
|
void adm_bip_delconn(bip_t *bip, struct link_client *ic, const char *conn_name)
|
||||||
{
|
{
|
||||||
struct bipuser *user = LINK(ic)->user;
|
struct bipuser *user = LINK(ic)->user;
|
||||||
@ -664,6 +704,31 @@ static int add_connection(bip_t *bip, struct bipuser *user, list_t *data)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct link *find_link(const char *link_name, struct bipuser *bu)
|
||||||
|
{
|
||||||
|
list_iterator_t it;
|
||||||
|
|
||||||
|
// Immediately return NULL when bip user (bu) is NULL
|
||||||
|
if (!bu) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (list_it_init(&_bip->link_list, &it); list_it_item(&it);
|
||||||
|
list_it_next(&it)) {
|
||||||
|
struct link *lnk = list_it_item(&it);
|
||||||
|
if (!lnk)
|
||||||
|
continue;
|
||||||
|
// Only lookup in optionally specified user links
|
||||||
|
if (bu != lnk->user)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (strcmp(link_name, lnk->name) == 0)
|
||||||
|
return lnk;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static char *get_tuple_pvalue(list_t *tuple_l, int lex)
|
static char *get_tuple_pvalue(list_t *tuple_l, int lex)
|
||||||
{
|
{
|
||||||
struct tuple *t;
|
struct tuple *t;
|
||||||
@ -1992,8 +2057,8 @@ void adm_bip_help(struct link_client *ic, int admin, const char *subhelp)
|
|||||||
bip_notify(ic, "/BIP LIST networks|connections");
|
bip_notify(ic, "/BIP LIST networks|connections");
|
||||||
}
|
}
|
||||||
bip_notify(ic,
|
bip_notify(ic,
|
||||||
"/BIP JUMP # jump to next server (in same "
|
"/BIP JUMP [-f] [conn_name] # jump to next "
|
||||||
"network)");
|
"server (defaults to current network)");
|
||||||
bip_notify(ic,
|
bip_notify(ic,
|
||||||
"/BIP BLRESET [channel|query]# reset backlog "
|
"/BIP BLRESET [channel|query]# reset backlog "
|
||||||
"(this connection only). Add -q flag and the "
|
"(this connection only). Add -q flag and the "
|
||||||
@ -2046,8 +2111,14 @@ void adm_bip_help(struct link_client *ic, int admin, const char *subhelp)
|
|||||||
" Removing a connection will cause "
|
" Removing a connection will cause "
|
||||||
"its disconnection.");
|
"its disconnection.");
|
||||||
} else if (strcasecmp(subhelp, "JUMP") == 0) {
|
} else if (strcasecmp(subhelp, "JUMP") == 0) {
|
||||||
bip_notify(ic, "/BIP JUMP :");
|
bip_notify(ic, "/BIP JUMP [-f] [conn_name]:");
|
||||||
bip_notify(ic, " Jump to next server in current network.");
|
bip_notify(ic, " Jump to next server in current network.");
|
||||||
|
bip_notify(ic,
|
||||||
|
" If [conn_name] is set, jump to next server in "
|
||||||
|
"[conn_name] network instead.");
|
||||||
|
bip_notify(ic,
|
||||||
|
" If [-f] flag is used, also resets reconnect "
|
||||||
|
"timer.");
|
||||||
} else if (strcasecmp(subhelp, "BLRESET") == 0) {
|
} else if (strcasecmp(subhelp, "BLRESET") == 0) {
|
||||||
bip_notify(ic, "/BIP BLRESET :");
|
bip_notify(ic, "/BIP BLRESET :");
|
||||||
bip_notify(ic, " Reset backlog on this network.");
|
bip_notify(ic, " Reset backlog on this network.");
|
||||||
@ -2227,12 +2298,16 @@ int adm_bip(bip_t *bip, struct link_client *ic, struct line *line, int privmsg)
|
|||||||
bip_notify(ic, "-- Invalid INFO request");
|
bip_notify(ic, "-- Invalid INFO request");
|
||||||
}
|
}
|
||||||
} else if (irc_line_elem_case_equals(line, privmsg + 1, "JUMP")) {
|
} else if (irc_line_elem_case_equals(line, privmsg + 1, "JUMP")) {
|
||||||
if (LINK(ic)->l_server) {
|
if (irc_line_count(line) == privmsg + 2) {
|
||||||
WRITE_LINE1(CONN(LINK(ic)->l_server), NULL, "QUIT",
|
adm_bip_jump(ic, NULL, 0);
|
||||||
"jumpin' jumpin'");
|
} else if (irc_line_count(line) == privmsg + 3) {
|
||||||
connection_close(CONN(LINK(ic)->l_server));
|
adm_bip_jump(ic, irc_line_elem(line, privmsg + 2), 0);
|
||||||
|
} else if (irc_line_count(line) == privmsg + 4
|
||||||
|
&& irc_line_elem_equals(line, privmsg + 2, "-f")) {
|
||||||
|
adm_bip_jump(ic, irc_line_elem(line, privmsg + 3), 1);
|
||||||
|
} else {
|
||||||
|
bip_notify(ic, "-- Invalid usage (/BIP HELP JUMP)");
|
||||||
}
|
}
|
||||||
bip_notify(ic, "-- Jumping to next server");
|
|
||||||
} else if (irc_line_elem_case_equals(line, privmsg + 1, "BLRESET")) {
|
} else if (irc_line_elem_case_equals(line, privmsg + 1, "BLRESET")) {
|
||||||
if (irc_line_includes(line, privmsg + 2)) {
|
if (irc_line_includes(line, privmsg + 2)) {
|
||||||
if (irc_line_elem_equals(line, privmsg + 2, "-q")) {
|
if (irc_line_elem_equals(line, privmsg + 2, "-q")) {
|
||||||
|
16
src/irc.c
16
src/irc.c
@ -33,6 +33,7 @@
|
|||||||
extern int sighup;
|
extern int sighup;
|
||||||
extern bip_t *_bip;
|
extern bip_t *_bip;
|
||||||
|
|
||||||
|
static int irc_generic_error(struct link_server *server, struct line *line);
|
||||||
static int irc_join(struct link_server *server, struct line *line);
|
static int irc_join(struct link_server *server, struct line *line);
|
||||||
static int irc_part(struct link_server *server, struct line *line);
|
static int irc_part(struct link_server *server, struct line *line);
|
||||||
static int irc_mode(struct link_server *server, struct line *line);
|
static int irc_mode(struct link_server *server, struct line *line);
|
||||||
@ -625,6 +626,10 @@ int irc_dispatch_server(bip_t *bip, struct link_server *server,
|
|||||||
ret = irc_quit(server, line);
|
ret = irc_quit(server, line);
|
||||||
} else if (irc_line_elem_equals(line, 0, "NICK")) {
|
} else if (irc_line_elem_equals(line, 0, "NICK")) {
|
||||||
ret = irc_nick(server, line);
|
ret = irc_nick(server, line);
|
||||||
|
} else if (irc_line_is_error(line)) {
|
||||||
|
// IRC errors catchall (for unhandled ones)
|
||||||
|
// logs error to bip.log
|
||||||
|
ret = irc_generic_error(server, line);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret == OK_COPY) {
|
if (ret == OK_COPY) {
|
||||||
@ -1448,6 +1453,17 @@ static int origin_is_me(struct line *l, struct link_server *server)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int irc_generic_error(struct link_server *server, struct line *line)
|
||||||
|
{
|
||||||
|
if (irc_line_count(line) == 4)
|
||||||
|
mylog(LOG_INFO, "[%s] IRC error: %s", LINK(server)->name,
|
||||||
|
irc_line_elem(line, 3));
|
||||||
|
else
|
||||||
|
mylog(LOG_INFO, "[%s] IRC error: %s", LINK(server)->name,
|
||||||
|
irc_line_to_string(line));
|
||||||
|
return OK_COPY;
|
||||||
|
}
|
||||||
|
|
||||||
static int irc_join(struct link_server *server, struct line *line)
|
static int irc_join(struct link_server *server, struct line *line)
|
||||||
{
|
{
|
||||||
char *s_nick;
|
char *s_nick;
|
||||||
|
@ -143,6 +143,12 @@ void irc_line_drop(struct line *line, int elem)
|
|||||||
bip_cfree(array_drop(&line->words, elem));
|
bip_cfree(array_drop(&line->words, elem));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int irc_line_is_error(struct line *line)
|
||||||
|
{
|
||||||
|
const char *irc_code = irc_line_elem(line, 0);
|
||||||
|
return (irc_code[0] == '4');
|
||||||
|
}
|
||||||
|
|
||||||
int irc_line_elem_equals(struct line *line, int elem, const char *cmp)
|
int irc_line_elem_equals(struct line *line, int elem, const char *cmp)
|
||||||
{
|
{
|
||||||
return !strcmp(irc_line_elem(line, elem), cmp);
|
return !strcmp(irc_line_elem(line, elem), cmp);
|
||||||
|
@ -98,6 +98,7 @@ int irc_line_includes(struct line *line, int elem);
|
|||||||
const char *irc_line_elem(struct line *line, int elem);
|
const char *irc_line_elem(struct line *line, int elem);
|
||||||
int irc_line_count(struct line *line);
|
int irc_line_count(struct line *line);
|
||||||
char *irc_line_pop(struct line *l);
|
char *irc_line_pop(struct line *l);
|
||||||
|
int irc_line_is_error(struct line *line);
|
||||||
int irc_line_elem_equals(struct line *line, int elem, const char *cmp);
|
int irc_line_elem_equals(struct line *line, int elem, const char *cmp);
|
||||||
int irc_line_elem_case_equals(struct line *line, int elem, const char *cmp);
|
int irc_line_elem_case_equals(struct line *line, int elem, const char *cmp);
|
||||||
void irc_line_drop(struct line *line, int elem);
|
void irc_line_drop(struct line *line, int elem);
|
||||||
|
Loading…
Reference in New Issue
Block a user