#include "socket.h"
#include "inspircd.h"
#include "xline.h"
-#include "../transport.h"
#include "utils.h"
-#include "handshaketimer.h"
/*
* The server list in InspIRCd is maintained as two structures
{
SpanningTreeUtilities* Utils; /* Utility class */
std::string myhost; /* Canonical hostname */
- std::string in_buffer; /* Input buffer */
ServerState LinkState; /* Link state */
std::string InboundServerName; /* Server name sent to us by other side */
std::string InboundDescription; /* Server description (GECOS) sent to us by the other side */
int num_lost_servers; /* Servers lost in split */
time_t NextPing; /* Time when we are due to ping this server */
bool LastPingWasGood; /* Responded to last ping we sent? */
+ std::string IP;
std::string ModuleList; /* Required module list of other server from CAPAB */
std::string OptModuleList; /* Optional module list of other server from CAPAB */
std::map<std::string,std::string> CapKeys; /* CAPAB keys from other server */
- Module* Hook; /* I/O hooking module that we're attached to for this socket */
std::string ourchallenge; /* Challenge sent for challenge/response */
std::string theirchallenge; /* Challenge recv for challenge/response */
std::string OutboundPass; /* Outbound password */
bool auth_challenge; /* Did we auth using challenge/response */
int proto_version; /* Remote protocol version */
public:
- HandshakeTimer* hstimer; /* Handshake timer, needed to work around I/O hook buffering */
+ reference<Autoconnect> myautoconnect; /* Autoconnect used to cause this connection, if any */
time_t age;
/** Because most of the I/O gubbins are encapsulated within
* most of the action, and append a few of our own values
* to it.
*/
- TreeSocket(SpanningTreeUtilities* Util, InspIRCd* SI, std::string host, int port, unsigned long maxtime, const std::string &ServerName, const std::string &bindto, Module* HookMod = NULL);
+ TreeSocket(SpanningTreeUtilities* Util, const std::string& host, int port, unsigned long maxtime, const std::string &ServerName, const std::string &bindto, Autoconnect* myac, const std::string& Hook);
/** When a listening socket gives us a new file descriptor,
* we must associate it with a socket without creating a new
* connection. This constructor is used for this purpose.
*/
- TreeSocket(SpanningTreeUtilities* Util, InspIRCd* SI, int newfd, char* ip, Module* HookMod = NULL);
+ TreeSocket(SpanningTreeUtilities* Util, int newfd, ListenSocket* via, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server);
/** Get link state
*/
*/
void CleanNegotiationInfo();
- /** Return the module which we are hooking to for I/O encapsulation
- */
- Module* GetHook();
-
+ CullResult cull();
/** Destructor
*/
~TreeSocket();
* to server docs on the inspircd.org site, the other side
* will then send back its own server string.
*/
- virtual bool OnConnected();
+ virtual void OnConnected();
/** Handle socket error event
*/
*/
void SendError(const std::string &errormessage);
- /** Handle socket disconnect event
- */
- virtual int OnDisconnect();
-
/** Recursively send the server tree with distances as hops.
* This is used during network burst to inform the other server
* (and any of ITS servers too) of what servers we know about.
void Squit(TreeServer* Current, const std::string &reason);
/** FMODE command - server mode with timestamp checks */
- bool ForceMode(const std::string &source, parameterlist ¶ms);
+ void ForceMode(User* who, parameterlist ¶ms);
/** FTOPIC command */
bool ForceTopic(const std::string &source, parameterlist ¶ms);
/** FJOIN, similar to TS6 SJOIN, but not quite. */
- bool ForceJoin(const std::string &source, parameterlist ¶ms);
+ void ForceJoin(User* who, parameterlist ¶ms);
/* Used on nick collision ... XXX ugly function HACK */
int DoCollision(User *u, time_t remotets, const std::string &remoteident, const std::string &remoteip, const std::string &remoteuid);
void DoBurst(TreeServer* s);
/** This function is called when we receive data from a remote
- * server. We buffer the data in a std::string (it doesnt stay
- * there for long), reading using BufferedSocket::Read() which can
- * read up to 16 kilobytes in one operation.
- *
- * IF THIS FUNCTION RETURNS FALSE, THE CORE CLOSES AND DELETES
- * THE SOCKET OBJECT FOR US.
+ * server.
*/
- virtual bool OnDataReady();
+ void OnDataReady();
/** Send one or more complete lines down the socket
*/
void WriteLine(std::string line);
/** Handle ERROR command */
- bool Error(parameterlist ¶ms);
+ void Error(parameterlist ¶ms);
- /** remote MOTD. leet, huh? */
+ /** remote MOTD. */
bool Motd(const std::string &prefix, parameterlist ¶ms);
- /** remote ADMIN. leet, huh? */
+ /** remote ADMIN. */
bool Admin(const std::string &prefix, parameterlist ¶ms);
- /** Remote MODULES */
- bool Modules(const std::string &prefix, parameterlist ¶ms);
-
bool Stats(const std::string &prefix, parameterlist ¶ms);
/** Because the core won't let users or even SERVERS set +o,
/** SAVE to resolve nick collisions without killing */
bool ForceNick(const std::string &prefix, parameterlist ¶ms);
- /** PRIVMSG or NOTICE with server origin ONLY
- */
- bool ServerMessage(const std::string &messagetype, const std::string &prefix, parameterlist ¶ms, const std::string &sourceserv);
-
/** ENCAP command
*/
- bool Encap(const std::string &prefix, parameterlist ¶ms);
+ void Encap(User* who, parameterlist ¶ms);
/** OPERQUIT command
*/
/** Remove all modes from a channel, including statusmodes (+qaovh etc), simplemodes, parameter modes.
* This does not update the timestamp of the target channel, this must be done seperately.
*/
- bool RemoveStatus(const std::string &prefix, parameterlist ¶ms);
+ void RemoveStatus(User* source, parameterlist ¶ms);
/** <- (remote) <- SERVER
*/
*/
bool Inbound_Server(parameterlist ¶ms);
- /** Handle netsplit
+ /** Handle IRC line split
*/
- void Split(const std::string &line, parameterlist &n);
+ void Split(const std::string &line, std::string& prefix, std::string& command, parameterlist ¶ms);
/** Process complete line from buffer
*/
- bool ProcessLine(std::string &line);
+ void ProcessLine(std::string &line);
+
+ void ProcessConnectedLine(std::string& prefix, std::string& command, parameterlist& params);
/** Get this server's name
*/
/** Handle socket timeout from connect()
*/
virtual void OnTimeout();
-
- /** Handle socket close event
+ /** Handle server quit on close
*/
- virtual void OnClose();
+ virtual void Close();
};
/* Used to validate the value lengths of multiple parameters for a command */