]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Added first part of server linking code
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Sun, 2 Feb 2003 16:43:53 +0000 (16:43 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Sun, 2 Feb 2003 16:43:53 +0000 (16:43 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@160 e03df62e-2008-0410-955e-edbf42e46eb7

include/connection.h
include/inspircd.h
include/servers.h
src/InspIRCd.dev
src/InspIRCd.layout
src/Makefile.FreeBSD
src/Makefile.Linux
src/inspircd.cpp
src/inspircd_io.cpp
src/servers.cpp
src/version.sh

index 91eb7f0dc7093802b0d223d1de6cfc79099998f9..94b657288b019d8e86d7f6bae323d01d3daf2dd8 100644 (file)
@@ -2,17 +2,43 @@
 
 */
 
-#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
@@ -28,6 +54,16 @@ class connection : public classbase
        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();
 };
 
 
index 100b473343cade62b44d9047b778da1f6e62842e..1e1582723bd14f3e690e8c3e4f52d8a730b1085a 100644 (file)
@@ -68,6 +68,7 @@ userrec* Find(string nick);
 chanrec* FindChan(const char* chan);
 char* cmode(userrec *user, chanrec *chan);
 string getservername();
+string getserverdesc();
 string getnetworkname();
 string getadminname();
 string getadminemail();
index 876b54566d45551f52104e0f69bec78877e796da..fc271b37e2ed26df2b3d93be38f70dbdac38ee93 100644 (file)
 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);
 };
 
 
index 7dd7af93e05d506a2f1ac62dd83dc03852dee523..158897e8b498b503539b693bd66ae56f7612532f 100644 (file)
@@ -1,7 +1,7 @@
 [Project]
 FileName=InspIRCd.dev
 Name=InspIRCd
-UnitCount=24
+UnitCount=25
 Type=1
 Ver=1
 ObjFiles=
@@ -212,8 +212,8 @@ OverrideBuildCmd=0
 BuildCmd=
 
 [Unit25]
-FileName=..\include\base.h
-Folder=Headers
+FileName=N:\inspircd-cvs\inspircd\src\connection.cpp
+Folder=Source
 Compile=1
 CompileCpp=1
 OverrideBuildCmd=0
index 322dca836f10ea21b845525f41079eeb141c7665..a9ffae4f7afc0a3860ccca1f0baa274b60967559 100644 (file)
@@ -1,10 +1,10 @@
 [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
@@ -12,18 +12,18 @@ LeftChar=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]
@@ -38,7 +38,7 @@ LeftChar=1
 Open=1
 Top=0
 CursorCol=1
-CursorRow=3
+CursorRow=33
 TopLine=1
 LeftChar=1
 
@@ -46,7 +46,7 @@ LeftChar=1
 Open=1
 Top=0
 CursorCol=1
-CursorRow=3
+CursorRow=40
 TopLine=1
 LeftChar=1
 
@@ -67,7 +67,7 @@ TopLine=1
 LeftChar=1
 
 [Editor_8]
-Open=1
+Open=0
 Top=0
 CursorCol=1
 CursorRow=1
@@ -75,7 +75,7 @@ TopLine=1
 LeftChar=1
 
 [Editor_9]
-Open=1
+Open=0
 Top=0
 CursorCol=1
 CursorRow=1
@@ -83,7 +83,7 @@ TopLine=1
 LeftChar=1
 
 [Editor_10]
-Open=1
+Open=0
 Top=0
 CursorCol=1
 CursorRow=1
@@ -91,7 +91,7 @@ TopLine=1
 LeftChar=1
 
 [Editor_11]
-Open=1
+Open=0
 Top=0
 CursorCol=1
 CursorRow=1
@@ -102,7 +102,7 @@ LeftChar=1
 Open=1
 Top=0
 CursorCol=1
-CursorRow=3
+CursorRow=1
 TopLine=1
 LeftChar=1
 
@@ -110,12 +110,12 @@ 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
@@ -123,7 +123,7 @@ TopLine=1
 LeftChar=1
 
 [Editor_15]
-Open=1
+Open=0
 Top=0
 CursorCol=1
 CursorRow=3
@@ -131,7 +131,7 @@ TopLine=1
 LeftChar=1
 
 [Editor_16]
-Open=1
+Open=0
 Top=0
 CursorCol=1
 CursorRow=3
@@ -142,28 +142,28 @@ LeftChar=1
 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
@@ -174,12 +174,12 @@ LeftChar=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
@@ -187,7 +187,7 @@ TopLine=1
 LeftChar=1
 
 [Editor_23]
-Open=1
+Open=0
 Top=0
 CursorCol=1
 CursorRow=3
@@ -195,5 +195,9 @@ TopLine=1
 LeftChar=1
 
 [Editor_24]
-Open=0
+Open=1
 Top=0
+CursorCol=1
+CursorRow=63
+TopLine=42
+LeftChar=1
index 755f3c7ffc1aa24a4720e1a9715e12c0362f427e..8e8bdce4d81eef724ea0ac8b337d0d8987badf11 100644 (file)
@@ -7,7 +7,7 @@
 
 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)
index 755f3c7ffc1aa24a4720e1a9715e12c0362f427e..8e8bdce4d81eef724ea0ac8b337d0d8987badf11 100644 (file)
@@ -7,7 +7,7 @@
 
 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)
index ac8a46c1f5e19f35b0c2b25cf56f1b37ad7a4cce..33fa511c249c0dbf4f0e87ccdebae664dd93f51a 100644 (file)
@@ -125,10 +125,12 @@ typedef hash_map<in_addr,string*, hash<in_addr>, InAddr_HashComp> address_cache;
 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;
@@ -199,6 +201,11 @@ string getservername()
        return ServerName;
 }
 
+string getserverdesc()
+{
+       return ServerDesc;
+}
+
 string getnetworkname()
 {
        return Network;
@@ -3437,6 +3444,11 @@ void handle_stats(char **parameters, int pcnt, userrec *user)
 
 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)
@@ -3962,6 +3974,12 @@ int InspIRCd(void)
   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);
@@ -4005,7 +4023,8 @@ int InspIRCd(void)
   }
 
   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 (;;)
@@ -4029,6 +4048,11 @@ int InspIRCd(void)
       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];
@@ -4085,38 +4109,38 @@ int InspIRCd(void)
       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);
@@ -4124,7 +4148,7 @@ int InspIRCd(void)
              break;
            }
 
-       }
+          }
       }
   }
 
index d561a9c381063cdaf995c8b5e8b6ff0a6cb97cb8..6e36de4778f00943196b0bfcba3dd27e5c2afef8 100644 (file)
@@ -51,12 +51,17 @@ void Start (void)
 }
 
 
+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);
index 98da2264c19c578ef0923e0075e0feb37f2a1249..2affa9a94391486008393d80b3c7c3d389fb3dcf 100644 (file)
 
 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;
 }
@@ -28,30 +26,15 @@ serverrec::~serverrec()
 {
 }
 
-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);
-}
-
index 14b08aa6144b37381556364e55fc07f2e41539d0..216b9e821989484c912b913b147a2a42d61372a3 100755 (executable)
@@ -1,2 +1,2 @@
 #!sh
-echo "InspIRCd-1.0[Alpha9]"
+echo "InspIRCd-1.0[Alpha10]"