Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- A:/github/eq_stream.cpp Sun Nov 23 14:11:11 2014
- +++ A:/github/new/eq_stream.cpp Sun Nov 23 14:29:46 2014
- @@ -50,7 +50,15 @@
- uint16 EQStream::MaxWindowSize=2048;
- -void EQStream::init() {
- +void EQStream::init(bool resetSession) {
- +
- + // we only reset these statistics if it is a 'new' connection
- + if ( resetSession )
- + {
- + streamactive = false;
- + sessionAttempts = 0;
- + }
- +
- active_users = 0;
- Session=0;
- Key=0;
- @@ -315,19 +323,23 @@ void EQStream::ProcessPacket(EQProtocolPacket *p)
- break;
- }
- #ifndef COLLECTOR
- - if (GetState()==ESTABLISHED) {
- - _log(NET__ERROR, _L "Received OP_SessionRequest in ESTABLISHED state (%d)" __L, GetState());
- + if (GetState()==ESTABLISHED) {
- + _log(NET__ERROR, _L "Received OP_SessionRequest in ESTABLISHED state (%d) streamactive (%i) attempt (%i)" __L, GetState(),streamactive,sessionAttempts);
- - /*RemoveData();
- - init();
- - State=UNESTABLISHED;*/
- - _SendDisconnect();
- - SetState(CLOSED);
- - break;
- + // client seems to try a max of 4 times (initial+3 retries) then gives up, giving it a few more attempts just in case
- + // streamactive means we identified the opcode for the stream, we cannot re-establish this connection
- + if ( streamactive || ( sessionAttempts > 5 ) )
- + {
- + _SendDisconnect();
- + SetState(CLOSED);
- + break;
- + }
- }
- #endif
- //std::cout << "Got OP_SessionRequest" << std::endl;
- - init();
- + sessionAttempts++;
- + // we set established below, so statistics will not be reset for session attempts/stream active.
- + init(GetState()!=ESTABLISHED);
- OutboundQueueClear();
- SessionRequest *Request=(SessionRequest *)p->pBuffer;
- Session=ntohl(Request->Session);
- --- A:/github/eq_stream.h Sun Nov 23 14:12:44 2014
- +++ A:/github/new/eq_stream.h Sun Nov 23 14:15:58 2014
- @@ -101,6 +101,9 @@ class EQStream : public EQStreamInterface {
- uint32 retransmittimer;
- uint32 retransmittimeout;
- + uint16 sessionAttempts;
- + bool streamactive;
- +
- //uint32 buffer_len;
- uint32 Session, Key;
- @@ -194,7 +197,8 @@ class EQStream : public EQStreamInterface {
- void _SendDisconnect();
- - void init();
- + // session is reset by default, an exception is in OP_SessionRequest handling
- + void init(bool resetSession=true);
- public:
- EQStream() { init(); remote_ip = 0; remote_port = 0; State=UNESTABLISHED; StreamType=UnknownStream; compressed=true; encoded=false; app_opcode_size=2; bytes_sent=0; bytes_recv=0; create_time=Timer::GetTimeSeconds(); }
- EQStream(sockaddr_in addr) { init(); remote_ip=addr.sin_addr.s_addr; remote_port=addr.sin_port; State=UNESTABLISHED; StreamType=UnknownStream; compressed=true; encoded=false; app_opcode_size=2; bytes_sent=0; bytes_recv=0; create_time=Timer::GetTimeSeconds(); }
- @@ -221,6 +225,9 @@ class EQStream : public EQStreamInterface {
- void SetLastPacketTime(uint32 t) {LastPacket=t;}
- void Write(int eq_fd);
- + // whether or not the stream has been assigned (we passed our stream match)
- + void SetActive(bool val) { streamactive = val; }
- +
- //
- inline bool IsInUse() { bool flag; MInUse.lock(); flag=(active_users>0); MInUse.unlock(); return flag; }
- inline void PutInUse() { MInUse.lock(); active_users++; MInUse.unlock(); }
- --- A:/github/eq_stream_ident.cpp Sun Nov 23 14:13:11 2014
- +++ A:/github/new/eq_stream_ident.cpp Sun Nov 23 14:25:59 2014
- @@ -110,7 +110,10 @@ void EQStreamIdentifier::Process() {
- _log(NET__IDENTIFY, "Identified stream %s:%d with signature %s", long2ip(r->stream->GetRemoteIP()).c_str(), ntohs(r->stream->GetRemotePort()), p->name.c_str());
- - //might want to do something less-specific here... some day..
- + // before we assign the eqstream to an interface, let the stream recognize it is in use and the session should not be reset any further
- + r->stream->SetActive(true);
- +
- + //might want to do something less-specific here... some day..
- EQStreamInterface *s = new EQStreamProxy(r->stream, p->structs, p->opcodes);
- m_identified.push(s);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement