Example #1
0
int translateconnected(int uid)
{
    struct translatet *lkm;
    char buf[4096];
    char buf2[5190];
    char *pt;
    pcontext;
    lkm=gettranslate(uid);
    pcontext;
    if(lkm==NULL)
	return 0x0;
    pt=lkm->translatetext;
    while(*pt) /* $%&@ */
    {
	if(*pt==' ') *pt='+';
	pt++;
    }
    /*
     * Altavista changed to Microsoft-Products. This is bad,
     * i have to give more Header-Infos.
     *
     */
    ap_snprintf(buf,sizeof(buf),lngtxt(865),lkm->translatetext,lkm->lang);
    ap_snprintf(buf2,sizeof(buf2),lngtxt(866),strlen(buf),buf);
    writesock_URGENT(lkm->sock,buf2);
    return 0x0;
}
Example #2
0
int linkrelayconnected(int nlink)
{
    int tmpsock;
    pcontext;
    tmpsock=datalink(nlink)->outsock;
    ssnprintf(tmpsock,lngtxt(507),datalink(nlink)->iam,datalink(nlink)->iam,datalink(nlink)->iam);
    ssnprintf(tmpsock,lngtxt(508),datalink(nlink)->iam);
    p_log(LOG_INFO,-1,lngtxt(509),datalink(nlink)->iam);
    return 0x0;
}
Example #3
0
int killedlink(int nlink)
{
    pcontext;
    p_log(LOG_WARNING,-1,lngtxt(519),
	nlink,datalink(nlink)->host,datalink(nlink)->port);
    sysparty(lngtxt(520),datalink(nlink)->iam);
    killsocket(datalink(nlink)->outsock);
    datalink(nlink)->outstate=STD_NOCON;
    removetopology(me,datalink(nlink)->iam,lostlink);
    return -1;
}
Example #4
0
int addtranslate(int usern, char *totranslate, char *from, char *dest, int direction, char *lang, char *command)
{
    struct translatet *lkm;
    int lastuid;
    int cnt=0;
    char buf[200];
    pcontext;
    if(translate==NULL)
    {
	translate=(struct translatet *)pmalloc(sizeof(struct translatet));
	lkm=translate;
	lastuid=0;
    } else {
	lkm=translate;
	lastuid=translate->uid;
	while(lkm->next!=NULL)
	{
	    lastuid=lkm->next->uid;
	    lkm=lkm->next;
	    cnt++;
	}
	lkm->next=(struct translatet *)pmalloc(sizeof(struct translatet));
	lkm=lkm->next;
    }
    if(cnt>MAXSYNTRANS) return -1;
    lastuid++;
    lkm->uid=lastuid;
    lkm->delayed=30; /* before it times out, doubled, altavista got slow */
    lkm->translatetext=(char *)pmalloc(strlen(totranslate)+1);
    strcpy(lkm->translatetext,totranslate);
    if(direction==TR_TO)
    {
	ap_snprintf(buf,sizeof(buf),lngtxt(861),command,dest);
    } else {
	if(strchr("&!#+",*dest)!=NULL)
	    ap_snprintf(buf,sizeof(buf),lngtxt(862),from,command,dest);
	else	
	    ap_snprintf(buf,sizeof(buf),lngtxt(863),from,command,user(usern)->nick);
    }
    lkm->translatedtext=(char *)pmalloc(strlen(buf)+1);
    strcpy(lkm->translatedtext,buf);
    lkm->dest=(char *)pmalloc(strlen(dest)+1);
    strcpy(lkm->dest,dest);
    lkm->source=(char *)pmalloc(strlen(from)+1);
    strcpy(lkm->source,from);
    lkm->lang=(char *)pmalloc(strlen(lang)+1);
    strcpy(lkm->lang,lang);
    lkm->direction=direction;
    lkm->usern=usern;
    lkm->sock=createsocket(0,ST_CONNECT,lastuid,SGR_NONE,NULL,translateconnected,translatederror,translatedpart1,translatedone,NULL,AF_INET,SSL_OFF);
    lkm->sock=connectto(lkm->sock,lngtxt(864),80,NULL);
    return 0x0;    
}
Example #5
0
int printbanner(void)
{
   int i;
   for(i=979;i<990;i++)
   {
       fprintf(stdout,"%s",lngtxt(i));
       if(i==984)
           fprintf(stdout,"%s", APPVER);
   }
   if(getuid()==0)
       fprintf(stdout, "%s", lngtxt(990));
   fflush(stdout);
   return 0x0;
}
Example #6
0
int *digdisptopology(struct topologyt *topo)
{
    int i,j,k,rc;
    char oem;
    if(displevel>100) return 0x0;
    displevel++;
    maximumdigs--;
    dispbuffer[0]=0;
    if(maximumdigs==0) return NULL;    
    for(i=0;i<100;i++)
    {
	if(topo->linked[i]!=NULL)
	{
	    nxchar[displevel-1]=' ';
	    oem='`';
	    for(k=i+1;k<100;k++)
		if(topo->linked[k]!=NULL) { nxchar[displevel-1]='|'; oem='|';}
	    dispbuffer[0]=0;
	    for(j=0;j<displevel-1;j++)
	    {
		mm[0]=nxchar[j];
		mm[1]=0;
		if(strlen(dispbuffer)+10<sizeof(dispbuffer))
		{
		    strcat(dispbuffer,mm);
		    strcat(dispbuffer,lngtxt(859));
		}
	    }
	    mm[0]=oem;
	    mm[1]=0;
	    if(strlen(dispbuffer)+11+strlen(topo->linked[i]->server)<sizeof(dispbuffer))
	    {
		strcat(dispbuffer,mm);
		strcat(dispbuffer,lngtxt(860));
		if(topo->linked[i]->linktype==TP_LTO)
		    strcat(dispbuffer,">");
		else
		    strcat(dispbuffer,"<");
		strcat(dispbuffer,topo->linked[i]->server);
		strcat(dispbuffer,"\n");
		rc=(*displaytopo)(dispbuffer);
	    }
	    digdisptopology(topo->linked[i]);
	}
    }
    displevel--;
    return 0x0;
}
Example #7
0
int cleartranslates()
{
    struct translatet *lkm,*pre;
    lkm=translate;
    pre=NULL;
    pcontext;
    while(lkm!=NULL)
    {
	lkm->delayed-=delayinc;
	if(lkm->delayed<=0)
	{
	    p_log(LOG_WARNING,-1,lngtxt(876),lkm->uid,lkm->dest,lkm->lang);
	    erasetranslate(lkm->uid);
	    pcontext;
	    if(pre==NULL)
		lkm=translate;
	    else
		lkm=pre->next;
	} else {
	    pre=lkm;
	    lkm=lkm->next;
	}
    }
    return 0x0;
}
Example #8
0
int translatedpart3(int uid)
{
    char *ept;
    struct translatet *th;
    struct socketnodes *lkm;
    pcontext;
    th=gettranslate(uid);
    pcontext;
    if(th==NULL)
	return 0x0;
    lkm=getpsocketbysock(th->sock);
    if(lkm==NULL)
    {
	erasetranslate(uid);
	return 0x0;
    }
    pcontext;
    ept=nobreak(ircbuf);
    ept=strstr(ept,lngtxt(870));
    if(ept!=NULL)
    {
	ept=strchr(ept,'>');
	if(ept!=NULL)
	{
	    ept++;
	    th->translatedtext=strmcat(th->translatedtext,ept);
	    th->translatedtext=strmcat(th->translatedtext," ");
	}
	lkm->sock->handler=translatedpart4;
    } else {
	if(strstr(ircbuf,"</strong>")!=NULL)
	    lkm->sock->handler=translatedpart4;
    }
    return 0x0;
}
Example #9
0
void initSSL()
{
    SSL_load_error_strings();
    OpenSSL_add_ssl_algorithms();
    srvctx=SSL_CTX_new(SSLv23_server_method());
    /* setting up the server context */
    if(srvctx==NULL)
    {
        p_log(LOG_ERROR,-1,lngtxt(970));
	exit(0x1);
    }
    if (SSL_CTX_use_certificate_file(srvctx, SSLCERT, SSL_FILETYPE_PEM) <= 0)
    {
	p_log(LOG_ERROR,-1,lngtxt(971), SSLCERT);
	exit(0x1);
    }
    if (SSL_CTX_use_PrivateKey_file(srvctx, SSLKEY, SSL_FILETYPE_PEM) <= 0)
    {
	p_log(LOG_ERROR,-1,lngtxt(972), SSLKEY);
	exit(0x1);
    }
    if (!SSL_CTX_check_private_key(srvctx))
    {
    	p_log(LOG_ERROR,-1,lngtxt(973));
    	exit(0x1);
    }
    /* create client context */
    clnctx=SSL_CTX_new(SSLv23_client_method());
    if(clnctx==NULL)
    {
	p_log(LOG_ERROR,-1,lngtxt(974));
	exit(0x1);
    }
    if (SSL_CTX_use_certificate_file(clnctx, SSLCERT, SSL_FILETYPE_PEM) <= 0)
    {
	p_log(LOG_ERROR,-1,lngtxt(975), SSLCERT);
	exit(3);
    }
    if (SSL_CTX_use_PrivateKey_file(clnctx, SSLKEY, SSL_FILETYPE_PEM) <= 0)
    {
    	p_log(LOG_ERROR,-1,lngtxt(976), SSLKEY);
    	exit(4);
    }
    if (!SSL_CTX_check_private_key(clnctx))
    {
	p_log(LOG_ERROR,-1,lngtxt(977));
	exit(5);
    }
    p_log(LOG_INFO,-1,lngtxt(978));
    return;
}
Example #10
0
int checklinkkill(int nlink,int errn)
{
    int sock;
    pcontext;
    if(datalink(nlink)->type==LI_ALLOW)
	sock=datalink(nlink)->insock;
    else
	sock=datalink(nlink)->outsock;
    sysparty(lngtxt(556),datalink(nlink)->iam);
    p_log(LOG_WARNING,-1,lngtxt(557),nlink);
    killsocket(sock);
    datalink(nlink)->instate=STD_NOCON;
    datalink(nlink)->outstate=STD_NOCON;
    datalink(nlink)->insock=0;
    datalink(nlink)->outsock=0;
    removetopology(me,datalink(nlink)->iam,lostlink);
    return 0x0;
}
Example #11
0
int errorlink(int nlink,int errn)
{
    pcontext;
    p_log(LOG_ERROR,-1,lngtxt(518),
	nlink,datalink(nlink)->host,datalink(nlink)->port);
    currentsocket->sock->destructor=NULL;
    killsocket(datalink(nlink)->outsock);
    datalink(nlink)->outstate=STD_NOCON;
    return -1;
}
Example #12
0
int connectlink(int nlink)
{
    int tmpsock;
    int proto=AF_INET;
    int issl=SSL_OFF;
    char vsl[10];
    char *ho;
    pcontext;
    vsl[0]=0;
    if (datalink(nlink)->type!=LI_LINK)
	return 0x0;
    if (datalink(nlink)->outstate==STD_CONN)
	return 0x0;
    if (datalink(nlink)->delayed>0)
    {
	datalink(nlink)->delayed-=1;
	return 0x0;
    }
#ifdef HAVE_SSL
    if(strstr(datalink(nlink)->host,"S=")==datalink(nlink)->host)
    {
	ho=datalink(nlink)->host+2;
	issl=SSL_ON;
	strcpy(vsl,"SSL-");
    } else
#endif
	ho=datalink(nlink)->host;
    datalink(nlink)->delayed=0;
    p_log(LOG_INFO,-1,lngtxt(561),vsl,nlink,ho,datalink(nlink)->port);
    /* we got a server and a port */
    tmpsock=createsocket(0,ST_CONNECT,nlink,SGR_NONE,NULL,connectedlink,errorlink,checklinkdata,killedlink,linkremap,proto,issl);
    if (tmpsock!=0)
    {
	datalink(nlink)->outstate=STD_CONN;
	datalink(nlink)->outsock=tmpsock;
    }
    tmpsock=connectto(tmpsock,ho,datalink(nlink)->port,NULL);
    if(tmpsock!=0)
	return 0x1;
    p_log(LOG_ERROR,-1,lngtxt(562),nlink,datalink(nlink)->host,datalink(nlink)->port);
    datalink(nlink)->outstate=STD_NOCON;
    return -1;
}
Example #13
0
void kill_error(int r)
{
    if(nosignals == 0)
    {
        nosignals=1;
        p_debug();
        p_log(LOG_ERROR,-1,lngtxt(636));
    }
    exit(0x0);
}
Example #14
0
void term_error(int r)
{
    if(nosignals == 1)
        return;
    nosignals=1;
    p_debug();
    p_log(LOG_ERROR,-1,lngtxt(610));
    flushconfig();
    nosignals=0;
    return;
}
Example #15
0
void ill_error(int r)
{
    if(nosignals == 0)
    {
        nosignals=1;
        p_debug();
        p_log(LOG_WARNING,-1,lngtxt(635));
        nosignals=0;
    }
    return;
}
Example #16
0
int translatedpart2(int uid)
{
    char *ept,*upt,*pt;
    struct translatet *th;
    struct socketnodes *lkm;
    pcontext;
    th=gettranslate(uid);
    pcontext;
    if(th==NULL)
	return 0x0;
    lkm=getpsocketbysock(th->sock);
    if(lkm==NULL)
    {
	erasetranslate(uid);
	return 0x0;
    }
    pcontext;
    ept=strstr(ircbuf,lngtxt(869));
    if(ept==NULL)
    {
	ept=ircbuf;
	upt=strchr(ept,':');
	if(upt!=NULL)
	{
	    upt++;*upt=' ';
	    upt++;*upt=0;
	    upt=strchr(th->translatedtext,'\r');
	    if (upt==NULL) upt=strchr(th->translatedtext,'\n');
	    if (upt!=NULL) *upt=0;
	    pt=strchr(ept,'&');
	    if(pt!=NULL)
	    {
		upt=strchr(pt+1,';');
		if(upt!=NULL)
		{
		    upt++;
		    while(*upt)
		    {
			*pt=*upt;
			pt++;
			upt++;
		    }
		    *pt=0;
		}
	    }
	    if(th->direction!=TR_TO)
		th->translatedtext=strmcat(th->translatedtext,ept);
	    lkm->sock->handler=translatedpart3;
	}
    } else {
	lkm->sock->handler=translatedpart3;
    }
    return 0x0;
}
Example #17
0
int translatederror(int uid, int err)
{
    struct translatet *lkm;
    pcontext;
    p_log(LOG_ERROR,-1,lngtxt(867),uid,err);
    lkm=gettranslate(uid);
    pcontext;
    if(lkm==NULL)
	return 0x0;
    erasetranslate(uid);
    return 0x0;
}
Example #18
0
int connectedlink(int nlink)
{
    char buf[400];
    struct socketnodes *lkm;
    int tmpsock;
    pcontext;
    tmpsock=datalink(nlink)->outsock;
    ssnprintf(tmpsock,lngtxt(512),datalink(nlink)->name,socketnode->sock->sport);
    if (*datalink(nlink)->pass==0)
    {
	strmncpy(datalink(nlink)->pass,randstring(15),sizeof(datalink(nlink)->pass));
	writelink(nlink);
    }
    ssnprintf(tmpsock,lngtxt(513),datalink(nlink)->pass);
    ssnprintf(tmpsock,lngtxt(514),me,me);
#ifdef PARTYCHANNEL
    ssnprintf(tmpsock,lngtxt(515));
#endif
#ifdef INTNET
    joinintnettolink(nlink);
#endif
    ssnprintf(tmpsock,lngtxt(516));
    p_log(LOG_INFO,-1,lngtxt(517),
	nlink,datalink(nlink)->host,datalink(nlink)->port);
    return 0x0;
}
Example #19
0
void hup_error(int r)
{
    if(nosignals == 0)
    {
        nosignals=1;
        p_debug();
        p_log(LOG_WARNING,-1,lngtxt(611));
        if(*user(1)->login!=0)
            cmdrehash(1);
        nosignals=0;
    }
    return;
}
Example #20
0
/* delete user files */
int deluser(int uind)
{
    char buf[60];
    pcontext;
#ifdef TRAFFICLOG
    /* close the trafficlog before deleting */
    if(user(uind)->trafficlog!=NULL)
    {
	fclose(user(uind)->trafficlog);
	user(uind)->trafficlog=NULL;
    }
#endif
    ap_snprintf(buf,sizeof(buf),lngtxt(380),uind);
    oldfile(buf);
    ap_snprintf(buf,sizeof(buf),lngtxt(381),uind);
    oldfile(buf);
    pcontext;
    ap_snprintf(buf,sizeof(buf),lngtxt(382),uind);
    clearsectionconfig(buf);
    flushconfig();
    pcontext;
    return 0x0;
}
Example #21
0
void usr2_error(int r)
{
    if(nosignals == 0)
    {
        nosignals=1;
        p_debug();
        p_log(LOG_INFO,-1,lngtxt(633));
        resetconfig();
        readconfig();
        loadusers();
        nosignals=0;
    }
    return;
}
Example #22
0
int translatedpart1(int uid)
{
    struct socketnodes *lkm;
    struct translatet *th;
    pcontext;
    if(strstr(ircbuf,lngtxt(868))!=NULL)
    {
	th=gettranslate(uid);
	if(th!=NULL)
	{
	    lkm=getpsocketbysock(th->sock);
	    if(lkm!=NULL)
	    {
		lkm->sock->handler=translatedpart2;
	    }
	}
    }
    return 0x0;
}
Example #23
0
unsigned long *__pmalloc(unsigned long size,char *module,char *function, int line)
{
    unsigned long *rc;
    if (!(rc=(unsigned long *)malloc(size)))
    {
        p_log(LOG_ERROR,-1,lngtxt(602),module,function,line);
        exit(0x0);
    }
    memset(rc,0x0,size);
#ifdef LOGALLOC
    if(logm==NULL)
        logm=fopen("log/alloc.log","w");
    if(logm)
    {
        fprintf(logm,"%s/%s/%d: alloc(%d)=0x%08x\n",module,function,line,size,rc);
        fflush(logm);
    }
#endif
    return rc;
}
Example #24
0
int getserver(int srvnr, int usernum)
{
   char fnmuser[20];
   char buf[100];
   int ern;
   ap_snprintf(fnmuser,sizeof(fnmuser),lngtxt(373),usernum);
   ap_snprintf(buf,sizeof(buf),lngtxt(374),srvnr);
   ern = getini(lngtxt(375),buf,fnmuser);
   if (ern != 0) { return ern; }
   ap_snprintf(user(usernum)->server,sizeof(user(usernum)->server),"%s",value);
   ap_snprintf(buf,sizeof(buf),lngtxt(376),srvnr);
   ern = getini(lngtxt(377),buf,fnmuser);
   if (ern != 0) { user(usernum)->port = 6667; } else { user(usernum)->port = atoi(value); }
   ap_snprintf(buf,sizeof(buf),lngtxt(378),srvnr);
   ern = getini(lngtxt(379),buf,fnmuser);
   if (ern != 0) { *user(usernum)->spass=0; return 0; }
   ap_snprintf(user(usernum)->spass,sizeof(user(usernum)->spass),"%s",value);
   return 0;
}
Example #25
0
int killrelaylink(int nlink)
{
    struct socketnodes *lkm;
    pcontext;
    p_log(LOG_WARNING,-1,lngtxt(511),datalink(nlink)->iam);
    lkm=getpsocketbysock(datalink(nlink)->outsock);
    if(lkm!=NULL)
    {
	lkm->sock->destructor=NULL;
	killsocket(datalink(nlink)->outsock);
    }
    lkm=getpsocketbysock(datalink(nlink)->insock);
    if(lkm!=NULL)
    {
	lkm->sock->destructor=NULL;
	killsocket(datalink(nlink)->insock);
    }
    datalink(nlink)->instate=STD_NOCON;
    datalink(nlink)->outstate=STD_NOCON;
    datalink(nlink)->insock=0;
    datalink(nlink)->outsock=0;
    return -1;
}
Example #26
0
int errorrelaylink(int nlink, int errn)
{
    struct socketnodes *lkm;
    pcontext;
    p_log(LOG_ERROR,-1,lngtxt(510),datalink(nlink)->iam);
    lkm=getpsocketbysock(datalink(nlink)->outsock);
    if(lkm!=NULL)
    {
	lkm->sock->errorhandler=NULL;
	killsocket(datalink(nlink)->outsock);
    }
    lkm=getpsocketbysock(datalink(nlink)->insock);
    if(lkm!=NULL)
    {
	lkm->sock->errorhandler=NULL;
	killsocket(datalink(nlink)->insock);
    }
    datalink(nlink)->instate=STD_NOCON;
    datalink(nlink)->outstate=STD_NOCON;
    datalink(nlink)->insock=0;
    datalink(nlink)->outsock=0;
    return -1;
}
Example #27
0
int linkrelay(int npeer, int rootlink)
{
    int tmpsock;
    struct socketnodes *lkm;
    char *ho;
    char vsl[10];
    int issl=SSL_OFF;
    int nlink;
    int proto=AF_INET;
    pcontext;
    vsl[0]=0;
#ifdef HAVE_SSL
    if(strstr(newpeer(npeer)->server,"S=")==newpeer(npeer)->server)
    {
	issl=SSL_ON;
	ho=newpeer(npeer)->server+2;
	strcpy(vsl,"SSL-");
    } else
#endif
	ho=newpeer(npeer)->server;
    p_log(LOG_INFO,-1,lngtxt(558),
	 vsl,
         newpeer(npeer)->login,
	 datalink(rootlink)->name,
	 newpeer(npeer)->host,
	 newpeer(npeer)->lnkport,
	 ho,
	 newpeer(npeer)->port,
	 newpeer(npeer)->vhost);
    lkm=getpsocketbysock(newpeer(npeer)->insock);
    if(lkm!=NULL)
    {
	lkm->sock->flag=SOC_CONN;
	lkm->sock->param=npeer;
	lkm->sock->constructor=NULL;
	lkm->sock->constructed=NULL;
	lkm->sock->handler=checklinkdata;
	lkm->sock->errorhandler=errorrelaylink;
	lkm->sock->destructor=killrelaylink;
    }
    tmpsock=createsocket(0,ST_CONNECT,0,SGR_NONE,NULL,linkrelayconnected,errorrelaylink,checklinkdata,killrelaylink,linkrelayremap,proto,issl);
    tmpsock=connectto(tmpsock,ho,newpeer(npeer)->port,newpeer(npeer)->vhost);
    if (tmpsock!=0)
    {
	nlink=getnewlink();
	if (nlink==0) {
	    killsocket(tmpsock);
	    p_log(LOG_ERROR,-1,lngtxt(559));
	    return -1;
        }
        datalink(nlink)->type=LI_RELAY;
        datalink(nlink)->instate=STD_CONN;
        datalink(nlink)->insock=newpeer(npeer)->insock;
        strmncpy(datalink(nlink)->iam,newpeer(npeer)->nick,sizeof(datalink(nlink)->iam));
        strmncpy(datalink(nlink)->host,newpeer(npeer)->host,sizeof(datalink(nlink)->host));
        strmncpy(datalink(nlink)->pass,newpeer(npeer)->pass,sizeof(datalink(nlink)->pass));
        strmncpy(datalink(nlink)->name,newpeer(npeer)->name,sizeof(datalink(nlink)->name));
        datalink(nlink)->port=datalink(nlink)->port;
        datalink(nlink)->outstate=STD_CONN;
        datalink(nlink)->outsock=tmpsock;
	if(lkm) lkm->sock->param=nlink;
        lkm=getpsocketbysock(tmpsock);
        if(lkm!=NULL)
        {
    	    lkm->sock->flag=SOC_SYN;
    	    lkm->sock->param=nlink;
        }
	clearpeer(npeer);
	return 0x0;
    }
    p_log(LOG_ERROR,-1,lngtxt(560),newpeer(npeer)->server,newpeer(npeer)->port);
    killsocket(newpeer(npeer)->insock);
    return -1;
}
Example #28
0
int processlink(int nlink, int sock, int state)
{
    struct usernodes *th;
    struct linknodes *lh;
    int rc;
    char *pt,*pt2;
#ifdef PARTYCHANNEL
    int rr = 0;
    char buf[600] = "";
    char buf1[400] = "";
#endif
    char l;
    char o[]="->";
    char i[]="<-";
    char r[]="R ";
    char sic[500];
    int last;
    pcontext;
    if (state!=STD_CONN) return 0x0;
    parse();
    pcontext;
    if (!ifcommand("IAM") && !ifcommand(lngtxt(521))) broadcast(nlink); /* if its the IAM message, it does NOT
						get broadcasted */
    pcontext;
    pt=strchr(ircto,'@');
#ifdef PARTYCHANNEL
    if(pt==NULL) pt=strchr(ircto,'*');
#endif
    pcontext;
    if (pt!=NULL) 
    {
	*pt=0;
	pt++;
	if (strmcmp(pt,me)!=0 || (*ircto=='*' && strlen(pt)==1))
	{
	    pcontext;
	    if (ifcommand(lngtxt(522)))
	    {
		rc=checkuser(ircto);
		if (rc==0)
		{
		    ap_snprintf(ircbuf,sizeof(ircbuf),lngtxt(523),me,ircnick,irchost,ircto);
		    broadcast(0);	    
		    return 0x0;
		}
#ifdef PARTYCHANNEL
		ssnprintf(user(rc)->insock,lngtxt(524),ircnick,irchost,user(rc)->nick,irccontent);
#else
		ssnprintf(user(rc)->insock,lngtxt(525),ircnick,irchost,user(rc)->nick,irccontent);
#endif
		return 0x0;
	    }
	    pcontext;
	    if (ifcommand(lngtxt(526)))
	    {
		if(strstr(irccontent,o)!=NULL || strstr(irccontent,i)!=NULL) /* this is a listlink for the topology */
		{
		    pt=strchr(irccontent,'[');
		    if(pt!=NULL)
		    {
			pt++;
			pt2=strstr(pt,"]*");
			if(pt2!=NULL)
			{
			    *pt2=0;
			    strmncpy(sic,pt,sizeof(sic)); /* in sic we got the first linker */
			    pt2++;
			    pt=strstr(pt2,o);
			    if(pt==NULL) pt=strstr(pt2,i);
			    if(pt==NULL) return 0x0;		    
			    pt2=strchr(pt+3,' ');
			    if(pt2!=NULL)
			    {
				*pt2=0;
				if(strstr(pt,o)==pt)
				{
				    pt+=3;
				    addtopology(sic,pt);
				} else {
				    pt+=3;
				    addtopology(pt,sic);
				}
				return 0x0;
			    }
			}
		    }
		}
		pcontext;
#ifdef PARTYCHANNEL
		if(strstr(ircbuf,lngtxt(527))==ircbuf)
		{
		    if(*ircto=='*') /* systemrequest */
		    {
			pt=strchr(irccontent,']');
			if(pt!=NULL)
			{
			    pt+=2;
			    if(*pt=='*')
			    {
				pt2=strchr(pt,'(');
				if (pt2!=NULL)
				{
				    pt+=2;
				    *pt2=0;
				    ap_snprintf(buf,sizeof(buf),lngtxt(528),pt,irchost);
				    if(partyadd(buf)==1)
				    {
					ap_snprintf(buf1,sizeof(buf1),"%s%s\r\n",lngtxt(529),PARTYCHAN);
					ap_snprintf(buf,sizeof(buf),buf1,pt,irchost,pt,irchost);
					th=usernode;
					while(th!=NULL)
					{
					    rc=th->uid;
					    if(user(rc)->instate==STD_CONN && user(rc)->sysmsg==1 && user(rc)->parent==0)
					    {
						writesock(user(rc)->insock,buf);
					    }
					    th=th->next;
					}
					return 0x0;
				    }
				}
			    }
			}
		    }
		}
#endif
		rc=checkuser(ircto);
		if (rc!=0)
		{
		    ssnprintf(user(rc)->insock,lngtxt(530),ircnick,user(rc)->nick,irccontent);
		    return 0x0;
		}
	    }
	}
    }
    pcontext;
    if (ifcommand("IAM"))
    {
	if(*ircnick==0 || strchr(ircnick,' ')!=NULL || strchr(ircnick,'@')!=NULL || strchr(ircnick,'*')!=NULL)
	{
	    sysparty(lngtxt(531));
	    killsocket(sock);
	    datalink(nlink)->instate=STD_NOCON;
	    datalink(nlink)->outstate=STD_NOCON;
	    datalink(nlink)->insock=0;
	    datalink(nlink)->outsock=0;
	    clearlink(nlink);
	    eraselinkini(nlink);
	    return 0x0;
	}
	strmncpy(datalink(nlink)->iam,ircnick,sizeof(datalink(nlink)->iam));
	addtopology(me,datalink(nlink)->iam);
	writelink(nlink);
    }
    pcontext;
    if (ifcommand(lngtxt(532)))
    {
	if (strmcmp(me,ircto)!=0)
	{
	    p_log(LOG_ERROR,-1,lngtxt(533),
	      nlink,datalink(nlink)->host,datalink(nlink)->port);
	    killsocket(sock);
	    removetopology(me,datalink(nlink)->iam,lostlink);
	    datalink(nlink)->instate=STD_NOCON;
	    datalink(nlink)->outstate=STD_NOCON;
	    datalink(nlink)->insock=0;
	    datalink(nlink)->outsock=0;
	    clearlink(nlink);
	    eraselinkini(nlink);
	    return 0x0;	
	}
    }
    pcontext;
    if (ifcommand(lngtxt(534)))
    {
	th=usernode;
	while (th!=NULL) {
	    rc=th->uid;
	    if ((user(rc)->instate==STD_CONN && user(rc)->parent==0 && user(rc)->sysmsg==1) || rc==1)
	    {
		strmncpy(sic,irccontent,sizeof(sic));
#ifdef PARTYCHANNEL
		strmncpy(irccommand,lngtxt(535),sizeof(irccommand));
		strmncpy(ircto,PARTYCHAN,sizeof(ircto));
		if(strlen(ircto+1)<sizeof(ircto))
		    strcat(ircto," ");
#endif
		/* keeping being compatible with earlier versions requires this */
		if(strlen(ircnick)==6 && strstr(ircnick,lngtxt(536))==ircnick)
		{
#ifdef PARTYCHANNEL
		    if(strstr(irccontent,lngtxt(537))!=NULL)
		    {
			pt=strstr(irccontent,lngtxt(538));
			if(pt!=NULL)
			{
			    pt+=5;
			    pt2=strchr(pt,' ');
			    if (pt2!=NULL) *pt2=0;
			    strmncpy(ircnick,pt,sizeof(ircnick));
			    ap_snprintf(buf,sizeof(buf),lngtxt(539),pt,irchost);
			    strcpy(irccommand,"JOIN");
			    strmncpy(irccontent,PARTYCHAN,sizeof(irccontent));
			    *ircto=0;
			    if(rr==0) { partyadd(buf); rr=1; }
			}
		    }
		    if(strstr(irccontent,lngtxt(540))!=NULL)    
		    {
			pt=strstr(irccontent,lngtxt(541));
			if(pt!=NULL)
			{
			    pt+=5;
			    pt2=strchr(pt,' ');
			    if (pt2!=NULL) *pt2=0;
			    strmncpy(ircnick,pt,sizeof(ircnick));
			    ap_snprintf(buf,sizeof(buf),lngtxt(542),pt,irchost);
			    strcpy(irccommand,"PART");
			    strmncpy(irccontent,lngtxt(543),sizeof(irccontent));
			    if(rr==0) { partyremove(buf); rr=1; }
			}
		    }
#endif
		    if(strstr(irccontent,lngtxt(544))==irccontent)
		    {
			ap_snprintf(ircbuf,sizeof(ircbuf),lngtxt(545),me);
			broadcast(0);
			return 0x0;
		    }
		    if(strstr(irccontent,lngtxt(546))==irccontent)    
		    {
			pt=irccontent+11;
			pt2=strchr(pt,')');
			if(pt2!=NULL) *pt2=0;
			removetopology(irchost,pt,lostlink);
			if(pt2!=NULL) *pt2=')';
		    }
		}
#ifdef PARTYCHANNEL
		ap_snprintf(buf,sizeof(buf),lngtxt(547),
						    ircnick,irchost,ircnick,irchost,
						    irccommand,ircto,irccontent);
		if(user(rc)->instate==STD_CONN && user(rc)->parent==0 && user(rc)->sysmsg==1)
		    writesock(user(rc)->insock,buf);						    
#endif	
		ap_snprintf(irccontent,sizeof(irccontent),"%s",sic);
	    }
	    th=th->next;
	}	
	return 0x0;
    }
    pcontext;
    if (ifcommand("BWHO"))
    {
	th=usernode;
	while (th!=NULL) {
	    rc=th->uid;last=0;
	    if (user(rc)->instate!=STD_NOUSE)
	    {
	       if (user(rc)->parent != 0) l='^'; else { l='*';last=1; }
	       if (user(rc)->sysmsg == 0) l='+';
	       if (*user(rc)->host==0) l=' '; else last=0;
	       if(last==1)
      	           ap_snprintf(ircbuf,sizeof(ircbuf),lngtxt(548),me,ircnick,irchost,me,l,user(rc)->login,user(rc)->nick,user(rc)->network,user(rc)->server,user(rc)->user,user(rc)->last);
	       else	 
      	           ap_snprintf(ircbuf,sizeof(ircbuf),lngtxt(549),me,ircnick,irchost,me,l,user(rc)->login,user(rc)->nick,user(rc)->network,user(rc)->server,user(rc)->user);
	       broadcast(0);						    
	    }
	    th=th->next;
	}
	return 0x0;	
    }
    pcontext;
    if (ifcommand(lngtxt(550)))
    {
	lh=linknode;	
	while (lh!=NULL)
	{	
	    rc=lh->uid;
	    l=' ';
	    if (datalink(rc)->type!=0)
	    {
		if (datalink(rc)->type==LI_LINK) 
		{
		    pt=o;
		    if (datalink(rc)->outstate==STD_CONN) l='*';
		}
		if (datalink(rc)->type==LI_ALLOW) 
		{
		    if (datalink(rc)->instate==STD_CONN) l='*';
		    pt=i;
		}
		if (datalink(rc)->type==LI_RELAY) { pt=r; l='*';}
		ap_snprintf(ircbuf,sizeof(ircbuf),lngtxt(551),me,ircnick,irchost,me,l,rc,pt,datalink(rc)->iam,datalink(rc)->host,datalink(rc)->port); 
		broadcast(0);
	    }    
	    lh=lh->next;
	}
	return 0x0;
    }
    pcontext;
#ifdef PARTYCHANNEL
    if (ifcommand(lngtxt(552)))
    {
	strmncpy(partytopic,irccontent,sizeof(partytopic));
	th=usernode;
	while (th!=NULL) {
	    rc=th->uid;
	    if (user(rc)->instate==STD_CONN && user(rc)->parent==0)
	    {
	       ap_snprintf(buf1,sizeof(buf1),"%s%s%s",lngtxt(553),PARTYCHAN,lngtxt(554));
  	       ssnprintf(user(rc)->insock,buf1,
	                       ircnick,irchost,ircnick,irchost,irccontent);
	    }
	    th=th->next;
	}
    }
#endif
#ifdef INTNET
    if (ifcommand(lngtxt(555)))
    {
	pt=strchr(ircbuf,'\r');
	if(pt==NULL) pt=strchr(ircbuf,'\n');
	if(pt!=NULL) *pt=0;
	strmncpy(ircbuf,rtrim(irccontent),sizeof(ircbuf));
	internalinbound(0,nlink);
    }
#endif
    pcontext;
    return 0x0;
}
Example #29
0
void usr1_error(int r)
{
    struct socketnodes *lkm,*pre;
    char *types[4];
    char *flags[5];
    char *ssle[2];
    int noadv;
#ifdef HAVE_SSL
    char ssha[]="HANDSHAKE";
    SSL_CIPHER *c;
    int bits;
    SSL *reference=NULL;
    char *cname;
#endif
    types[0]="CONNECT";
    types[1]="LISTEN ";
    types[2]="RESOLVE";
    types[3]="UNKNOWN";
    flags[0]="NOUSE  ";
    flags[1]="SYN    ";
    flags[2]="CONN   ";
    flags[3]="ERROR  ";
    ssle[0] ="NONE";
    ssle[1] =" SSL";
    if(nosignals == 1) return;
    nosignals=1;
    if(r!=31337)
        p_log(LOG_INFO,-1,lngtxt(628));
    lkm=socketnode;
    pre=lkm;
    while(lkm!=NULL)
    {
        noadv=0;

        if(lkm->sock!=NULL)
        {
#ifdef HAVE_SSL
            if(lkm->sock->ssl==SSL_ON && lkm->sock->sslfd!=NULL)
            {
                c=SSL_get_current_cipher(lkm->sock->sslfd);
                SSL_CIPHER_get_bits(c,&bits);
                reference=lkm->sock->sslfd;
                if(bits==0)
                    cname=ssha;
                else
                    cname=(char *)SSL_CIPHER_get_name(c);
                p_log(LOG_INFO,-1,lngtxt(629),
                      lkm->sock->syssock,types[lkm->sock->type],lkm->sock->source,lkm->sock->sport,lkm->sock->dest,lkm->sock->dport,
                      flags[lkm->sock->flag],lkm->sock->bytesin,lkm->sock->bytesout,ssle[lkm->sock->ssl],cname,bits,lkm->sock->since);
            }
            else
                p_log(LOG_INFO,-1,lngtxt(630),
                      lkm->sock->syssock,types[lkm->sock->type],lkm->sock->source,lkm->sock->sport,lkm->sock->dest,lkm->sock->dport,
                      flags[lkm->sock->flag],lkm->sock->bytesin,lkm->sock->bytesout,ssle[lkm->sock->ssl],lkm->sock->since);
#else
            p_log(LOG_INFO,-1,lngtxt(631),
                  lkm->sock->syssock,types[lkm->sock->type],lkm->sock->source,lkm->sock->sport,lkm->sock->dest,lkm->sock->dport,
                  flags[lkm->sock->flag],lkm->sock->bytesin,lkm->sock->bytesout,lkm->sock->since);
#endif
            if(lkm->sock->type==SOC_CONN || lkm->sock->flag==SOC_SYN)
            {
                if(fcntl(lkm->sock->syssock, F_GETFD,0) <0) {
                    p_log(LOG_WARNING,-1,lngtxt(632),lkm->sock->syssock);
                    killsocket(lkm->sock->syssock);
                    lkm=pre->next;
                    noadv=1;
                }
            }
        }
        if (noadv==0) {
            pre=lkm;
            lkm=lkm->next;
        }
    }
#ifdef HAVE_SSL
    logsslstats(reference);
#endif
    if(r!=31337)
        p_log(LOG_INFO,-1,"Done");
    nosignals=0;
    return;
}
Example #30
0
int writeini(char *section, char *param, char *inidat, char *data)
{
    char ppuf[200];
    char spuf[200];
    char buf[2048];
    char *po;
    int wasinsection;
    char *data_p;
    struct stringarray *wconf,*xconf,*sectconf;
    wconf=conf;
    data_p = data;
    if (data_p != NULL)
       if (strlen(data) == 0) data_p = NULL;
    wasinsection = 0;
    ap_snprintf(ppuf,sizeof(ppuf),lngtxt(371),inidat,section,param);
    ap_snprintf(spuf,sizeof(spuf),lngtxt(372),inidat,section);
    if(data_p!=NULL)
	ap_snprintf(buf,sizeof(buf),"%s%s",ppuf,data_p);
    xconf=conf;
    sectconf=conf;
    while (wconf) 
    {
      if(wconf->entry!=NULL)
      {
    	   po = strstr(wconf->entry,spuf);
           if (po == wconf->entry) 
	   {
	      sectconf=xconf; /* save last entry of section */
	      wasinsection = 1; /* we had been in the section */
	      po = strstr(wconf->entry,ppuf);
	      if (po == wconf->entry) {
		 if(data_p==NULL)
		 {
		    if(wconf==conf)
		    {
			conf=wconf->next;
			xconf=conf;
		    } else {
			xconf->next=wconf->next;
		    }		     
		    free(wconf->entry);
		    free(wconf);
		    wconf=xconf;
		    return 0x0;
		 } else {
		    free(wconf->entry);
		    wconf->entry=(char *)pmalloc(strlen(buf)+2);
		    strmncpy(wconf->entry,buf,strlen(buf)+1);
		    return 0x0;
		 }    
	      }
	   }
      }
      xconf=wconf;
      wconf=wconf->next;
    }
    if(data_p==NULL) return 0x0;
    if(wasinsection==0) 
    {
	xconf->next=(struct stringarray *)pmalloc(sizeof(struct stringarray));
	xconf=xconf->next;
    } else {
	xconf=sectconf;
	wconf=(struct stringarray *)pmalloc(sizeof(struct stringarray));
	wconf->next=xconf->next;
	xconf->next=wconf;
	xconf=wconf;
    }
    xconf->entry=(char *)pmalloc(strlen(buf)+2);
    strmncpy(xconf->entry,buf,strlen(buf)+1);
    return 0x0;
}