X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;ds=sidebyside;f=include%2Fconnection.h;h=ab7bd81e1f68c46fce734c801cfdeee1c19c0316;hb=bfcc7d5ff4dcd453a89725d482d59b87b57a3c68;hp=954cc919bd7838995ffa942795098af5e369b796;hpb=ac60f15b03d248318e9378ce2abfb7c9a1663dd4;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/include/connection.h b/include/connection.h index 954cc919b..ab7bd81e1 100644 --- a/include/connection.h +++ b/include/connection.h @@ -1,13 +1,25 @@ -/* - -*/ +/* +------------------------------------+ + * | Inspire Internet Relay Chat Daemon | + * +------------------------------------+ + * + * Inspire is copyright (C) 2002-2004 ChatSpike-Dev. + * E-mail: + * + * + * + * Written by Craig Edwards, Craig McLure, and others. + * This program is free but copyrighted software; see + * the file COPYING for details. + * + * --------------------------------------------------- + */ #include "inspircd_config.h" #include "base.h" #include #include -#include #include +#include #include #include #include @@ -15,121 +27,80 @@ #include #include #include +#include #ifndef __CONNECTION_H__ #define __CONNECTION_H__ -#define STATE_DISCONNECTED 0 -#define STATE_CONNECTED 1 -#define STATE_SYNC 2 -#define STATE_NOAUTH_INBOUND 3 -#define STATE_NOAUTH_OUTBOUND 4 - -/** Each connection has one or more of these - * each represents ONE outbound connection to another ircd - * so each inbound has multiple outbounds. +/** Please note: classes serverrec and userrec both inherit from class connection. */ -class ircd_connector : public classbase +class connection : public Extensible { - private: - /** Sockaddr of the outbound ip and port - */ - sockaddr_in addr; - + public: /** File descriptor of the connection */ int fd; - /** Server name - */ - std::string servername; - - /** Server 'GECOS' + /** Hostname of connection. Not used if this is a serverrec */ - std::string description; + char host[160]; - /** Server names of servers that this server is linked to - * So for A->B->C, if this was the record for B it would contain A and C - * whilever both servers are connected to B. + /** IP of connection. */ - std::vector routes; + char ip[16]; - /** State. STATE_NOAUTH_INBOUND, STATE_NOAUTH_OUTBOUND - * STATE_SYNC, STATE_DISCONNECTED, STATE_CONNECTED + /** Stats counter for bytes inbound */ - int state; - - bool SetHostAddress(char* host, int port); - - public: - char host[MAXBUF]; - int port; - - - bool MakeOutboundConnection(char* host, int port); - std::string GetServerName(); - void SetServerName(std::string serv); - int GetDescriptor(); - void SetDescriptor(int fd); - int GetState(); - void SetState(int state); - char* GetServerIP(); - std::string GetDescription(); - void SetDescription(std::string desc); - int GetServerPort(); - bool SetHostAndPort(char* host, int port); -}; - + int bytes_in; -class packet : public classbase -{ - public: - long key; - int id; - short int type; - char data[MAXBUF]; + /** Stats counter for bytes outbound + */ + int bytes_out; - packet(); - ~packet(); -}; + /** Stats counter for commands inbound + */ + int cmds_in; + /** Stats counter for commands outbound + */ + int cmds_out; -class connection : public classbase -{ - public: - long key; - int fd; // file descriptor - char host[256]; // hostname - long ip; // ipv4 address - char inbuf[MAXBUF]; // recvQ - long bytes_in; - long bytes_out; - long cmds_in; - long cmds_out; + /** True if server/user has authenticated, false if otherwise + */ bool haspassed; + + /** Port number + * For a userrec, this is the port they connected to the network on. + * For a serverrec this is the current listening port of the serverrec object. + */ int port; - int registered; - short int state; + + /** Used by userrec to indicate the registration status of the connection + */ + char registered; + + /** Time the connection was last pinged + */ time_t lastping; + + /** Time the connection was created, set in the constructor + */ time_t signon; + + /** Time that the connection last sent data, used to calculate idle time + */ time_t idle_lastmsg; + + /** Used by PING checks with clients + */ time_t nping; - char internal_addr[1024]; - int internal_port; - std::vector connectors; + /** Default constructor + */ connection(); - bool CreateListener(char* host, int p); - bool BeginLink(char* targethost, int port, char* password, char* servername); - bool MeshCookie(char* targethost, int port, long cookie, char* servername); - void TerminateLink(char* targethost); - bool SendPacket(char *message, const char* host); - bool RecvPacket(std::deque &messages, char* host); - ircd_connector* FindHost(std::string host); - bool AddIncoming(int fd,char* targethost, int sourceport); - long GenKey(); }; #endif +