Example #1
0
//---------------------------------------------------------------------------
TRegistry::TRegistry() :
  FCurrentKey(0),
  FRootKey(0),
  FCloseRootKey(false),
  FAccess(KEY_ALL_ACCESS)
{
  // LazyWrite = True;
  SetRootKey(HKEY_CURRENT_USER);
  SetAccess(KEY_ALL_ACCESS);
}
Example #2
0
void UpdateAccess(struct userlist *user, const char *password) {
    struct channellist *clist ;

    SetAccess(user,password) ;

    clist=user->userinfo->channels;
    while(clist!=NULL) {
        SetChanAccess(user,clist->channel->name,password) ;
        clist=clist->next ;
    }
}
//
// The user has moved a scroll bar on the GUI.  Process the update.
// Typically, this means that the user has changed one of the following
// values: % reads, % random, % of size, etc.
//
void CAccessDialog::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar * pScrollBar)
{
	int position = ((CSliderCtrl *) pScrollBar)->GetPos();

	// Modifying access specification based on slider controls.
	if (nSBCode == SB_THUMBTRACK || nSBCode == SB_ENDSCROLL) {
		if (pScrollBar == (CScrollBar *) & m_SAccess) {
			SetAccess(position);
		} else if (pScrollBar == (CScrollBar *) & m_SRead) {
			SetReads(position);
		} else if (pScrollBar == (CScrollBar *) & m_SRandom) {
			SetRandom(position);
		}
	}
}
Example #4
0
static void authsenderr(aClient *cptr)
{
  ircstp->is_abad++;
  
  (void)close(cptr->authfd);
  if (cptr->authfd == highest_fd)
    while (!local[highest_fd])
      highest_fd--;
  cptr->authfd = -1;
  cptr->flags &= ~(FLAGS_AUTH|FLAGS_WRAUTH);
#ifdef SHOW_HEADERS
  send(cptr->fd, REPORT_FAIL_ID, R_fail_id, 0);
#endif

  if (!DoingDNS(cptr))
    SetAccess(cptr);

  return;
}
//
// Calls each of the Set functions.
//
void CAccessDialog::SetAll(Access_Spec * spec)
{
	SetSize(spec->size);
	SetAccess(spec->of_size);
	SetReads(spec->reads);
	SetRandom(spec->random);
	SetDelay(spec->delay);
	SetBurst(spec->burst);

	SetAlign(spec->align);
	EnableMKBControls(&align_controls, spec->align);
	if (!spec->align) {
		// Set the (disabled) alignment controls to 512 bytes (standard sector size).
		SetMKBSpinners(&align_controls, 512);
	}

	SetReply(spec->reply);
	EnableMKBControls(&reply_controls, spec->reply);
	if (!spec->reply) {
		// Set the (disabled) reply size controls to the current transfer size.
		SetMKBSpinners(&reply_controls, spec->size);
	}
}
Example #6
0
void HelpEntry::UpdateAccess(FLAG access)
{
    SetAccess(access);
}
Example #7
0
/*
 * start_auth
 *
 * Flag the client to show that an attempt to contact the ident server on
 * the client's host.  The connect and subsequently the socket are all put
 * into 'non-blocking' mode.  Should the connect or any later phase of the
 * identifing process fail, it is aborted and the user is given a username
 * of "unknown".
 */
void	start_auth(aClient *cptr)
{
  struct sockaddr_in	sock;
  struct sockaddr_in	localaddr;
  int			locallen;

  Debug((DEBUG_NOTICE,"start_auth(%x) fd %d status %d",
	 cptr, cptr->fd, cptr->status));
  if ((cptr->authfd = socket(AF_INET, SOCK_STREAM, 0)) == -1)
    {
#ifdef	USE_SYSLOG
      syslog(LOG_ERR, "Unable to create auth socket for %s:%m",
	     get_client_name(cptr,TRUE));
#endif
      if (!DoingDNS(cptr))
	SetAccess(cptr);
      ircstp->is_abad++;
      return;
    }
  if (cptr->authfd >= MAXCONNECTIONS)
    {
      sendto_ops("Can't allocate fd for auth on %s",
		 get_client_name(cptr, TRUE));
      (void)close(cptr->authfd);
      return;
    }
#ifdef SHOW_HEADERS
  send(cptr->fd, REPORT_DO_ID, R_do_id, 0);
#endif
  set_non_blocking(cptr->authfd, cptr);

  /* get the local address of the client and bind to that to
   * make the auth request.  This used to be done only for
   * ifdef VIRTTUAL_HOST, but needs to be done for all clients
   * since the ident request must originate from that same address--
   * and machines with multiple IP addresses are common now
   */
  locallen = sizeof(struct sockaddr_in);
  bzero(&localaddr, locallen);
  getsockname(cptr->fd, (struct sockaddr *)&localaddr, &locallen);
  localaddr.sin_port = htons(0);

  if (bind(cptr->authfd, (struct sockaddr *)&localaddr,
	   sizeof(localaddr)) == -1)
    {
      report_error("binding auth stream socket %s:%s", cptr);
      (void)close(cptr->fd);
      return;
    }

  bcopy((char *)&cptr->ip, (char *)&sock.sin_addr,
	sizeof(struct in_addr));
  
  sock.sin_port = htons(113);
  sock.sin_family = AF_INET;

/*	(void)alarm((unsigned)4);*/
  if (connect(cptr->authfd, (struct sockaddr *)&sock,
	      sizeof(sock)) == -1 && errno != EINPROGRESS)
    {
      ircstp->is_abad++;
      /*
       * No error report from this...
       */
      /*		(void)alarm((unsigned)0);*/
      (void)close(cptr->authfd);
      cptr->authfd = -1;
      if (!DoingDNS(cptr))
	SetAccess(cptr);
#ifdef SHOW_HEADERS
      send(cptr->fd, REPORT_FAIL_ID, R_fail_id, 0);
#endif
      return;
    }
  /*	(void)alarm((unsigned)0);*/
  cptr->flags |= (FLAGS_WRAUTH|FLAGS_AUTH);
  if (cptr->authfd > highest_fd)
    highest_fd = cptr->authfd;
  return;
}
Example #8
0
/*
 * read_authports
 *
 * read the reply (if any) from the ident server we connected to.
 * The actual read processing here is pretty weak - no handling of the reply
 * if it is fragmented by IP.
 * 
 * This is really broken and needs to be rewritten.  Somehow len is nonzero
 * on failed connects() on Solaris (and maybe others?).  I relocated the
 * REPORT_FIN_ID to hide the problem.  --Rodder
 *
 */
void	read_authports(aClient *cptr)
{
  Reg	char	*s, *t;
  Reg	int	len;
  char	ruser[USERLEN+1], tuser[USERLEN+1];
  u_short	remp = 0, locp = 0;

  *ruser = '******';
  Debug((DEBUG_NOTICE,"read_authports(%x) fd %d authfd %d stat %d",
	 cptr, cptr->fd, cptr->authfd, cptr->status));
  /*
   * Nasty.  Cant allow any other reads from client fd while we're
   * waiting on the authfd to return a full valid string.  Use the
   * client's input buffer to buffer the authd reply.
   * Oh. this is needed because an authd reply may come back in more
   * than 1 read! -avalon
   */
  if ((len = read(cptr->authfd, cptr->buffer + cptr->count,
		  sizeof(cptr->buffer) - 1 - cptr->count)) >= 0)
    {
      cptr->count += len;
      cptr->buffer[cptr->count] = '\0';
    }
  
  if ((len > 0) && (cptr->count != sizeof(cptr->buffer) - 1) &&
      (sscanf(cptr->buffer, "%hd , %hd : USERID : %*[^:]: %10s",
	      &remp, &locp, tuser) == 3) &&
      (s = strrchr(cptr->buffer, ':')))
    {
      for (++s, t = ruser; *s && (t < ruser + sizeof(ruser)); s++)
	if (!isspace(*s) && *s != ':' && *s != '@')
	  *t++ = *s;
      *t = '\0';
      Debug((DEBUG_INFO,"auth reply ok"));
    }
  else if(len != 0) /* then its < 0 an error */
    {
      /* sendto_realops("This is the infamous fdlist.c bug. congrats."); */
      *ruser = '******';
    }

  (void)close(cptr->authfd);
  if (cptr->authfd == highest_fd)
    while (!local[highest_fd])
      highest_fd--;
  cptr->count = 0;
  cptr->authfd = -1;
  ClearAuth(cptr);
  if (!DoingDNS(cptr))
    SetAccess(cptr);
  if (len > 0)
    Debug((DEBUG_INFO,"ident reply: [%s]", cptr->buffer));
  if (!locp || !remp || !*ruser)
    {
      ircstp->is_abad++;
      (void)strcpy(cptr->username, "unknown");
      return;
    }
#ifdef SHOW_HEADERS
  else
    send(cptr->fd, REPORT_FIN_ID, R_fin_id, 0);
#endif

  ircstp->is_asuc++;
  strncpyzt(cptr->username, ruser, USERLEN+1);
  cptr->flags |= FLAGS_GOTID;
  Debug((DEBUG_INFO, "got username [%s]", ruser));
  return;
}
Example #9
0
void be_exception::Generate (be_ClientHeader & source)
{
   if (!Generated ())
   {
      ostream & os = source.Stream ();
      be_Tab tab (source);
      DDS_StdString lname = LocalName ();

      Generated (pbtrue);

      be_root::AddGlobalDeclarations (this);
      be_root::AddAnyOps (*this);
      be_root::AddStreamOps (*this);
      be_root::AddTypedef (*this);
      be_root::AddTypecode (*this);

      GenerateOpenClassDefinition (source);
      GenerateClassDeclarations (source);
      SetAccess (source, CA_PUBLIC);

      // now define nested types

      be_CodeGenerator::Generate (source);

      // generate _downcast

      os << tab << "static " << lname << "* _downcast ("
         << "DDS::Exception *);" << nl;
      os << tab << "static const " << lname << "* _downcast ("
         << "const DDS::Exception *);" << nl;

      // generate factory and builder

      os << tab << "static DDS::Exception * factory ();" << nl;
      os << tab << "static DDS::ExceptionInitializer m_initializer;" << nl << nl;

      // generate inline default constructor

      os << tab << lname << " () {};" << nl;

      // generate convenience constructor

      if (nmembers())
      {
         GenerateConvenienceConstructor (source);
      }

      // generate copy constructor

      os << tab << lname << " (const " << lname << " &);" << nl;

      // generate assignment operator

      os << tab << lname << "& operator = " << "(const " << lname << " &);" << nl;

      // generate duplicate

      os << tab << "virtual DDS::Exception * _clone () const;" << nl;

      // generate raise

      os << tab << "virtual void _raise (" << XBE_Ev::arg (XBE_ENV_ARG1)
         << ") const;" << nl;

      // generate name

      os << tab << "virtual const char * _name () const { return m_name; };" << nl;

      // generate repository id

      os << tab << "virtual const char * _rep_id () const { return m_id; };" << nl;

      // generate virtual destructor

      os << tab << "virtual ~" << lname << " () {}" << nl;

      GenerateMembers (source);
      SetAccess (source, CA_PRIVATE);

      os << tab << "static const char * m_name;" << nl;
      os << tab << "static const char * m_id;" << nl;

      GenerateCloseClassDefinition (source);

      be_root::GenerateDependants
      (
         source,
         SequenceMemberTypeName (),
         EnclosingScope ()
      );
   }
}
Example #10
0
static      time_t
check_pings(time_t currenttime)
{
aClient 	*cptr;
aConfItem 	*aconf = (aConfItem *) NULL;
int     	 killflag, zkillflag, ping = 0, i;
time_t      	 oldest = 0; /* timeout removed, see EXPLANATION below */
char       	*reason, *ktype, fbuf[512];
char 		*errtxt = "No response from %s, closing link";


   for (i = 0; i <= highest_fd; i++) 
   {
      if (!(cptr = local[i]) || IsMe(cptr) || IsLog(cptr))
	 continue;

       /* Note: No need to notify opers here. It's 
	* already done when "FLAGS_DEADSOCKET" is set.
        */

      if (cptr->flags & FLAGS_DEADSOCKET) 
      {
	 (void) exit_client(cptr, cptr, &me, (cptr->flags & FLAGS_SENDQEX) ?
			    "SendQ exceeded" : "Dead socket");
	 i--;
	 continue;
      }

      killflag = NO;
      zkillflag = NO;

      if (rehashed) 
      {
	 if (zline_in_progress) 
	 {
	    if (IsPerson(cptr)) 
	    {
	       if ((aconf = find_zkill(cptr)))	
		  zkillflag = YES;
	    }
	 }
	 else 
	 {
	    if(IsPerson(cptr)) 
	    {
	       if((aconf = find_kill(cptr)))	
		  killflag = YES;	
	    }
	 }
      }

      /* Added a bit of code here to differentiate 
       * between K and Z-lines. -ThemBones
       */

      if (zkillflag || killflag)
      {
         ktype = zkillflag ? "Z-lined" : 
            ((aconf->status == CONF_KILL) ? "K-lined" : "Autokilled");

	 if (killflag) 
         {
	    sendto_ops("%s active for %s",
                       (aconf->status == CONF_KILL) ? "K-line" : "Autokill",
		       get_client_name(cptr, FALSE));
	    reason = aconf->passwd ? aconf->passwd : ktype;
	 }
	 else 
         {			/* its a Z line */
	    sendto_ops("Z-line active for %s",
		       get_client_name(cptr, FALSE));
	    reason = aconf->passwd ? aconf->passwd : "Z-lined";
	 }

	 sendto_one(cptr, err_str(ERR_YOUREBANNEDCREEP),
		    me.name, cptr->name, ktype);

         ircsprintf(fbuf, "%s: %s", ktype, reason);
	 (void) exit_client(cptr, cptr, &me, fbuf);
	 i--;			/* subtract out this fd so we check it again.. */			
	 continue;
      }

      if (IsRegistered(cptr))
	 ping = cptr->pingval;
      else
	 ping = CONNECTTIMEOUT;

      /*
       * Ok, so goto's are ugly and can be avoided here but this code
       * is already indented enough so I think its justified. -avalon
       *
       * justified by what? laziness? <g>
       * If the client pingtime is fine (ie, not larger than the client ping) 
       * skip over all the checks below. - lucas
       */

      if (ping < (currenttime - cptr->lasttime))
      {
         /*
          * If the server hasnt talked to us in 2*ping seconds and it has
          * a ping time, then close its connection. If the client is a
          * user and a KILL line was found to be active, close this
          * connection too.
          */
         if (((cptr->flags & FLAGS_PINGSENT) && ((currenttime - cptr->lasttime) >= (2 * ping))) ||
             ((!IsRegistered(cptr) && (currenttime - cptr->since) >= ping))) 
         {
	    if (!IsRegistered(cptr) && (DoingDNS(cptr) || DoingAuth(cptr))) 
            {
	       if (cptr->authfd >= 0) 
	       {
	          (void) close(cptr->authfd);
	          cptr->authfd = -1;
	          cptr->count = 0;
	          *cptr->buffer = '\0';
	       }
#ifdef SHOW_HEADERS
	       if (DoingDNS(cptr))
	          ssl_send(cptr, REPORT_FAIL_DNS, R_fail_dns, 0);
	       if (DoingAuth(cptr))
	          ssl_send(cptr, REPORT_FAIL_ID, R_fail_id, 0);
#endif
	       Debug((DEBUG_NOTICE, "DNS/AUTH timeout %s",
	 	      get_client_name(cptr, TRUE)));
	       del_queries((char *) cptr);
	       ClearAuth(cptr);
	       ClearDNS(cptr);
	       SetAccess(cptr);
	       cptr->since = currenttime;
	       continue;
	    }

	    if (IsServer(cptr) || IsConnecting(cptr) || IsHandshake(cptr)) 
	    {
	       ircsprintf(fbuf, "from %s: %s", me.name, errtxt);
	       sendto_gnotice(fbuf, get_client_name(cptr, HIDEME));
	       ircsprintf(fbuf, ":%s GNOTICE :%s", me.name, errtxt);                                
	       sendto_serv_butone(cptr, fbuf, get_client_name(cptr, HIDEME));
	    }

	    (void) exit_client(cptr, cptr, &me, "Ping timeout");
	    i--;			/* subtract out this fd so we check it again.. */			
	    continue;
         } /* don't send pings during a burst, as we send them already. */

         else if (!(cptr->flags & (FLAGS_PINGSENT|FLAGS_BURST))) {
	    /*
	     * if we havent PINGed the connection and we havent heard from
	     * it in a while, PING it to make sure it is still alive.
	     */
	    cptr->flags |= FLAGS_PINGSENT;
	    /*
	     * not nice but does the job 
	     */
	    cptr->lasttime = currenttime - ping;
	    sendto_one(cptr, "PING :%s", me.name);
         }
      }

      /* see EXPLANATION below
       *
       * timeout = cptr->lasttime + ping;
       * while (timeout <= currenttime)
       *  timeout += ping;
       * if (timeout < oldest || !oldest)
       *   oldest = timeout;
       */

      /*
       * Check UNKNOWN connections - if they have been in this state
       * for > 100s, close them.
       */
      if (IsUnknown(cptr))
	 if (cptr->firsttime ? ((timeofday - cptr->firsttime) > 100) : 0) 
	    (void) exit_client(cptr, cptr, &me, "Connection Timed Out");
   }

   rehashed = 0;
   zline_in_progress = 0;

   /* EXPLANATION
    * on a server with a large volume of clients, at any given point
    * there may be a client which needs to be pinged the next second,
    * or even right away (a second may have passed while running
    * check_pings). Preserving CPU time is more important than
    * pinging clients out at exact times, IMO. Therefore, I am going to make
    * check_pings always return currenttime + 9. This means that it may take
    * a user up to 9 seconds more than pingfreq to timeout. Oh well.
    * Plus, the number is 9 to 'stagger' our check_pings calls out over
    * time, to avoid doing it and the other tasks ircd does at the same time
    * all the time (which are usually done on intervals of 5 seconds or so). 
    * - lucas
    *
    *  if (!oldest || oldest < currenttime)
    *     oldest = currenttime + PINGFREQUENCY;
    */

   oldest = currenttime + 9;

   Debug((DEBUG_NOTICE, "Next check_ping() call at: %s, %d %d %d",
	  myctime(oldest), ping, oldest, currenttime));

   return oldest;
}
Example #11
0
static	time_t	check_pings(time_t currenttime)
{		
  register	aClient	*cptr;		/* current local cptr being examined */
  aConfItem 	*aconf = (aConfItem *)NULL;
  int		ping = 0;		/* ping time value from client */
  int		i;			/* used to index through fd/cptr's */
  time_t	oldest = 0;		/* next ping time */
  time_t	timeout;		/* found necessary ping time */
  char *reason;				/* pointer to reason string */
  int die_index=0;			/* index into list */
  char ping_time_out_buffer[64];	/* blech that should be a define */

					/* of dying clients */
  dying_clients[0] = (aClient *)NULL;	/* mark first one empty */

  /*
   * I re-wrote the way klines are handled. Instead of rescanning
   * the local[] array and calling exit_client() right away, I
   * mark the client thats dying by placing a pointer to its aClient
   * into dying_clients[]. When I have examined all in local[],
   * I then examine the dying_clients[] for aClient's to exit.
   * This saves the rescan on k-lines, also greatly simplifies the code,
   *
   * Jan 28, 1998
   * -Dianora
   */

   for (i = 0; i <= highest_fd; i++)
    {
      if (!(cptr = local[i]) || IsMe(cptr) || IsLog(cptr))
	continue;		/* and go examine next fd/cptr */
      /*
      ** Note: No need to notify opers here. It's
      ** already done when "FLAGS_DEADSOCKET" is set.
      */
      if (cptr->flags & FLAGS_DEADSOCKET)
	{
	  /* N.B. EVERY single time dying_clients[] is set
	   * it must be followed by an immediate continue,
	   * to prevent this cptr from being marked again for exit.
	   * If you don't, you could cause exit_client() to be called twice
	   * for the same cptr. i.e. bad news
	   * -Dianora
	   */

	  dying_clients[die_index] = cptr;
	  dying_clients_reason[die_index++] =
	    ((cptr->flags & FLAGS_SENDQEX) ?
	     "SendQ exceeded" : "Dead socket");
	  dying_clients[die_index] = (aClient *)NULL;
	  continue;		/* and go examine next fd/cptr */
	}

      if (rehashed)
	{
	  if(dline_in_progress)
	    {
	      if(IsPerson(cptr))
		{
		  if( (aconf = find_dkill(cptr)) ) /* if there is a returned 
						      aConfItem then kill it */
		    {
		      sendto_ops("D-line active for %s",
				 get_client_name(cptr, FALSE));

		      dying_clients[die_index] = cptr;
#ifdef KLINE_WITH_REASON
		      reason = aconf->passwd ? aconf->passwd : "D-lined";
		      dying_clients_reason[die_index++] = reason;
#else
		      dying_clients_reason[die_index++] = "D-lined";
#endif
		      dying_clients[die_index] = (aClient *)NULL;
		      sendto_one(cptr, err_str(ERR_YOUREBANNEDCREEP),
				 me.name, cptr->name, reason);
		      continue;		/* and go examine next fd/cptr */
		    }
		}
	    }
	  else
	    {
	      if(IsPerson(cptr))
		{
#ifdef GLINES
		  if( (aconf = find_gkill(cptr)) )
		    {
		      sendto_ops("G-line active for %s",
				 get_client_name(cptr, FALSE));

		      dying_clients[die_index] = cptr;
#ifdef KLINE_WITH_REASON
		      reason = aconf->passwd ? aconf->passwd : "G-lined";
		      dying_clients_reason[die_index++] = reason;
#else
		      dying_clients_reason[die_index++] = "G-lined";
#endif
		      dying_clients[die_index] = (aClient *)NULL;
		      sendto_one(cptr, err_str(ERR_YOUREBANNEDCREEP),
				 me.name, cptr->name, reason);
		      continue;		/* and go examine next fd/cptr */
		    }
		  else
#endif
		  if((aconf = find_kill(cptr)))	/* if there is a returned
						   aConfItem.. then kill it */
		    {
		      sendto_ops("K-line active for %s",
				 get_client_name(cptr, FALSE));
		      dying_clients[die_index] = cptr;

#ifdef KLINE_WITH_REASON
#ifdef K_COMMENT_ONLY
		      reason = aconf->passwd ? aconf->passwd : "K-lined";
#else
		      reason = (BadPtr(aconf->passwd) || 
				!is_comment(aconf->passwd)) ?
			"K-lined" : aconf->passwd;
#endif
		      dying_clients_reason[die_index++] = reason;
#else
		      dying_clients_reason[die_index++] = "K-lined";
#endif
		      dying_clients[die_index] = (aClient *)NULL;
		      sendto_one(cptr, err_str(ERR_YOUREBANNEDCREEP),
				 me.name, cptr->name, reason);
		      continue;		/* and go examine next fd/cptr */
		    }
		}
	    }
	}

#ifdef IDLE_CHECK
      if (IsPerson(cptr))
	{
	  if( !IsElined(cptr) && ((timeofday - cptr->user->last) > idle_time))
	    {
	      aConfItem *aconf;

	      dying_clients[die_index] = cptr;
	      dying_clients_reason[die_index++] = "idle exceeder";
	      dying_clients[die_index] = (aClient *)NULL;

	      aconf = make_conf();
	      aconf->status = CONF_KILL;
	      DupString(aconf->host, cptr->user->host);
	      DupString(aconf->passwd, "idle exceeder" );
	      DupString(aconf->name, cptr->user->username);
	      aconf->port = 0;
	      aconf->hold = timeofday + 60;
	      add_temp_kline(aconf);
	      sendto_ops("Idle exceeder %s temp k-lining",
			 get_client_name(cptr,FALSE));
	      continue;		/* and go examine next fd/cptr */
	    }
	}
#endif

#ifdef REJECT_HOLD
      if (IsRejectHeld(cptr))
	{
	  if( timeofday > (cptr->firsttime + REJECT_HOLD_TIME) )
	    {
	      dying_clients[die_index] = cptr;
	      dying_clients_reason[die_index++] = "reject held client";
	      dying_clients[die_index] = (aClient *)NULL;
	      continue;		/* and go examine next fd/cptr */
	    }
	}
#endif

#if defined(R_LINES) && defined(R_LINES_OFTEN)
      /*
       * this is used for KILL lines with time restrictions
       * on them - send a message to the user being killed
       * first.
       * *** Moved up above  -taner ***
       *
       * Moved here, no more rflag -Dianora 
       */
      if (IsPerson(cptr) && find_restrict(cptr))
	{
	  sendto_ops("Restricting %s, closing link.",
		     get_client_name(cptr,FALSE));

	  dying_clients[die_index] = cptr;
	  dying_clients_reason[die_index++] = "you have been R-lined";
	  dying_clients[die_index] = (aClient *)NULL;
	  continue;			/* and go examine next fd/cptr */
	}
#endif

      if (!IsRegistered(cptr))
	ping = CONNECTTIMEOUT;
      else
	ping = get_client_ping(cptr);

      /*
       * Ok, so goto's are ugly and can be avoided here but this code
       * is already indented enough so I think its justified. -avalon
       */
       /*  if (!rflag &&
	       (ping >= currenttime - cptr->lasttime))
	      goto ping_timeout; */

      /*
       * *sigh* I think not -Dianora
       */

      if (ping < (currenttime - cptr->lasttime))
	{

	  /*
	   * If the server hasnt talked to us in 2*ping seconds
	   * and it has a ping time, then close its connection.
	   * If the client is a user and a KILL line was found
	   * to be active, close this connection too.
	   */
	  if (((currenttime - cptr->lasttime) >= (2 * ping) &&
	       (cptr->flags & FLAGS_PINGSENT)) ||
	      ((!IsRegistered(cptr) && (currenttime - cptr->since) >= ping)))
	    {
	      if (!IsRegistered(cptr) &&
		  (DoingDNS(cptr) || DoingAuth(cptr)))
		{
		  if (cptr->authfd >= 0)
		    {
		      (void)close(cptr->authfd);
		      cptr->authfd = -1;
		      cptr->count = 0;
		      *cptr->buffer = '\0';
		    }
#ifdef SHOW_HEADERS
		  if (DoingDNS(cptr))
		    send(cptr->fd, REPORT_FAIL_DNS, R_fail_dns, 0);
		  else
		    send(cptr->fd, REPORT_FAIL_ID, R_fail_id, 0);
#endif
		  Debug((DEBUG_NOTICE,"DNS/AUTH timeout %s",
			 get_client_name(cptr,TRUE)));
		  del_queries((char *)cptr);
		  ClearAuth(cptr);
		  ClearDNS(cptr);
		  SetAccess(cptr);
		  cptr->since = currenttime;
		  continue;
		}
	      if (IsServer(cptr) || IsConnecting(cptr) ||
		  IsHandshake(cptr))
		{
		  sendto_ops("No response from %s, closing link",
			     get_client_name(cptr, FALSE));
		}
	      /*
	       * this is used for KILL lines with time restrictions
	       * on them - send a messgae to the user being killed
	       * first.
	       * *** Moved up above  -taner ***
	       */
	      cptr->flags2 |= FLAGS2_PING_TIMEOUT;
	      dying_clients[die_index++] = cptr;
	      /* the reason is taken care of at exit time */
      /*      dying_clients_reason[die_index++] = "Ping timeout"; */
	      dying_clients[die_index] = (aClient *)NULL;
	      
	      /*
	       * need to start loop over because the close can
	       * affect the ordering of the local[] array.- avalon
	       *
	       ** Not if you do it right - Dianora
	       */

	      continue;
	    }
	  else if ((cptr->flags & FLAGS_PINGSENT) == 0)
	    {
	      /*
	       * if we havent PINGed the connection and we havent
	       * heard from it in a while, PING it to make sure
	       * it is still alive.
	       */
	      cptr->flags |= FLAGS_PINGSENT;
	      /* not nice but does the job */
	      cptr->lasttime = currenttime - ping;
	      sendto_one(cptr, "PING :%s", me.name);
	    }
	}
      /* ping_timeout: */
      timeout = cptr->lasttime + ping;
      while (timeout <= currenttime)
	timeout += ping;
      if (timeout < oldest || !oldest)
	oldest = timeout;

      /*
       * Check UNKNOWN connections - if they have been in this state
       * for > 100s, close them.
       */

      if (IsUnknown(cptr))
	{
	  if (cptr->firsttime ? ((timeofday - cptr->firsttime) > 100) : 0)
	    {
	      dying_clients[die_index] = cptr;
	      dying_clients_reason[die_index++] = "Connection Timed Out";
	      dying_clients[die_index] = (aClient *)NULL;
	      continue;
	    }
	}
    }

  /* Now exit clients marked for exit above.
   * it doesn't matter if local[] gets re-arranged now
   *
   * -Dianora
   */

  for(die_index = 0; (cptr = dying_clients[die_index]); die_index++)
    {
      if(cptr->flags2 & FLAGS2_PING_TIMEOUT)
	{
	  (void)ircsprintf(ping_time_out_buffer,
			    "Ping timeout: %d seconds",
			    currenttime - cptr->lasttime);
	  (void)exit_client(cptr, cptr, &me, ping_time_out_buffer );
	}
      else
	(void)exit_client(cptr, cptr, &me, dying_clients_reason[die_index]);
    }

  rehashed = 0;
  dline_in_progress = 0;

  if (!oldest || oldest < currenttime)
    oldest = currenttime + PINGFREQUENCY;
  Debug((DEBUG_NOTICE,"Next check_ping() call at: %s, %d %d %d",
	 myctime(oldest), ping, oldest, currenttime));
  
  return (oldest);
}
Example #12
0
void BindClass(Cm::Sym::SymbolTable& symbolTable, Cm::Sym::ContainerScope* containerScope, const std::vector<std::unique_ptr<Cm::Sym::FileScope>>& fileScopes,
    Cm::Core::ClassTemplateRepository& classTemplateRepository, Cm::BoundTree::BoundCompileUnit& boundCompileUnit, Cm::Ast::ClassNode* classNode, Cm::Sym::ClassTypeSymbol* classTypeSymbol)
{
    if (classTypeSymbol->Bound()) return;
    if (classNode->GetCompileUnit())
    {
        classTypeSymbol->SetSourceFilePath(classNode->GetCompileUnit()->FilePath());
    }
    Cm::Ast::Specifiers specifiers = classNode->GetSpecifiers();
    bool isClassMember = classNode->Parent()->IsClassNode();
    SetAccess(classTypeSymbol, specifiers, isClassMember);
    if ((specifiers & Cm::Ast::Specifiers::static_) != Cm::Ast::Specifiers::none)
    {
        classTypeSymbol->SetStatic();
    }
    if ((specifiers & Cm::Ast::Specifiers::abstract_) != Cm::Ast::Specifiers::none)
    {
        classTypeSymbol->SetAbstract();
    }
    if ((specifiers & Cm::Ast::Specifiers::virtual_) != Cm::Ast::Specifiers::none)
    {
        throw Cm::Core::Exception("class cannnot be virtual", classTypeSymbol->GetSpan());
    }
    if ((specifiers & Cm::Ast::Specifiers::override_) != Cm::Ast::Specifiers::none)
    {
        throw Cm::Core::Exception("class cannnot be override", classTypeSymbol->GetSpan());
    }
    if ((specifiers & Cm::Ast::Specifiers::explicit_) != Cm::Ast::Specifiers::none)
    {
        throw Cm::Core::Exception("class cannnot be explicit", classTypeSymbol->GetSpan());
    }
    if ((specifiers & Cm::Ast::Specifiers::external) != Cm::Ast::Specifiers::none)
    {
        throw Cm::Core::Exception("class cannnot be external", classTypeSymbol->GetSpan());
    }
    if ((specifiers & Cm::Ast::Specifiers::suppress) != Cm::Ast::Specifiers::none)
    {
        throw Cm::Core::Exception("class cannnot be suppressed", classTypeSymbol->GetSpan());
    }
    if ((specifiers & Cm::Ast::Specifiers::default_) != Cm::Ast::Specifiers::none)
    {
        throw Cm::Core::Exception("class cannnot be default", classTypeSymbol->GetSpan());
    }
    if ((specifiers & Cm::Ast::Specifiers::inline_) != Cm::Ast::Specifiers::none)
    {
        throw Cm::Core::Exception("class cannnot be inline", classTypeSymbol->GetSpan());
    }
    if ((specifiers & Cm::Ast::Specifiers::constexpr_) != Cm::Ast::Specifiers::none)
    {
        throw Cm::Core::Exception("class cannnot be constexpr", classTypeSymbol->GetSpan());
    }
    if ((specifiers & Cm::Ast::Specifiers::cdecl_) != Cm::Ast::Specifiers::none)
    {
        throw Cm::Core::Exception("class cannnot be cdecl", classTypeSymbol->GetSpan());
    }
    if ((specifiers & Cm::Ast::Specifiers::nothrow_) != Cm::Ast::Specifiers::none)
    {
        throw Cm::Core::Exception("class cannnot be nothrow", classTypeSymbol->GetSpan());
    }
    if ((specifiers & Cm::Ast::Specifiers::throw_) != Cm::Ast::Specifiers::none)
    {
        throw Cm::Core::Exception("class cannnot be throw", classTypeSymbol->GetSpan());
    }
    if ((specifiers & Cm::Ast::Specifiers::new_) != Cm::Ast::Specifiers::none)
    {
        throw Cm::Core::Exception("class cannnot be new", classTypeSymbol->GetSpan());
    }
    if (classNode->TemplateParameters().Count() > 0)
    {
        classTypeSymbol->SetBound();
        return;
    }
    for (const std::unique_ptr<Cm::Ast::Node>& baseClassOrImplIntf : classNode->BaseClassOrImplIntfTypeExprs())
    {
        Cm::Sym::TypeSymbol* type = ResolveType(symbolTable, classTypeSymbol->GetContainerScope(), fileScopes, classTemplateRepository, boundCompileUnit, baseClassOrImplIntf.get());
        if (type)
        {
            if (type->IsClassTypeSymbol())
            {
                Cm::Sym::ClassTypeSymbol* baseClassType = static_cast<Cm::Sym::ClassTypeSymbol*>(type);
                if (Cm::Sym::TypesEqual(classTypeSymbol, baseClassType))
                {
                    Cm::Core::Exception("class cannot derive from itself", classTypeSymbol->GetSpan());
                }
                else
                {
                    if (!classTypeSymbol->BaseClassSet() && classTypeSymbol->BaseClass())
                    {
                        throw Cm::Core::Exception("class cannot have more than one base class", classTypeSymbol->GetSpan(), baseClassType->GetSpan());
                    }
                    Cm::Ast::Node* node = symbolTable.GetNode(baseClassType, false);
                    if (node)
                    {
                        if (node->IsClassNode())
                        {
                            Cm::Ast::ClassNode* baseClassNode = static_cast<Cm::Ast::ClassNode*>(node);
                            Cm::Sym::ContainerScope* baseClassContainerScope = symbolTable.GetContainerScope(baseClassNode);
                            BindClass(symbolTable, baseClassContainerScope, fileScopes, classTemplateRepository, boundCompileUnit, baseClassNode, baseClassType);
                        }
                        else
                        {
                            throw std::runtime_error("class node expected");
                        }
                    }
                    if (baseClassType->Access() < classTypeSymbol->Access())
                    {
                        throw Cm::Core::Exception("base class type must be at least as accessible as the class type itself", baseClassType->GetSpan(), classTypeSymbol->GetSpan());
                    }
                    classTypeSymbol->SetBaseClass(baseClassType);
                    classTypeSymbol->GetContainerScope()->SetBase(baseClassType->GetContainerScope());
                }
            }
            else if (type->IsInterfaceTypeSymbol())
            {
                Cm::Sym::InterfaceTypeSymbol* interfaceType = static_cast<Cm::Sym::InterfaceTypeSymbol*>(type);
                Cm::Ast::Node* node = symbolTable.GetNode(interfaceType, false);
                if (node)
                {
                    if (node->IsInterfaceNode())
                    {
                        Cm::Ast::InterfaceNode* interfaceNode = static_cast<Cm::Ast::InterfaceNode*>(node);
                        Cm::Sym::ContainerScope* interfaceContainerScope = symbolTable.GetContainerScope(interfaceNode);
                        BindInterface(symbolTable, interfaceContainerScope, fileScopes, interfaceNode);
                    }
                    else
                    {
                        throw std::runtime_error("interface node expected");
                    }
                }
                if (!classTypeSymbol->ImplementedInterfacesSet())
                {
                    for (Cm::Sym::InterfaceTypeSymbol* implementedInterface : classTypeSymbol->ImplementedInterfaces())
                    {
                        if (Cm::Sym::TypesEqual(interfaceType, implementedInterface))
                        {
                            throw Cm::Core::Exception("class already implements interface '" + implementedInterface->FullName() + "'", interfaceType->GetSpan());
                        }
                    }
                    classTypeSymbol->AddImplementedInterface(interfaceType);
                }
            }
            else
            {
                throw Cm::Core::Exception("type expression does not denote a class type or interface type", baseClassOrImplIntf->GetSpan());
            }
        }
        else
        {
            throw Cm::Core::Exception("type expression does not denote a type", baseClassOrImplIntf->GetSpan());
        }
    }
    if (!classTypeSymbol->IrTypeMade())
    {
        classTypeSymbol->SetIrType(Cm::IrIntf::CreateClassTypeName(classTypeSymbol->FullName()));
    }
    classTypeSymbol->SetBaseClassSet();
    classTypeSymbol->SetImplementedInterfacesSet();
    classTypeSymbol->SetBound();
}