mirror of
https://github.com/anope/anope.git
synced 2026-07-02 01:05:44 +02:00
Added support for multiple uplink blocks in the new config.
Moved the type and id directives from the uplink block to the serverinfo block. Small config fixes. git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1746 5417fbe8-f217-4b02-8779-1006273d7864
This commit is contained in:
+19
-19
@@ -80,19 +80,6 @@
|
||||
*/
|
||||
uplink
|
||||
{
|
||||
/*
|
||||
* This directive instructs Anope which IRCd Protocol to speak when connecting.
|
||||
* You MUST modify this to match the IRCd you run.
|
||||
*
|
||||
* Supported:
|
||||
* - inspircd11
|
||||
* - ratbox
|
||||
* - bahamut
|
||||
* - charybdis
|
||||
* - unreal32
|
||||
*/
|
||||
type = "inspircd11"
|
||||
|
||||
/*
|
||||
* The IP or hostname of the IRC server you wish to connect Services to.
|
||||
* Usually, you will want to connect Services over 127.0.0.1 (aka localhost).
|
||||
@@ -117,12 +104,6 @@ uplink
|
||||
* Refer to your IRCd documentation for more information on link blocks.
|
||||
*/
|
||||
password = "mypassword"
|
||||
|
||||
/*
|
||||
* What Server ID to use for this connection?
|
||||
* Note: This should *ONLY* be used for TS6/P10 IRCds.
|
||||
*/
|
||||
#id = "64"
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -146,6 +127,25 @@ serverinfo {
|
||||
*/
|
||||
description = "Services for IRC Networks"
|
||||
|
||||
/*
|
||||
* This directive instructs Anope which IRCd Protocol to speak when connecting.
|
||||
* You MUST modify this to match the IRCd you run.
|
||||
*
|
||||
* Supported:
|
||||
* - inspircd11
|
||||
* - ratbox
|
||||
* - bahamut
|
||||
* - charybdis
|
||||
* - unreal32
|
||||
*/
|
||||
type = "inspircd11"
|
||||
|
||||
/*
|
||||
* What Server ID to use for this connection?
|
||||
* Note: This should *ONLY* be used for TS6/P10 IRCds.
|
||||
*/
|
||||
#id = "64"
|
||||
|
||||
/*
|
||||
* These identify the ident@hostname which will be used by the Serivces pesudoclients.
|
||||
* They can be overridden by the -user and -host command-line options when starting
|
||||
|
||||
+2
-10
@@ -227,15 +227,7 @@ char *sockstrerror(int error);
|
||||
|
||||
/**** config.c ****/
|
||||
|
||||
E char *RemoteServer;
|
||||
E int RemotePort;
|
||||
E char *RemotePassword;
|
||||
E char *RemoteServer2;
|
||||
E int RemotePort2;
|
||||
E char *RemotePassword2;
|
||||
E char *RemoteServer3;
|
||||
E int RemotePort3;
|
||||
E char *RemotePassword3;
|
||||
E std::list<Uplink *> Uplinks;
|
||||
E char *LocalHost;
|
||||
E int LocalPort;
|
||||
|
||||
@@ -514,7 +506,7 @@ E void set_lastmask(User * u);
|
||||
E void introduce_user(const char *user);
|
||||
E int init_primary(int ac, char **av);
|
||||
E int init_secondary(int ac, char **av);
|
||||
E int servernum;
|
||||
E Uplink *uplink_server;
|
||||
|
||||
/**** ircd.c ****/
|
||||
E void pmodule_ircd_proto(IRCDProto *);
|
||||
|
||||
+24
-4
@@ -229,6 +229,7 @@ extern int strncasecmp(const char *, const char *, size_t);
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <exception>
|
||||
#include <list>
|
||||
|
||||
/** This class can be used on its own to represent an exception, or derived to represent a module-specific exception.
|
||||
* When a module whishes to abort, e.g. within a constructor, it should throw an exception using ModuleException or
|
||||
@@ -351,7 +352,7 @@ class Extensible
|
||||
* @return Returns true on success.
|
||||
*/
|
||||
bool Shrink(const std::string &key);
|
||||
|
||||
|
||||
/** Get an extension item.
|
||||
*
|
||||
* @param key The key parameter is an arbitary string which identifies the extension data
|
||||
@@ -372,12 +373,12 @@ class Extensible
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** Get an extension item.
|
||||
*
|
||||
* @param key The key parameter is an arbitary string which identifies the extension data
|
||||
* @return Returns true if the item was found and false if it was not.
|
||||
*
|
||||
*
|
||||
* This single-parameter version only checks if the key exists, it does nothing with
|
||||
* the 'data' field and is probably only useful in conjunction with the single-parameter
|
||||
* version of Extend().
|
||||
@@ -1249,11 +1250,11 @@ struct capabinfo_ {
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*
|
||||
* Forward declaration reqired, because the base IRCDProto class uses some crap from in here.
|
||||
*/
|
||||
class IRCDProto;
|
||||
struct Uplink;
|
||||
#include "extern.h"
|
||||
|
||||
class IRCDProto {
|
||||
@@ -1517,4 +1518,23 @@ class IRCDTS6Proto : public IRCDProto
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
struct Uplink {
|
||||
char *host;
|
||||
int port;
|
||||
char *password;
|
||||
Uplink(const char *_host, int _port, const char *_password)
|
||||
{
|
||||
host = sstrdup(_host);
|
||||
port = _port;
|
||||
password = sstrdup(_password);
|
||||
}
|
||||
~Uplink()
|
||||
{
|
||||
free(host);
|
||||
free(password);
|
||||
}
|
||||
};
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
#endif /* SERVICES_H */
|
||||
|
||||
+65
-35
File diff suppressed because it is too large
Load Diff
+12
-30
@@ -14,7 +14,7 @@
|
||||
|
||||
#include "services.h"
|
||||
#include "pseudo.h"
|
||||
int servernum = 0;
|
||||
Uplink *uplink_server;
|
||||
|
||||
extern void moduleAddMsgs(void);
|
||||
extern void moduleAddIRCDMsgs(void);
|
||||
@@ -142,14 +142,14 @@ static int parse_options(int ac, char **av)
|
||||
*t++ = 0;
|
||||
portnum = atoi(t);
|
||||
if ((portnum > 0) && (portnum < 65535))
|
||||
RemotePort = portnum;
|
||||
/*RemotePort = portnum*/; // Needs fixing to handle the Uplinks list
|
||||
else {
|
||||
fprintf(stderr,
|
||||
"-remote: Port numbers must be in the range 1..65535. Using default.\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
RemoteServer = s;
|
||||
/*RemoteServer = s*/; // Needs fixing to handle the Uplinks list
|
||||
} else if (strcmp(s, "local") == 0) {
|
||||
if (++i >= ac) {
|
||||
fprintf(stderr,
|
||||
@@ -608,35 +608,17 @@ int init_secondary(int ac, char **av)
|
||||
send_event(EVENT_CONNECT, 1, EVENT_START);
|
||||
|
||||
/* Connect to the remote server */
|
||||
servsock = conn(RemoteServer, RemotePort, LocalHost, LocalPort);
|
||||
if (servsock < 0 && RemoteServer2) {
|
||||
servsock = conn(RemoteServer2, RemotePort2, LocalHost, LocalPort);
|
||||
if (servsock < 0 && RemoteServer3) {
|
||||
servsock =
|
||||
conn(RemoteServer3, RemotePort3, LocalHost, LocalPort);
|
||||
if (servsock < 0) {
|
||||
fatal_perror("Can't connect to server");
|
||||
} else {
|
||||
servernum = 3;
|
||||
alog("Connected to Server %d (%s:%d)", servernum,
|
||||
RemoteServer3, RemotePort3);
|
||||
}
|
||||
} else {
|
||||
if (servsock < 0) {
|
||||
fatal_perror("Can't connect to server");
|
||||
}
|
||||
servernum = 2;
|
||||
alog("Connected to Server %d (%s:%d)", servernum,
|
||||
RemoteServer2, RemotePort2);
|
||||
std::list<Uplink *>::iterator curr_uplink = Uplinks.begin(), end_uplink = Uplinks.end();
|
||||
int servernum = 1;
|
||||
for (; curr_uplink != end_uplink; ++curr_uplink, ++servernum) {
|
||||
uplink_server = *curr_uplink;
|
||||
servsock = conn(uplink_server->host, uplink_server->port, LocalHost, LocalPort);
|
||||
if (servsock >= 0) {
|
||||
alog("Connected to Server %d (%s:%d)", servernum, uplink_server->host, uplink_server->port);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (servsock < 0) {
|
||||
fatal_perror("Can't connect to server");
|
||||
}
|
||||
servernum = 1;
|
||||
alog("Connected to Server %d (%s:%d)", servernum, RemoteServer,
|
||||
RemotePort);
|
||||
}
|
||||
if (curr_uplink == end_uplink) fatal_perror("Can't connect to any servers");
|
||||
|
||||
ircdproto->SendConnect();
|
||||
send_event(EVENT_CONNECT, 1, EVENT_STOP);
|
||||
|
||||
+3
-13
@@ -221,19 +221,9 @@ int m_stats(const char *source, int ac, const char **av)
|
||||
|
||||
if (u && is_oper(u)) {
|
||||
|
||||
if (servernum == 1) {
|
||||
ircdproto->SendNumeric(ServerName, 211, source, "Server SendBuf SentBytes SentMsgs RecvBuf RecvBytes RecvMsgs ConnTime");
|
||||
ircdproto->SendNumeric(ServerName, 211, source, "%s %d %d %d %d %d %d %ld", RemoteServer, write_buffer_len(), total_written, -1, read_buffer_len(),
|
||||
total_read, -1, time(NULL) - start_time);
|
||||
} else if (servernum == 2) {
|
||||
ircdproto->SendNumeric(ServerName, 211, source, "Server SendBuf SentBytes SentMsgs RecvBuf RecvBytes RecvMsgs ConnTime");
|
||||
ircdproto->SendNumeric(ServerName, 211, source, "%s %d %d %d %d %d %d %ld", RemoteServer2, write_buffer_len(), total_written, -1, read_buffer_len(),
|
||||
total_read, -1, time(NULL) - start_time);
|
||||
} else if (servernum == 3) {
|
||||
ircdproto->SendNumeric(ServerName, 211, source, "Server SendBuf SentBytes SentMsgs RecvBuf RecvBytes RecvMsgs ConnTime");
|
||||
ircdproto->SendNumeric(ServerName, 211, source, "%s %d %d %d %d %d %d %ld", RemoteServer3, write_buffer_len(), total_written, -1, read_buffer_len(),
|
||||
total_read, -1, time(NULL) - start_time);
|
||||
}
|
||||
ircdproto->SendNumeric(ServerName, 211, source, "Server SendBuf SentBytes SentMsgs RecvBuf RecvBytes RecvMsgs ConnTime");
|
||||
ircdproto->SendNumeric(ServerName, 211, source, "%s %d %d %d %d %d %d %ld", uplink_server->host, write_buffer_len(), total_written, -1, read_buffer_len(),
|
||||
total_read, -1, time(NULL) - start_time);
|
||||
}
|
||||
|
||||
ircdproto->SendNumeric(ServerName, 219, source, "%c :End of /STATS report.", *av[0] ? *av[0] : '*');
|
||||
|
||||
@@ -721,9 +721,7 @@ class BahamutIRCdProto : public IRCDProto
|
||||
void SendConnect()
|
||||
{
|
||||
me_server = new_server(NULL, ServerName, ServerDesc, SERVER_ISME, NULL);
|
||||
if (servernum == 1) bahamut_cmd_pass(RemotePassword);
|
||||
else if (servernum == 2) bahamut_cmd_pass(RemotePassword2);
|
||||
else if (servernum == 3) bahamut_cmd_pass(RemotePassword3);
|
||||
bahamut_cmd_pass(uplink_server->password);
|
||||
bahamut_cmd_capab();
|
||||
SendServer(ServerName, 1, ServerDesc);
|
||||
bahamut_cmd_svinfo();
|
||||
|
||||
@@ -606,9 +606,7 @@ class InspIRCdProto : public IRCDProto
|
||||
|
||||
void SendConnect()
|
||||
{
|
||||
if (servernum == 1) inspircd_cmd_pass(RemotePassword);
|
||||
else if (servernum == 2) inspircd_cmd_pass(RemotePassword2);
|
||||
else if (servernum == 3) inspircd_cmd_pass(RemotePassword3);
|
||||
inspircd_cmd_pass(uplink_server->password);
|
||||
SendServer(ServerName, 0, ServerDesc);
|
||||
send_cmd(NULL, "BURST");
|
||||
send_cmd(ServerName, "VERSION :Anope-%s %s :%s - %s (%s) -- %s", version_number, ServerName, ircd->name, version_flags, EncModule, version_build);
|
||||
|
||||
@@ -609,9 +609,7 @@ class InspIRCdProto : public IRCDProto
|
||||
|
||||
void SendConnect()
|
||||
{
|
||||
if (servernum == 1) inspircd_cmd_pass(RemotePassword);
|
||||
else if (servernum == 2) inspircd_cmd_pass(RemotePassword2);
|
||||
else if (servernum == 3) inspircd_cmd_pass(RemotePassword3);
|
||||
inspircd_cmd_pass(uplink_server->password);
|
||||
SendServer(ServerName, 0, ServerDesc);
|
||||
send_cmd(NULL, "BURST");
|
||||
send_cmd(TS6SID, "VERSION :Anope-%s %s :%s - %s (%s) -- %s", version_number, ServerName, ircd->name, version_flags, EncModule, version_build);
|
||||
@@ -728,16 +726,16 @@ int anope_event_mode(const char *source, int ac, const char **av)
|
||||
*/
|
||||
User *u = find_byuid(source);
|
||||
User *u2 = find_byuid(av[0]);
|
||||
|
||||
|
||||
// This can happen with server-origin modes.
|
||||
if (u == NULL)
|
||||
u = u2;
|
||||
|
||||
|
||||
// drop it like fire.
|
||||
// most likely situation was
|
||||
if (u == NULL || u2 == NULL)
|
||||
return MOD_CONT;
|
||||
|
||||
|
||||
av[0] = u2->nick;
|
||||
do_umode(u->nick, ac, av);
|
||||
}
|
||||
|
||||
@@ -595,9 +595,7 @@ class RatboxProto : public IRCDTS6Proto
|
||||
{
|
||||
/* Make myself known to myself in the serverlist */
|
||||
me_server = new_server(NULL, ServerName, ServerDesc, SERVER_ISME, TS6SID);
|
||||
if (servernum == 1) ratbox_cmd_pass(RemotePassword);
|
||||
else if (servernum == 2) ratbox_cmd_pass(RemotePassword2);
|
||||
else if (servernum == 3) ratbox_cmd_pass(RemotePassword3);
|
||||
ratbox_cmd_pass(uplink_server->password);
|
||||
ratbox_cmd_capab();
|
||||
SendServer(ServerName, 1, ServerDesc);
|
||||
ratbox_cmd_svinfo();
|
||||
|
||||
@@ -739,9 +739,7 @@ class UnrealIRCdProto : public IRCDProto
|
||||
if (Numeric) me_server = new_server(NULL, ServerName, ServerDesc, SERVER_ISME, Numeric);
|
||||
else me_server = new_server(NULL, ServerName, ServerDesc, SERVER_ISME, NULL);
|
||||
unreal_cmd_capab();
|
||||
if (servernum == 1) unreal_cmd_pass(RemotePassword);
|
||||
else if (servernum == 2) unreal_cmd_pass(RemotePassword2);
|
||||
else if (servernum == 3) unreal_cmd_pass(RemotePassword3);
|
||||
unreal_cmd_pass(uplink_server->password);
|
||||
SendServer(ServerName, 1, ServerDesc);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user