]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree/treesocket.h
Make classbase and refcountbase uncopyable; expand comments on their indended uses
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / treesocket.h
index 93016126b027d06ab4fc2039073e6d073f7ae046..b5f97c30f55b49ea84737a7ec75ae466392ed2bc 100644 (file)
 #ifndef __TREESOCKET_H__
 #define __TREESOCKET_H__
 
-#include "commands/cmd_whois.h"
-#include "commands/cmd_stats.h"
 #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
@@ -73,7 +69,6 @@ class TreeSocket : public BufferedSocket
 {
        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 */
@@ -82,19 +77,19 @@ class TreeSocket : public BufferedSocket
        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 sentcapab;                         /* Have sent CAPAB already */
+       int capab_phase;                        /* Have sent CAPAB already */
        bool auth_fingerprint;                  /* Did we auth using SSL fingerprint */
        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
@@ -102,13 +97,13 @@ class TreeSocket : public BufferedSocket
         * 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, ListenSocketBase* via, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server);
 
        /** Get link state
         */
@@ -138,10 +133,7 @@ class TreeSocket : public BufferedSocket
         */
        void CleanNegotiationInfo();
 
-       /** Return the module which we are hooking to for I/O encapsulation
-        */
-       Module* GetHook();
-
+       CullResult cull();
        /** Destructor
         */
        ~TreeSocket();
@@ -161,7 +153,7 @@ class TreeSocket : public BufferedSocket
         * 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
         */
@@ -172,10 +164,6 @@ class TreeSocket : public BufferedSocket
         */
        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.
@@ -194,7 +182,10 @@ class TreeSocket : public BufferedSocket
 
        /** Send my capabilities to the remote side
         */
-       void SendCapabilities();
+       void SendCapabilities(int phase);
+
+       /** Add modules to VF_COMMON list for backwards compatability */
+       void CompatAddModules(std::vector<std::string>& modlist);
 
        /* Check a comma seperated list for an item */
        bool HasItem(const std::string &list, const std::string &item);
@@ -256,14 +247,9 @@ class TreeSocket : public BufferedSocket
        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
         */
@@ -272,15 +258,12 @@ class TreeSocket : public BufferedSocket
        /** Handle ERROR command */
        bool Error(parameterlist &params);
 
-       /** remote MOTD. leet, huh? */
+       /** remote MOTD. */
        bool Motd(const std::string &prefix, parameterlist &params);
 
-       /** remote ADMIN. leet, huh? */
+       /** remote ADMIN. */
        bool Admin(const std::string &prefix, parameterlist &params);
 
-       /** Remote MODULES */
-       bool Modules(const std::string &prefix, parameterlist &params);
-
        bool Stats(const std::string &prefix, parameterlist &params);
 
        /** Because the core won't let users or even SERVERS set +o,
@@ -288,14 +271,16 @@ class TreeSocket : public BufferedSocket
         */
        bool OperType(const std::string &prefix, parameterlist &params);
 
+       /** Remote AWAY */
+       bool Away(const std::string &prefix, parameterlist &params);
+
        /** Because Andy insists that services-compatible servers must
         * implement SVSNICK and SVSJOIN, that's exactly what we do :p
         */
-       bool ForceNick(const std::string &prefix, parameterlist &params);
+       bool SVSNick(const std::string &prefix, parameterlist &params);
 
-       /** PRIVMSG or NOTICE with server origin ONLY
-        */
-       bool ServerMessage(const std::string &messagetype, const std::string &prefix, parameterlist &params, const std::string &sourceserv);
+       /** SAVE to resolve nick collisions without killing */
+       bool ForceNick(const std::string &prefix, parameterlist &params);
 
        /** ENCAP command
         */
@@ -381,13 +366,15 @@ class TreeSocket : public BufferedSocket
         */
        bool Inbound_Server(parameterlist &params);
 
-       /** 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 &params);
 
        /** 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
         */
@@ -396,10 +383,9 @@ class TreeSocket : public BufferedSocket
        /** 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 */