Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9308 in orxonox.OLD


Ignore:
Timestamp:
Jul 17, 2006, 5:47:32 PM (18 years ago)
Author:
patrick
Message:

proxy server ip synchronizeing bug, nodes get registered

Location:
branches/proxy/src/lib/network
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • branches/proxy/src/lib/network/monitor/network_monitor.cc

    r9303 r9308  
    2020
    2121#include "proxy/proxy_settings.h"
     22#include "shared_network_data.h"
    2223
    2324#include "network_monitor.h"
     
    5253  this->setSynchronized(false);
    5354
    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    }
    6773  }
    6874}
     
    111117 * @param ip ip of the new node
    112118 */
    113 void NetworkMonitor::addNode(IPaddress ip)
    114 {}
     119void 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}
    115127
    116128
  • branches/proxy/src/lib/network/monitor/network_monitor.h

    r9300 r9308  
    3434    void removeNetworkNode(NetworkNode* node);
    3535
    36     void addNode(IPaddress ip);
    3736    void addNode(PeerInfo* pInfo);
     37    void addNode(IPaddress ip, int nodeType);
    3838    void addNode(NetworkNode* node) { this->nodeList.push_back(node); }
    3939    void addNode(NetworkNode* node, PeerInfo* pInfo);
  • branches/proxy/src/lib/network/monitor/network_node.cc

    r9300 r9308  
    239239  for(; it != this->masterServerList.end(); it++)
    240240  {
    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());
    245246  it = this->activeProxyServerList.begin();
    246247  for(; it != this->activeProxyServerList.end(); it++)
    247248  {
    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);
    249259  }
    250260
     
    253263  for(; it != this->clientList.end(); it++)
    254264  {
    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  
    3333{
    3434  bOk = true;
     35  this->ip.host = 0;
     36  this->ip.port = 0;
    3537}
    3638
  • branches/proxy/src/lib/network/network_socket.h

    r9291 r9308  
    5656
    5757    /** @returns the ip adderess of the destination socket */
    58     IPaddress getDestAddress() { return ip; }
     58    IPaddress getRemoteAddress() { return ip; }
    5959
    6060
  • branches/proxy/src/lib/network/network_stream.cc

    r9303 r9308  
    8181  this->peers[0].nodeType = NET_MASTER_SERVER;
    8282  this->peers[0].connectionMonitor = new ConnectionMonitor( 0 );
    83   this->peers[0].ip = this->peers[0].socket->getDestAddress();
     83  this->peers[0].ip = this->peers[0].socket->getRemoteAddress();
    8484  // and set also the localhost
    8585  this->pInfo->nodeType = NET_CLIENT;
    8686  // get the local ip address
    87   SDLNet_ResolveHost( &this->pInfo->ip, "localhost", port );
    88 
     87  SDLNet_ResolveHost( &this->pInfo->ip, NULL, port );
    8988}
    9089
     
    10099  this->pInfo->nodeType = NET_MASTER_SERVER;
    101100  // get the local ip address
    102   SDLNet_ResolveHost( &this->pInfo->ip, "localhost", port );
     101  SDLNet_ResolveHost( &this->pInfo->ip, NULL, port );
    103102}
    104103
     
    204203  hs->setPreferedNickName( Preferences::getInstance()->getString( "multiplayer", "nickname", "Player" ) );
    205204
    206 //   peers[0].handshake->setSynchronized( true );
    207   //this->connectSynchronizeable(*hs);
    208   //this->connectSynchronizeable(*hs);
    209205  PRINTF(0)("NetworkStream: Handshake created: %s\n", hs->getName());
    210206}
     
    305301
    306302/**
    307  * if we are a server update the connection list to accept new connections (clients)
    308  * also start the handsake for the new clients
     303 * 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
    309305 */
    310306void NetworkStream::updateConnectionList( )
     
    326322      peers[clientId].handshake = new Handshake(this->pInfo->nodeType, clientId, this->networkGameManager->getUniqueID(), MessageManager::getInstance()->getUniqueID() );
    327323      peers[clientId].handshake->setUniqueID(clientId);
     324      peers[clientId].ip = tempNetworkSocket->getRemoteAddress();
    328325
    329326      // get the proxy server informations and write them to the handshake, if any (proxy)
     
    501498
    502499              it->second.nodeType = it->second.handshake->getRemoteNodeType();
    503               it->second.ip = it->second.socket->getDestAddress();
     500              it->second.ip = it->second.socket->getRemoteAddress();
    504501              this->networkMonitor->addNode(&it->second);
    505502
    506503              // 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);
    508505              // 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);
    510507
    511508
     
    520517                // disconnect from the current server and reconnect to proxy server
    521518//                 it->second.socket->disconnectServer();
    522 
    523519              }
    524520
     
    537533          else
    538534          {
    539             // handsheke finished registring new player
     535            // handshake finished registring new player
    540536            if ( it->second.handshake->canDel() )
    541537            {
     
    543539              {
    544540                it->second.nodeType = it->second.handshake->getRemoteNodeType();
     541                it->second.ip = it->second.socket->getRemoteAddress();
     542
    545543                this->networkMonitor->addNode(&it->second);
    546544
  • branches/proxy/src/lib/network/peer_info.cc

    r9303 r9308  
    4949  this->lastRecvedState = 0;
    5050  this->connectionMonitor = NULL;
     51
     52  this->ip.host = 0;
     53  this->ip.port = 0;
    5154}
    5255
     
    5962      return std::string("client");
    6063    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");
    6267    case NET_MASTER_SERVER:
    6368      return std::string("master server");
  • branches/proxy/src/lib/network/proxy/proxy_settings.cc

    r9300 r9308  
    6464  LoadParam(root, "max-player", this, ProxySettings, setMaxPlayer);
    6565
    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
    6774}
    6875
  • branches/proxy/src/lib/network/synchronizeable.cc

    r9272 r9308  
    105105      delete *it2;
    106106    }
    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}
    132109
    133110
     
    181158  while ( it != sentStates[userId].end() && (*it)->stateId != fromStateId )
    182159    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 //  }
    188160
    189161  if ( it == sentStates[userId].end() )
  • branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_ip.cc

    r9294 r9308  
    2222 * @todo this constructor is not jet implemented - do it
    2323*/
    24 SynchronizeableIP::SynchronizeableIP( IPaddress * ptrIn, IPaddress * ptrOut, std::string name, int permission, int priority) : SynchronizeableVar( ptrIn, ptrOut, name, 3*FLOATSIZE, permission, priority )
     24SynchronizeableIP::SynchronizeableIP( IPaddress * ptrIn, IPaddress * ptrOut, std::string name, int permission, int priority) : SynchronizeableVar( ptrIn, ptrOut, name, 2*INTSIZE, permission, priority )
    2525{
    2626  this->vPtrIn = ptrIn;
  • branches/proxy/src/lib/network/udp_socket.cc

    r8802 r9308  
    105105  assert( serverSocket == NULL );
    106106
    107   IPaddress ip;
    108  
    109107  this->randomByte = generateNewRandomByte();
    110108
    111109  PRINTF(0)("connect to server %s on port %d\n", host.c_str(), port);
    112110
    113   if ( SDLNet_ResolveHost( &ip, host.c_str(), port ) != 0 )
     111  if ( SDLNet_ResolveHost( &this->ip, host.c_str(), port ) != 0 )
    114112  {
    115113    PRINTF(1)("SDLNet_ResolveHost: %s\n", SDLNet_GetError() );
     
    126124  }
    127125
    128   int channel = SDLNet_UDP_Bind(socket, 1, &ip);
     126  int channel = SDLNet_UDP_Bind(socket, 1, &this->ip);
    129127  if ( channel == -1 )
    130128  {
     
    147145  bOk = false;
    148146  socket = NULL;
     147
     148  this->ip.host = 0;
     149  this->ip.port = 0;
    149150}
    150151
     
    179180
    180181    byte udpCmd = 0;
    181    
     182
    182183    if ( networkPacket.length > 0 )
    183184    {
     
    189190    else
    190191      return 0;
    191      
     192
    192193    if ( !checkRandomByte( networkPacket.data[0] ) )
    193194      return 0;
     
    198199      networkPacket.data = NULL;
    199200    }
    200    
     201
    201202    if ( !checkUdpCmd( udpCmd ) )
    202203      return 0;
     
    207208  {
    208209    int numrecv = SDLNet_UDP_Recv( socket, packet);
    209    
     210
    210211    byte udpCmd = 0;
    211212
     
    218219      else
    219220        return 0;
    220            
     221
    221222      if ( !checkRandomByte( packet->data[0] ) )
    222223        return 0;
    223              
     224
    224225      if ( !checkUdpCmd( udpCmd ) )
    225226        return 0;
     
    283284    return false;
    284285  }
    285  
     286
    286287  if ( !this->serverSocket && ( udpCmd & UDPCMD_INVALIDRNDBYTE ) )
    287288  {
     
    292293    return false;
    293294  }
    294  
     295
    295296  return true;
    296297}
     
    300301  srand( SDL_GetTicks() );
    301302  byte res = ( rand() & 0xFC );
    302  
     303
    303304  PRINTF(0)("generated random byte: %x\n", res);
    304  
     305
    305306  return res;
    306307}
Note: See TracChangeset for help on using the changeset viewer.