Beispiel #1
0
void show_login_prompt()
{     
	write_string("************************************************************\n");
	write_string("*       $$      Open Source Switch Solution     $$         *\n");
	write_string("************************************************************");
	process_login ();
}
Beispiel #2
0
bool cookie_auth::handle_request(http::request_ptr& http_request_ptr, tcp::connection_ptr& tcp_conn)
{
    if (process_login(http_request_ptr,tcp_conn)) {
        return false; // we processed login/logout request, no future processing for this request permitted
    }

    if (!need_authentication(http_request_ptr)) {
        return true; // this request does not require authentication
    }

    // check if it is redirection page.. If yes, then do not test its credentials ( as used for login)
    if (!m_redirect.empty() && m_redirect==http_request_ptr->get_resource()) {
        return true; // this request does not require authentication
    }
    
    // check cache for expiration
    boost::posix_time::ptime time_now(boost::posix_time::second_clock::universal_time());
    expire_cache(time_now);

    // if we are here, we need to check if access authorized...
    const std::string auth_cookie(http_request_ptr->get_cookie(AUTH_COOKIE_NAME));
    if (! auth_cookie.empty()) {
        // check if this cookie is in user cache
        boost::mutex::scoped_lock cache_lock(m_cache_mutex);
        user_cache_type::iterator user_cache_itr=m_user_cache.find(auth_cookie);
        if (user_cache_itr != m_user_cache.end()) {
            // we find those credential in our cache...
            // we can approve authorization now!
            http_request_ptr->set_user(user_cache_itr->second.second);
            // and update cache timeout
            user_cache_itr->second.first = time_now;
            return true;
        }
    }

    // user not found
    handle_unauthorized(http_request_ptr,tcp_conn);
    return false;
}
Beispiel #3
0
/**
 * This internal method process packets from a pointer to a struct and
 * a packet type
 * 
 * @remarks Scope: private
 * 
 * @param player Player this method affects
 * @param pkttype Type of packet that 'packet' points to
 * @param packet Pointer to struct of packet type 'packetid'
 */
void
process_packet(struct PL_entry *player, uint8_t pkttype, void * packet)
{
  switch(pkttype)
  {
    case PID_LOGIN:
    {
      process_login(player, ((struct packet_login*) packet)->username, ((struct packet_login*) packet)->version);
      return;
    }
    case PID_HANDSHAKE:
    {
      process_handshake(player,((struct packet_handshake*) packet)->username);
      return;
    }
    case PID_CHAT:
    {
      process_chat(player,((struct packet_chat*) packet)->message);
      return;
    }
    case PID_PLAYERPOS:
    {
      pthread_rwlock_wrlock(&player->position.rwlock);
      
      int oldx = player->position.x/16, oldz = player->position.z/16;
      
      /* Flip bits */
      player->position.x = Cswapd(((struct packet_playerpos*) packet)->x);
      player->position.y = Cswapd(((struct packet_playerpos*) packet)->y);
      player->position.z = Cswapd(((struct packet_playerpos*) packet)->z);
      
      int newx = player->position.x/16, newz = player->position.z/16;
      
      if (oldx != newx || oldz != newz)
	send_chunk_radius(player, player->position.x, player->position.z, 
			  RADIUS);
      
      pthread_rwlock_unlock(&player->position.rwlock);
      
      return;
    }
    case PID_PLAYERLOOK:
    {
      pthread_rwlock_wrlock(&player->position.rwlock);
      /* Flip bits */
      player->position.yaw = Cswapf(((struct packet_look*) packet)->yaw);
      player->position.pitch = Cswapf(((struct packet_look*) packet)->pitch);
      pthread_rwlock_unlock(&player->position.rwlock);
      return;
    }
    case PID_PLAYERMOVELOOK:
    {
      pthread_rwlock_wrlock(&player->position.rwlock);
      
      int oldx = player->position.x/16, oldz = player->position.z/16;
      
      /* Flip bits */
      player->position.x = Cswapd(((struct packet_movelook*) packet)->x);
      player->position.y = Cswapd(((struct packet_movelook*) packet)->y);
      player->position.z = Cswapd(((struct packet_movelook*) packet)->z);
      player->position.yaw = Cswapf(((struct packet_movelook*) packet)->yaw);
      player->position.pitch = Cswapf(((struct packet_movelook*) packet)->pitch);
      
      int newx = player->position.x/16, newz = player->position.z/16;
      
      if (oldx != newx || oldz != newz)
	send_chunk_radius(player, player->position.x, player->position.z, 
			  RADIUS);

      pthread_rwlock_unlock(&player->position.rwlock);
      
      return;
    }
    case PID_PLAYERDIG:
    {
	switch(((struct packet_dig*) packet)->status)
	{
		case STATUS_STARTED:
		{
			LOG(LOG_DEBUG, "block dig STARTED");
			break;
		}
		case STATUS_DIGGING:
		{
			LOG(LOG_DEBUG, "block dig DIGGING");
			break;
		}
		case STATUS_STOPPED:
		{
			LOG(LOG_DEBUG, "block dig STOPPED");
			break;
		}
		case STATUS_BROKEN:
		{
			LOG(LOG_DEBUG, "block dig BROKEN");
			break;
		}
		case STATUS_ITEMDROP:
		{
			LOG(LOG_DEBUG, "block dig ITEMDROP");
			break;
		}
	}
	return;
    }
    case PID_DISCONNECT:
    {
      deferLogout(player);
      return;
    }
    default:
    {
      return; //Do nothing
    }
  }
  return;
}
        std::string dbname;
        config >> host >> port >> dbname;
        config.close();
        HOST = QString(host.c_str());
        PORT = port;
        DBNAME = QString(dbname.c_str());
    }
    db_login=QString("");
    db=QSqlDatabase::addDatabase("QPSQL");
    db.setHostName(HOST);
    db.setPort(PORT);
    db.setDatabaseName(DBNAME);
    db.setConnectOptions("connect_timeout=2");
    db_login=QString("");
    ls = new login_screen(db);
    connect(ls,SIGNAL(loginSucceed(QString,QString)),this,SLOT(process_login(QString,QString)));

    mainwin = new MainWindow;

    connect(mainwin,SIGNAL(close_main_window()),this,SLOT(hide_main_window()));

}

windows_manager::~windows_manager(){
    if(ls) delete ls;
    if(menu) delete menu;
    if(mainwin) delete mainwin;
}

void windows_manager::show_login(){
    ls->show();
Beispiel #5
0
int process_logout()
{
	return process_login ();
}