*/
-#include "inspircd_config.h"
+#include "inspircd_config.h"
#include "base.h"
#include <string>
#include <map.h>
-
-#ifndef __CONNECTION_H__
-#define __CONNECTION_H__
-
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <netdb.h>
+#include <netinet/in.h>
+#include <unistd.h>
+#include <errno.h>
+#include <time.h>
+
+#ifndef __CONNECTION_H__
+#define __CONNECTION_H__
+
+#define PT_SYN_ONLY 0
+#define PT_ACK_ONLY 1
+#define PT_SYN_WITH_DATA 2
+
+
+class packet : public classbase
+{
+ public:
+ long key;
+ short int id;
+ short int type;
+ char data[MAXBUF];
+
+ packet();
+ ~packet();
+};
+
+
class connection : public classbase
{
public:
+ long key;
int fd; // file descriptor
char host[256]; // hostname
long ip; // ipv4 address
time_t signon;
time_t idle_lastmsg;
time_t nping;
+
+ connection();
+ bool CreateListener(char* host, int port);
+ bool BeginLink(char* targethost, int port, char* password);
+ void TerminateLink(char* targethost);
+ bool SendPacket(char *message, char* host, int port);
+ bool RecvPacket(char *message, char* host, int &port);
+ bool SendSYN(char* host, int port);
+ bool SendACK(char* host, int port, int reply_id);
+ long GenKey();
};
chanrec* FindChan(const char* chan);
char* cmode(userrec *user, chanrec *chan);
string getservername();
+string getserverdesc();
string getnetworkname();
string getadminname();
string getadminemail();
class serverrec : public connection
{
private:
- map<string, serverrec*> leaf; // list of child servers (leaves)
public:
char name[MAXBUF]; // server name
- int pingtime; // last ping response (ms)
- int linktype; // link type, LINK_ACTIVE or LINK_INACTIVE
- time_t lastping; // time the link was last pinged
+ long pingtime; // last ping response (ms)
long usercount_i; // invisible users on server
long usercount; // non-invisible users on server
long opercount; // opers on server
- time_t connected_at; // time server was connected into the network
- time_t hops_away; // number of hops away (for quick access)
+ int hops_away; // number of hops away (for quick access)
long version; // ircd version
bool jupiter; // is a JUPE server (faked to enforce a server ban)
serverrec();
- serverrec(char* n, int link_t, long ver, bool jupe);
+ serverrec(char* n, long ver, bool jupe);
~serverrec();
- void AddLeaf(serverrec *child);
- void DelLeaf(string n);
};
[Project]
FileName=InspIRCd.dev
Name=InspIRCd
-UnitCount=24
+UnitCount=25
Type=1
Ver=1
ObjFiles=
BuildCmd=
[Unit25]
-FileName=..\include\base.h
-Folder=Headers
+FileName=N:\inspircd-cvs\inspircd\src\connection.cpp
+Folder=Source
Compile=1
CompileCpp=1
OverrideBuildCmd=0
[Editors]
-Focused=0
-Order=-1,7,1,2,3,4,5,6,0
+Focused=1
+Order=7,1,2,3,4,5,6,0,-1
[Editor_0]
Open=1
-Top=1
+Top=0
CursorCol=1
CursorRow=1
TopLine=1
[Editor_1]
Open=1
-Top=0
+Top=1
CursorCol=1
-CursorRow=1
-TopLine=1
+CursorRow=3977
+TopLine=3952
LeftChar=1
[Editor_2]
Open=1
Top=0
CursorCol=1
-CursorRow=1
-TopLine=1
+CursorRow=56
+TopLine=36
LeftChar=1
[Editor_3]
Open=1
Top=0
CursorCol=1
-CursorRow=3
+CursorRow=33
TopLine=1
LeftChar=1
Open=1
Top=0
CursorCol=1
-CursorRow=3
+CursorRow=40
TopLine=1
LeftChar=1
LeftChar=1
[Editor_8]
-Open=1
+Open=0
Top=0
CursorCol=1
CursorRow=1
LeftChar=1
[Editor_9]
-Open=1
+Open=0
Top=0
CursorCol=1
CursorRow=1
LeftChar=1
[Editor_10]
-Open=1
+Open=0
Top=0
CursorCol=1
CursorRow=1
LeftChar=1
[Editor_11]
-Open=1
+Open=0
Top=0
CursorCol=1
CursorRow=1
Open=1
Top=0
CursorCol=1
-CursorRow=3
+CursorRow=1
TopLine=1
LeftChar=1
Open=1
Top=0
CursorCol=1
-CursorRow=3
-TopLine=1
+CursorRow=60
+TopLine=27
LeftChar=1
[Editor_14]
-Open=1
+Open=0
Top=0
CursorCol=1
CursorRow=1
LeftChar=1
[Editor_15]
-Open=1
+Open=0
Top=0
CursorCol=1
CursorRow=3
LeftChar=1
[Editor_16]
-Open=1
+Open=0
Top=0
CursorCol=1
CursorRow=3
Open=1
Top=0
CursorCol=1
-CursorRow=3
-TopLine=1
+CursorRow=72
+TopLine=32
LeftChar=1
[Editor_18]
-Open=1
+Open=0
Top=0
CursorCol=1
-CursorRow=14
+CursorRow=1
TopLine=1
LeftChar=1
[Editor_19]
-Open=1
+Open=0
Top=0
CursorCol=1
-CursorRow=3
+CursorRow=1
TopLine=1
LeftChar=1
[Editor_20]
-Open=1
+Open=0
Top=0
CursorCol=1
CursorRow=1
Open=1
Top=0
CursorCol=1
-CursorRow=3
+CursorRow=29
TopLine=1
LeftChar=1
[Editor_22]
-Open=1
+Open=0
Top=0
CursorCol=1
CursorRow=1
LeftChar=1
[Editor_23]
-Open=1
+Open=0
Top=0
CursorCol=1
CursorRow=3
LeftChar=1
[Editor_24]
-Open=0
+Open=1
Top=0
+CursorCol=1
+CursorRow=63
+TopLine=42
+LeftChar=1
CC = im a cheezeball
-SRC_1 = inspircd.cpp inspircd_util.cpp inspircd_io.cpp
+SRC_1 = inspircd.cpp inspircd_util.cpp inspircd_io.cpp connection.cpp
SRC_2 = dynamic.cpp users.cpp modules.cpp wildcard.cpp servers.cpp
SRC = $(SRC_1) $(SRC_2)
CC = im a cheezeball
-SRC_1 = inspircd.cpp inspircd_util.cpp inspircd_io.cpp
+SRC_1 = inspircd.cpp inspircd_util.cpp inspircd_io.cpp connection.cpp
SRC_2 = dynamic.cpp users.cpp modules.cpp wildcard.cpp servers.cpp
SRC = $(SRC_1) $(SRC_2)
typedef deque<command_t> command_table;
typedef DLLFactory<ModuleFactory> ircd_module;
+serverrec* me;
+server_list* servers;
+
user_hash clientlist;
chan_hash chanlist;
user_hash whowas;
-server_list servers;
command_table cmdlist;
file_cache MOTD;
file_cache RULES;
return ServerName;
}
+string getserverdesc()
+{
+ return ServerDesc;
+}
+
string getnetworkname()
{
return Network;
void handle_connect(char **parameters, int pcnt, userrec *user)
{
+ WriteServ(user->fd,"NOTICE %s :*** Connecting to %s port 7000...",user->nick,parameters[0]);
+ if (!me->BeginLink(parameters[0],7000,"password"))
+ {
+ WriteServ(user->fd,"NOTICE %s :*** Failed to send auth packet to %s!",user->nick,parameters[0]);
+ }
}
void handle_squit(char **parameters, int pcnt, userrec *user)
MODCOUNT = count - 1;
debug("Total loaded modules: %d",MODCOUNT+1);
+ me = new serverrec(ServerName,100L,false);
+ servers = new server_list;
+ servers->clear();
+
+ me->CreateListener("127.0.0.1",7000);
+
printf("\nInspIRCd is now running!\n");
startup_time = time(NULL);
}
length = sizeof (client);
- int flip_flop = 0;
+ int flip_flop = 0, udp_port = 0;
+ char udp_msg[MAXBUF], udp_host[MAXBUF];
/* main loop for multiplexing/resetting */
for (;;)
tv.tv_sec = 0;
selectResult = select(MAXSOCKS, &selectFds, NULL, NULL, &tv);
+ if (me->RecvPacket(udp_msg, udp_host, udp_port))
+ {
+ WriteOpers("UDP Link Packet: '%s' from %s:%d",udp_msg,udp_host,udp_port);
+ }
+
for (user_hash::iterator count2 = clientlist.begin(); count2 != clientlist.end(); count2++)
{
char data[MAXBUF];
if (selectResult > 0)
{
char target[MAXBUF], resolved[MAXBUF];
- for (count = 0; count < boundPortCount; count++)
+ for (count = 0; count < boundPortCount; count++)
{
if (FD_ISSET (openSockfd[count], &selectFds))
{
incomingSockfd = accept (openSockfd[count], (struct sockaddr *) &client, &length);
address_cache::iterator iter = IP.find(client.sin_addr);
- bool iscached = false;
+ bool iscached = false;
if (iter == IP.end())
{
/* ip isn't in cache, add it */
strncpy (target, (char *) inet_ntoa (client.sin_addr), MAXBUF);
- if(CleanAndResolve(resolved, target) != TRUE)
- {
- strncpy(resolved,target,MAXBUF);
- }
+ if(CleanAndResolve(resolved, target) != TRUE)
+ {
+ strncpy(resolved,target,MAXBUF);
+ }
/* hostname now in 'target' */
IP[client.sin_addr] = new string(resolved);
- /* hostname in cache */
+ /* hostname in cache */
}
else
{
- /* found ip (cached) */
- strncpy(resolved, iter->second->c_str(), MAXBUF);
- iscached = true;
- }
+ /* found ip (cached) */
+ strncpy(resolved, iter->second->c_str(), MAXBUF);
+ iscached = true;
+ }
if (incomingSockfd < 0)
{
- WriteOpers("*** WARNING: Accept failed on port %d (%s)", ports[count],target);
- debug("InspIRCd: accept failed: %d",ports[count]);
- break;
+ WriteOpers("*** WARNING: Accept failed on port %d (%s)", ports[count],target);
+ debug("InspIRCd: accept failed: %d",ports[count]);
+ break;
}
AddClient(incomingSockfd, resolved, ports[count], iscached);
break;
}
- }
+ }
}
}
}
+void DeadPipe(int status)
+{
+ signal (SIGPIPE, DeadPipe);
+}
+
int DaemonSeed (void)
{
int childpid;
signal (SIGALRM, SIG_IGN);
signal (SIGHUP, Rehash);
- signal (SIGPIPE, SIG_IGN);
+ signal (SIGPIPE, DeadPipe);
signal (SIGTERM, Exit);
signal (SIGABRT, Exit);
signal (SIGSEGV, Error);
serverrec::serverrec()
{
- leaf.clear();
strcpy(name,"");
pingtime = 0;
- linktype = LINK_ACTIVE;
lastping = time(NULL);
usercount_i = usercount = opercount = version = 0;
hops_away = 1;
- connected_at = time(NULL);
+ signon = time(NULL);
jupiter = false;
fd = 0;
}
{
}
-serverrec::serverrec(char* n, int link_t, long ver, bool jupe)
+serverrec::serverrec(char* n, long ver, bool jupe)
{
- leaf.clear();
strcpy(name,n);
- linktype = link_t;
lastping = time(NULL);
usercount_i = usercount = opercount = 0;
version = ver;
hops_away = 1;
- connected_at = time(NULL);
+ signon = time(NULL);
jupiter = jupe;
fd = 0;
}
-void serverrec::AddLeaf(serverrec *child)
-{
- leaf[child->name] = child;
-}
-
-void serverrec::DelLeaf(string n)
-{
- server_list::iterator i = leaf.find(n);
-
- if (i != leaf.end())
- leaf.erase(i);
-}
-
#!sh
-echo "InspIRCd-1.0[Alpha9]"
+echo "InspIRCd-1.0[Alpha10]"