Beispiel #1
0
void irc_Kill(IRC_User* u, IRC_User *s, char *msg)
{
  if(irc_IsLocalUser(u))
    return;
  sendto_ircd(s->nick,"KILL %s :%s", u->nick, msg ? msg : "");
  irc_CallEvent(ET_KILL, u, s);
  remove_remote_user(u);
}
Beispiel #2
0
/* sends a sanotice */
void irc_SendSanotice(IRC_User* from, char *fmt, ...)
{
  char buf[512];
  va_list args;
  
  va_start(args, fmt);
  vsnprintf(buf, sizeof(buf), fmt, args);
  sendto_ircd(from->nick, "SANOTICE :%s", buf);
  va_end(args);
}
Beispiel #3
0
void irc_GlobalMessage(IRC_User *from, char *mask, char *fmt, ...)
{
  char buf[512];
  va_list args;
  
  va_start(args, fmt);
  vsnprintf(buf, sizeof(buf), fmt, args);
  sendto_ircd(from->nick, "PRIVMSG $*%s :%s", mask, buf);
  va_end(args);
}
Beispiel #4
0
void irc_SendONotice(IRC_Chan *to, IRC_User *from, char *fmt, ...)
{
  char buf[512];
  va_list args;
  
  va_start(args, fmt);
  vsnprintf(buf, sizeof(buf), fmt, args);
  sendto_ircd(from->nick, "NOTICE @%s :%s", to->name, buf);
  va_end(args);
}
Beispiel #5
0
void irc_SendMsg(IRC_User *to, IRC_User *from, char *fmt, ...)
{
  char buf[512];
  va_list args;
  
  va_start(args, fmt);
  vsnprintf(buf, sizeof(buf), fmt, args);
  sendto_ircd(from->nick, "PRIVMSG %s :%s", to->nick, buf);
  va_end(args);
}
Beispiel #6
0
/*
 * passwd_start
 *
 *	This procedure is called to start an authentication.
 *	Returns 0 if everything went fine,
 *	+1 if still waiting for some data (username, password)..
 *	-1 otherwise (nothing to be done, or failure)
 *
 *	It is responsible for sending error messages where appropriate.
 *	In case of failure, it's responsible for cleaning up (e.g. passwd_clean
 *	will NOT be called)
 */
int	passwd_start(u_int cl)
{
	if (cldata[cl].authuser &&
	    cldata[cl].authfrom < cldata[cl].instance->in)
	    {
		/*
		** another instance preceding this one in the configuration
		** has already authenticated the user, no need to bother
		** doing anything here then. (the other takes precedence)
		*/
		return -1;
	    }
	if ((cldata[cl].state & A_GOTU) == 0)
		/* haven't received username/password pair from ircd yet */
		return 1;
	if ((cldata[cl].state & A_GOTP) == 0)
	    {
		/* no password to check -> reject user! */
		cldata[cl].state |= A_DENY;
		sendto_ircd("K %d %s %u ", cl, cldata[cl].itsip,
			    cldata[cl].itsport);
		return -1; /* done */
	    }
	/* 
	**
	**
	** INSERT FUNCTION TO CHECK PASSWORD VALIDITY
	**
	**
	*/
	/* if failure, see above */
	/* if success: */
	cldata[cl].state |= A_UNIX;
	if (cldata[cl].authuser)
		free(cldata[cl].authuser);
	cldata[cl].authuser = mystrdup(cldata[cl].user);
	cldata[cl].authfrom = cldata[cl].instance->in;
	sendto_ircd("U %d %s %u %s", cl, cldata[cl].itsip, cldata[cl].itsport,
		    cldata[cl].authuser);
	return -1; /* done */
}
Beispiel #7
0
/*
 * pipe_work
 *
 *	This procedure is called whenever there's new data in the buffer.
 *	Returns 0 if everything went fine, and there is more work to be done,
 *	Returns -1 if the module has finished its work (and cleaned up).
 *
 *	It is responsible for sending error messages where appropriate.
 */
static	int	pipe_work(u_int cl)
{
    	DebugLog((ALOG_DPIPE, 0, "pipe_work(%d): %d %d buflen=%d %c", cl,
		  cldata[cl].rfd, cldata[cl].wfd, cldata[cl].buflen,
		  cldata[cl].inbuffer[0]));

	switch (cldata[cl].inbuffer[0])
	    {
	    case 'Y':
		    break;
	    case 'N':
		    cldata[cl].state |= A_DENY;
		    sendto_ircd("K %d %s %u ", cl, cldata[cl].itsip,
				cldata[cl].itsport);
		    break;
#if 0
		    /* hm.. need deeper mods to ircd */
	    case 'y':
		    /* restricted connection only */
		    cldata[cl].state |= A_RESTRICT;
		    sendto_ircd("k %d %s %u ", cl, cldata[cl].itsip,
				cldata[cl].itsport);
		    break;
#endif
	    default :
		    /* error */
		    sendto_log(ALOG_FLOG|ALOG_IRCD, LOG_WARNING,
			       "pipe: unexpected %c for %s[%s]",
			       cldata[cl].inbuffer[0],
			       cldata[cl].host,
			       cldata[cl].itsip);
		    break;
	    }

	/* We're done */
	close(cldata[cl].rfd);
	cldata[cl].rfd = 0;
	return -1;
}
Beispiel #8
0
/* This command will send the required NNICK for user
 * It is safe for services to always send NNICKS instead of SNICKS
 * we will also send NCHANS for the chans the user is joining
 */
void irc_IntroduceUser(IRC_User* u)
{
  
  sendto_ircd(NULL,
    "NICK %s %d %lu +%s %s %s %s %s :%s",
    u->nick, 
    1,
    time(NULL),
    umode_string(u->umodes),
    u->username,
    u->realhost,
    u->publichost,
    myservername,
    u->info);

  send_user_njoins(u);
}
Beispiel #9
0
/*
 * m_nick
 */
void m_nick(int parc,char *parv[])
{
  IRC_User* nuser = NULL;
  IRC_Server* from = NULL;
  char *nick;
  int npc;
  int hopc;
  int ts;
  char *umode;
  char *username;
  char *realhost;
  char *publichost;
  char *servername;
  char *info;
  char *vlink = NULL;
  
  if(parc>3) /* new user */
    {
      if(ircd_type==PTLINK6)
      {
        npc=10;
      	nick = parv[1];
      	if((nuser = irc_FindLocalUser(nick))) /* kill on nick collision */
      	{
      	  sendto_ircd(irc_LocalServer->sname,"KILL %s :%s", 
      	    nuser->nick, "Service override, remote nick !");
          irc_IntroduceUser(nuser);
      	  return;
        }
      	hopc = atoi(parv[2]);
      	ts = atoi(parv[3]);
      	umode = parv[4];
      	username = parv[5];
      	realhost = parv[6];
      	publichost = parv[7];
      	if(parc == 11) /* support for brasnet vlinks */
      	{      	
          servername = parv[8];
          vlink = parv[9];          
          info = parv[10];
        }
        else
      	{
          servername = parv[8];
          info = parv[9];
        }        
      }
      else return;
    } 
  else /* nick change */
    {
      nuser = irc_FindUser(parv[0]);
      if(nuser==NULL)
        {
          fprintf(ircslogf,"Nick change from non-existent user %s\n",parv[0]);    
          return;        
        }
      strncpy(nuser->lastnick, parv[0], NICKLEN);
      del_from_user_hash_table(parv[0], nuser);          
      strncpy(nuser->nick, parv[1], NICKLEN);
      add_to_user_hash_table(parv[1], nuser);
      nuser->umodes &= ~UMODE_IDENTIFIED;
      irc_CallEvent(ET_NICK_CHANGE, nuser, parv[0]);
      return;      
    }
    
  if(parc < npc)
    return;
    
  if(parv[0])
    {
      from = irc_FindServer(parv[0]);
      if(from == NULL)
        {
          fprintf(ircslogf,"NICK from non-existent server %s\n",parv[0]);
          return;
        }
    }
  /* this is a new nick introduction */           	
  nuser = irc_CreateUser(nick, username, realhost, publichost,
        info, umode, servername);
  nuser->from = from;
  nuser->ts = ts;
  if(vlink)
    nuser->vlink = strdup(vlink);

  /* add to hash table */
  add_to_user_hash_table(nick, nuser);
  /* add to user global list */
  add_user_to_global_list(nuser);
  if(irc_CallEvent(ET_NEW_USER, nuser, NULL) == 0) /* could be killed */
    umode_change(umode, nuser);
}
Beispiel #10
0
void irc_ChgHost(IRC_User* to, char *vhost)
{
  sendto_ircd(NULL, "CHGHOST %s %s", to->nick, vhost);
  strncpy(to->publichost, vhost, HOSTLEN);
}
Beispiel #11
0
/* send a svs guest */
void irc_SvsGuest(IRC_User* u, IRC_User *s, char *prefix, int number)
{ 
  u->guest_count++;
  sendto_ircd(s->nick,"SVSGUEST %s %s %d", u->nick, prefix, number);
}
Beispiel #12
0
/* send a svs nick change */
void irc_SvsNick(IRC_User* u, IRC_User *s, char *newnick)
{
  sendto_ircd(s->nick,"SVSNICK %s :%s", u->nick, newnick);
}
Beispiel #13
0
/* send a svs join */
void irc_SvsJoin(IRC_User* u, IRC_User *s, char *channel)
{
    sendto_ircd(s->nick,"SVSJOIN %s :%s", u->nick, channel);
}
Beispiel #14
0
/* send svs mode for nick */
void irc_SvsMode(IRC_User* u, IRC_User *s, char *mchange)
{
  sendto_ircd(s->nick,"SVSMODE %s :%s", u->nick, mchange);
}
Beispiel #15
0
void irc_Gline(IRC_User* s, char *who, char *mask, int duration, char *msg)
{
  sendto_ircd(s->nick, "GLINE %s %d %s :%s", mask, duration, who, msg);
}
Beispiel #16
0
/* quits local user with msg */
void irc_QuitLocalUser(IRC_User* u, char *msg)
{
  sendto_ircd(u->nick,"QUIT :%s", msg ? msg : "");
  remove_local_user(u);
}