Exemplo n.º 1
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;
}
Exemplo n.º 2
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;
}
Exemplo n.º 3
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;
}
Exemplo n.º 4
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;
}
Exemplo n.º 5
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;
}
Exemplo n.º 6
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;
}
Exemplo n.º 7
0
int translatedpart4(int uid)
{
    char *ept,*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(871));
    if(ept==NULL)
    {
	ept=strstr(ircbuf,"<p>");
    }
    if(ept!=NULL)
    {
	ept=strstr(th->translatedtext,lngtxt(872));
	if(ept!=NULL)
	{
	    ept=strchr(th->translatedtext,':');
	    if(ept==th->translatedtext) ept=strchr(ept+1,':');
	    if(ept!=NULL)
	    {
		*ept=0;
		th->translatedtext=strmcat(th->translatedtext,lngtxt(873));
	    }
	}
	ept=strstr(th->translatedtext,"<P>");
	if(ept!=NULL)
	{ 
	    *ept=0;
	}
	th->translatedtext=strmcat(th->translatedtext,"\r\n");
	if(th->direction==TR_TO)
	{
	    if(user(th->usern)->outstate==STD_CONN)
	    {
		writesock(user(th->usern)->outsock,th->translatedtext);
		if(user(th->usern)->instate>STD_NOCON)
		{
		    pt=strchr(th->translatedtext,':');
		    if(pt!=NULL)
		    {
			if(strchr("#!&+",*th->dest)!=NULL)
			{
			    ssnprintf(user(th->usern)->insock,lngtxt(874),user(th->usern)->nick,user(th->usern)->login,user(th->usern)->host,th->dest,pt);
			} else {
			    ssnprintf(user(th->usern)->insock,lngtxt(875),th->dest,user(th->usern)->nick,pt);
			}
		    }
		}
	    }
	} else {
	    if(user(th->usern)->instate>STD_NOCON)
	    {
		writesock(user(th->usern)->insock,th->translatedtext);
	    }
	}
	erasetranslate(uid); /* job done, socket gone */
    } else {    
	ept=nobreak(ircbuf);
	pt=strstr(ept,"<textarea");
	if(pt!=NULL)
	{
	    pt=strchr(pt,'>');
	    if(pt!=NULL)
	    {
		ept=pt+1;
	    }
	}
	while(*ept==' ' || *ept==9) ept++;
	if(*ept)
	{
	    th->translatedtext=strmcat(th->translatedtext,ept);
	    th->translatedtext=strmcat(th->translatedtext," ");
	}
    }
    return 0x0;
}