- Timestamp:
- Jul 17, 2006, 5:47:32 PM (18 years ago)
- Location:
- branches/proxy/src/lib/network
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/proxy/src/lib/network/monitor/network_monitor.cc
r9303 r9308 20 20 21 21 #include "proxy/proxy_settings.h" 22 #include "shared_network_data.h" 22 23 23 24 #include "network_monitor.h" … … 52 53 this->setSynchronized(false); 53 54 54 // assuming that the config files are already read we get the proxy servers 55 std::vector<IPaddress*>* proxyList = ProxySettings::getInstance()->getProxyList(); 56 std::vector<IPaddress*>::iterator it = proxyList->begin(); 57 // create a peer info class and a network node class for each new proxy and add them to the passive list 58 for(; it < proxyList->end(); it++) 59 { 60 PeerInfo* peer = new PeerInfo(); 61 peer->ip = *(*it); 62 peer->nodeType = NET_PROXY_SERVER_ACTIVE; 63 peer->userId = -1; 64 65 NetworkNode* node = new NetworkNode(peer); 66 this->addPassiveProxyServer( this->localNode, peer); 55 // read in the proxy server list, this is only the case for the master server 56 if( SharedNetworkData::getInstance()->isMasterServer()) 57 { 58 // assuming that the config files are already read we get the proxy servers 59 std::vector<IPaddress*>* proxyList = ProxySettings::getInstance()->getProxyList(); 60 std::vector<IPaddress*>::iterator it = proxyList->begin(); 61 // create a peer info class and a network node class for each new proxy and add them to the passive list 62 for(; it < proxyList->end(); it++) 63 { 64 PeerInfo* peer = new PeerInfo(); 65 peer->ip = *(*it); 66 peer->nodeType = NET_PROXY_SERVER_ACTIVE; 67 peer->userId = -1; 68 69 NetworkNode* node = new NetworkNode(peer); 70 this->addNode( node); 71 this->addPassiveProxyServer( this->localNode, peer); 72 } 67 73 } 68 74 } … … 111 117 * @param ip ip of the new node 112 118 */ 113 void NetworkMonitor::addNode(IPaddress ip) 114 {} 119 void NetworkMonitor::addNode(IPaddress ip, int nodeType) 120 { 121 PeerInfo* pInfo = new PeerInfo(); 122 pInfo->nodeType = nodeType; 123 pInfo->ip = ip; 124 125 this->addNode( pInfo); 126 } 115 127 116 128 -
branches/proxy/src/lib/network/monitor/network_monitor.h
r9300 r9308 34 34 void removeNetworkNode(NetworkNode* node); 35 35 36 void addNode(IPaddress ip);37 36 void addNode(PeerInfo* pInfo); 37 void addNode(IPaddress ip, int nodeType); 38 38 void addNode(NetworkNode* node) { this->nodeList.push_back(node); } 39 39 void addNode(NetworkNode* node, PeerInfo* pInfo); -
branches/proxy/src/lib/network/monitor/network_node.cc
r9300 r9308 239 239 for(; it != this->masterServerList.end(); it++) 240 240 { 241 PRINT(0)(" - ms, id: %i\n", (*it)->userId); 242 } 243 244 PRINT(0)(" proxy servers: %i\n", this->activeProxyServerList.size()); 241 int ip = (*it)->ip.host; 242 PRINT(0)(" - ms, id: %i (%d.%d.%d.%d:9999)\n", (*it)->userId, (ip & 0x000000FF), (ip & 0x0000FF00) >> 8, (ip & 0x00FF0000) >> 16, (ip & 0xFF000000)>>24); 243 } 244 245 PRINT(0)(" proxy servers active: %i\n", this->activeProxyServerList.size()); 245 246 it = this->activeProxyServerList.begin(); 246 247 for(; it != this->activeProxyServerList.end(); it++) 247 248 { 248 PRINT(0)(" - ps, id: %i\n", (*it)->userId); 249 int ip = (*it)->ip.host; 250 PRINT(0)(" - ps-a, id: %i (%d.%d.%d.%d:9999)\n", (*it)->userId, (ip & 0x000000FF), (ip & 0x0000FF00) >> 8, (ip & 0x00FF0000) >> 16, (ip & 0xFF000000)>>24); 251 } 252 253 PRINT(0)(" proxy servers passive: %i\n", this->passiveProxyServerList.size()); 254 it = this->passiveProxyServerList.begin(); 255 for(; it != this->passiveProxyServerList.end(); it++) 256 { 257 int ip = (*it)->ip.host; 258 PRINT(0)(" - ps-p, id: %i (%d.%d.%d.%d:9999)\n", (*it)->userId, (ip & 0x000000FF), (ip & 0x0000FF00) >> 8, (ip & 0x00FF0000) >> 16, (ip & 0xFF000000)>>24); 249 259 } 250 260 … … 253 263 for(; it != this->clientList.end(); it++) 254 264 { 255 PRINT(0)(" - client, id: %i\n", (*it)->userId); 256 } 257 } 258 265 int ip = (*it)->ip.host; 266 PRINT(0)(" - client, id: %i (%d.%d.%d.%d:9999)\n", (*it)->userId, (ip & 0x000000FF), (ip & 0x0000FF00) >> 8, (ip & 0x00FF0000) >> 16, (ip & 0xFF000000)>>24); 267 } 268 } 269 -
branches/proxy/src/lib/network/network_socket.cc
r7954 r9308 33 33 { 34 34 bOk = true; 35 this->ip.host = 0; 36 this->ip.port = 0; 35 37 } 36 38 -
branches/proxy/src/lib/network/network_socket.h
r9291 r9308 56 56 57 57 /** @returns the ip adderess of the destination socket */ 58 IPaddress get DestAddress() { return ip; }58 IPaddress getRemoteAddress() { return ip; } 59 59 60 60 -
branches/proxy/src/lib/network/network_stream.cc
r9303 r9308 81 81 this->peers[0].nodeType = NET_MASTER_SERVER; 82 82 this->peers[0].connectionMonitor = new ConnectionMonitor( 0 ); 83 this->peers[0].ip = this->peers[0].socket->get DestAddress();83 this->peers[0].ip = this->peers[0].socket->getRemoteAddress(); 84 84 // and set also the localhost 85 85 this->pInfo->nodeType = NET_CLIENT; 86 86 // get the local ip address 87 SDLNet_ResolveHost( &this->pInfo->ip, "localhost", port ); 88 87 SDLNet_ResolveHost( &this->pInfo->ip, NULL, port ); 89 88 } 90 89 … … 100 99 this->pInfo->nodeType = NET_MASTER_SERVER; 101 100 // get the local ip address 102 SDLNet_ResolveHost( &this->pInfo->ip, "localhost", port );101 SDLNet_ResolveHost( &this->pInfo->ip, NULL, port ); 103 102 } 104 103 … … 204 203 hs->setPreferedNickName( Preferences::getInstance()->getString( "multiplayer", "nickname", "Player" ) ); 205 204 206 // peers[0].handshake->setSynchronized( true );207 //this->connectSynchronizeable(*hs);208 //this->connectSynchronizeable(*hs);209 205 PRINTF(0)("NetworkStream: Handshake created: %s\n", hs->getName()); 210 206 } … … 305 301 306 302 /** 307 * if we are a server update the connection list to accept new connections (clients)308 * also start the handsake for the new clients303 * if we are a NET_MASTER_SERVER or NET_PROXY_SERVER_ACTIVE update the connection list to accept new 304 * connections (clients) also start the handsake for the new clients 309 305 */ 310 306 void NetworkStream::updateConnectionList( ) … … 326 322 peers[clientId].handshake = new Handshake(this->pInfo->nodeType, clientId, this->networkGameManager->getUniqueID(), MessageManager::getInstance()->getUniqueID() ); 327 323 peers[clientId].handshake->setUniqueID(clientId); 324 peers[clientId].ip = tempNetworkSocket->getRemoteAddress(); 328 325 329 326 // get the proxy server informations and write them to the handshake, if any (proxy) … … 501 498 502 499 it->second.nodeType = it->second.handshake->getRemoteNodeType(); 503 it->second.ip = it->second.socket->get DestAddress();500 it->second.ip = it->second.socket->getRemoteAddress(); 504 501 this->networkMonitor->addNode(&it->second); 505 502 506 503 // get proxy 1 address and add it 507 this->networkMonitor->addNode(it->second.handshake->getProxy1Address() );504 this->networkMonitor->addNode(it->second.handshake->getProxy1Address(), NET_PROXY_SERVER_ACTIVE); 508 505 // get proxy 2 address and add it 509 this->networkMonitor->addNode(it->second.handshake->getProxy2Address() );506 this->networkMonitor->addNode(it->second.handshake->getProxy2Address(), NET_PROXY_SERVER_ACTIVE); 510 507 511 508 … … 520 517 // disconnect from the current server and reconnect to proxy server 521 518 // it->second.socket->disconnectServer(); 522 523 519 } 524 520 … … 537 533 else 538 534 { 539 // handsh eke finished registring new player535 // handshake finished registring new player 540 536 if ( it->second.handshake->canDel() ) 541 537 { … … 543 539 { 544 540 it->second.nodeType = it->second.handshake->getRemoteNodeType(); 541 it->second.ip = it->second.socket->getRemoteAddress(); 542 545 543 this->networkMonitor->addNode(&it->second); 546 544 -
branches/proxy/src/lib/network/peer_info.cc
r9303 r9308 49 49 this->lastRecvedState = 0; 50 50 this->connectionMonitor = NULL; 51 52 this->ip.host = 0; 53 this->ip.port = 0; 51 54 } 52 55 … … 59 62 return std::string("client"); 60 63 case NET_PROXY_SERVER_ACTIVE: 61 return std::string("proxy server"); 64 return std::string("proxy server active"); 65 case NET_PROXY_SERVER_PASSIVE: 66 return std::string("proxy server passive"); 62 67 case NET_MASTER_SERVER: 63 68 return std::string("master server"); -
branches/proxy/src/lib/network/proxy/proxy_settings.cc
r9300 r9308 64 64 LoadParam(root, "max-player", this, ProxySettings, setMaxPlayer); 65 65 66 LoadParam(root, "proxy-addr", this, ProxySettings, setProxyAddr); 66 LOAD_PARAM_START_CYCLE(root, element); 67 { 68 element->ToText(); 69 // PER-PARTICLE-ATTRIBUTES: 70 LoadParam(root, "proxy-addr", this, ProxySettings, setProxyAddr); 71 } 72 LOAD_PARAM_END_CYCLE(element); 73 67 74 } 68 75 -
branches/proxy/src/lib/network/synchronizeable.cc
r9272 r9308 105 105 delete *it2; 106 106 } 107 108 } 109 } 110 111 /** 112 * Sets the server flag to a given value 113 * @param isServer: the boolean value which the server flag is to set to 114 */ 115 // void Synchronizeable::setIsServer(bool isServer) 116 // { 117 // if( isServer ) 118 // this->state = this->state | STATE_SERVER; 119 // else 120 // this->state = this->state & (~STATE_SERVER); 121 // } 122 123 124 /** 125 * Determines if the server flag is set 126 * @return true, if the server flag is true, false else 127 */ 128 // bool Synchronizeable::isServer() 129 // { 130 // return (this->state & STATE_SERVER) >0; 131 // } 107 } 108 } 132 109 133 110 … … 181 158 while ( it != sentStates[userId].end() && (*it)->stateId != fromStateId ) 182 159 it++; 183 184 // if ( getLeafClassID() == CL_SPACE_SHIP )185 // {186 // PRINTF(0)("getStateDiff:SpaceShip from: %d stateId: %d\n", (it == sentStates[userId].end())?-1:fromStateId, stateId);187 // }188 160 189 161 if ( it == sentStates[userId].end() ) -
branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_ip.cc
r9294 r9308 22 22 * @todo this constructor is not jet implemented - do it 23 23 */ 24 SynchronizeableIP::SynchronizeableIP( IPaddress * ptrIn, IPaddress * ptrOut, std::string name, int permission, int priority) : SynchronizeableVar( ptrIn, ptrOut, name, 3*FLOATSIZE, permission, priority )24 SynchronizeableIP::SynchronizeableIP( IPaddress * ptrIn, IPaddress * ptrOut, std::string name, int permission, int priority) : SynchronizeableVar( ptrIn, ptrOut, name, 2*INTSIZE, permission, priority ) 25 25 { 26 26 this->vPtrIn = ptrIn; -
branches/proxy/src/lib/network/udp_socket.cc
r8802 r9308 105 105 assert( serverSocket == NULL ); 106 106 107 IPaddress ip;108 109 107 this->randomByte = generateNewRandomByte(); 110 108 111 109 PRINTF(0)("connect to server %s on port %d\n", host.c_str(), port); 112 110 113 if ( SDLNet_ResolveHost( & ip, host.c_str(), port ) != 0 )111 if ( SDLNet_ResolveHost( &this->ip, host.c_str(), port ) != 0 ) 114 112 { 115 113 PRINTF(1)("SDLNet_ResolveHost: %s\n", SDLNet_GetError() ); … … 126 124 } 127 125 128 int channel = SDLNet_UDP_Bind(socket, 1, & ip);126 int channel = SDLNet_UDP_Bind(socket, 1, &this->ip); 129 127 if ( channel == -1 ) 130 128 { … … 147 145 bOk = false; 148 146 socket = NULL; 147 148 this->ip.host = 0; 149 this->ip.port = 0; 149 150 } 150 151 … … 179 180 180 181 byte udpCmd = 0; 181 182 182 183 if ( networkPacket.length > 0 ) 183 184 { … … 189 190 else 190 191 return 0; 191 192 192 193 if ( !checkRandomByte( networkPacket.data[0] ) ) 193 194 return 0; … … 198 199 networkPacket.data = NULL; 199 200 } 200 201 201 202 if ( !checkUdpCmd( udpCmd ) ) 202 203 return 0; … … 207 208 { 208 209 int numrecv = SDLNet_UDP_Recv( socket, packet); 209 210 210 211 byte udpCmd = 0; 211 212 … … 218 219 else 219 220 return 0; 220 221 221 222 if ( !checkRandomByte( packet->data[0] ) ) 222 223 return 0; 223 224 224 225 if ( !checkUdpCmd( udpCmd ) ) 225 226 return 0; … … 283 284 return false; 284 285 } 285 286 286 287 if ( !this->serverSocket && ( udpCmd & UDPCMD_INVALIDRNDBYTE ) ) 287 288 { … … 292 293 return false; 293 294 } 294 295 295 296 return true; 296 297 } … … 300 301 srand( SDL_GetTicks() ); 301 302 byte res = ( rand() & 0xFC ); 302 303 303 304 PRINTF(0)("generated random byte: %x\n", res); 304 305 305 306 return res; 306 307 }
Note: See TracChangeset
for help on using the changeset viewer.