Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9592 in orxonox.OLD for branches/proxy/src/lib/network


Ignore:
Timestamp:
Jul 29, 2006, 12:11:13 AM (18 years ago)
Author:
patrick
Message:

completely reworked network permission system

File:
1 edited

Legend:

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

    r9591 r9592  
    215215    else if( SharedNetworkData::getInstance()->isMasterServer() && this->owner != userId && (*it)->checkPermission( PERMISSION_OWNER ))
    216216      hasPermission = true;
     217
    217218    // PROXY_SERVER  |====> *
    218219    else if( SharedNetworkData::getInstance()->isProxyServerActive() && (*it)->checkPermission( PERMISSION_PROXY_SERVER ))
     
    220221    else if( SharedNetworkData::getInstance()->isProxyServerActive() && this->owner != userId && (*it)->checkPermission( PERMISSION_OWNER ))
    221222      hasPermission = true;
     223    // PROXY_SERVER  |====> MASTER_SERVER
     224    else if( SharedNetworkData::getInstance()->isProxyServerActive() && this->networkStream->isUserMasterServer(userId)
     225             && this->networkStream->isUserLocal(userId) && (*it)->checkPermission( PERMISSION_MASTER_SERVER))
     226      hasPermission = true;
     227    // PROXY_SERVER  |====> CLIENT
     228    else if( SharedNetworkData::getInstance()->isProxyServerActive() && this->networkStream->isUserClient(userId)
     229             && this->owner != userId && (*it)->checkPermission( PERMISSION_OWNER ) )
     230      hasPermission = true;
     231    else if( SharedNetworkData::getInstance()->isProxyServerActive() && this->networkStream->isUserClient(userId)
     232             && (*it)->checkPermission( PERMISSION_MASTER_SERVER) )
     233      hasPermission = true;
     234
    222235    // OWNER         |====> *
    223236    else if( this->owner == SharedNetworkData::getInstance()->getHostID() && (*it)->checkPermission( PERMISSION_OWNER ))
    224237      hasPermission = true;
     238
    225239    // ALL           |====> *
    226240    else if( (*it)->checkPermission( PERMISSION_ALL ))
    227241      hasPermission = true;
    228     // SPECIAL: permission to forward syncs from the master server to the clients
    229     else if( SharedNetworkData::getInstance()->isProxyServerActive() && this->networkStream->isUserClient(userId)
    230              && (*it)->checkPermission( PERMISSION_MASTER_SERVER) )
    231       hasPermission = true;
    232     // SPECIAL: permission to forward to the master server
    233     else if( SharedNetworkData::getInstance()->isProxyServerActive() && this->networkStream->isUserMasterServer(userId)
    234              && (*it)->checkPermission( PERMISSION_MASTER_SERVER)  && this->networkStream->isUserLocal(userId))
    235       hasPermission = true;
    236     else if( SharedNetworkData::getInstance()->isProxyServerActive() && this->networkStream->isUserClient(userId)
    237              && this->owner != userId && (*it)->checkPermission( PERMISSION_OWNER ) )
    238       hasPermission = true;
     242
    239243    else
    240244      hasPermission = false;
     
    360364    // check if this synchronizeable has the permissions to write the data
    361365
    362     // first check MASTER_SERVER permissions
     366#if 0
     367
     368    //  MASTER_SERVER |====> *
     369    if( SharedNetworkData::getInstance()->isMasterServer() && (*it)->checkPermission( PERMISSION_MASTER_SERVER ))
     370      hasPermission = true;
     371    else if( SharedNetworkData::getInstance()->isMasterServer() && this->owner != userId && (*it)->checkPermission( PERMISSION_OWNER ))
     372      hasPermission = true;
     373
     374    // PROXY_SERVER  |====> *
     375    else if( SharedNetworkData::getInstance()->isProxyServerActive() && (*it)->checkPermission( PERMISSION_PROXY_SERVER ))
     376      hasPermission = true;
     377    else if( SharedNetworkData::getInstance()->isProxyServerActive() && this->owner != userId && (*it)->checkPermission( PERMISSION_OWNER ))
     378      hasPermission = true;
     379    // PROXY_SERVER  |====> MASTER_SERVER
     380    else if( SharedNetworkData::getInstance()->isProxyServerActive() && this->networkStream->isUserMasterServer(userId)
     381             && this->networkStream->isUserLocal(userId) && (*it)->checkPermission( PERMISSION_MASTER_SERVER))
     382      hasPermission = true;
     383    // PROXY_SERVER  |====> CLIENT
     384    else if( SharedNetworkData::getInstance()->isProxyServerActive() && this->networkStream->isUserClient(userId)
     385             && this->owner != userId && (*it)->checkPermission( PERMISSION_OWNER ) )
     386      hasPermission = true;
     387    else if( SharedNetworkData::getInstance()->isProxyServerActive() && this->networkStream->isUserClient(userId)
     388             && (*it)->checkPermission( PERMISSION_MASTER_SERVER) )
     389      hasPermission = true;
     390
     391    // OWNER         |====> *
     392    else if( this->owner == SharedNetworkData::getInstance()->getHostID() && (*it)->checkPermission( PERMISSION_OWNER ))
     393      hasPermission = true;
     394
     395    // ALL           |====> *
     396    else if( (*it)->checkPermission( PERMISSION_ALL ))
     397      hasPermission = true;
     398
     399    else
     400      hasPermission = false;
     401
     402#endif
     403
     404
     405    //  *              <====|  MASTER_SERVER
    363406    if(  this->networkStream->isUserMasterServer( userId ) && (*it)->checkPermission( PERMISSION_MASTER_SERVER ))
    364407      hasPermission = true;
    365     // now check PROXY_SERVER permissions
     408    else if( this->networkStream->isUserMasterServer( userId ) && this->owner != SharedNetworkData::getInstance()->getHostID()
     409             && (*it)->checkPermission( PERMISSION_OWNER ))
     410      hasPermission = true;
     411
     412    //  *              <====|  PROXY_SERVER
    366413    else if( this->networkStream->isUserProxyServerActive( userId )  && (*it)->checkPermission( PERMISSION_MASTER_SERVER )
    367414             && SharedNetworkData::getInstance()->isClient())
    368415      hasPermission = true;
    369     // check for forwarded data
     416    else if( this->networkStream->isUserProxyServerActive( userId ) && this->owner != SharedNetworkData::getInstance()->getHostID()
     417             && (*it)->checkPermission( PERMISSION_OWNER ))
     418      hasPermission = true;
     419
     420    //  CLIENT         <====|  PROXY_SERVER
     421    else if( this->networkStream->isUserProxyServerActive( userId ) && SharedNetworkData::getInstance()->isClient()
     422             && this->owner != SharedNetworkData::getInstance()->getHostID() && (*it)->checkPermission( PERMISSION_OWNER ))
     423      hasPermission = true;
     424    // MASTER_SERVER   <====|  PROXY_SERVER
     425
    370426    else if( this->networkStream->isUserProxyServerActive( userId )  && SharedNetworkData::getInstance()->isMasterServer() &&
    371427             !this->networkStream->isUserLocal( userId ))
    372428      hasPermission = true;
    373     // now check OWNER permissions
     429
     430    //  *              <====|  OWNER
    374431    else if( this->owner == userId && (*it)->checkPermission( PERMISSION_OWNER ))
    375432      hasPermission = true;
    376     // now check ALL permissions
     433
     434    //  *              <====|  ALL
    377435    else if( (*it)->checkPermission( PERMISSION_ALL ))
    378436      hasPermission = true;
    379     // SPECIAL: get write permissions if im sending to a master server that does not own this sync
    380     else if( this->networkStream->isUserMasterServer( userId ) && this->owner != SharedNetworkData::getInstance()->getHostID() && (*it)->checkPermission( PERMISSION_OWNER ))
    381       hasPermission = true;
    382     // SPECIAL: get write permissions if im sending to a proxy server that does not own this sync
    383     else if( this->networkStream->isUserProxyServerActive( userId ) && SharedNetworkData::getInstance()->isClient()
    384               && this->owner != SharedNetworkData::getInstance()->getHostID() && (*it)->checkPermission( PERMISSION_OWNER ))
    385       hasPermission = true;
     437
    386438    else
    387439      hasPermission = false;
Note: See TracChangeset for help on using the changeset viewer.