Commit initial: GNUWorld servicii IRC cu README.md complet in limba romana - Analiza arhitecturala completa a proiectului - Documentatie ierarhie clase, bucla de evenimente, protocol P10 - Identificare probleme memorie si recomandari modernizare

This commit is contained in:
Underchat committed 2026-03-02 00:51:45 +02:00
commit fcb24f6de9
870 files changed
+311128

No files matched your search

+4
View File
@@ -0,0 +1,4 @@
Makefile
*.la *.lo
.deps .libs
.arch-ids
+47
View File
@@ -0,0 +1,47 @@
## Process this file with automake to produce Makefile.in
## $Id: Makefile.am,v 1.11 2010/08/31 21:16:45 denspike Exp $
lib_LTLIBRARIES = libircu.la
libircu_la_SOURCES = msg_AC.cc \
msg_AD.cc \
msg_B.cc \
msg_C.cc \
msg_CM.cc \
msg_D.cc \
msg_DS.cc \
msg_EA.cc \
msg_EB.cc \
msg_G.cc \
msg_GL.cc \
msg_I.cc \
msg_J.cc \
msg_JU.cc \
msg_K.cc \
msg_L.cc \
msg_M351.cc \
msg_M391.cc \
msg_M.cc \
msg_N.cc \
msg_NOOP.cc \
msg_O.cc \
msg_OM.cc \
msg_PA.cc \
msg_P.cc \
msg_Q.cc \
msg_R.cc \
msg_RI.cc \
msg_RO.cc \
msg_S.cc \
msg_Server.cc \
msg_SQ.cc \
msg_T.cc \
msg_V.cc \
msg_WA.cc \
msg_W.cc \
msg_XQ.cc \
msg_XR.cc \
msg_Y.cc \
msg_FA.cc
libircu_la_CXXFLAGS = -I${top_srcdir}/include -I${top_srcdir}/libgnuworld
libircu_la_LDFLAGS = -module -export-dynamic
+1019
View File
File diff suppressed because it is too large. Load diff
+102
View File
@@ -0,0 +1,102 @@
/**
* msg_AC.cc
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* "$Id: msg_AC.cc,v 1.9 2005/03/25 03:07:29 dan_karrels Exp $"
*/
#include <string>
#include <iostream>
#include "gnuworld_config.h"
#include "ServerCommandHandler.h"
#include "server.h"
#include "xparameters.h"
#include "Channel.h"
#include "Network.h"
#include "iClient.h"
#include "ELog.h"
RCSTAG( "$Id: msg_AC.cc,v 1.9 2005/03/25 03:07:29 dan_karrels Exp $" ) ;
namespace gnuworld
{
CREATE_HANDLER(msg_AC)
/**
* ACCOUNT message handler.
* SOURCE AC TARGET ACCOUNT
* Eg:
* AXAAA AC BQrTd Gte
*/
bool msg_AC::Execute( const xParameters& Param )
{
if( Param.size() != 3 )
{
elog << "msg_AC> Invalid number of parameters"
<< std::endl ;
return false ;
}
// Find the target user
iClient* theClient = Network->findClient( Param[ 1 ] ) ;
if( !theClient )
{
elog << "msg_AC> Unable to find target client: "
<< Param[ 1 ]
<< std::endl ;
return false;
}
std::string account( Param[2] );
time_t account_ts = 0;
/* If we have an account, does it have a timestamp? */
if( ! account.empty() ) {
std::string::size_type pos = account.find(':');
if( ! ( pos == std::string::npos ) ) {
/* We have a timestamp */
if ( pos == ( account.length() - 1 ) ) {
/* Bizarre - colon but no following TS */
elog << "msg_N> Invalid account format: "
<< account
<< std::endl;
} else {
std::string account_ts_s = account;
account_ts_s.erase(0, pos + 1);
account.erase(pos);
account_ts = atoi(account_ts_s.c_str());
}
}
}
// Update user information
theClient->setAccount( account ) ;
if( account_ts != 0 ) theClient->setAccountTS( account_ts );
// Post event to listening clients
theServer->PostEvent( EVT_ACCOUNT, static_cast< void* >( theClient ) ) ;
// Return success
return true;
}
} // namespace gnuworld
+40
View File
@@ -0,0 +1,40 @@
/**
* msg_AD.cc
* Copyright (C) 2002 Daniel Karrels <dan@karrels.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: msg_AD.cc,v 1.4 2005/03/25 03:07:29 dan_karrels Exp $
*/
#include "gnuworld_config.h"
#include "server.h"
#include "xparameters.h"
#include "ServerCommandHandler.h"
RCSTAG( "$Id: msg_AD.cc,v 1.4 2005/03/25 03:07:29 dan_karrels Exp $" ) ;
namespace gnuworld
{
CREATE_HANDLER(msg_AD)
bool msg_AD::Execute( const xParameters& )
{
return true ;
}
} // namespace gnuworld
+540
View File
@@ -0,0 +1,540 @@
/**
* msg_B.cc
* Author: Daniel Karrels (dan@karrels.com)
* Copyright (C) 2002 Daniel Karrels <dan@karrels.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: msg_B.cc,v 1.12 2008/04/16 20:29:37 danielaustin Exp $
*/
#include <sys/types.h>
#include <sys/time.h>
#include <new>
#include <map>
#include <string>
#include <vector>
#include <iostream>
#include <utility>
#include <cassert>
#include "gnuworld_config.h"
#include "server.h"
#include "xparameters.h"
#include "StringTokenizer.h"
#include "ELog.h"
#include "Channel.h"
#include "ChannelUser.h"
#include "Network.h"
#include "iClient.h"
#include "ServerCommandHandler.h"
RCSTAG( "$Id: msg_B.cc,v 1.12 2008/04/16 20:29:37 danielaustin Exp $" ) ;
namespace gnuworld
{
using std::pair ;
using std::make_pair ;
using std::string ;
using std::vector ;
using std::endl ;
class msg_B : public ServerCommandHandler
{
public:
msg_B( xServer* theServer )
: ServerCommandHandler( theServer )
{}
virtual ~msg_B()
{}
virtual bool Execute( const xParameters& ) ;
protected:
void parseBurstUsers( Channel*, const string& ) ;
void parseBurstBans( Channel*, const string& ) ;
} ;
CREATE_LOADER(msg_B)
// MSG_B
// This is the BURST command.
// 0 B #merida 957075177 +tn BAA:o
// 0 B #ValHalla 000031335 +stn CAA:o
// 0 B #linux 801203210 +stn OBL,LLf:ov,MBU:o,OBE,MAg,MAh
// 0 B #mylinux 953234759 +tn OBL,MBU:o,OBE,MAg,MAh
// 0 B #krushnet 000031337 +tn LEM,qAD,OAi,2B6,kA],kA9,qAA,2B2,NCR,kAD,OAC,0DK:o,MAL,zDj
// :%*!*lamer@*lamer.lamer.lamer.lamer11.com *!*lamer@*lamer.lamer.lamer.lamer10.com
// *!*lamer@*lamer.lamer.lamer.lamer9.com *!*lamer@*lamer.lamer.lamer.lamer8.com
// *!*lamer@*lamer.lamer.lamer.lamer7.com *!*lamer@*lamer.lamer.lamer.lamer6.com
// *!*lamer@*lamer.lamer.lamer.lamer5.com *!*lamer@*lamer.lamer.lamer.lamer4.com
// *!*lamer@*lamer.lamer.lamer.lamer3.com *!*lamer@*lamer.lamer.lamer.lamer2.com
//
// Q B #ateneo 848728923 +tnl 2000 r]Q,ZLC,Smt,rGN,gPk,uhy,Z]N,oTL,uem,31b,Znt,
// 3x3,oC0,TvC,3vs,oSo,IP7,oXL,aF2,CW9,sTq,Znw,Is9,gPD,rI1,ToI,ZZK,oGB,$Q
// B #ateneo 848728923 4Qt,LE2,LXJ,3ys,oIG,lwc,TQX,HwR,3iZ,g2D,ZP3,3m2,uPi,Z0n,
// LTi,oG[,a3N,IH4,T3T,La],goY,geE,sar,oid,o90,35Y,TUL,Z7K,Zx7,TN1,C6$Q
// B #ateneo 848728923 :%*!*@203.145.226.149 *!*@203.177.4.* *!*@203.145.226.134
// *!*@202.8.230.*
//
// Q B #hgsd 933357379 +tn PIs,OfK,OAu,PZl:o,eAA
//
// Here is a special case, when the only occupant of the channel
// is a zombie:
// BG B #nails 1036089823
// We ignore this case.
//
// With u2.10.12's oplevels, we have to deal with an extra case:
// <numeric> B <channel> <ts> <modes...> <numnick>:<oplevel>
// Ck B #test 1128024142 +tnAU apass upass BBAAA:999
//
bool msg_B::Execute( const xParameters& Param )
{
// Make sure there are at least four arguments supplied:
// servernumeric #channel time_stamp arguments
if( Param.size() < 3 )
{
elog << "msg_B> Invalid number of arguments: "
<< Param
<< endl ;
return false ;
}
// Attempt to find the channel in the network channel table
Channel* theChan = Network->findChannel( Param[ 1 ] ) ;
// Was the channel found?
if( NULL == theChan )
{
// The channel does not yet exist, go ahead and create it.
theChan = new (std::nothrow)
Channel( Param[ 1 ], atoi( Param[ 2 ] ) ) ;
assert( theChan != 0 ) ;
// Add the new Channel to the network channel table
if( !Network->addChannel( theChan ) )
{
// The addition of this channel failed, *shrug*
elog << "msg_B> Failed to add channel: "
<< Param[ 1 ]
<< endl ;
// Prevent a memory leak by deleting the channel
delete theChan ; theChan = 0 ;
// Return error
return false ;
}
} // if( NULL == theChan )
else
{
// The channel was already found.
// Make sure the timestamp is accurate, this is an oddity imho.
time_t newCreationTime =
static_cast< time_t >( ::atoi( Param[ 2 ] ) ) ;
// Is the old TS greater than the new TS?
if( theChan->getCreationTime() > newCreationTime )
{
// Nope, update the timestamp
theChan->setCreationTime( newCreationTime ) ;
theChan->removeAllModes() ;
theChan->removeAllBans() ;
}
}
if( 3 == Param.size() )
{
// Zombie in channel.
// If the user is dezombified, the client will be shown
// to issue a "J", and the channel will be created anyway.
// Only difference is the timestamp difference.
return true ;
}
// Parse out the channel state
xParameters::size_type whichToken = 3 ;
// Channel modes will always be the first thing to follow if it's in the burst
if( '+' == Param[ whichToken ][ 0 ] )
{
// channel modes
const char* currentPtr = Param[ whichToken ] ;
// Skip over the '+'
++currentPtr ;
xServer::modeVectorType modeVector ;
for( ; currentPtr && *currentPtr ; ++currentPtr )
{
switch( *currentPtr )
{
case 't':
modeVector.push_back( make_pair(
true, Channel::MODE_T ) ) ;
break ;
case 'n':
modeVector.push_back( make_pair(
true, Channel::MODE_N ) ) ;
break ;
case 'm':
modeVector.push_back( make_pair(
true, Channel::MODE_M ) ) ;
break ;
case 'p':
modeVector.push_back( make_pair(
true, Channel::MODE_P ) ) ;
break ;
case 's':
modeVector.push_back( make_pair(
true, Channel::MODE_S ) ) ;
break ;
case 'i':
modeVector.push_back( make_pair(
true, Channel::MODE_I ) ) ;
break ;
case 'r':
modeVector.push_back( make_pair(
true, Channel::MODE_R ) ) ;
break ;
case 'R':
modeVector.push_back( make_pair(
true, Channel::MODE_REG ) ) ;
break ;
case 'D':
modeVector.push_back( make_pair(
true, Channel::MODE_D ) ) ;
break ;
case 'l':
theServer->OnChannelModeL( theChan, true,
0,
::atoi( Param[ whichToken + 1 ] ) ) ;
whichToken++ ;
break ;
case 'k':
theServer->OnChannelModeK( theChan, true,
0,
Param[ whichToken + 1 ] ) ;
whichToken++ ;
break ;
case 'A':
theServer->OnChannelModeA( theChan, true,
0,
Param[ whichToken + 1 ] ) ;
whichToken++ ;
break ;
case 'U':
theServer->OnChannelModeU( theChan, true,
0,
Param[ whichToken + 1 ] ) ;
whichToken++ ;
break ;
default:
break ;
} // switch
} // for( currentPtr != endPtr )
if( !modeVector.empty() )
{
theServer->OnChannelMode( theChan, 0, modeVector ) ;
}
// Skip over the modes token
// whichToken either points to the modes token if no +l/+k
// was specified, or it points to the last +l/+k argument;
// skip over this token no matter which.
whichToken++ ;
} // if( '+' == Param[ whichToken ][ 0 ]
// Have we reached the end of this burst command?
if( whichToken >= Param.size() )
{
return true ;
}
// Parse the remaining tokens
for( ; whichToken < Param.size() ; ++whichToken )
{
// Bans will always be the last thing burst, so no users
// will be burst afterwards. This is useful because xParameters
// will only delimit tokens by ':', so the ban string is guaranteed
// to be caught.
if( '~' == Param[ whichToken ][ 0 ] )
{
// Channel ban exceptions
// Be sure to skip over the '%'
//parseBurstExcepts( theChan, Param[ whichToken ] + 1 ) ;
}
else if( '%' == Param[ whichToken ][ 0 ] )
{
// Channel bans
// Be sure to skip over the '%'
parseBurstBans( theChan, Param[ whichToken ] + 1 ) ;
}
else
{
// Userlist
parseBurstUsers( theChan, Param[ whichToken ] ) ;
}
}
return true ;
}
// dA1,jBN:ov,C3K:v,jGZ:o,CkU
// ':' indicates a mode state. Eg: ':ov' indicates this and
// all the following numerics are opped and voiced up to the next
// mode state.
// Mode states will always be in the order ov, v, o if present
// at all.
void msg_B::parseBurstUsers( Channel* theChan, const string& theUsers )
{
// This is a protected method, so the method arguments are
// guaranteed to be valid
//elog << "msg_B::parseBurstUsers> Channel: " << theChan->getName()
// << ", users: " << theUsers << endl ;
// Parse out users and their modes
StringTokenizer st( theUsers, ',' ) ;
// Used to track op/voice/opvoice mode state switches.
// 1 = op, 2 = voice, 3 = opvoice.
unsigned short int mode_state = 0;
typedef xServer::opVectorType opVectorType ;
typedef xServer::voiceVectorType voiceVectorType ;
opVectorType opVector ;
opVectorType halfOpVector ;
voiceVectorType voiceVector ;
for( StringTokenizer::const_iterator ptr = st.begin() ; ptr != st.end() ;
++ptr )
{
// Each token is of the form:
// abc or abc:modes
string::size_type pos = (*ptr).find_first_of( ':' ) ;
// Find the client in the client table
iClient* theClient = Network->findClient( (*ptr).substr( 0, pos ) ) ;
// Was the search successful?
if( NULL == theClient )
{
// Nope, no such user
// Log the error
elog << "msg_B::parseBurstUsers> ("
<< theChan->getName() << ")"
<< ": Unable to find client: "
<< (*ptr).substr( 0, pos )
<< endl ;
// Skip this user
continue ;
}
// elog << "msg_B::parseBurstUsers> Adding user "
// << theClient->getNickName()
// << "(" << theClient->getCharYYXXX() << ") to channel "
// << theChan->getName() << endl ;
// Add this channel to the user's channel structure.
if( !theClient->addChannel( theChan ) )
{
elog << "msg_B::parseBurstUsers> Failed to add "
<< "channel "
<< *theChan
<< " to iClient "
<< *theClient
<< endl ;
// Non-fatal error
continue ;
}
// Create a ChannelUser object to represent this user's presence
// in this channel
ChannelUser* chanUser =
new (std::nothrow) ChannelUser( theClient ) ;
assert( chanUser != 0 ) ;
// Add this user to the channel's database.
if( !theChan->addUser( chanUser ) )
{
// The addition failed
elog << "msg_B::parseBurstUsers> Unable to add user "
<< theClient->getNickName()
<< " to channel "
<< theChan->getName()
<< endl ;
// Prevent a memory leak by deallocating the unused
// ChannelUser object
delete chanUser ; chanUser = 0 ;
// Remove the channel info from the client
theClient->removeChannel( theChan ) ;
continue ;
}
// Notify the services clients that a user has
// joined the channel
theServer->PostChannelEvent( EVT_JOIN, theChan,
static_cast< void* >( theClient ),
static_cast< void* >( chanUser ) ) ;
// Is there a ':' in this client's info?
if( string::npos == pos )
{
// no ':' in this string, add the user with the current
// MODE state.
switch( mode_state )
{
case 1:
opVector.push_back(
opVectorType::value_type(
true, chanUser ) ) ;
break;
case 2:
voiceVector.push_back(
voiceVectorType::value_type(
true, chanUser ) ) ;
break;
case 3:
opVector.push_back(
opVectorType::value_type(
true, chanUser ) ) ;
voiceVector.push_back(
voiceVectorType::value_type(
true, chanUser ) ) ;
break;
}
// mode_state still 0, not opped or voiced.
continue ;
}
// Otherwise, user modes have been specified.
for( pos++ ; pos < (*ptr).size() ; ++pos )
{
switch( (*ptr)[ pos ] )
{
case 'o':
opVector.push_back(
opVectorType::value_type(
true, chanUser ) ) ;
mode_state = 1;
break ;
case 'h':
halfOpVector.push_back(
opVectorType::value_type(
true, chanUser ) ) ;
//mode_state = 1;
break ;
case 'v':
// Does the user already
// have mode 'o'?
if( 1 == mode_state )
{
// User has 'o' mode already
opVector.push_back(
opVectorType::value_type(
true, chanUser ) ) ;
}
voiceVector.push_back(
voiceVectorType::value_type(
true, chanUser ) ) ;
mode_state = (mode_state == 1) ? 3 : 2;
break ;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
/* This is an oplevel, which we are not (currently) interested in.
* However, we also don't want it to cause an error!
*/
break;
default:
elog << "msg_B::parseBurstUsers> "
<< "Unknown mode: "
<< (*ptr)[ pos ] << endl ;
break ;
} // switch
} // for()
} // while( ptr != st.end() )
// Commit the user modes to the internal tables, and notify
// all listening clients
if( !opVector.empty() )
{
theServer->OnChannelModeO( theChan, 0, opVector ) ;
}
if( !halfOpVector.empty() )
{
theServer->OnChannelModeH( theChan, 0, halfOpVector ) ;
}
if( !voiceVector.empty() )
{
theServer->OnChannelModeV( theChan, 0, voiceVector ) ;
}
}
void msg_B::parseBurstBans( Channel* theChan, const string& theBans )
{
// This is a protected method, so the method arguments are
// guaranteed to be valid
//elog << "msg_B::parseBurstBans> Found bans for channel "
// << theChan->getName()
// << ": "
// << theBans
// << endl ;
// Tokenize the ban string
StringTokenizer st( theBans ) ;
typedef xServer::banVectorType banVectorType ;
banVectorType banVector( st.size() ) ;
// Move through each token and add the ban
for( StringTokenizer::size_type i = 0 ; i < st.size() ; ++i )
{
banVector.push_back(
banVectorType::value_type( true, st[ i ] ) ) ;
}
if( !banVector.empty() )
{
theServer->OnChannelModeB( theChan, 0, banVector ) ;
}
}
} // namespace gnuworld
+235
View File
@@ -0,0 +1,235 @@
/**
* msg_C.cc
* Author: Daniel Karrels (dan@karrels.com)
* Copyright (C) 2002 Daniel Karrels <dan@karrels.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: msg_C.cc,v 1.10 2007/03/16 15:31:28 mrbean_ Exp $
*/
#include <new>
#include <string>
#include <utility>
#include <cassert>
#include "gnuworld_config.h"
#include "server.h"
#include "Network.h"
#include "events.h"
#include "ELog.h"
#include "StringTokenizer.h"
#include "xparameters.h"
#include "iClient.h"
#include "Channel.h"
#include "ChannelUser.h"
#include "ServerCommandHandler.h"
RCSTAG( "$Id: msg_C.cc,v 1.10 2007/03/16 15:31:28 mrbean_ Exp $" ) ;
namespace gnuworld
{
using std::pair ;
using std::string ;
using std::endl ;
CREATE_HANDLER(msg_C)
/**
* Someone has just joined an empty channel (create)
* UAA C #xfactor 957134023
* zBP C #OaXaCa,#UruApan,#skatos 957207634
*/
bool msg_C::Execute( const xParameters& Param )
{
// Verify that there exist sufficient arguments to successfully
// handle this command
// client_numeric #channel[,#channel2,...] timestamp
if( Param.size() < 3 )
{
// Insufficient arguments provided
elog << "msg_C> Invalid number of parameters"
<< endl ;
// Return error
return false ;
}
// Find the client in question.
iClient* theClient = Network->findClient( Param[ 0 ] ) ;
// Did we find the client?
if( NULL == theClient )
{
// Nope, log the error
elog << "msg_C> ("
<< Param[ 1 ]
<< ") Unable to find client: "
<< Param[ 0 ]
<< endl ;
// Return error
return false ;
}
// Grab the creation time.
time_t creationTime =
static_cast< time_t >( atoi( Param[ Param.size() - 1 ] ) ) ;
// Tokenize based on ','. Multiple channels may be put into the
// same C(REATE) command.
StringTokenizer st( Param[ 1 ], ',' ) ;
for( StringTokenizer::const_iterator ptr = st.begin() ; ptr != st.end() ;
++ptr )
{
// Is this a modeless channel?
if( '+' == (*ptr)[ 0 ] )
{
// Modeless channel, ignore it
continue ;
}
// Find the channel in question.
Channel* theChan = Network->findChannel( *ptr ) ;
// Did we find the channel?
if( NULL == theChan )
{
// Channel doesn't exist..this transmutes to a create
theChan = new (std::nothrow)
Channel( *ptr, creationTime ) ;
assert( theChan != 0 ) ;
// Add this channel to the network channel table
if( !Network->addChannel( theChan ) )
{
// Addition failed, log the error
elog << "msg_C> Failed to add channel: "
<< *theChan
<< endl ;
// Prevent memory leaks by removing the unused
// channel
delete theChan ; theChan = 0 ;
// continue to next one *shrug*
continue ;
}
}
ChannelUser* theUser = 0 ;
if( theClient->findChannel( theChan ) )
{
// The client knows about this channel already
// Verify that the channel knows about the user.
theUser = theChan->findUser( theClient ) ;
if( 0 == theUser )
{
// The client knows of the channel, but not
// the other way around.
// theUser will be created and added to the
// channel membership table below.
elog << "msg_C> Half-way membership found "
<< " for client "
<< *theClient
<< ", in channel "
<< *theChan
<< endl ;
}
else
{
// User is already in the channel, probably lag or
// a non-authoritative kick
// theUser->removeZombie() ;
}
}
else
{
// Add this channel to the client's channel structure.
if( !theClient->addChannel( theChan ) )
{
elog << "msg_C> Unable to add channel "
<< *theChan
<< " to iClient "
<< *theClient
<< endl ;
continue ;
}
}
// The client now knows about the channel, build the second
// half of the channel<->user association, if necessary.
if( 0 == theUser )
{
// Create a new ChannelUser to represent this iClient's
// membership in this channel.
theUser = new (std::nothrow) ChannelUser( theClient ) ;
assert( theUser != 0 ) ;
// Add the ChannelUser to the Channel's information
if( !theChan->addUser( theUser ) )
{
// Addition failed, log the error
// This should never happen.
elog << "msg_C> Unable to add user "
<< theUser->getNickName()
<< " to channel "
<< theChan->getName()
<< endl ;
// Prevent a memory leak by deallocating the
// unused ChannelUser structure
delete theUser ; theUser = 0 ;
// Remove the channel information from the client
theClient->removeChannel( theChan ) ;
// Continue to next channel
continue ;
}
}
int creationTime = atoi ( Param [ 2 ] );
// The user who created the channel is automatically +o
if(creationTime == theChan->getCreationTime() )
{
theUser->setModeO();
}
if(creationTime < theChan->getCreationTime() )
{
//Need to clean all the channel modes and op the user who created the channel
theChan->removeAllModes();
theUser->setModeO() ;
theChan->setCreationTime(creationTime);
}
// Notify all listening xClients of this event
theServer->PostChannelEvent( EVT_CREATE, theChan,
static_cast< void* >( theClient ) ) ;
} // for()
return true ;
}
} // namespace gnuworld
+276
View File
@@ -0,0 +1,276 @@
/*
* msg_CM. cc
* Copyright (C) 2002 Daniel Karrels <dan@karrels.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: msg_CM.cc,v 1.11 2008/04/16 20:29:37 danielaustin Exp $
*/
#include <map>
#include <string>
#include <iostream>
#include "gnuworld_config.h"
#include "server.h"
#include "Channel.h"
#include "ChannelUser.h"
#include "Network.h"
#include "iClient.h"
#include "xparameters.h"
#include "ELog.h"
#include "ServerCommandHandler.h"
RCSTAG( "$Id: msg_CM.cc,v 1.11 2008/04/16 20:29:37 danielaustin Exp $" ) ;
namespace gnuworld
{
using std::pair ;
using std::make_pair ;
using std::endl ;
CREATE_HANDLER(msg_CM)
/**
* CLEARMODE message handler.
* ZZAAA CM #channel obv
* The above message would remove all ops, bans, and voice modes
* from channel #channel.
*/
bool msg_CM::Execute( const xParameters& Param )
{
if( Param.size() < 3 )
{
elog << "msg_CM> Invalid number of parameters"
<< endl ;
return false ;
}
Channel* tmpChan = Network->findChannel( Param[ 1 ] ) ;
if( !tmpChan )
{
// Log Error.
elog << "msg_CM> Unable to locate channel: "
<< Param[ 1 ]
<< endl ;
return false ;
}
/*
* First, determine what we are going to clear.
*/
std::string Modes = Param[ 2 ] ;
// These three variables will be set to true if we are to clear either
// the ops, voice, or bans, respectively
bool clearOps = false ;
bool clearVoice = false ;
bool clearBans = false ;
// Go ahead and post the server mode event
iServer* serverSource = 0 ;
if( NULL != strchr( Param[ 0 ], '.' ) )
{
// Server, by name
serverSource = Network->findServerName( Param[ 0 ] ) ;
} else if( strlen( Param[ 0 ] ) < 3 )
{
// 1 or 2 char numeric, server
serverSource = Network->findServer( Param[ 0 ] ) ;
}
if (serverSource != 0)
{
elog << "msg_CM ("
<< tmpChan->getName()
<< ") server "
<< serverSource->getName()
<< " performed a mode"
<< std::endl;
theServer->PostChannelEvent( EVT_SERVERMODE, tmpChan,
static_cast< void* >( serverSource ) );
}
xServer::modeVectorType modeVector ;
for( std::string::size_type i = 0 ; i < Modes.size() ; i++ )
{
switch( Modes[ i ] )
{
case 'o':
clearOps = true ;
// elog << tmpChan->getName()
// << "msg_CM> Doing CLEAR_CHANOPS"
// << endl;
break ;
case 'v':
clearVoice = true ;
// elog << tmpChan->getName()
// << "msg_CM> Doing CLEAR_VOICED"
// << endl;
break ;
case 's':
modeVector.push_back( make_pair(
false, Channel::MODE_S ) ) ;
// elog << tmpChan->getName()
// << "msg_CM> Doing CLEAR_SECRET"
// << endl;
break ;
case 'r':
modeVector.push_back( make_pair(
false, Channel::MODE_R ) ) ;
// elog << tmpChan->getName()
// << "msg_CM> Doing CLEAR_REGISTER"
// << endl;
break ;
case 'R':
modeVector.push_back( make_pair(
false, Channel::MODE_REG ) ) ;
break ;
case 'D':
modeVector.push_back( make_pair(
false, Channel::MODE_D ) ) ;
// elog << tmpChan->getName()
// << "msg_CM> Doing CLEAR_MODED"
// << endl;
break ;
case 'm':
modeVector.push_back( make_pair(
false, Channel::MODE_M ) ) ;
// elog << tmpChan->getName()
// << "msg_CM> Doing CLEAR_MODERATED"
// << endl;
break ;
case 't':
modeVector.push_back( make_pair(
false, Channel::MODE_T ) ) ;
// elog << tmpChan->getName()
// << "msg_CM> Doing CLEAR_TOPICLIMIT"
// << endl;
break ;
case 'i':
modeVector.push_back( make_pair(
false, Channel::MODE_I ) ) ;
// elog << tmpChan->getName()
// << "msg_CM> Doing CLEAR_INVITEONLY"
// << endl;
break ;
case 'n':
modeVector.push_back( make_pair(
false, Channel::MODE_N ) ) ;
// elog << tmpChan->getName()
// << "msg_CM> Doing CLEAR_NOPRIVMSGS"
// << endl;
break ;
case 'p':
modeVector.push_back( make_pair(
false, Channel::MODE_P ) ) ;
// elog << tmpChan->getName()
// << "msg_CM> Doing CLEAR_NOPRIVMSGS"
// << endl;
break ;
case 'k':
theServer->OnChannelModeK( tmpChan, false, 0,
std::string() ) ;
tmpChan->setKey( std::string() );
// elog << tmpChan->getName()
// << "msg_CM> Doing CLEAR_KEY"
// << endl;
break ;
case 'b':
clearBans = true ;
tmpChan->removeAllBans();
// elog << tmpChan->getName()
// << "msg_CM> Doing CLEAR_BANS"
// << endl;
break ;
case 'l':
theServer->OnChannelModeL( tmpChan, false, 0, 0 ) ;
// elog << tmpChan->getName()
// << "msg_CM> Doing CLEAR_LIMIT"
// << endl;
break ;
default:
// Unknown mode
elog << "msg_CM> Unknown mode: "
<< Modes[ i ]
<< endl ;
break ;
} // switch
} // for
if( !modeVector.empty() )
{
theServer->OnChannelMode( tmpChan, 0, modeVector ) ;
}
if( clearOps || clearVoice )
{
/*
* Lets loop over everyone in the channel and either deop
* or devoice them.
*/
xServer::opVectorType opVector ;
xServer::voiceVectorType voiceVector ;
for( Channel::const_userIterator ptr = tmpChan->userList_begin();
ptr != tmpChan->userList_end() ; ++ptr )
{
if( clearOps && ptr->second->isModeO() )
{
ptr->second->removeModeO();
opVector.push_back( pair< bool, ChannelUser* >
( false, ptr->second ) ) ;
}
if( clearVoice && ptr->second->isModeV() )
{
ptr->second->removeModeV();
voiceVector.push_back( pair< bool, ChannelUser* >
( false, ptr->second ) ) ;
}
}
if( !voiceVector.empty() )
{
theServer->OnChannelModeV( tmpChan, 0, voiceVector ) ;
}
if( !opVector.empty() )
{
theServer->OnChannelModeO( tmpChan, 0, opVector ) ;
}
} // if( clearOps || clearVoice )
if( clearBans )
{
xServer::banVectorType banVector ;
for( Channel::banIterator ptr = tmpChan->banList_begin(),
endPtr = tmpChan->banList_end() ;
ptr != endPtr ; ++ptr )
{
banVector.push_back( pair< bool, std::string >
( false, *ptr ) ) ;
}
theServer->OnChannelModeB( tmpChan, 0, banVector ) ;
} // if( clearBans )
return true ;
}
} // namespace gnuworld
+159
View File
@@ -0,0 +1,159 @@
/**
* msg_D.cc
* Copyright (C) 2002 Daniel Karrels <dan@karrels.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: msg_D.cc,v 1.5 2005/03/25 03:07:29 dan_karrels Exp $
*/
#include <new>
#include <string>
#include <cassert>
#include "gnuworld_config.h"
#include "server.h"
#include "iClient.h"
#include "iServer.h"
#include "events.h"
#include "Network.h"
#include "ELog.h"
#include "StringTokenizer.h"
#include "ServerCommandHandler.h"
RCSTAG( "$Id: msg_D.cc,v 1.5 2005/03/25 03:07:29 dan_karrels Exp $" ) ;
namespace gnuworld
{
using std::string ;
using std::endl ;
CREATE_HANDLER(msg_D)
/**
* Kill command
* QAA D BB5 :localhost!_reppir (Im using my super duper clone detecting
* skills)
* G D r[l :NewYork-R.NY.US.Undernet.Org!NewYork-R.NY.US.Undernet.org ...
* The source of the kill could be a server or a client.
*/
bool msg_D::Execute( const xParameters& Param )
{
if( Param.size() < 3 )
{
elog << "msg_D> Invalid number of parameters"
<< endl ;
return false ;
}
if( (Param[ 1 ][ 0 ] == theServer->getCharYY()[ 0 ]) &&
(Param[ 1 ][ 1 ] == theServer->getCharYY()[ 1 ]) )
{
// See if the client being killed is one of my own.
xClient* myClient = Network->findLocalClient( Param[ 1 ] ) ;
// Is the user being killed on this server?
if( NULL != myClient )
{
// doh, yes it is :(
myClient->OnKill() ;
// Don't detach the client until it requests so.
// TODO: Work on this system.
// Note that the client is still attached to the
// server.
return true ;
}
else
{
// It's a client on my server, but not an xClient.
// This is ok, the normal client kill handling code
// (for iClient) will handle removing fake clients.
// Allow it continue instead of returning.
}
}
// Otherwise, it's a non-local client.
iClient* source = 0 ;
iServer* serverSource = 0 ;
if( strchr( Param[ 0 ], '.' ) != NULL )
{
// Server, by name
serverSource = Network->findServerName( Param[ 0 ] ) ;
}
else if( strlen( Param[ 0 ] ) >= 3 )
{
// Client, by numeric
source = Network->findClient( Param[ 0 ] ) ;
}
else
{
// Server, by numeric
serverSource = Network->findServer( Param[ 0 ] ) ;
}
if( (NULL == serverSource) && (NULL == source) )
{
elog << "msg_D> Unable to find source: "
<< Param[ 0 ]
<< endl ;
return false ;
}
// Find and remove the client that was just killed.
// xNetwork::removeClient will remove user<->channel associations
iClient* target = Network->removeClient( Param[ 1 ] ) ;
// Make sure we have valid pointers to both source
// and target.
if( NULL == target )
{
elog << "msg_D> Unable to find target client: "
<< Param[ 1 ]
<< endl ;
return false ;
}
// Notify all listeners of the EVT_KILL event.
string reason( Param[ 2 ] ) ;
if( source != NULL )
{
theServer->PostEvent( EVT_KILL,
static_cast< void* >( source ),
static_cast< void* >( target ),
static_cast< void* >( &reason ) ) ;
}
else
{
theServer->PostEvent( EVT_KILL,
static_cast< void* >( serverSource ),
static_cast< void* >( target ),
static_cast< void* >( &reason ) ) ;
}
// Deallocate the memory associated with this iClient.
delete target ;
return true ;
}
} // namespace gnuworld
+43
View File
@@ -0,0 +1,43 @@
/**
* msg_DS.cc
* Copyright (C) 2002 Daniel Karrels <dan@karrels.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: msg_DS.cc,v 1.4 2005/03/25 03:07:29 dan_karrels Exp $
*/
#include "gnuworld_config.h"
#include "server.h"
#include "xparameters.h"
#include "ServerCommandHandler.h"
RCSTAG( "$Id: msg_DS.cc,v 1.4 2005/03/25 03:07:29 dan_karrels Exp $" ) ;
namespace gnuworld
{
CREATE_HANDLER(msg_DS)
// DeSynch handler?
// 0 DS :HACK: JavaDude MODE #irc.core.com +smtink lamers [957881646]
bool msg_DS::Execute( const xParameters& )
{
// TODO
return true ;
}
} // namespace gnuworld
+77
View File
@@ -0,0 +1,77 @@
/**
* msg_EA.cc
* Copyright (C) 2002 Daniel Karrels <dan@karrels.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: msg_EA.cc,v 1.5 2005/03/25 03:07:29 dan_karrels Exp $
*/
#include <string>
#include <iostream>
#include <cstring>
#include "gnuworld_config.h"
#include "server.h"
#include "Network.h"
#include "events.h"
#include "ELog.h"
#include "iServer.h"
#include "ServerCommandHandler.h"
RCSTAG( "$Id: msg_EA.cc,v 1.5 2005/03/25 03:07:29 dan_karrels Exp $" ) ;
namespace gnuworld
{
using std::string ;
using std::endl ;
CREATE_HANDLER(msg_EA)
// Q EA
// Q: Remote server numeric
// EA: End Of Burst Acknowledge
// Our uplink server has acknowledged our EB
bool msg_EA::Execute( const xParameters& Param )
{
if( !strcmp( Param[ 0 ], theServer->getUplinkCharYY().c_str() ) )
{
// My uplink! :)
// Reset EOB just to be sure
theServer->setBursting( false ) ; // ACKNOWLEDGE! :)
}
//if( !theServer->isBursting() )
// {
iServer* burstServer = Network->findServer( Param[ 0 ] ) ;
if( NULL == burstServer )
{
elog << "msg_EA> Unable to find server: "
<< Param[ 0 ]
<< endl ;
return false ;
}
theServer->PostEvent( EVT_BURST_ACK,
static_cast< void* >( burstServer ) );
// }
return true ;
}
} // namespace gnuworld
+143
View File
@@ -0,0 +1,143 @@
/**
* msg_EB.cc
* Copyright (C) 2002 Daniel Karrels <dan@karrels.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: msg_EB.cc,v 1.10 2005/03/25 03:07:29 dan_karrels Exp $
*/
#include <sys/types.h>
#include <sys/time.h>
#include <iostream>
#include "gnuworld_config.h"
#include "server.h"
#include "iServer.h"
#include "events.h"
#include "Network.h"
#include "ELog.h"
#include "xparameters.h"
#include "ServerCommandHandler.h"
RCSTAG( "$Id: msg_EB.cc,v 1.10 2005/03/25 03:07:29 dan_karrels Exp $" ) ;
namespace gnuworld
{
using std::clog ;
using std::endl ;
CREATE_HANDLER(msg_EB)
// Q EB
// Q: Remote server numeric
// EB: End Of Burst
bool msg_EB::Execute( const xParameters& params )
{
if( !strcmp( params[ 0 ], theServer->getUplinkCharYY().c_str() ) )
{
// elog << "msg_EB> sendEA: "
// << theServer->getSendEA()
// << endl ;
// It's my uplink
if( theServer->getSendEA() && theServer->getSendEB() )
{
theServer->setBurstEnd( ::time( 0 ) ) ;
// Our uplink is done bursting
// This is done here instead of down below the if/else
// structure because some of the methods called here
// may depend or use the Uplink's isBursting() method
theServer->getUplink()->stopBursting() ;
}
// Signal that all Write()'s should write to the
// normal output buffer
theServer->setUseHoldBuffer( false ) ;
// Burst our clients
theServer->BurstClients() ;
// Burst our channels
theServer->BurstChannels() ;
// Only need EB to be sent to turn off bursting, since after
// EB no bursts can be sent
if( theServer->getSendEB() )
{
// We are no longer bursting
theServer->setBursting( false ) ;
}
// Called PostEvent() here to notify all attached clients
// that we are no longer bursting. This will ensure
// that all end of burst items are written to the
// burstOutputBuffer before the burst if officially
// completed (as seen by the network)
theServer->PostEvent( EVT_BURST_CMPLT,
static_cast< void* >( theServer->getUplink() ) ) ;
if( theServer->isVerbose() )
{
clog << "*** Completed net burst"
<< endl ;
}
elog << "*** Completed net burst"
<< endl ;
if( theServer->getSendEB() )
{
// Send our EB
theServer->Write( "%s EB\n", theServer->getCharYY().c_str() ) ;
}
if( theServer->getSendEA() )
{
// Acknowledge their end of burst
theServer->Write( "%s EA\n", theServer->getCharYY().c_str() ) ;
}
// Is the burstOutputBuffer empty?
theServer->WriteBurstBuffer() ;
theServer->PostEvent( EVT_EA_SENT,
static_cast< void* >( theServer->getUplink() ) ) ;
}
else
{
/* Its another server that has just completed its net.burst. */
iServer* targetServer = Network->findServer( params[ 0 ] ) ;
if( NULL == targetServer )
{
elog << "msg_EB> Unable to find server: "
<< params[ 0 ]
<< endl ;
return -1 ;
}
targetServer->stopBursting() ;
theServer->PostEvent( EVT_BURST_CMPLT,
static_cast< void* >( targetServer ) ) ;
}
return true ;
}
} // namespace gnuworld
+83
View File
@@ -0,0 +1,83 @@
/**
* msg_FA.cc
* Copyright (C) 2002 Daniel Karrels <dan@karrels.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*/
#include <new>
#include <string>
#include <iostream>
#include <cassert>
#include "gnuworld_config.h"
#include "server.h"
#include "iClient.h"
#include "events.h"
#include "ip.h"
#include "Network.h"
#include "ELog.h"
#include "xparameters.h"
#include "ServerCommandHandler.h"
#include "StringTokenizer.h"
namespace gnuworld
{
using std::string ;
using std::endl ;
CREATE_HANDLER(msg_FA)
/**
* Any server sends out the FA handler, need to be handled by servers/services,
*
* Syntax:
* Az FA AzAAA new.fake.host.com
*
* [0] Az - Numeric of the sending server
* [0] FA - Fake Host Token
* [1] AzAAA - target client's numeric
* [2] new.fake.host.com - the desired new host
*/
bool msg_FA::Execute( const xParameters& params )
{
if( params.size() < 3 )
{
// Error
elog << "msg_FA> Invalid format: "
<< params
<< endl ;
return false ;
}
iClient* Target = Network->findClient(params[1]);
if( NULL == Target )
{
elog << "msg_FA> Unable to find client for: %s"
<< params[ 1 ]
<< endl;
return false ;
}
Target->setFakeHost(params[2]);
return true;
}
} // namespace gnuworld
+180
View File
@@ -0,0 +1,180 @@
/**
* msg_G.cc
* Copyright (C) 2002 Daniel Karrels <dan@karrels.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: msg_G.cc,v 1.8 2009/07/25 18:12:34 hidden1 Exp $
*/
#include <sys/time.h>
#include <string>
#include <sstream>
#include <iostream>
#include <ctime>
#include <cerrno>
#include <cstring>
#include "gnuworld_config.h"
#include "server.h"
#include "xparameters.h"
#include "ELog.h"
#include "ServerCommandHandler.h"
#include "StringTokenizer.h"
RCSTAG( "$Id: msg_G.cc,v 1.8 2009/07/25 18:12:34 hidden1 Exp $" ) ;
namespace gnuworld
{
using std::string ;
using std::endl ;
using std::stringstream ;
CREATE_HANDLER(msg_G)
// Q G :ripper.ufl.edu
// Q: Remote server numeric
// G: PING
// :ripper.ufl.edu: Ping argument
// Reply with:
// <Our Numeric> Z <Their Numeric> :<arguments>
// Strings will be passed to this method in format:
// Q ripper.ufl.edu
//
// New style ping:
// MJ G !1026249984.71811 test.gnuworld.org 1026249984.71811
// Here, params contains all but the 'G', and does include the '!'
//
// Reply with:
// <my_numeric> Z <remote_numeric> !<remotets> <difference> <localts>
// <my_numeric> Z <my_numeric> <remote_numeric> !<remotets> <difference> <localts>
// The format of <remotets> = <seconds>.<useconds>
//
bool msg_G::Execute( const xParameters& params )
{
if( params.size() < 2 )
{
elog << "msg_G> Invalid number of parameters"
<< endl ;
return false ;
}
string s( theServer->getCharYY() ) ;
s += " Z " ;
if( 2 == params.size() )
{
// Old style ping
s += params[ 0 ] ;
if( params.size() >= static_cast< xParameters::size_type >( 1 ) )
{
s += " :" ;
s += params[ 1 ] ;
}
}
else
{
// New style ping
// This little algorithm is purposely verbose
// MJ !1026249984.71811 test.gnuworld.org 1026249984.71811
// <my_numeric> Z <remote_numeric> !<remotets> <difference> <localts>
// elog << "msg_G> New style ping"
// << endl ;
s += theServer->getCharYY();
s += " " ;
// Target server
//s += params[ 0 ] ;
//s += " " ;
// Remote TS, including the '!'
s += params[ 1 ] ;
s += " " ;
string tStr = params[ 1 ];
s += tStr.substr(1,string::npos) ;
s += " " ;
double remoteTSDouble = ::atof( params[ 1 ] + 1 ) ;
// elog << "remoteTSDouble: "
// << ((int) remoteTSDouble)
// << "."
// << (remoteTSDouble - (int) remoteTSDouble)
// << endl ;
timeval now = { 0, 0 } ;
if( ::gettimeofday( &now, 0 ) < 0 )
{
elog << "msg_G> gettimeofday() failed: "
<< strerror( errno )
<< endl ;
return false ;
}
StringTokenizer st(params[1] + 1, '.');
if (st.size() != 2) {
elog << "msg_G> Error in Remote TS" << endl;
return false;
}
int tsDiff = (now.tv_sec - atoi(st[0])) * 1000 + (now.tv_usec - atoi(st[1])) / 1000;
//elog << "msg_G> tsDiff = " << tsDiff << endl;
stringstream theStream ;
theStream << now.tv_sec
<< "."
<< now.tv_usec ;
string localTSString = theStream.str();
// Obtain localTS as double val
double localTSDouble = 0.0 ;
theStream >> localTSDouble ;
// elog << "msg_G> localTSString: "
// << localTSString
// << endl ;
//double tsDiffDouble = localTSDouble - remoteTSDouble ;
//double tsDiffD = 1000 * (localTSDouble - remoteTSDouble);
//int tsDiff = static_cast<int>(tsDiffD);
// elog << "msg_G> tsDiffDouble: "
// << tsDiffDouble
// << endl ;
stringstream stream2 ;
stream2 << tsDiff ;
// elog << "msg_G> stream2: "
// << stream2.str()
// << endl ;
// Difference TS
s += stream2.str() + " " ;
// Local TS
s += localTSString ;
}
//elog << "msg_G> Message: " << s << endl;
return theServer->Write( s ) ;
}
} // namespace gnuworld
+117
View File
@@ -0,0 +1,117 @@
/**
* msg_GL.cc
* Copyright (C) 2002 Daniel Karrels <dan@karrels.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: msg_GL.cc,v 1.9 2009/08/01 08:32:21 mrbean_ Exp $
*/
#include <new>
#include <iostream>
#include <cassert>
#include "gnuworld_config.h"
#include "ServerCommandHandler.h"
#include "server.h"
#include "events.h"
#include "Gline.h"
#include "ELog.h"
#include "xparameters.h"
RCSTAG( "$Id: msg_GL.cc,v 1.9 2009/08/01 08:32:21 mrbean_ Exp $" ) ;
namespace gnuworld
{
using std::endl ;
CREATE_HANDLER(msg_GL)
/**
* GLine message handler.
* C GL * +~*@209.9.117.131 180 :Banned (~*@209.9.117.131) until 957235403
* (On Mon May 1 22:40:23 2000 GMT from SE5 for 180 seconds: remgline
* test.. [0])
*/
bool msg_GL::Execute( const xParameters& Params )
{
if( '-' == Params[ 2 ][ 0 ] )
{
// Removing a gline
if( Params.size() < 3 )
{
elog << "msg_GL> Invalid number of arguments"
<< endl ;
return false ;
}
xServer::glineIterator gItr = theServer->findGlineIterator(
Params[ 2 ] + 1 ) ;
if( gItr == theServer->glines_end() )
{
// Unable to find the gline to be removed *shrug*
return true ;
}
// Let the modules know that it has been removed
theServer->PostEvent( EVT_REMGLINE,
static_cast< void* >( gItr->second ) ) ;
// Clean up memory
delete gItr->second ;
theServer->eraseGline( gItr ) ;
return true ;
}
// Else, adding a gline
if( Params.size() < 5 )
{
elog << "msg_GL> Invalid number of arguments"
<< endl ;
return false ;
}
Gline* newGline = new (std::nothrow) Gline(
Params[ 0 ],
Params[ 2 ] + 1,
Params[ Params.size() - 1 ],
atoi( Params[ 3 ] ),
atoi( Params[ 4 ] )) ;
assert( newGline != 0 ) ;
// Temporary variable
{
xServer::glineIterator gItr = theServer->findGlineIterator(
newGline->getUserHost() ) ;
if( gItr != theServer->glines_end() )
{
// This gline is already present
delete gItr->second ;
theServer->eraseGline( gItr ) ;
}
}
theServer->addGline( newGline ) ;
theServer->PostEvent( EVT_GLINE,
static_cast< void* >( newGline ) ) ;
return true ;
}
} // namespace gnuworld
+96
View File
@@ -0,0 +1,96 @@
/**
* msg_I.cc
* Copyright (C) 2002 Daniel Karrels <dan@karrels.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: msg_I.cc,v 1.7 2007/04/18 10:23:39 kewlio Exp $
*/
#include <iostream>
#include "gnuworld_config.h"
#include "server.h"
#include "xparameters.h"
#include "Channel.h"
#include "iClient.h"
#include "ELog.h"
#include "client.h"
#include "Network.h"
#include "ServerCommandHandler.h"
RCSTAG( "$Id: msg_I.cc,v 1.7 2007/04/18 10:23:39 kewlio Exp $" ) ;
namespace gnuworld
{
using std::endl ;
CREATE_HANDLER(msg_I)
// ABAHo I X :#lksdlkj (non-ts)
// ABAHo I X :#lksdlkj 1234567890 (ts)
bool msg_I::Execute( const xParameters& Param )
{
if (( Param.size() < 3 ) || ( Param.size() > 4))
{
elog << "msg_I> Invalid number of arguments ("
<< Param.size()
<< ")"
<< endl ;
int i;
for (i = 0; i < (int)Param.size(); i++)
elog << "msg_I> arg"
<< i
<< " = '"
<< Param[i]
<< "'"
<< endl ;
return false ;
}
iClient* srcClient = Network->findClient( Param[ 0 ] ) ;
if( NULL == srcClient )
{
elog << "msg_I> Unable to find source client: "
<< Param[ 0 ]
<< endl ;
return false ;
}
xClient* destClient = Network->findLocalNick( Param[ 1 ] ) ;
if( NULL == destClient )
{
elog << "msg_I> Unable to find destination client: "
<< Param[ 1 ]
<< endl ;
return false ;
}
Channel* theChan = Network->findChannel( Param[ 2 ] ) ;
if( NULL == theChan )
{
elog << "msg_I> Unable to find channel: "
<< Param[ 2 ]
<< endl ;
return false ;
}
destClient->OnInvite( srcClient, theChan ) ;
return true ;
}
} // namespace gnuworld
+372
View File
@@ -0,0 +1,372 @@
/**
* msg_J.cc
* Copyright (C) 2002 Daniel Karrels <dan@karrels.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: msg_J.cc,v 1.10 2007/04/18 11:00:20 kewlio Exp $
*/
#include <new>
#include <string>
#include <iostream>
#include <cassert>
#include "gnuworld_config.h"
#include "server.h"
#include "iClient.h"
#include "Channel.h"
#include "ChannelUser.h"
#include "events.h"
#include "Network.h"
#include "ELog.h"
#include "StringTokenizer.h"
#include "ServerCommandHandler.h"
RCSTAG( "$Id: msg_J.cc,v 1.10 2007/04/18 11:00:20 kewlio Exp $" ) ;
namespace gnuworld
{
using std::string ;
using std::endl ;
class msg_J : public ServerCommandHandler
{
public:
msg_J( xServer* theServer )
: ServerCommandHandler( theServer )
{}
virtual ~msg_J()
{}
virtual bool Execute( const xParameters& ) ;
protected:
void userPartAllChannels( iClient* ) ;
} ;
CREATE_LOADER(msg_J)
/**
* Someone has just joined a non-empty channel.
*
* 0AT J #coder-com 1234567890
* OAT J #coder-com,#blah 1234567890
* OAT J 0 <optional-ts?>
*/
bool msg_J::Execute( const xParameters& Param )
{
// Verify that sufficient arguments have been provided
// client_numeric #channel[,#channel2,...]
if( Param.size() < 2 )
{
// Insufficient arguments provided, log the error
elog << "msg_J> Invalid number of arguments"
<< endl ;
int i;
for (i = 0; i < (int)Param.size(); i++)
elog << "msg_J> arg"
<< i
<< " = '"
<< Param[i]
<< "'"
<< endl ;
// Return error
return false ;
}
/* a join to '0' may not have a timestamp, but all others should */
if ((Param[1][0]!='0') && Param.size() < 3)
{
elog << "msg_J> Invalid number of arguments"
<< endl ;
// Return error
return false;
}
// Find the client in question.
iClient* Target = Network->findClient( Param[ 0 ] ) ;
// Did we find the client?
if( NULL == Target )
{
// Nope, log the error
elog << "msg_J> ("
<< Param[ 1 ]
<< ") Unable to find user: "
<< Param[ 0 ]
<< endl ;
// Return error
return false ;
}
// Tokenize by ',', as the client may join more than one
// channel at once.
StringTokenizer st( Param[ 1 ], ',' ) ;
time_t joinTs = 0;
if (Param.size() < 3)
joinTs = ::time(NULL);
else
joinTs = atoi( Param [ 2 ] );
for( StringTokenizer::size_type i = 0 ; i < st.size() ; i++ )
{
// Is it a modeless channel?
if( '+' == st[ i ][ 0 ] )
{
// Don't care about modeless channels
continue ;
}
// Is the user parting all channels?
if( '0' == st[ i ][ 0 ] )
{
// Yup, call userPartAllChannels which will update
// the user's information and notify listening
// services clients of the parts
userPartAllChannels( Target ) ;
// continue to next channel
continue ;
}
// Attempt to allocate a ChannelUser structure for this
// user<->channel association
ChannelUser* theUser =
new (std::nothrow) ChannelUser( Target ) ;
assert( theUser != 0 ) ;
// This variable represents which event actually occurs
channelEventType whichEvent = EVT_JOIN ;
// On a JOIN command, the channel should already exist.
Channel* theChan = Network->findChannel( st[ i ] ) ;
// Does the channel already exist?
if( NULL == theChan )
{
// Nope, this transmutes to a CREATE
// Create a new Channel to represent this
// network channel
theChan = new (std::nothrow)
Channel( st[ i ], ::time( 0 ) ) ;
assert( theChan != 0 ) ;
// Add the channel to the network tables
if( !Network->addChannel( theChan ) )
{
// Addition to network tables failed
// Log the error
elog << "msg_J> Unable to add channel: "
<< theChan->getName()
<< endl ;
// Prevent memory leaks by deallocating the
// Channel and ChannelUser objects
delete theChan ; theChan = 0 ;
delete theUser ; theUser = 0 ;
// Continue to next channel
continue ;
}
// Since this is equivalent to a CREATE, set the user
// as operator.
theUser->setModeO() ;
// Update the event type
whichEvent = EVT_CREATE ;
} // if( NULL == theChan )
/*
else if( theChan->findUser( Target ) != 0 )
{
// The user is already in the channel...check for
// zombie state
ChannelUser* oldUser = theChan->findUser( Target ) ;
if( oldUser->getMode( ChannelUser::ZOMBIE ) )
{
// The user was in the zombie state
// Remove the zombie state, and continue
// to the next channel
oldUser->removeMode( ChannelUser::ZOMBIE ) ;
// elog << "msg_J> Removed zombie: "
// << *oldUser
// << " on channel "
// << theChan->getName()
// << endl ;
}
else
{
// User was found in channel, no reason apparent
// This message can happen a lot due
// to lag....it's not too important tho it
// bugs me so.
// elog << "msg_J> Unexpectedly found "
// << "user "
// << *Target
// << " in channel "
// << theChan->getName()
// << endl ;
}
// In either case, there is no need to add the newly
// created ChannelUser to the channel, because it
// is already there.
delete theUser ; theUser = 0 ;
// Continue, nothing more to do here
continue ;
}
*/
else if( joinTs < theChan->getCreationTime() )
{
//The time of join is earlier than the creation time of the channel
//Need to clear all the modes of the channel
theChan->removeAllModes();
//Now reset the channel creation time to the join ts
theChan->setCreationTime(joinTs);
}
// Add a new ChannelUser representing this client to this
// channel's user structure.
if( !theChan->addUser( theUser ) )
{
// Addition of this ChannelUser to the Channel failed
// Log the error
elog << "msg_J> Unable to add user "
<< theUser->getNickName()
<< " to channel: "
<< theChan->getName()
<< endl ;
// Prevent memory leaks by deallocating the unused
// ChannelUser object
delete theUser ; theUser = 0 ;
if( EVT_CREATE == whichEvent )
{
// The channel did not exist before
// this message, so go ahead and
// remove it
Network->removeChannel( theChan->getName() ) ;
// Do some cleanup
delete theChan ; theChan = 0 ;
}
// Continue to next channel
continue ;
}
// Add this channel to this client's channel structure.
if( !Target->addChannel( theChan ) )
{
elog << "msg_J> Unable to add channel "
<< *theChan
<< " to iClient "
<< *Target
<< endl ;
// Remove the ChannelUser from this channel, and
// deallocate the ChannelUser to prevent memory
// leaks
theChan->removeUser( theUser ) ;
delete theUser ; theUser = 0 ;
// Did we just create the channel?
if( EVT_CREATE == whichEvent )
{
// Yup, remove the channel from the network
// data structures
Network->removeChannel( theChan->getName() ) ;
// Prevent memory leaks by deallocating
// the channel
delete theChan ; theChan = 0 ;
}
// Continue on with the next channel
continue ;
}
// Post the event to the clients listening for events on this
// channel, if any.
theServer->PostChannelEvent( whichEvent, theChan,
static_cast< void* >( Target ),
static_cast< void* >( theUser ) ) ;
// TODO: Update event posting so that CREATE is also
// passed the client who created the channel
} // for()
return true ;
}
void msg_J::userPartAllChannels( iClient* theClient )
{
// Artifact, user is parting all channels
for( iClient::channelIterator ptr = theClient->channels_begin(),
endPtr = theClient->channels_end() ; ptr != endPtr ; ++ptr )
{
// Remove this ChannelUser from the Channel's internal
// structure.
// Deallocate the ChannelUser
ChannelUser* theChanUser = (*ptr)->removeUser( theClient ) ;
if( NULL == theChanUser )
{
elog << "msg_J::userPartAllChannels> Unable to "
<< "remove iClient "
<< *theClient
<< " from channel "
<< *(*ptr)
<< endl ;
}
delete theChanUser ; theChanUser = 0 ;
// BUG: This iClient has inconsistent state because
// no channels have been removed from its internal
// structure until the end of this method.
// Post this event to all listeners
theServer->PostChannelEvent( EVT_PART,
*ptr,
static_cast< void* >( theClient ) ) ; // iClient*
// Is the channel empty of all network and services
// clients?
if( (*ptr)->empty() )
{
// TODO: Post event
// Yup, remove the channel from the network channel
// table
delete Network->removeChannel( (*ptr)->getName() ) ;
}
}
// Just to be sure
theClient->clearChannels() ;
} // userPartAllChannels()
} // namespace gnuworld
+119
View File
@@ -0,0 +1,119 @@
/**
* msg_JU.cc
* Copyright (C) 2002 Daniel Karrels <dan@karrels.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: msg_JU.cc,v 1.9 2010/09/20 17:36:25 denspike Exp $
*/
#include <string>
#include "gnuworld_config.h"
#include "server.h"
#include "Network.h"
#include "xparameters.h"
#include "ServerCommandHandler.h"
RCSTAG( "$Id: msg_JU.cc,v 1.9 2010/09/20 17:36:25 denspike Exp $" ) ;
namespace gnuworld
{
using std::endl;
CREATE_HANDLER(msg_JU)
/**
* JUPE message handler.
*/
bool msg_JU::Execute( const xParameters& Param)
{
if (Param.size() < 6)
{
elog << "msg_JU: Invalid number of arguments"
<< endl;
return false;
}
if(Param[2][0] == '+')
{
/*
* A new jupe is interduced, need to create an iServer for it
* and notify all the modules
*/
std::string Reason = Param.assemble(5);
std::string SName = Param[2];
SName = SName.substr(1);
std::string CTime = Param[4];
unsigned int intYY = 0;
char *temp = new char[2];
if (!Network->allocateServerNumeric(intYY))
{
elog << "msg_JU> Error while allocating server numeric!"
<< endl;
return false;
}
const char* temp2 = inttobase64(temp,intYY,2);
if (Reason[0] == ':')
{
Reason = Reason.substr(1);
};
iServer* jupeServer = new (std::nothrow) iServer(
base64toint(Param[0]),
temp2,
SName,
atoi(CTime.c_str()),
Reason
);
assert (jupeServer != 0);
jupeServer->setJupe();
if (!Network->addServer(jupeServer))
{
elog << "msg_JU> error while adding new server :(" << endl;
return false;
}
theServer->PostEvent(EVT_NETJOIN, //TODO add EVT_JUPE
static_cast< void* >(jupeServer),
NULL);
}
else
{ // its a removal..
std::string SName = Param[2];
SName = SName.substr(1);
iServer* jupeServer = Network->findServerName(SName);
if(!jupeServer)
{
elog << "msg_JU> Cant find server for removal" << endl;
return false;
}
if(jupeServer->getCharYY() == theServer->getCharYY())
{
elog << "msg_JU> Let's not even try to remove ourself" << endl;
return false;
}
// BUG: Nothing here?
if(!Network->removeServer(jupeServer->getIntYY(),true))
{}
}
// TODO
return false ;
}
} // namespace gnuworld
+241
View File
@@ -0,0 +1,241 @@
/**
* msg_K.cc
* Copyright (C) 2002 Daniel Karrels <dan@karrels.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: msg_K.cc,v 1.5 2005/03/25 03:07:29 dan_karrels Exp $
*/
#include <new>
#include <string>
#include <iostream>
#include <cassert>
#include "gnuworld_config.h"
#include "server.h"
#include "iClient.h"
#include "Channel.h"
#include "ChannelUser.h"
#include "events.h"
#include "Network.h"
#include "ELog.h"
#include "StringTokenizer.h"
#include "ServerCommandHandler.h"
RCSTAG( "$Id: msg_K.cc,v 1.5 2005/03/25 03:07:29 dan_karrels Exp $" ) ;
namespace gnuworld
{
using std::string ;
using std::endl ;
CREATE_HANDLER(msg_K)
// AIAAA K #coder-com 0C] :This is now an IRCoperator only channel
// Note that when a user is kicked from a channel, the user is not
// actually parted. A separate MSG_L message will be issued after
// the MSG_K().
//
// About the zombie state
// ----------------------
// P10 CHECK POINT:
// If the KICK message is issued for a user on the same
// server of the sender, the KICK is authoritative, and
// we may proceed to remove the user from the channel.
// In all other cases, the server will issue a PART
// message for the user that will make us acknowledge
// the KICK has happened. During this phase the user
// is placed in zombie state. However, the server has
// the ability to send a MODE or a JOIN while the user
// is in zombie state. If the MODE issued for the user
// is a +o, or JOIN is issued, the user gets reinstated
// in the channel and the zombie state is cleared out.
// The server can accept the MODE and the JOIN silently
// or bounce them back to the sender, thus invalidating
// the command sent.
//
bool msg_K::Execute( const xParameters& Param )
{
// Verify that there are at least three arguments provided
// client_source_numeric #channel client_target_numeric
if( Param.size() < 3 )
{
// Invalid number of arguments
elog << "msg_K> Invalid number of arguments"
<< endl ;
// Return error
return false ;
}
// Is this a modeless channel?
// Can there even be kicks on modeless channels?
if( '+' == Param[ 1 ][ 0 ] )
{
// Don't care about modeless channels
return true ;
}
// Find the source client
// The source can still be a server, so the srcClient here
// may be NULL
iClient* srcClient = Network->findClient( Param[ 0 ] ) ;
// Find the target client
iClient* destClient = Network->findClient( Param[ 2 ] ) ;
// Did we find the target client?
if( NULL == destClient )
{
// Nope, log the error
elog << "msg_K> ("
<< Param[ 1 ]
<< ") Unable to find target client: "
<< Param[ 2 ]
<< endl ;
// Return error
return false ;
}
// Find the channel in question.
Channel* theChan = Network->findChannel( Param[ 1 ] ) ;
// Did we find the channel?
if( NULL == theChan )
{
// Nope, log the error
elog << "msg_K> Unable to find channel: "
<< Param[ 1 ]
<< endl ;
// Return error
return false ;
}
ChannelUser* destChanUser = theChan->findUser( destClient ) ;
if( NULL == destChanUser )
{
// This is commented out due to lag kicks happening quite a bit
// on production networks, especially in channels with fasting
// banning bots.
// elog << "msg_K> Unable to find target ChannelUser "
// << "for channel "
// << theChan->getName()
// << ", iClient: "
// << *destClient
// << endl ;
// Return error
return false ;
}
// On a network with more than 2 servers, the chances are greater
// that the two clients will be on different servers...thus,
// initialize localKick to false here.
bool localKick = false ;
// Check to see if the source and destination user are
// on the same server.
if( srcClient != 0 )
{
if( srcClient->getIntYY() == destClient->getIntYY() )
{
// Local kick
localKick = true ;
}
}
if( localKick )
{
// Only remove the ChannelUser from the channel if this
// is a local kick...otherwise, the kick is unauthoritative
theChan->removeUser( destClient ) ;
// Deallocate the ChannelUser
delete destChanUser ; destChanUser = 0 ;
// Remove the channel information from the client's internal
// channel structure
if( !destClient->removeChannel( theChan ) )
{
elog << "msg_K> Unable to remove channel "
<< theChan->getName()
<< " from the iClient "
<< *destClient
<< endl ;
}
}
else
{
// Check if the kick wasnt issued by a server ,
// if it does, then its authoritative
// if((srcClient == 0) && (Network->findServer(Param[0])))
// {
theChan->removeUser( destClient ) ;
// Deallocate the ChannelUser
delete destChanUser ; destChanUser = 0 ;
// Remove the channel information from the client's internal
// channel structure
if( !destClient->removeChannel( theChan ) )
{
elog << "msg_K> Unable to remove channel "
<< theChan->getName()
<< " from the iClient "
<< *destClient
<< endl ;
}
// }
// else
// {
// The kick is unauthoritative, the destination client
// is now in the zombie state
// destChanUser->setZombie() ;
// elog << "msg_K> Adding zombie for user "
// << *destChanUser
// << " on channel "
// << theChan->getName()
// << endl ;
// }
}
// Post the channel kick event
theServer->PostChannelKick( theChan,
srcClient,
destClient,
(Param.size() >= 4) ? Param[ 3 ] : string(),
localKick ) ;
// Any users or services clients left in the channel?
if( theChan->empty() )
{
// Nope, remove the channel
delete Network->removeChannel( theChan->getName() ) ;
// TODO: Post event
}
return true ;
}
} // namespace gnuworld
+173
View File
@@ -0,0 +1,173 @@
/**
* msg_L.cc
* Copyright (C) 2002 Daniel Karrels <dan@karrels.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: msg_L.cc,v 1.5 2005/03/25 03:07:29 dan_karrels Exp $
*/
#include <new>
#include <string>
#include "gnuworld_config.h"
#include "server.h"
#include "iClient.h"
#include "Channel.h"
#include "ChannelUser.h"
#include "Network.h"
#include "ELog.h"
#include "StringTokenizer.h"
#include "events.h"
#include "xparameters.h"
#include "ServerCommandHandler.h"
RCSTAG( "$Id: msg_L.cc,v 1.5 2005/03/25 03:07:29 dan_karrels Exp $" ) ;
namespace gnuworld
{
using std::string ;
using std::endl ;
CREATE_HANDLER(msg_L)
/**
* Someone has just left a channel.
* AABBB L #channel
*/
bool msg_L::Execute( const xParameters& Param )
{
// Verify that there are at least 2 arguments:
// client_numeric #channel
if( Param.size() < 2 )
{
elog << "msg_L> Invalid number of arguments"
<< endl ;
return false ;
}
// Find the client in question
iClient* theClient = Network->findClient( Param[ 0 ] ) ;
// Was the client found?
if( NULL == theClient )
{
// Nope, no matching client found
// Log the error
elog << "msg_L> ("
<< Param[ 1 ]
<< "): Unable to find client: "
<< Param[ 0 ]
<< endl ;
// Return error
return false ;
}
// Tokenize the channel string
// Be sure to take into account the channel parting message
// This first line will first tokenize the string containing the
// names of the channel(s) being parted and the part message (if any)
// by ' ' (space). The first token of this StringTokenizer (the channel
// name(s)) will then be tokenized by ':' to separate out the channel
// name(s) from the part message (if any).
// This first partString StringTokenizer will tokenize out the string
// into two tokens (by space): chan1[,chan2,...] :part message
StringTokenizer partString( Param[ 1 ] ) ;
// This tokenizer will separate out the invidividual channel names
StringTokenizer st( partString[ 0 ], ',' ) ;
// Iterate through all channels that this user is parting
for( StringTokenizer::size_type i = 0 ; i < st.size() ; ++i )
{
// Is this a modeless channel?
if( '+' == st[ i ][ 0 ] )
{
// Ignore modeless channels
continue ;
}
// Get the channel that was just parted.
Channel* theChan = Network->findChannel( st[ i ] ) ;
// Was the channel found?
if( NULL == theChan )
{
// Channel not found, log the error
elog << "msg_L> Unable to find channel: "
<< st[ i ]
<< endl ;
// Continue on to the next channel
continue ;
}
// Remove client<->channel associations
// Remove and deallocate the ChannelUser instance from this
// channel's ChannelUser structure.
ChannelUser* theChanUser = theChan->removeUser( theClient ) ;
if( NULL == theChanUser )
{
// This can happen if the user is a zombie
// Since atm GNUWorld ignores zombies, just ignore
// this message.
continue ;
// elog << "msg_L> Unable to remove "
// << *theClient
// << " from channel: "
// << *theChan
// << endl ;
}
delete theChanUser ; theChanUser = 0 ;
// Remove this channel from this client's channel structure.
if( !theClient->removeChannel( theChan ) )
{
elog << "msg_L> Unable to remove iClient "
<< *theClient
<< " from channel "
<< *theChan
<< endl ;
}
// Post the event to the clients listening for events on this
// channel, if any.
// TODO: Update message posting
theServer->PostChannelEvent( EVT_PART, theChan,
static_cast< void* >( theClient ) ) ;
// Is the channel now empty, and no services clients are
// on the channel?
if( theChan->empty() )
{
// No users in the channel, remove it.
delete Network->removeChannel( theChan->getName() ) ;
// TODO: Post event
}
} // for
return true ;
}
} // namespace gnuworld
+507
View File
@@ -0,0 +1,507 @@
/**
* msg_M.cc
* Copyright (C) 2002 Daniel Karrels <dan@karrels.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: msg_M.cc,v 1.14 2008/04/16 20:29:37 danielaustin Exp $
*/
#include <new>
#include <map>
#include <string>
#include <vector>
#include <iostream>
#include "gnuworld_config.h"
#include "misc.h"
#include "events.h"
#include "server.h"
#include "iClient.h"
#include "Channel.h"
#include "ChannelUser.h"
#include "Network.h"
#include "ELog.h"
#include "StringTokenizer.h"
#include "ServerCommandHandler.h"
RCSTAG( "$Id: msg_M.cc,v 1.14 2008/04/16 20:29:37 danielaustin Exp $" ) ;
namespace gnuworld
{
using std::pair ;
using std::make_pair ;
using std::string ;
using std::vector ;
using std::endl ;
class msg_M : public ServerCommandHandler
{
public:
msg_M( xServer* theServer )
: ServerCommandHandler( theServer )
{}
virtual ~msg_M()
{}
virtual bool Execute( const xParameters& ) ;
protected:
bool onUserModeChange( const xParameters& ) ;
} ;
CREATE_LOADER(msg_M)
// Mode change
// OAD M ripper_ :+owg
//
// i M #3dx +o eAA
// J[K M DEMET_33 :+i
bool msg_M::Execute( const xParameters& Param )
{
//DEBUG
elog << "Entered msg_M> " << Param << std::endl;
if( Param.size() < 3 )
{
elog << "msg_M> Invalid number of arguments"
<< endl ;
return false ;
}
// This source stuff really isn't used here, but it's here for
// debugging and validation.
iServer* serverSource = 0 ;
iClient* clientSource = 0 ;
// Note that the order of this if/else if/else is important
if( NULL != strchr( Param[ 0 ], '.' ) )
{
// Server, by name
serverSource = Network->findServerName( Param[ 0 ] ) ;
}
else if( strlen( Param[ 0 ] ) >= 3 )
{
// Client numeric
clientSource = Network->findClient( Param[ 0 ] ) ;
}
else
{
// 1 or 2 char numeric, server
serverSource = Network->findServer( Param[ 0 ] ) ;
}
if( (NULL == clientSource) && (NULL == serverSource) )
{
elog << "msg_M> Unable to find source: "
<< Param[ 0 ]
<< endl ;
return false ;
}
// Is it a user mode change?
if( '#' != Param[ 1 ][ 0 ] )
{
// Yup, process the user's mode change(s)
return onUserModeChange( Param ) ;
}
// Find the channel in question
Channel* theChan = Network->findChannel( Param[ 1 ] ) ;
if( NULL == theChan )
{
elog << "msg_M> Unable to find channel: "
<< Param[ 1 ]
<< endl ;
return false ;
}
if( serverSource != 0 )
{
elog << "msg_M ("
<< theChan->getName()
<< ") server "
<< serverSource->getName()
<< " performed a mode"
<< std::endl;
theServer->PostChannelEvent( EVT_SERVERMODE, theChan,
static_cast< void* >( serverSource ) ) ;
}
/* XXX OPMODE FAILS HERE */
// Find the ChannelUser of the source client
// It is possible that the ChannelUser will be NULL, in the
// case that a server is setting the mode(s)
ChannelUser* theUser = 0 ;
if( clientSource != 0 )
{
theUser = theChan->findUser( clientSource ) ;
if( NULL == theUser )
{
// elog << "msg_M> ("
// << theChan->getName()
// << ") Unable to find channel user: "
// << clientSource->getCharYYXXX()
// << endl ;
return false ;
}
}
bool polarity = true ;
xParameters::size_type argPos = 3 ;
xServer::opVectorType opVector ;
xServer::voiceVectorType voiceVector ;
xServer::banVectorType banVector ;
xServer::modeVectorType modeVector ;
for( const char* modePtr = Param[ 2 ] ; *modePtr ; ++modePtr )
{
switch( *modePtr )
{
case '+':
polarity = true ;
break ;
case '-':
polarity = false ;
break ;
case 't':
modeVector.push_back(
make_pair( polarity, Channel::MODE_T ) ) ;
break ;
case 'n':
modeVector.push_back(
make_pair( polarity, Channel::MODE_N ) ) ;
break ;
case 's':
modeVector.push_back(
make_pair( polarity, Channel::MODE_S ) ) ;
break ;
case 'p':
modeVector.push_back(
make_pair( polarity, Channel::MODE_P ) ) ;
break ;
case 'm':
modeVector.push_back(
make_pair( polarity, Channel::MODE_M ) ) ;
break ;
case 'i':
modeVector.push_back(
make_pair( polarity, Channel::MODE_I ) ) ;
break ;
case 'r':
modeVector.push_back(
make_pair( polarity, Channel::MODE_R ) ) ;
break ;
case 'R':
modeVector.push_back(
make_pair( polarity, Channel::MODE_REG ) ) ;
break ;
case 'D':
modeVector.push_back(
make_pair( polarity, Channel::MODE_D ) ) ;
break;
// Channel mode l only has an argument if
// it is being added, but not removed
case 'l':
if( polarity && (argPos >= Param.size()) )
{
elog << "msg_M> Invalid "
<< "format for message: missing "
<< "argument to mode +l"
<< " in channel "
<< *theChan
<< endl ;
continue ;
}
theServer->OnChannelModeL( theChan,
polarity, theUser,
polarity ? atoi( Param[ argPos++ ] )
: 0 ) ;
break ;
// Channel mode k always has an argument
case 'k':
if( argPos >= Param.size() )
{
elog << "msg_M> Invalid "
<< "format for message: missing "
<< "argument for mode 'k'"
<< " in channel "
<< *theChan
<< endl ;
continue ;
}
theServer->OnChannelModeK( theChan,
polarity, theUser,
Param[ argPos++ ] ) ;
break ;
case 'o':
{
if( argPos >= Param.size() )
{
elog << "msg_M> Invalid "
<< "format for message: missing "
<< "argument for mode 'o'"
<< " in channel "
<< *theChan
<< endl ;
continue ;
}
iClient* targetClient = Network->findClient(
Param[ argPos++ ] ) ;
if( NULL == targetClient )
{
// elog << "msg_M> Unable to "
// << "find op target client: "
// << Param[ argPos - 1 ]
// << " in channel "
// << *theChan
// << endl ;
break ;
}
ChannelUser* targetUser = theChan->findUser(
targetClient ) ;
if( NULL == targetUser )
{
// elog << "msg_M> Unable to "
// << "find op target user: "
// << Param[ argPos - 1 ]
// << " in channel "
// << *theChan
// << endl ;
break ;
}
opVector.push_back(
pair< bool, ChannelUser* >(
polarity, targetUser ) ) ;
// If the op mode is +o, remove the ZOMBIE
// state from this user.
// if( polarity && targetUser->isZombie() )
// {
// targetUser->removeZombie() ;
// elog << "msg_M> Removing "
// << "zombie"
// << endl ;
// }
break ;
}
case 'v':
{
if( argPos >= Param.size() )
{
elog << "msg_M> Invalid "
<< "format for message: missing "
<< "argument for mode 'v'"
<< " in channel "
<< *theChan
<< endl ;
continue ;
}
iClient* targetClient = Network->findClient(
Param[ argPos++ ] ) ;
if( NULL == targetClient )
{
// elog << "msg_M> Unable to "
// << "find voice target client: "
// << Param[ argPos - 1 ]
// << " in channel "
// << *theChan
// << endl ;
break ;
}
ChannelUser* targetUser = theChan->findUser(
targetClient ) ;
if( NULL == targetUser )
{
// elog << "msg_M> Unable to "
// << "find voice target user: "
// << Param[ argPos - 1 ]
// << " in channel "
// << *theChan
// << endl ;
break ;
}
voiceVector.push_back(
pair< bool, ChannelUser* >(
polarity, targetUser ) ) ;
break ;
}
case 'b':
{
if( argPos >= Param.size() )
{
elog << "msg_M> Invalid "
<< "format for message: missing "
<< "argument for mode 'b'"
<< " in channel "
<< *theChan
<< endl ;
continue ;
}
const char* targetBan = Param[ argPos++ ] ;
banVector.push_back(
pair< bool, string >(
polarity, string( targetBan ) ) ) ;
break ;
}
} // switch()
} // for()
if( !modeVector.empty() )
{
theServer->OnChannelMode( theChan, theUser, modeVector ) ;
}
if( !opVector.empty() )
{
theServer->OnChannelModeO( theChan, theUser, opVector ) ;
}
if( !voiceVector.empty() )
{
theServer->OnChannelModeV( theChan, theUser, voiceVector ) ;
}
if( !banVector.empty() )
{
theServer->OnChannelModeB( theChan, theUser, banVector ) ;
}
return true ;
}
// OAD M ripper_ :+owg
bool msg_M::onUserModeChange( const xParameters& Param )
{
// Since users aren't allowed to change modes for anyone other than
// themselves, there is no need to lookup the second user argument
// For some reason, when a user changes his/her/its modes, it still
// specifies the second argument to be nickname instaed of numeric.
iClient* theClient = Network->findClient( Param[ 0 ] ) ;
if( NULL == theClient )
{
elog << "msg_M::OnUserModeChange> Unable to find target "
<< "client: "
<< Param[ 1 ]
<< endl ;
return false ;
}
if( theClient->getNickName() != Param[ 1 ] )
{
elog << "msg_M::OnUserModeChange> User trying to change "
<< "mode for someone other than itself: "
<< *theClient
<< ", nickname: "
<< Param[ 1 ]
<< endl ;
return false ;
}
// It's important that the mode '+' be default
bool plus = true ;
for( const char* modePtr = Param[ 2 ] ; *modePtr ; ++modePtr )
{
switch( *modePtr )
{
case '+':
plus = true ;
break;
case '-':
plus = false ;
break;
case 'i':
if( plus ) theClient->setModeI() ;
else theClient->removeModeI() ;
break ;
case 'k':
if( plus ) theClient->setModeK() ;
else theClient->removeModeK() ;
break ;
case 'd':
if( plus ) theClient->setModeD() ;
else theClient->removeModeD() ;
break ;
case 'w':
if( plus ) theClient->setModeW() ;
else theClient->removeModeW() ;
break ;
case 'x':
if( plus ) theClient->setModeX() ;
else theClient->removeModeX() ;
break ;
case 'r':
if( plus ) theClient->setModeR() ;
else theClient->removeModeR() ;
break ;
case 'g':
if( plus ) theClient->setModeG() ;
else theClient->removeModeG() ;
break ;
case 'o':
if( plus )
{
theClient->setModeO() ;
theServer->PostEvent( EVT_OPER,
static_cast< void* >( theClient ) ) ;
}
else
{
// elog << "msg_M::onUserModeChange> "
// << "Caught -o for user: "
// << *theClient
// << endl ;
theClient->removeModeO() ;
}
break ;
case 'n':
case 'I':
case 'h':
if( plus ) theClient->setModeH() ;
else theClient->removeModeH() ;
break;
case 'f':
if( plus ) theClient->setModeF() ;
else theClient->removeModeF() ;
break;
case 'X':
case 'R':
// Unsupported but used on networks that
// GNUWorld runs on.
// TODO?
break ;
default:
elog << "msg_M::onUserModeChange> "
<< "Unknown mode: "
<< *modePtr
<< endl ;
break ;
} // close switch
} // close for
return true ;
}
} // namespace gnuworld
+86
View File
@@ -0,0 +1,86 @@
/**
* msg_M351.cc
* Copyright (C) 2002 Daniel Karrels <dan@karrels.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: msg_M351.cc,v 1.4 2005/03/25 03:07:29 dan_karrels Exp $
*/
#include <iostream>
#include <string>
#include "gnuworld_config.h"
#include "server.h"
#include "Network.h"
#include "ELog.h"
#include "xparameters.h"
#include "ServerCommandHandler.h"
RCSTAG( "$Id: msg_M351.cc,v 1.4 2005/03/25 03:07:29 dan_karrels Exp $" ) ;
namespace gnuworld
{
using std::endl ;
using std::string ;
CREATE_HANDLER(msg_M351)
bool msg_M351::Execute( const xParameters& Param )
{
if( Param.empty() )
{
elog << "msg_M351> Invalid number of "
<< "arguments"
<< endl ;
return false ;
}
xClient* theClient = Network->findLocalClient( Param[ 1 ] ) ;
if( NULL == theClient )
{
elog << "msg_M351> Unable to find nick: "
<< Param[ 1 ]
<< endl ;
return false ;
}
iServer* tmpServer = Network->findServer(Param[0]);
if( NULL == tmpServer )
{
elog << "msg_M351> Unable to find server: "
<< Param[ 0 ]
<< endl ;
return false ;
}
string tMessage = string( tmpServer->getCharYY() ) + " 351 " ;
for( xParameters::size_type i = 2 ; i < Param.size() ; ++i )
{
tMessage += Param[ i ] ;
if( (i + 1) < Param.size() )
{
tMessage += " " ;
}
}
theClient->OnServerMessage( tmpServer, tMessage );
return true ;
}
} // namespace gnuworld
+86
View File
@@ -0,0 +1,86 @@
/**
* msg_M391.cc
* Copyright (C) 2002 Daniel Karrels <dan@karrels.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: msg_M391.cc,v 1.1 2009/07/25 18:12:34 hidden1 Exp $
*/
#include <iostream>
#include <string>
#include "gnuworld_config.h"
#include "server.h"
#include "Network.h"
#include "ELog.h"
#include "xparameters.h"
#include "ServerCommandHandler.h"
RCSTAG( "$Id: msg_M391.cc,v 1.1 2009/07/25 18:12:34 hidden1 Exp $" ) ;
namespace gnuworld
{
using std::endl ;
using std::string ;
CREATE_HANDLER(msg_M391)
bool msg_M391::Execute( const xParameters& Param )
{
if( Param.empty() )
{
elog << "msg_M391> Invalid number of "
<< "arguments"
<< endl ;
return false ;
}
xClient* theClient = Network->findLocalClient( Param[ 1 ] ) ;
if( NULL == theClient )
{
elog << "msg_M391> Unable to find nick: "
<< Param[ 1 ]
<< endl ;
return false ;
}
iServer* tmpServer = Network->findServer(Param[0]);
if( NULL == tmpServer )
{
elog << "msg_M391> Unable to find server: "
<< Param[ 0 ]
<< endl ;
return false ;
}
string tMessage = string( tmpServer->getCharYY() ) + " 391 " ;
for( xParameters::size_type i = 2 ; i < Param.size() ; ++i )
{
tMessage += Param[ i ] ;
if( (i + 1) < Param.size() )
{
tMessage += " " ;
}
}
theClient->OnServerMessage( tmpServer, tMessage );
return true ;
}
} // namespace gnuworld
+326
View File
@@ -0,0 +1,326 @@
/**
* msg_N.cc
* Copyright (C) 2002 Daniel Karrels <dan@karrels.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: msg_N.cc,v 1.11 2005/11/30 19:37:34 kewlio Exp $
*/
#include <new>
#include <string>
#include <iostream>
#include <cassert>
#include "gnuworld_config.h"
#include "server.h"
#include "iClient.h"
#include "events.h"
#include "ip.h"
#include "Network.h"
#include "ELog.h"
#include "xparameters.h"
#include "ServerCommandHandler.h"
#include "StringTokenizer.h"
RCSTAG( "$Id: msg_N.cc,v 1.11 2005/11/30 19:37:34 kewlio Exp $" ) ;
namespace gnuworld
{
using std::string ;
using std::endl ;
CREATE_HANDLER(msg_N)
/**
* A new user has joined the network, we are receiving a burst,
* or a user has changed his/her nickname.
*
* Possible cases:
* 1) Simple nick change
* AUAAB N Gte- 949527071
* 2) Client without modes
* AU N Gte2 3 949526996 Gte 212.49.240.147 DUMfCT AUAAB :I am the
* one that was.
* 3) Client with modes
* B0 N hektik 2 948677656 hektik p62-max7.ham.ihug.co.nz +i DLbcbC
* B0AAA :DiMeBoX ProduXiiions
*
* 1) <nickname>
* 2) <hops>
* 3) <TS>
* 4) <userid>
* 5) <host>
* 6) [<+modes>]
* 7+) [<mode parameters>]
* -3 <base64 IP>
* -2 <numeric>
* -1 <fullname
*
* AF N Client1 1 947957573 User userhost.net +oiwg DAqAoB AFAAA
* :Generic Client.
*
* AF - numeric of the server the user is on
* N - NICK token
* Client1 - nick
* 1 - hopcount
* 947957573 - timestamp
* User - username
* userhost.net - domain
* +oiwg - modes
* [Cloaked Host] - Nefarious2
* [Cloaked IP ] - Nefarious2
* DAqAoB - base64 IP
* AFAAA - numnick
* :Generic Client - description
*/
bool msg_N::Execute( const xParameters& params )
{
if( params.size() < 3 )
{
// Error
elog << "msg_N> Invalid format: "
<< params
<< endl ;
return false ;
}
// AUAAB N Gte- 949527071
if( 3 == params.size() )
{
// User changing nick
// elog << "msg_N> Rehashing nickname: "
// << params
// << endl ;
Network->rehashNick( params[ 0 ], params[ 1 ] ) ;
return true ;
}
// Else, it's the network giving us a new client.
iServer* nickUplink = Network->findServer( params[ 0 ] ) ;
if( NULL == nickUplink )
{
elog << "msg_N> Unable to find server: "
<< params[ 0 ]
<< endl ;
return false ;
}
////DEBUG
//for (int i = 0; i < (int)params.size(); i++)
//{
// elog << "msg_N> params[" << i << "] = " << params[i] << endl;
//}
////DEBUG End
// Default arguments, assuming
// no modes set.
const char* modes = "+" ;
/*
* 1) <nickname>
* 2) <hops>
* 3) <TS>
* 4) <userid>
* 5) <host>
* 6) [<+modes>]
* 7+) [<mode parameters>]
* -3 <base64 IP>
* -2 <numeric>
* -1 <fullname
*/
string account ;
time_t account_ts = 0 ;
string sethost ;
string fakehost ;
string cloakhost ;
string cloakip ;
xParameters::size_type currentArgIndex = 6 ;
bool IsRegistered = false;
bool HasFakeHost = false;
bool HasSetHost = false;
bool HasCloakHost = false;
bool HasCloakIP = false;
// This will be true if any sethost/fakehost/cloakhost is present
bool HasExtraHost = false;
// precondition: currentArgIndex points at the next params[] index
// to check
if( '+' == params[ currentArgIndex ][ 0 ] )
{
// Got modes
currentArgIndex = 7 ;
// If any of the modes 'r', 'h', 'f' are present, then
// another param will follow.
// The mode order will always be rhf if all 3 are present.
modes = params[ 6 ] ;
for( const char* modePtr = params[ 6 ] ; *modePtr ; ++modePtr )
{
switch( *modePtr )
{
case 'r':
account = params[ currentArgIndex++ ] ;
IsRegistered = true;
break ;
case 'h':
HasSetHost = true;
HasExtraHost = true;
break ;
case 'f':
HasFakeHost = true;
HasExtraHost = true;
break ;
case 'C': // CloakHost
HasCloakHost = true;
HasExtraHost = true;
break;
case 'c': // CloakIP
HasCloakIP = true;
HasExtraHost = true;
break;
default: break ;
} // switch( *modePtr )
} // for()
} // if( '+' )
if (HasExtraHost && IsRegistered)
account = params[ --currentArgIndex ] ;
// postcondition: currentArgIndex points at the next params[] index
// to check
if (!HasExtraHost)
if (!account.empty())
{
StringTokenizer st( account, ':' ) ;
account = st[ 0 ] ;
if( 2 == st.size() )
{
// timestamp present
std::stringstream ss ;
ss << st[ 1 ] ;
if( !(ss >> account_ts) )
{
elog << "msg_N> Invalid account timestamp: "
<< st[ 1 ]
<< endl ;
// non-fatal error
}
} // if( 2 == st.size() )
} // if( !account.empty() )
iClient* newClient;
// Nefarious2 with cloaked host/IP
if (HasExtraHost)
{
if (IsRegistered) currentArgIndex++;
if (HasSetHost)
sethost = params[ currentArgIndex++ ] ;
if (HasFakeHost)
fakehost = params[ currentArgIndex++ ] ;
if (HasCloakHost)
cloakhost = params[ currentArgIndex++ ] ;
if (HasCloakIP)
cloakip = params[ currentArgIndex++ ] ;
const char* host = params[ currentArgIndex++ ] ;
const char* yyxxx = params[ currentArgIndex++ ] ;
const char* description = params [ currentArgIndex++ ] ;
newClient = new (std::nothrow) iClient(
nickUplink->getIntYY(),
yyxxx, // numeric
params[ 1 ], // nickname
params[ 4 ], // username
host, // base64 encoded ip
params[ 5 ], // insecureHost
params[ 5 ], // realInsecureHost
modes, // modes (default: +)
account, // account
account_ts, // account timestamp
description, // real name / infoline
atoi( params[ 3 ]), // connection time
cloakhost, // Nefarious2 cloakHost
cloakip, // Nefarious2 cloakIP
sethost, // asuka sethost
fakehost // srvx fakehost
) ;
}
else // <= 'normal' ircu introduction
{
/*
* -3 <base64 IP>
* -2 <numeric>
* -1 <fullname
*/
const char* host = params[ currentArgIndex++ ] ;
const char* yyxxx = params[ currentArgIndex++ ] ;
const char* description = params [ currentArgIndex ] ;
newClient = new (std::nothrow) iClient(
nickUplink->getIntYY(),
yyxxx, // numeric
params[ 1 ], // nickname
params[ 4 ], // username
host, // base64 encoded ip
params[ 5 ], // insecureHost
params[ 5 ], // realInsecureHost
modes, // modes (default: +)
account, // account
account_ts, // account timestamp
sethost, // asuka sethost
fakehost, // srvx fakehost
description, // real name / infoline
atoi( params[ 3 ] ) // connection time
) ;
}
assert( newClient != 0 ) ;
if (!newClient)
{
elog << "msg_N> newClient == NULL , returning" << endl;
return false;
}
if( !Network->addClient( newClient ) )
{
elog << "msg_N> Failed to add client: "
<< *newClient
<< ", user already exists? "
<< (Network->findClient( newClient->getCharYYXXX() ) ?
"yes" : "no")
<< endl ;
delete newClient ; newClient = 0 ;
return false ;
}
//elog << "msg_N> Added user: "
// << *newClient
// << endl ;
theServer->PostEvent( EVT_NICK, static_cast< void* >( newClient ) ) ;
return true ;
}
} // namespace gnuworld
+40
View File
@@ -0,0 +1,40 @@
/**
* msg_NOOP.cc
* Copyright (C) 2002 Daniel Karrels <dan@karrels.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: msg_NOOP.cc,v 1.5 2005/03/25 03:07:29 dan_karrels Exp $
*/
#include "gnuworld_config.h"
#include "server.h"
#include "xparameters.h"
#include "ServerCommandHandler.h"
RCSTAG( "$Id: msg_NOOP.cc,v 1.5 2005/03/25 03:07:29 dan_karrels Exp $" ) ;
namespace gnuworld
{
CREATE_HANDLER(msg_NOOP)
bool msg_NOOP::Execute( const xParameters& )
{
return true ;
}
} // namespace gnuworld
+280
View File
@@ -0,0 +1,280 @@
/**
* msg_O.cc
* Copyright (C) 2002 Daniel Karrels <dan@karrels.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: msg_O.cc,v 1.10 2005/03/25 03:07:29 dan_karrels Exp $
*/
#include <string>
#include <iostream>
#include "gnuworld_config.h"
#include "server.h"
#include "Network.h"
#include "iClient.h"
#include "client.h"
#include "ELog.h"
#include "xparameters.h"
#include "ServerCommandHandler.h"
#include "StringTokenizer.h"
RCSTAG( "$Id: msg_O.cc,v 1.10 2005/03/25 03:07:29 dan_karrels Exp $" ) ;
namespace gnuworld
{
using std::string ;
using std::endl ;
CREATE_HANDLER(msg_O)
void channelNotice( iClient* srcClient,
Channel* theChan,
const string& message )
{
for( Channel::userIterator userItr = theChan->userList_begin() ;
userItr != theChan->userList_end() ; ++userItr )
{
unsigned int intYYXXX = userItr->second->getIntYYXXX() ;
xClient* servicesClient = Network->findLocalClient( intYYXXX ) ;
if( servicesClient != 0
&& servicesClient->isOnChannel( theChan )
&& !servicesClient->getMode( iClient::MODE_DEAF ) )
{
// xClient, invoke OnChannelNotice()
servicesClient->OnChannelNotice( srcClient,
theChan,
message ) ;
continue ;
}
// Not an xClient, check if it's a fake client
iClient* targetClient = Network->findFakeClient(
userItr->second->getClient() ) ;
if( 0 == targetClient )
{
// Nope
continue ;
}
// Fake client
// Get its owner, use a different variable name here
// just for readability.
xClient* ownerClient = Network->findFakeClientOwner(
targetClient ) ;
if( 0 == ownerClient )
{
elog << "msg_O::channelNotice> Unable to "
<< "find owner of client: "
<< *targetClient
<< ", in channel: "
<< *theChan
<< endl ;
continue ;
}
ownerClient->OnFakeChannelNotice( srcClient,
targetClient,
theChan,
message ) ;
} // for()
}
/**
* A nick has sent a private message
* QBg O PAA :help
* QBg: Source nickname's numeric
* O: NOTICE
* PAA: Destination nickname's numeric
* :help: Notice
*
* QAE O PAA :translate xaa
* QAE O AAPAA :translate xaa
* abcDE O #chanName :testing 12 3
*/
bool msg_O::Execute( const xParameters& Param )
{
if( Param.size() < 3 )
{
elog << "msg_O> Invalid number of arguments"
<< endl ;
return false ;
}
Channel* theChan = 0 ;
if( '#' == Param[ 1 ][ 0 ] )
{
// Channel notice
theChan = Network->findChannel( Param[ 1 ] ) ;
if( 0 == theChan )
{
elog << "msg_O> Unable to locate channel: "
<< Param[ 1 ]
<< endl ;
return false ;
}
}
if( '+' == Param[ 1 ][ 0 ] )
{
// Chances of receiving a local channel are slim to
// none anyway
// *shrug*
return true ;
}
iClient* srcClient = Network->findClient( Param[ 0 ] ) ;
if( 0 == srcClient )
{
elog << "msg_O> Unable to find source client: "
<< Param[ 0 ]
<< endl ;
return false ;
}
// abcDE O FGhij :hi, how are you?
bool secure = false ;
xClient* targetClient = 0 ;
iClient* fakeTarget = 0 ;
if( (0 == theChan) && (strchr( Param[ 1 ], '@' ) != 0) )
{
// nick@host.name specified, secure message
secure = true ;
StringTokenizer st( Param[ 1 ], '@' ) ;
targetClient = Network->findLocalNick( st[ 0 ] ) ;
if( 0 == targetClient )
{
fakeTarget = Network->findFakeNick( st[ 0 ] ) ;
if( 0 == fakeTarget )
{
elog << "msg_O> Received notice for unknown "
<< "client: "
<< Param[ 1 ]
<< ", nick: "
<< st[ 0 ]
<< endl ;
return true ;
}
}
// Found the target xClient
}
else if( (0 == theChan) &&
(Param[ 1 ][ 0 ] == theServer->getCharYY()[ 0 ]) &&
(Param[ 1 ][ 1 ] == theServer->getCharYY()[ 1 ]) )
{
// elog << "msg_O> Notice for local client: "
// << Param[ 1 ]
// << endl ;
// Normal notice to an xClient
targetClient = Network->findLocalClient( Param[ 1 ] ) ;
if( 0 == targetClient )
{
// Not an xClient, is it a fake client?
fakeTarget = Network->findFakeClient( Param[ 1 ] ) ;
if( 0 == fakeTarget )
{
elog << "msg_O> Unable to find local client: "
<< Param[ 1 ]
<< endl ;
return true ;
}
}
}
else if( 0 == theChan )
{
// TODO
elog << "msg_O> Unknown target: "
<< Param[ 1 ]
<< endl ;
// May be a message to a juped client on a juped server,
// ignore it.
return true ;
}
else
{
// theChan != 0
// It's a channel message, this is not a problem for
// the case in which there is an xClient in the channel.
// However, it becomes a bit more complicated if there are
// one or more fake clients (possibly in addition to the
// xClient) in the channel.
}
xClient* ownerClient = 0 ;
if( fakeTarget != 0 )
{
// The target is a fake client, let's find its owner
ownerClient = Network->findFakeClientOwner( fakeTarget ) ;
if( 0 == ownerClient )
{
elog << "msg_O> Fake client without owner: "
<< *fakeTarget
<< endl ;
return true ;
}
}
string message( Param[ 2 ] ) ;
if( theChan != 0 )
{
// elog << "msg_O> Channel message from: "
// << *srcClient
// << ", message: "
// << message
// << ", on channel: "
// << *theChan
// << endl ;
channelNotice( srcClient,
theChan,
message ) ;
}
else
{
// elog << "msg_O> Private message from: "
// << *srcClient
// << ", message: "
// << message
// << endl ;
if( fakeTarget != 0 )
{
ownerClient->OnFakePrivateNotice(
srcClient,
fakeTarget,
message,
secure ) ;
}
else
{
targetClient->OnPrivateNotice( srcClient,
message,
secure ) ;
} // else()
} // else( theChan != 0 )
return true ;
} // msg_O
} // namespace gnuworld
+509
View File
@@ -0,0 +1,509 @@
/**
* msg_OM.cc
* Copyright (C) 2013 Seven <gergo_f@yahoo.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: msg_OM.cc,v 1.00 2013/01/09 10:44:37 Seven Exp $
*/
#include <new>
#include <map>
#include <string>
#include <vector>
#include <iostream>
#include "gnuworld_config.h"
#include "misc.h"
#include "events.h"
#include "server.h"
#include "iClient.h"
#include "Channel.h"
#include "ChannelUser.h"
#include "Network.h"
#include "ELog.h"
#include "StringTokenizer.h"
#include "ServerCommandHandler.h"
RCSTAG( "$Id: msg_OM.cc,v 1.00 2013/01/09 10:44:37 Seven Exp $" ) ;
namespace gnuworld
{
using std::pair ;
using std::make_pair ;
using std::string ;
using std::vector ;
using std::endl ;
class msg_OM : public ServerCommandHandler
{
public:
msg_OM( xServer* theServer )
: ServerCommandHandler( theServer )
{}
virtual ~msg_OM()
{}
virtual bool Execute( const xParameters& ) ;
//protected:
// bool onUserModeChange( const xParameters& ) ;
} ;
CREATE_LOADER(msg_OM)
// Mode change
// OAD M ripper_ :+owg
//
// i OM #3dx +o eAA
// J[K M DEMET_33 :+i
bool msg_OM::Execute( const xParameters& Param )
{
//elog << "Entered msg_OM" << std::endl;
//elog << Param << endl;
if( Param.size() < 3 )
{
elog << "msg_OM> Invalid number of arguments"
<< endl ;
return false ;
}
// This source stuff really isn't used here, but it's here for
// debugging and validation.
iServer* serverSource = 0 ;
iClient* clientSource = 0 ;
// Note that the order of this if/else if/else is important
if( NULL != strchr( Param[ 0 ], '.' ) )
{
// Server, by name
serverSource = Network->findServerName( Param[ 0 ] ) ;
}
else if( strlen( Param[ 0 ] ) >= 3 )
{
// Client numeric
clientSource = Network->findClient( Param[ 0 ] ) ;
}
else
{
// 1 or 2 char numeric, server
serverSource = Network->findServer( Param[ 0 ] ) ;
}
if( (NULL == clientSource) && (NULL == serverSource) )
{
elog << "msg_OM> Unable to find source: "
<< Param[ 0 ]
<< endl ;
return false ;
}
// Is it a user mode change?
if( '#' != Param[ 1 ][ 0 ] )
{
// Yup, process the user's mode change(s)
//return onUserModeChange( Param ) ;
return false;
}
// Find the channel in question
Channel* theChan = Network->findChannel( Param[ 1 ] ) ;
if( NULL == theChan )
{
elog << "msg_OM> Unable to find channel: "
<< Param[ 1 ]
<< endl ;
return false ;
}
if( serverSource != 0 )
{
// elog << "msg_OM ("
// << theChan->getName()
// << ") server "
// << serverSource->getName()
// << " performed a mode"
// << std::endl;
theServer->PostChannelEvent( EVT_SERVERMODE, theChan,
static_cast< void* >( serverSource ) ) ;
}
/* XXX OPMODE FAILS HERE */
// Find the ChannelUser of the source client
// It is possible that the ChannelUser will be NULL, in the
// case that a server is setting the mode(s) - AND if the user is outside of the channel! --Seven
ChannelUser* theUser = 0 ;
if( clientSource != 0 )
{
theUser = theChan->findUser( clientSource ) ;
if( NULL == theUser )
{
// elog << "msg_OM> ("
// << theChan->getName()
// << ") Unable to find channel user: "
// << clientSource->getCharYYXXX()
// << endl ;
// So we allow NULL ChannelUser, who is outside of the channel
//return false ;
}
else
theUser->setMadeOpMode();
}
bool polarity = true ;
xParameters::size_type argPos = 3 ;
xServer::opVectorType opVector ;
xServer::voiceVectorType voiceVector ;
xServer::banVectorType banVector ;
xServer::modeVectorType modeVector ;
for( const char* modePtr = Param[ 2 ] ; *modePtr ; ++modePtr )
{
switch( *modePtr )
{
case '+':
polarity = true ;
break ;
case '-':
polarity = false ;
break ;
case 't':
modeVector.push_back(
make_pair( polarity, Channel::MODE_T ) ) ;
break ;
case 'n':
modeVector.push_back(
make_pair( polarity, Channel::MODE_N ) ) ;
break ;
case 's':
modeVector.push_back(
make_pair( polarity, Channel::MODE_S ) ) ;
break ;
case 'p':
modeVector.push_back(
make_pair( polarity, Channel::MODE_P ) ) ;
break ;
case 'm':
modeVector.push_back(
make_pair( polarity, Channel::MODE_M ) ) ;
break ;
case 'i':
modeVector.push_back(
make_pair( polarity, Channel::MODE_I ) ) ;
break ;
case 'r':
modeVector.push_back(
make_pair( polarity, Channel::MODE_R ) ) ;
break ;
case 'R':
modeVector.push_back(
make_pair( polarity, Channel::MODE_REG ) ) ;
break ;
case 'D':
modeVector.push_back(
make_pair( polarity, Channel::MODE_D ) ) ;
break;
// Channel mode l only has an argument if
// it is being added, but not removed
case 'l':
if( polarity && (argPos >= Param.size()) )
{
elog << "msg_OM> Invalid "
<< "format for message: missing "
<< "argument to mode +l"
<< " in channel "
<< *theChan
<< endl ;
continue ;
}
theServer->OnChannelModeL( theChan,
polarity, theUser,
polarity ? atoi( Param[ argPos++ ] )
: 0 ) ;
break ;
// Channel mode k always has an argument
case 'k':
if( argPos >= Param.size() )
{
elog << "msg_OM> Invalid "
<< "format for message: missing "
<< "argument for mode 'k'"
<< " in channel "
<< *theChan
<< endl ;
continue ;
}
theServer->OnChannelModeK( theChan,
polarity, theUser,
Param[ argPos++ ] ) ;
break ;
case 'o':
{
if( argPos >= Param.size() )
{
elog << "msg_OM> Invalid "
<< "format for message: missing "
<< "argument for mode 'o'"
<< " in channel "
<< *theChan
<< endl ;
continue ;
}
iClient* targetClient = Network->findClient(
Param[ argPos++ ] ) ;
if( NULL == targetClient )
{
// elog << "msg_OM> Unable to "
// << "find op target client: "
// << Param[ argPos - 1 ]
// << " in channel "
// << *theChan
// << endl ;
break ;
}
ChannelUser* targetUser = theChan->findUser(
targetClient ) ;
if( NULL == targetUser )
{
// elog << "msg_OM> Unable to "
// << "find op target user: "
// << Param[ argPos - 1 ]
// << " in channel "
// << *theChan
// << endl ;
break ;
}
opVector.push_back(
pair< bool, ChannelUser* >(
polarity, targetUser ) ) ;
// If the op mode is +o, remove the ZOMBIE
// state from this user.
// if( polarity && targetUser->isZombie() )
// {
// targetUser->removeZombie() ;
// elog << "msg_M> Removing "
// << "zombie"
// << endl ;
// }
break ;
}
case 'v':
{
if( argPos >= Param.size() )
{
elog << "msg_OM> Invalid "
<< "format for message: missing "
<< "argument for mode 'v'"
<< " in channel "
<< *theChan
<< endl ;
continue ;
}
iClient* targetClient = Network->findClient(
Param[ argPos++ ] ) ;
if( NULL == targetClient )
{
// elog << "msg_OM> Unable to "
// << "find voice target client: "
// << Param[ argPos - 1 ]
// << " in channel "
// << *theChan
// << endl ;
break ;
}
ChannelUser* targetUser = theChan->findUser(
targetClient ) ;
if( NULL == targetUser )
{
// elog << "msg_OM> Unable to "
// << "find voice target user: "
// << Param[ argPos - 1 ]
// << " in channel "
// << *theChan
// << endl ;
break ;
}
voiceVector.push_back(
pair< bool, ChannelUser* >(
polarity, targetUser ) ) ;
break ;
}
case 'b':
{
if( argPos >= Param.size() )
{
elog << "msg_OM> Invalid "
<< "format for message: missing "
<< "argument for mode 'b'"
<< " in channel "
<< *theChan
<< endl ;
continue ;
}
const char* targetBan = Param[ argPos++ ] ;
banVector.push_back(
pair< bool, string >(
polarity, string( targetBan ) ) ) ;
break ;
}
} // switch()
} // for()
if( !modeVector.empty() )
{
theServer->OnChannelMode( theChan, theUser, modeVector ) ;
}
if( !opVector.empty() )
{
theServer->OnChannelModeO( theChan, theUser, opVector ) ;
}
if( !voiceVector.empty() )
{
theServer->OnChannelModeV( theChan, theUser, voiceVector ) ;
}
if( !banVector.empty() )
{
theServer->OnChannelModeB( theChan, theUser, banVector ) ;
}
if (theUser)
theUser->removeMadeOpMode();
return true ;
}
/*
// OAD M ripper_ :+owg
bool msg_OM::onUserModeChange( const xParameters& Param )
{
// Since users aren't allowed to change modes for anyone other than
// themselves, there is no need to lookup the second user argument
// For some reason, when a user changes his/her/its modes, it still
// specifies the second argument to be nickname instaed of numeric.
iClient* theClient = Network->findClient( Param[ 0 ] ) ;
if( NULL == theClient )
{
elog << "msg_OM::OnUserModeChange> Unable to find target "
<< "client: "
<< Param[ 1 ]
<< endl ;
return false ;
}
if( theClient->getNickName() != Param[ 1 ] )
{
elog << "msg_OM::OnUserModeChange> User trying to change "
<< "mode for someone other than itself: "
<< *theClient
<< ", nickname: "
<< Param[ 1 ]
<< endl ;
return false ;
}
// It's important that the mode '+' be default
bool plus = true ;
for( const char* modePtr = Param[ 2 ] ; *modePtr ; ++modePtr )
{
switch( *modePtr )
{
case '+':
plus = true ;
break;
case '-':
plus = false ;
break;
case 'i':
if( plus ) theClient->setModeI() ;
else theClient->removeModeI() ;
break ;
case 'k':
if( plus ) theClient->setModeK() ;
else theClient->removeModeK() ;
break ;
case 'd':
if( plus ) theClient->setModeD() ;
else theClient->removeModeD() ;
break ;
case 'w':
if( plus ) theClient->setModeW() ;
else theClient->removeModeW() ;
break ;
case 'x':
if( plus ) theClient->setModeX() ;
else theClient->removeModeX() ;
break ;
case 'r':
if( plus ) theClient->setModeR() ;
else theClient->removeModeR() ;
break ;
case 'g':
if( plus ) theClient->setModeG() ;
else theClient->removeModeG() ;
break ;
case 'o':
if( plus )
{
theClient->setModeO() ;
theServer->PostEvent( EVT_OPER,
static_cast< void* >( theClient ) ) ;
}
else
{
// elog << "msg_OM::onUserModeChange> "
// << "Caught -o for user: "
// << *theClient
// << endl ;
theClient->removeModeO() ;
}
break ;
case 'n':
case 'I':
case 'h':
case 'X':
case 'R':
case 'f':
// Unsupported but used on networks that
// GNUWorld runs on.
// TODO?
break ;
default:
elog << "msg_OM::onUserModeChange> "
<< "Unknown mode: "
<< *modePtr
<< endl ;
break ;
} // close switch
} // close for
return true ;
}
*/
} // namespace gnuworld
+439
View File
@@ -0,0 +1,439 @@
/**
* msg_P.cc
* Copyright (C) 2002 Daniel Karrels <dan@karrels.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: msg_P.cc,v 1.15 2005/03/25 03:07:29 dan_karrels Exp $
*/
#include <string>
#include <iostream>
#include "gnuworld_config.h"
#include "server.h"
#include "Network.h"
#include "iClient.h"
#include "client.h"
#include "ELog.h"
#include "xparameters.h"
#include "ServerCommandHandler.h"
#include "StringTokenizer.h"
RCSTAG( "$Id: msg_P.cc,v 1.15 2005/03/25 03:07:29 dan_karrels Exp $" ) ;
namespace gnuworld
{
using std::string ;
using std::endl ;
CREATE_HANDLER(msg_P)
void channelCTCP( iClient* srcClient,
Channel* theChan,
const string& command,
const string& message )
{
for( Channel::userIterator userItr = theChan->userList_begin() ;
userItr != theChan->userList_end() ; ++userItr )
{
unsigned int intYYXXX = userItr->second->getIntYYXXX() ;
xClient* servicesClient = Network->findLocalClient( intYYXXX ) ;
if( servicesClient != 0
&& servicesClient->isOnChannel( theChan )
&& !servicesClient->getMode( iClient::MODE_DEAF ) )
{
// xClient, invoke OnChannelMessage()
servicesClient->OnChannelCTCP( srcClient,
theChan,
command,
message ) ;
continue ;
}
// Not an xClient, check if it's a fake client
iClient* targetClient = Network->findFakeClient(
userItr->second->getClient() ) ;
if( 0 == targetClient )
{
// Nope
continue ;
}
// Fake client
// Get its owner, use a different variable name here
// just for readability.
xClient* ownerClient = Network->findFakeClientOwner(
targetClient ) ;
if( 0 == ownerClient )
{
elog << "msg_P::channelMessage> Unable to "
<< "find owner of client: "
<< *targetClient
<< ", in channel: "
<< *theChan
<< endl ;
continue ;
}
ownerClient->OnFakeChannelCTCP( srcClient,
targetClient,
theChan,
command,
message ) ;
} // for()
}
void channelMessage( iClient* srcClient,
Channel* theChan,
const string& message )
{
for( Channel::userIterator userItr = theChan->userList_begin() ;
userItr != theChan->userList_end() ; ++userItr )
{
unsigned int intYYXXX = userItr->second->getIntYYXXX() ;
xClient* servicesClient = Network->findLocalClient( intYYXXX ) ;
if( servicesClient != 0
&& servicesClient->isOnChannel( theChan )
&& !servicesClient->getMode( iClient::MODE_DEAF ) )
{
// xClient, invoke OnChannelMessage()
servicesClient->OnChannelMessage( srcClient,
theChan,
message ) ;
continue ;
}
// Not an xClient, check if it's a fake client
iClient* targetClient = Network->findFakeClient(
userItr->second->getClient() ) ;
if( 0 == targetClient )
{
// Nope
continue ;
}
// Fake client
// Get its owner, use a different variable name here
// just for readability.
xClient* ownerClient = Network->findFakeClientOwner(
targetClient ) ;
if( 0 == ownerClient )
{
elog << "msg_P::channelMessage> Unable to "
<< "find owner of client: "
<< *targetClient
<< ", in channel: "
<< *theChan
<< endl ;
continue ;
}
ownerClient->OnFakeChannelMessage( srcClient,
targetClient,
theChan,
message ) ;
} // for()
}
/**
* A nick has sent a private message
* QBg P PAA :help
* QBg: Source nickname's numeric
* P: PRIVMSG
* PAA: Destination nickname's numeric
* :help: Message
*
* QAE P PAA :translate xaa
* QAE P AAPAA :translate xaa
* abcDE P #chanName :testing 12 3
*/
bool msg_P::Execute( const xParameters& Param )
{
if( Param.size() < 3 )
{
elog << "msg_P> Invalid number of arguments"
<< endl ;
return false ;
}
Channel* theChan = 0 ;
if( '#' == Param[ 1 ][ 0 ] )
{
// Channel message
theChan = Network->findChannel( Param[ 1 ] ) ;
if( 0 == theChan )
{
elog << "msg_P> Unable to locate channel: "
<< Param[ 1 ]
<< endl ;
return false ;
}
}
if( '+' == Param[ 1 ][ 0 ] )
{
// Chances of receiving a local channel are slim to
// none anyway
// *shrug*
return true ;
}
iClient* srcClient = Network->findClient( Param[ 0 ] ) ;
if( 0 == srcClient )
{
elog << "msg_P> Unable to find source client: "
<< Param[ 0 ]
<< endl ;
return false ;
}
// abcDE P FGhij :hi, how are you?
bool secure = false ;
xClient* targetClient = 0 ;
iClient* fakeTarget = 0 ;
if( (0 == theChan) && (strchr( Param[ 1 ], '@' ) != 0) )
{
// nick@host.name specified, secure message
secure = true ;
StringTokenizer st( Param[ 1 ], '@' ) ;
targetClient = Network->findLocalNick( st[ 0 ] ) ;
if( 0 == targetClient )
{
fakeTarget = Network->findFakeNick( st[ 0 ] ) ;
if( 0 == fakeTarget )
{
// elog << "msg_P> Looking for control nick: "
// << st[ 0 ]
// << endl ;
bool controlNick =
theServer->findControlNick( st[ 0 ] ) ;
if( controlNick )
{
theServer->ControlCommand( srcClient,
Param[ 2 ] ) ;
// All done
return true ;
}
// !controlNick
elog << "msg_P> Received message for "
<< "unknown client: "
<< Param[ 1 ]
<< ", nick: "
<< st[ 0 ]
<< endl ;
return true ;
}
}
// Found the target xClient
}
else if( (0 == theChan) &&
(Param[ 1 ][ 0 ] == theServer->getCharYY()[ 0 ]) &&
(Param[ 1 ][ 1 ] == theServer->getCharYY()[ 1 ]) )
{
// elog << "msg_P> Message for local client: "
// << Param[ 1 ]
// << endl ;
// Normal message to an xClient
targetClient = Network->findLocalClient( Param[ 1 ] ) ;
if( 0 == targetClient )
{
// Not an xClient, is it a fake client?
fakeTarget = Network->findFakeClient( Param[ 1 ] ) ;
if( 0 == fakeTarget )
{
elog << "msg_P> Unable to find local client: "
<< Param[ 1 ]
<< endl ;
return true ;
}
}
}
else if( 0 == theChan )
{
// TODO
elog << "msg_P> Unknown target: "
<< Param[ 1 ]
<< endl ;
// May be a message to a juped client on a juped server,
// ignore it.
return true ;
}
else
{
// theChan != 0
// It's a channel message, this is not a problem for
// the case in which there is an xClient in the channel.
// However, it becomes a bit more complicated if there are
// one or more fake clients (possibly in addition to the
// xClient) in the channel.
}
xClient* ownerClient = 0 ;
if( fakeTarget != 0 )
{
// The target is a fake client, let's find its owner
ownerClient = Network->findFakeClientOwner( fakeTarget ) ;
if( 0 == ownerClient )
{
elog << "msg_P> Fake client without owner: "
<< *fakeTarget
<< endl ;
return true ;
}
}
bool CTCP = (Param[ 2 ][ 0 ] == 1) ? true : false ;
// Prepare a message string to pass to the client which is
// void of any CTCP control chars
// CTCP messages begin and end with '\1'
// In the case of CTCP, it is of the form:
// abcDE P EFghi :\1ctcp_command\1 message
// abcDE P EFghi :\1PING 123456789\1
// Note that Param[ 2 ] is \1PING 123456789\1 message
string message( Param[ 2 ] ) ;
string command ;
if( CTCP )
{
// CTCP, remove the control chars from the command.
// Tokenize by the CTCP delimiter, \1
StringTokenizer st( Param[ 2 ], '\1' ) ;
// Make sure there is at least one token
if( st.empty() )
{
elog << "msg_P> Found empty tokenizer for CTCP, from: "
<< Param[ 2 ]
<< endl ;
return false ;
}
// The CTCP command is now everything that was surrounded
// by the two \1's, or the first token of st, st[ 0 ]
command = st[ 0 ] ;
// If there was an optional message after the CTCP command,
// st.size() will be greater than 1.
if( st.size() > 1 )
{
message = st.assemble( 2 ) ;
}
else
{
// No message, clear it
message = "" ;
}
}
if( CTCP )
{
if( theChan != 0 )
{
// elog << "msg_P> Found channel ctcp, command from: "
// << *srcClient
// << ", command: "
// << command
// << ", message: "
// << message
// << ", on channel: "
// << *theChan
// << endl ;
channelCTCP( srcClient, theChan, command, message ) ;
}
else
{
// elog << "msg_P> Found privmsg CTCP, command from: "
// << *srcClient
// << ", command: "
// << command
// << ", message: "
// << message
// << endl ;
if( fakeTarget != 0 )
{
ownerClient->OnFakeCTCP( srcClient,
fakeTarget,
command,
message,
secure ) ;
}
else
{
targetClient->OnCTCP( srcClient,
command,
message,
secure ) ;
}
}
}
else
{
if( theChan != 0 )
{
// elog << "msg_P> Channel message from: "
// << *srcClient
// << ", message: "
// << message
// << ", on channel: "
// << *theChan
// << endl ;
channelMessage( srcClient,
theChan,
message ) ;
}
else
{
// elog << "msg_P> Private message from: "
// << *srcClient
// << ", message: "
// << message
// << endl ;
if( fakeTarget != 0 )
{
ownerClient->OnFakePrivateMessage(
srcClient,
fakeTarget,
message,
secure ) ;
}
else
{
targetClient->OnPrivateMessage( srcClient,
message,
secure ) ;
} // else()
} // else( theChan != 0 )
} // else( CTCP )
return true ;
} // msg_P
} // namespace gnuworld
+42
View File
@@ -0,0 +1,42 @@
/**
* msg_PA.cc
* Copyright (C) 2002 Daniel Karrels <dan@karrels.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: msg_PA.cc,v 1.4 2005/03/25 03:07:29 dan_karrels Exp $
*/
#include "server.h"
#include "xparameters.h"
#include "ServerCommandHandler.h"
RCSTAG( "$Id: msg_PA.cc,v 1.4 2005/03/25 03:07:29 dan_karrels Exp $" ) ;
namespace gnuworld
{
CREATE_HANDLER(msg_PA)
bool msg_PA::Execute( const xParameters& )
{
theServer->setBursting( true ) ;
theServer->setUseHoldBuffer( true ) ;
return true ;
}
} // namespace gnuworld
+74
View File
@@ -0,0 +1,74 @@
/**
* msg_Q.cc
* Copyright (C) 2002 Daniel Karrels <dan@karrels.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: msg_Q.cc,v 1.4 2005/03/25 03:07:29 dan_karrels Exp $
*/
#include <iostream>
#include "server.h"
#include "events.h"
#include "Network.h"
#include "iClient.h"
#include "Network.h"
#include "ELog.h"
#include "ServerCommandHandler.h"
RCSTAG( "$Id: msg_Q.cc,v 1.4 2005/03/25 03:07:29 dan_karrels Exp $" ) ;
namespace gnuworld
{
using std::endl ;
CREATE_HANDLER(msg_Q)
/**
* A client has quit.
* QAE Q :Signed off
*/
bool msg_Q::Execute( const xParameters& Param )
{
if( Param.size() < 1 )
{
elog << "msg_Q> Invalid number of parameters"
<< endl ;
return false ;
}
// xNetwork::removeClient will remove user<->channel associations
iClient* theClient = Network->removeClient( Param[ 0 ] ) ;
if( NULL == theClient )
{
elog << "msg_Q> Unable to find client: "
<< Param[ 0 ]
<< endl ;
return false ;
}
theServer->PostEvent( EVT_QUIT, static_cast< void* >( theClient ) ) ;
// xNetwork::removeClient() will remove channel->user associations.
delete theClient ;
return true ;
}
} // namespace gnuworld
+42
View File
@@ -0,0 +1,42 @@
/**
* msg_R.cc
* Copyright (C) 2002 Daniel Karrels <dan@karrels.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: msg_R.cc,v 1.4 2005/03/25 03:07:29 dan_karrels Exp $
*/
#include "server.h"
#include "xparameters.h"
#include "ServerCommandHandler.h"
RCSTAG( "$Id: msg_R.cc,v 1.4 2005/03/25 03:07:29 dan_karrels Exp $" ) ;
namespace gnuworld
{
CREATE_HANDLER(msg_R)
// STATS
// kAB R O :AI
//
bool msg_R::Execute( const xParameters& )
{
return false ;
}
} // namespace gnuworld
+111
View File
@@ -0,0 +1,111 @@
/**
* msg_RI.cc
* Copyright (C) 2002 Daniel Karrels <dan@karrels.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*/
#include <sys/types.h>
#include <sys/time.h>
#include <iostream>
#include <sstream>
#include "server.h"
#include "iServer.h"
#include "iClient.h"
#include "events.h"
#include "Network.h"
#include "ELog.h"
#include "xparameters.h"
#include "ServerCommandHandler.h"
RCSTAG( "$Id: msg_RI.cc,v 1.4 2010/07/12 18:14:47 hidden1 Exp $" ) ;
namespace gnuworld
{
using std::endl ;
using std::stringstream ;
CREATE_HANDLER(msg_RI)
/* RPING:
*
* Ar == random.server.netgamers.org
* Ay == cservice.netgamers.org
*
* This is an RPING from AyAAA to Ar, ie we are Ar in this scenario.
*
* IN : Ay RI Ar AyAAA 1085745254 37971 :<No client start time>
* OUT: Ar RO cservice.netgamers.org AyAAA 1085745254 37971 :<No client start time>
*
* Due to gnuworld wierdness, we actually get:
* params: AB Az ABAAA 1085753348 87482 <No client start time>
*/
bool msg_RI::Execute( const xParameters& params )
{
//return true;
if( params.size() < 5 ) {
elog << "msg_RI> Invalid number of arguments."
<< endl;
return false;
}
if( params[1] != theServer->getCharYY() ) {
elog << "msg_RI> Got RPING destined for someone else."
<< endl;
return false;
}
iServer *remoteServer = Network->findServer(params[0]);
iClient *remoteClient = Network->findClient(params[2]);
if( !remoteServer || !remoteClient ) {
elog << "msg_RI> Got RPING from non-existant client/server."
<< endl;
return false;
}
/* Construct our reply */
stringstream reply;
reply << theServer->getCharYY()
<< " RO "
<< remoteServer->getName()
<< " "
<< remoteClient->getCharYYXXX()
<< " "
<< params[3]
<< " "
<< params[4]
;
if( params.size() > 5 ) {
reply << " :"
<< params.assemble(5)
;
}
theServer->Write(reply);
return true;
}
} // namespace gnuworld
+86
View File
@@ -0,0 +1,86 @@
/**
* msg_RO.cc
* Copyright (C) 2002 Daniel Karrels <dan@karrels.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: msg_RO.cc,v 1.1 2009/07/25 18:12:34 hidden1 Exp $
*/
#include <iostream>
#include <string>
#include "gnuworld_config.h"
#include "server.h"
#include "Network.h"
#include "ELog.h"
#include "xparameters.h"
#include "ServerCommandHandler.h"
RCSTAG( "$Id: msg_RO.cc,v 1.1 2009/07/25 18:12:34 hidden1 Exp $" ) ;
namespace gnuworld
{
using std::endl ;
using std::string ;
CREATE_HANDLER(msg_RO)
bool msg_RO::Execute( const xParameters& Param )
{
if( Param.empty() )
{
elog << "msg_RO> Invalid number of "
<< "arguments"
<< endl ;
return false ;
}
xClient* theClient = Network->findLocalClient( Param[ 2 ] ) ;
if( NULL == theClient )
{
elog << "msg_RO> Unable to find nick: "
<< Param[ 1 ]
<< endl ;
return false ;
}
iServer* tmpServer = Network->findServer(Param[0]);
if( NULL == tmpServer )
{
elog << "msg_RO> Unable to find server: "
<< Param[ 0 ]
<< endl ;
return false ;
}
string tMessage = string( tmpServer->getCharYY() ) + " RO " + theServer->getCharYY() + " ";
for( xParameters::size_type i = 2 ; i < Param.size() ; ++i )
{
tMessage += Param[ i ] ;
if( (i + 1) < Param.size() )
{
tMessage += " " ;
}
}
theClient->OnServerMessage( tmpServer, tMessage );
return true ;
}
} // namespace gnuworld
+139
View File
@@ -0,0 +1,139 @@
/**
* msg_S.cc
* Copyright (C) 2002 Daniel Karrels <dan@karrels.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: msg_S.cc,v 1.7 2007/05/12 13:20:00 mrbean_ Exp $
*/
#include <new>
#include <string>
#include <iostream>
#include <cassert>
#include "gnuworld_config.h"
#include "server.h"
#include "events.h"
#include "Network.h"
#include "iServer.h"
#include "ELog.h"
#include "xparameters.h"
#include "ServerCommandHandler.h"
RCSTAG( "$Id: msg_S.cc,v 1.7 2007/05/12 13:20:00 mrbean_ Exp $" ) ;
namespace gnuworld
{
using std::string ;
using std::endl ;
CREATE_HANDLER(msg_S)
/**
* New server joined the network.
* Q S irc.dynmc.net 2 0 948159347 P10 BD] +6hs :[209.0.37.10]
* [209.0.37.10] Dynamic Networking Solutions
*
* B S EUWorld1.test.net 3 0 947284938 P10 OD] +6hs :[128.227.184.152]
* EUWorld Undernet Service
* B: Uplink Server numeric
* S: SERVER message
* EUWorld1.test.net: server name
* 3: hopcount
* 0: creation time
* 947284938: link time
* P10: Protocol
* B: Server numeric
* D]: Last used nick number for clients
* +6/+h/+s: server/services flags
* EUWorld Undernet Server: description
* As always, the second token, the command, is not
* included in the xParameters passed here.
*/
bool msg_S::Execute( const xParameters& params )
{
// We need at least 9 tokens
if( params.size() < 9 )
{
elog << "msg_S> Not enough parameters"
<< endl ;
return false ;
}
int uplinkIntYY = base64toint( params[ 0 ] ) ;
iServer* uplinkServer = Network->findServer( uplinkIntYY ) ;
if( NULL == uplinkServer )
{
elog << "msg_S> Unable to find uplink server"
<< endl ;
return false ;
}
const string serverName( params[ 1 ] ) ;
// Don't care about hop count
// Don't care about start time
time_t connectTime = static_cast< time_t >( atoi( params[ 4 ] ) ) ;
// Don't care about version
int serverIntYY = base64toint( params[ 6 ], 2 ) ;
// Does the new server's numeric already exist?
if( NULL != Network->findServer( serverIntYY ) )
{
elog << "msg_S> Server numeric collision, numeric: "
<< params[ 6 ]
<< ", old name: "
<< Network->findServer( serverIntYY )->getName()
<< ", new name: "
<< serverName
<< endl ;
delete Network->removeServer( serverIntYY ) ;
}
// Dun really care about the server description
iServer* newServer = new (std::nothrow) iServer( uplinkIntYY,
params[ 6 ], // yxx
serverName,
connectTime ) ;
assert( newServer != 0 ) ;
// params[ 5 ] is either "P10", or "J10". The J10 means
// that the server is bursting
if( 'J' == params[ 5 ][ 0 ] )
{
newServer->setBursting( true ) ;
}
// Set any appropriate server flags
newServer->setFlags( params[ 7 ] ) ;
Network->addServer( newServer ) ;
//elog << "msg_S> Added server: "
// << *newServer
// << endl ;
theServer->PostEvent( EVT_NETJOIN,
static_cast< void* >( newServer ),
static_cast< void* >( uplinkServer ) ) ;
return true ;
}
} // namespace gnuworld
+122
View File
@@ -0,0 +1,122 @@
/**
* msg_SQ.cc
* Copyright (C) 2002 Daniel Karrels <dan@karrels.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: msg_SQ.cc,v 1.8 2007/04/27 19:30:43 mrbean_ Exp $
*/
#include <iostream>
#include <string>
#include <cstring>
#include "gnuworld_config.h"
#include "server.h"
#include "events.h"
#include "Network.h"
#include "iServer.h"
#include "ELog.h"
#include "xparameters.h"
#include "ServerCommandHandler.h"
RCSTAG( "$Id: msg_SQ.cc,v 1.8 2007/04/27 19:30:43 mrbean_ Exp $" ) ;
namespace gnuworld
{
using std::string ;
using std::endl ;
CREATE_HANDLER(msg_SQ)
/**
* SQUIT message handler.
* :ripper_ SQ ripper.ufl.edu 0 :squitting the services server
* :ripper_ SQ maniac.krushnet.org 954445164 :remote server squit
* 0 SQ Auckland.NZ.KrushNet.Org 957468458 :Ping timeout
* kAm SQ Luxembourg.LU.EU.KrushNet.Org 957423889 :byyyyyye
*
* The following example is gnuworld being squitted:
* OAO SQ Asheville-R.NC.US.KrushNet.Org 0 :I bid you adoo
* asheville-r.* was gnuworld's uplink
* 0 SQ Asheville-R.NC.US.KrushNet.Org 0 :Ping timeout
* Az SQ Seattle-R.WA.US.KrushNet.Org 0 :Ping timeout
*/
bool msg_SQ::Execute( const xParameters& Param )
{
if( Param.size() < 2 )
{
elog << "msg_SQ> Invalid number of parameters"
<< endl ;
return false ;
}
iServer* squitServer = 0 ;
if( strchr( Param[ 1 ], '.' ) != NULL )
{
// Full server name specified
squitServer = Network->findServerName( Param[ 1 ] ) ;
}
else
{
// Numeric
squitServer = Network->findServer( Param[ 1 ] ) ;
}
if( NULL == squitServer )
{
elog << "msg_SQ> Unable to find server: "
<< Param[ 1 ]
<< endl ;
return false ;
}
if( squitServer->getIntYY() == theServer->getUplinkIntYY() )
{
elog << "msg_SQ> Ive been delinked!!"
<< endl ;
// It's my uplink, we have been squit...those bastards!
theServer->Shutdown() ;
return true ;
}
else
{
// elog << "msg_SQ> " << squitServer->getName()
// << " has been squit"
// << endl ;
string source( Param[ 0 ] ) ;
string reason( Param[ 3 ] ) ;
squitServer->setBursting(false); //If the server was in bursting state, its not anymore :)
theServer->PostEvent( EVT_NETBREAK,
static_cast< void* >( squitServer ),
static_cast< void* >( &source ),
static_cast< void* >( &reason ) ) ;
// Otherwise, it's just some server.
// xNetwork::OnSplit() will deallocate all servers
// which are split
Network->OnSplit( squitServer->getIntYY() ) ;
}
return true ;
}
} // namespace gnuworld
+147
View File
@@ -0,0 +1,147 @@
/**
* msg_Server.cc
* Copyright (C) 2002 Daniel Karrels <dan@karrels.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: msg_Server.cc,v 1.7 2006/12/22 06:41:41 kewlio Exp $
*/
#include <new>
#include <iostream>
#include <cstring>
#include <cassert>
#include "gnuworld_config.h"
#include "server.h"
#include "events.h"
#include "Network.h"
#include "iServer.h"
#include "ELog.h"
#include "xparameters.h"
#include "ServerCommandHandler.h"
RCSTAG( "$Id: msg_Server.cc,v 1.7 2006/12/22 06:41:41 kewlio Exp $" ) ;
namespace gnuworld
{
using std::endl ;
CREATE_HANDLER(msg_Server)
/**
* New server message
* SERVER irc-r.mediabit.net 1 934191376 946934706 J10 BD] :MCS MEDIABIT Testnet
* Routing Server, Padova, Italy
* SERVER Austin-R.TX.US.KrushNet.Org 1 900000000 958147697 J10 1]] :Large Penis
* Support Group IRC Server
*
* The following command has been changed to token S
* B SERVER irc.mediabit.net 2 0 945972199 P10 CD] 0 :[193.76.114.11]
* [193.76.114.11] MCS MEDIABIT Testnet Server, Padov
*
* Declaration of our own server:
* SERVER ripper.ufl.edu 1 933022556 948162945 J10 QD] :[128.227.184.152]
* University of Florida
*
* Remember that the "SERVER" parameter is removed.
*/
bool msg_Server::Execute( const xParameters& Param )
{
theServer->setBurstEnd( 0 ) ;
theServer->setBurstStart( ::time( 0 ) ) ;
// Check the hopcount
// 1: It's our uplink
if( Param[ 1 ][ 0 ] == '1' )
{
// elog << "msg_Server> Got Uplink: "
// << Param[ 0 ]
// << endl ;
// It's our uplink
if( Param.size() < 6 )
{
elog << "msg_Server> Invalid number of parameters"
<< endl ;
return false ;
}
// Here's the deal:
// We are just connecting to the network
// We have just received the first server command,
// telling us who our uplink server is.
// We need to add our uplink to network tables.
// Assume 5 character numerics
unsigned int uplinkIntYY = base64toint( Param[ 5 ], 2 ) ;
// Our uplink has its own numeric as its uplinkIntYY.
iServer* tmpUplink = new (std::nothrow) iServer(
uplinkIntYY,
Param[ 5 ], // yyxxx
Param[ 0 ], // name
atoi( Param[ 3 ] ) ) ; // connect time
assert( tmpUplink != 0 ) ;
// Check for P10 versus J10, J10 means the server is
// bursting.
if( 'J' == Param[ 4 ][ 0 ] )
{
tmpUplink->setBursting( true ) ;
}
// Set any appropriate server flags
tmpUplink->setFlags( Param[ 6 ] ) ;
theServer->setUplink( tmpUplink ) ;
// Find this server (me)
iServer* me = Network->findServer( theServer->getIntYY() ) ;
if( NULL == me )
{
elog << "msg_Server> Unable to find myself "
<< " ("
<< theServer->getIntYY()
<< ")"
<< endl ;
::exit( 0 ) ;
}
// Now that I know my uplink, I can set its numeric
// in my own iServer info
me->setUplinkIntYY( uplinkIntYY ) ;
// We now have a pointer to our own uplink
// Add it to the tables
// We maintain a local pointer just for speed reasons
Network->addServer( theServer->getUplink() ) ;
// elog << "msg_Server> Added server: "
// << *(theServer->getUplink())
// << endl ;
}
// Not posting message here because this method is only called once
// using tokenized commands - when the xServer connects
return true ;
}
} // namespace gnuworld
+107
View File
@@ -0,0 +1,107 @@
/**
* msg_T.cc
* Copyright (C) 2002 Daniel Karrels <dan@karrels.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: msg_T.cc,v 1.8 2005/06/20 11:26:33 kewlio Exp $
*/
#include <string>
#include <iostream>
#include "gnuworld_config.h"
#include "ip.h"
#include "server.h"
#include "xparameters.h"
#include "Network.h"
#include "ELog.h"
#include "Channel.h"
#include "ServerCommandHandler.h"
namespace gnuworld
{
using std::endl ;
CREATE_HANDLER(msg_T)
// Channel topics currently are not tracked.
// kAI T #omniplex :-=[ Washington.DC.US.Krushnet.Org / Luxembourg.
// LU.EU.KrushNet.Org Admin Channel ]=-
bool msg_T::Execute( const xParameters& Param )
{
if( Param.size() < 3 )
{
elog << "msg_T> Invalid number of arguments"
<< endl ;
return false ;
}
Channel* theChan = Network->findChannel( Param[ 1 ] ) ;
if( 0 == theChan )
{
elog << "msg_T> Unable to locate channel: "
<< Param[ 1 ]
<< endl;
return false ;
}
// srcClient may be NULL if a server is setting the topic
iClient* srcClient = Network->findClient( Param[ 0 ] ) ;
std::string newTopic;
if (Param.size() == 5)
{
/* this is a .12 hub! */
/* params = numeric, channel, channel creation ts, topic ts, topic */
newTopic = Param[ 4 ];
#ifdef TOPIC_TRACK
theChan->setTopic(Param[4]);
theChan->setTopicTS(atoi(Param[3]));
#endif // TOPIC_TRACK
} else {
/* this is a .11 hub! (3 arguments) */
/* params = numeric, channel, topic */
newTopic = Param[ 2 ];
#ifdef TOPIC_TRACK
theChan->setTopic(Param[2]);
theChan->setTopicTS(::time(NULL));
#endif // TOPIC_TRACK
}
#ifdef TOPIC_TRACK
if (srcClient == NULL)
{
theChan->setTopicWhoSet("unknown");
} else {
std::string client_ip;
client_ip = xIP(srcClient->getIP()).GetNumericIP();
theChan->setTopicWhoSet(srcClient->getNickUserHost() + " [" + client_ip + "]");
}
#endif // TOPIC_TRACK
// No need to pass the new topic, it has already been stored
// in the theChan
theServer->PostChannelEvent( EVT_TOPIC,
theChan,
static_cast< void* >( srcClient ),
static_cast< void* >( &newTopic ) ) ;
return true ;
}
} // namespace gnuworld
+97
View File
@@ -0,0 +1,97 @@
/**
* msg_V.cc
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: msg_V.cc,v 1.7 2005/03/25 03:07:29 dan_karrels Exp $
*/
#include <sstream>
#include "gnuworld_config.h"
#include "server.h"
#include "ServerCommandHandler.h"
#include "xparameters.h"
RCSTAG( "$Id: msg_V.cc,v 1.7 2005/03/25 03:07:29 dan_karrels Exp $" ) ;
namespace gnuworld
{
using std::endl ;
using std::stringstream ;
CREATE_HANDLER(msg_V)
/**
* VERSION message handler:
* AHkav V :Ay
*
* AHkav - Requesting user numeric
* V - VERSION token (duh)
* Ay - Requested server version (should always be us!)
*
* As always, the token itself is missing from our xParameters
*/
bool msg_V::Execute( const xParameters& Param )
{
/* We should have exactly two parameters - source and destination */
if( Param.size() != 2)
{
elog << "msg_V> Invalid number of parameters received."
<< endl;
return false;
}
/* The destination numeric should always match us exactly */
if(strncmp(Param[1], theServer->getCharYY().c_str(), 2) != 0)
{
elog << "msg_V> Target server is not me!"
<< endl;
return false;
}
/*
* Should we check if the client exists here?
* If the version request got to us, presumably it has to exist
* on the network, even if we don't know about it.
*/
/*
* Reply looks like:
* A8 351 AyAAA u2.10.11.01. devlink.netgamers.org :B27AeEFfIKMpSU
*
* A8 - Answering server
* 351 - Numeric for version reply
* AyAAA - Target (requester)
* 'the rest' - Reply.
*/
stringstream versionReply;
versionReply << theServer->getCharYY()
<< " 351 "
<< Param[0]
<< " :" __DATE__ " " __TIME__
<< " GNUworld Services Core" ;
theServer->Write(versionReply);
return true;
} // bool msg_V::Execute()
} // namespace gnuworld
+81
View File
@@ -0,0 +1,81 @@
/**
* msg_W.cc
* Copyright (C) 2002 Daniel Karrels <dan@karrels.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: msg_W.cc,v 1.5 2005/03/25 03:07:29 dan_karrels Exp $
*/
#include <iostream>
#include "gnuworld_config.h"
#include "server.h"
#include "xparameters.h"
#include "ELog.h"
#include "Network.h"
#include "iClient.h"
#include "client.h"
#include "ServerCommandHandler.h"
RCSTAG( "$Id: msg_W.cc,v 1.5 2005/03/25 03:07:29 dan_karrels Exp $" ) ;
namespace gnuworld
{
using std::endl ;
CREATE_HANDLER(msg_W)
// ABAG7 W Az :Gte-
bool msg_W::Execute( const xParameters& Param )
{
if( Param.size() != 3 )
{
elog << "msg_W> Invalid number of parameters"
<< endl ;
return false ;
}
iClient* sourceClient = Network->findClient( Param[ 0 ] ) ;
if( NULL == sourceClient )
{
elog << "msg_W> Unable to find source client: "
<< Param[ 0 ]
<< endl ;
return false ;
}
iClient* targetClient = Network->findNick( Param[ 2 ] ) ;
if( NULL == targetClient )
{
elog << "msg_W> Unable to find target client: "
<< Param[ 2 ]
<< endl ;
return false ;
}
// WHOIS must be delivered to all xclients
xNetwork::localClientIterator ptr = Network->localClient_begin() ;
for( ; ptr != Network->localClient_end() ; ++ptr )
{
ptr->second->OnWhois( sourceClient, targetClient ) ;
}
return true ;
}
} // namespace gnuworld
+41
View File
@@ -0,0 +1,41 @@
/**
* msg_WA.cc
* Copyright (C) 2002 Daniel Karrels <dan@karrels.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: msg_WA.cc,v 1.4 2005/03/25 03:07:29 dan_karrels Exp $
*/
#include "gnuworld_config.h"
#include "server.h"
#include "xparameters.h"
#include "ServerCommandHandler.h"
RCSTAG( "$Id: msg_WA.cc,v 1.4 2005/03/25 03:07:29 dan_karrels Exp $" ) ;
namespace gnuworld
{
CREATE_HANDLER(msg_WA)
// WALLOPS
bool msg_WA::Execute( const xParameters& )
{
return false ;
}
} // namespace gnuworld
+117
View File
@@ -0,0 +1,117 @@
/**
* msg_XQ.cc
* Copyright (C) 2010 Jochen Meesters <ekips@pandora.be>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: msg_XQ.cc,v 1.1 2010/08/31 21:16:46 denspike Exp $
*/
#include <string>
#include <iostream>
#include "gnuworld_config.h"
#include "server.h"
#include "Network.h"
#include "iClient.h"
#include "client.h"
#include "ELog.h"
#include "xparameters.h"
#include "ServerCommandHandler.h"
#include "StringTokenizer.h"
namespace gnuworld
{
using std::string ;
using std::endl ;
CREATE_HANDLER(msg_XQ)
/**
* A server or oper sends an XQUERY
* <prefix> XQ <target> <routing> :<query>
*
* <prefix>: Originating server numeric, can be an oper for debugging purposes
* <target>: Our servernumeric
* <routing>: Token to supply in XR
* <query>: Message, can be spaced
*
* [IN ]: ABAAA XQ Az tokengoeshere :message goes here :)
*/
bool msg_XQ::Execute( const xParameters& Param )
{
if( Param.size() < 4 )
{
elog << "msg_XQ> Invalid number of arguments"
<< endl ;
return false ;
}
iServer* serverSource = 0 ;
iClient* clientSource = 0 ;
if( strlen( Param[ 0 ] ) >= 3 )
{
clientSource = Network->findClient( Param[ 0 ] ) ;
//This is an oper debugging, treat messages as originated from his server
serverSource = Network->findServer(clientSource->getIntYY());
}
else
{
serverSource = Network->findServer( Param[ 0 ] ) ;
}
if( (NULL == clientSource) && (NULL == serverSource) )
{
elog << "msg_XQ> Unable to find source: "
<< Param[ 0 ]
<< endl ;
return false ;
}
if (Network->findServer(Param[ 1 ]) != theServer->getMe())
{
//Should we do something here?
elog << "msg_XQ> Received XQ not meant for us but for: "
<< Param[ 1 ]
<< endl ;
return false ;
}
elog << "msg_XQ> Received, from: "
<< Param[ 0 ] << " To: "
<< Param[ 1 ] << " Token: "
<< Param[ 2 ] << " Message: "
<< Param[ 3 ]
<< endl;
string Routing( Param[2] );
string Message( Param[3] );
theServer->OnXQuery(serverSource, Routing, Message);
//string Routing = Param[2];
//string Message = Param[3];
//elog << "STRINGS:: " << Routing << " " << Message << endl;
//theServer->PostEvent( EVT_XQUERY,
// static_cast< void* >( serverSource ),
// reinterpret_cast< void* > ( &Routing ), reinterpret_cast< void* >( &Message ));
return true;
} // msg_XQ
} // namespace gnuworld
+101
View File
@@ -0,0 +1,101 @@
/**
* msg_XR.cc
* Copyright (C) 2010 Jochen Meesters <ekips@pandora.be>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: msg_XR.cc,v 1.1 2010/08/31 21:16:46 denspike Exp $
*/
#include <string>
#include <iostream>
#include "gnuworld_config.h"
#include "server.h"
#include "Network.h"
#include "iClient.h"
#include "client.h"
#include "ELog.h"
#include "xparameters.h"
#include "ServerCommandHandler.h"
#include "StringTokenizer.h"
namespace gnuworld
{
using std::string ;
using std::endl ;
CREATE_HANDLER(msg_XR)
/**
* A server replies an XREPLY
* <prefix> XR <target> <routing> :<query>
*
* <prefix>: Originating server numeric, can be an oper for debugging purposes
* <target>: Our servernumeric
* <routing>: Token to supply in XR
* <query>: Message, can be spaced
*
* [IN ]: AB XR Az tokengoeshere :message goes here :)
*/
bool msg_XR::Execute( const xParameters& Param )
{
if( Param.size() < 4 )
{
elog << "msg_XR> Invalid number of arguments"
<< endl ;
return false ;
}
iServer* serverSource = Network->findServer( Param[ 0 ] ) ;
if( NULL == serverSource)
{
elog << "msg_XR> Unable to find source: "
<< Param[ 0 ]
<< endl ;
return false ;
}
if (Network->findServer(Param[ 1 ]) != theServer->getMe())
{
//Should we do something here?
elog << "msg_XR> Received XQ not meant for us but for: "
<< Param[ 1 ]
<< endl ;
return false ;
}
elog << "msg_XR> Received, from: "
<< Param[ 0 ] << " To: "
<< Param[ 1 ] << " Token: "
<< Param[ 2 ] << " Message: "
<< Param[ 3 ]
<< endl;
string Routing( Param[2] );
string Message( Param[3] );
theServer->OnXReply(serverSource, Routing, Message);
//string Routing = Param[2];
//string Message = Param[3];
//elog << "STRINGS:: " << Routing << " " << Message << endl;
return true;
} // msg_XR
} // namespace gnuworld
+41
View File
@@ -0,0 +1,41 @@
/**
* msg_Y.cc
* Copyright (C) 2002 Daniel Karrels <dan@karrels.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: msg_Y.cc,v 1.4 2005/03/25 03:07:29 dan_karrels Exp $
*/
#include "gnuworld_config.h"
#include "server.h"
#include "xparameters.h"
#include "ServerCommandHandler.h"
RCSTAG( "$Id: msg_Y.cc,v 1.4 2005/03/25 03:07:29 dan_karrels Exp $" ) ;
namespace gnuworld
{
CREATE_HANDLER(msg_Y)
bool msg_Y::Execute( const xParameters& )
{
return true ;
}
} // namespace gnuworld