X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/808b843774dc48afcd43652cfbf1da7ac4487c21..448264c18905be2f577f0461be7cb417b67a8af1:/projects/sgauthstress/proto.h

diff --git a/projects/sgauthstress/proto.h b/projects/sgauthstress/proto.h
index 0a2fb2de..746622b7 100644
--- a/projects/sgauthstress/proto.h
+++ b/projects/sgauthstress/proto.h
@@ -1,11 +1,15 @@
 #ifndef __PROTO_H__
 #define __PROTO_H__
 
+#ifndef LINUX
+#include <netinet/in_systm.h>
+#endif
 #include <netinet/ip.h>
 #include <pthread.h>
 #include <poll.h>
 
 #include <string>
+#include <list>
 #include <vector>
 #include <map>
 
@@ -31,23 +35,26 @@ class PROTO {
 
         const std::string GetStrError() const { return errorStr; }
 
-        void AddUser(const USER & user);
+        void AddUser(const USER & user, bool connect = false);
 
         bool Connect(uint32_t ip);
         bool Disconnect(uint32_t ip);
+
+        size_t UserCount() const { return users.size(); }
     private:
         BLOWFISH_CTX ctx;
         struct sockaddr_in localAddr;
         struct sockaddr_in serverAddr;
         int timeout;
 
-        std::vector<std::pair<uint32_t, USER> > users;
+        std::list<std::pair<uint32_t, USER> > users;
         std::vector<struct pollfd> pollFds;
 
         bool running;
         bool stopped;
 
         pthread_t tid;
+        pthread_mutex_t mutex;
 
         std::string errorStr;
 
@@ -56,9 +63,10 @@ class PROTO {
         static void * Runner(void * data);
 
         void Run();
+        void CheckTimeouts();
         bool RecvPacket();
         bool SendPacket(const void * buffer, size_t length, USER * user);
-        bool HandlePacket(const char * buffer, USER * user);
+        bool HandlePacket(const char * buffer, size_t length, USER * user);
 
         bool CONN_SYN_ACK_Proc(const void * buffer, USER * user);
         bool ALIVE_SYN_Proc(const void * buffer, USER * user);
@@ -72,6 +80,9 @@ class PROTO {
         bool Send_DISCONN_SYN(USER * user);
         bool Send_DISCONN_ACK(USER * user);
         bool Send_ALIVE_ACK(USER * user);
+
+        bool RealConnect(USER * user);
+        bool RealDisconnect(USER * user);
 };
 
 #endif