Beispiel #1
0
void RemoteManager::setRemoteServerLive(RDTreeWidgetItem *node, bool live, bool busy)
{
  RemoteHost *host = getRemoteHost(node);

  if(!host)
    return;

  host->serverRunning = live;
  host->busy = busy;

  if(host->IsLocalhost())
  {
    node->setIcon(0, QIcon());
    node->setText(1, QString());
  }
  else
  {
    QString text = live ? tr("Remote server running") : tr("No remote server");

    if(host->connected)
      text += tr(" (Active Context)");
    else if(host->versionMismatch)
      text += tr(" (Version Mismatch)");
    else if(host->busy)
      text += tr(" (Busy)");

    node->setText(1, text);

    node->setIcon(0, live ? Icons::connect() : Icons::disconnect());
  }
}
Beispiel #2
0
void RemoteManager::on_addUpdateHost_clicked()
{
  RDTreeWidgetItem *item = ui->hosts->selectedItem();
  if(item && getRemoteHost(item))
    setRunCommand();
  else
    addNewHost();
}
Beispiel #3
0
void RemoteManager::runRemoteServer(RDTreeWidgetItem *node)
{
  RemoteHost *host = getRemoteHost(node);

  if(!host)
    return;

  host->Launch();

  // now refresh this host
  refreshHost(node);
}
Beispiel #4
0
void RemoteManager::setRunCommand()
{
  RDTreeWidgetItem *item = ui->hosts->selectedItem();

  if(!item)
    return;

  RemoteHost *h = getRemoteHost(item);

  if(h)
  {
    h->runCommand = ui->runCommand->text().trimmed();
    m_Ctx.Config().Save();
  }
}
Beispiel #5
0
void RemoteManager::on_deleteHost_clicked()
{
  RDTreeWidgetItem *item = ui->hosts->selectedItem();

  if(!item)
    return;

  RemoteHost *host = getRemoteHost(item);

  int itemIdx = ui->hosts->indexOfTopLevelItem(item);

  // don't delete running instances on a host
  if(item->parent() != ui->hosts->invisibleRootItem() || itemIdx < 0 || !host)
    return;

  QString hostname = item->text(0);

  if(hostname == lit("localhost"))
    return;

  QMessageBox::StandardButton res = RDDialog::question(
      this, tr("Deleting host"), tr("Are you sure you wish to delete %1?").arg(hostname),
      RDDialog::YesNoCancel);

  if(res == QMessageBox::Cancel || res == QMessageBox::No)
    return;

  if(res == QMessageBox::Yes)
  {
    int32_t idx = m_Ctx.Config().RemoteHosts.indexOf(host);
    if(idx < 0)
      return;

    // the host will be removed in queueDelete.
    m_Ctx.Config().RemoteHosts.erase(idx);
    m_Ctx.Config().Save();

    item->clear();

    queueDelete(ui->hosts->takeTopLevelItem(itemIdx));

    ui->hosts->clearSelection();

    ui->hostname->setText(hostname);
    on_hostname_textEdited(hostname);
  }
}
Beispiel #6
0
void CGI::logCGIData(const QString& filename)
{
	// create a QFile object to do the file I/O
	QFile file(filename);

	// open the file
	if (file.open(QIODevice::WriteOnly))
	{
		// create a QTextStream object on the file
		Q3TextStream textFile(&file);

		// get the environment
		textFile << "REQUEST_METHOD=" << getenv("REQUEST_METHOD") << endl;
		textFile << "CONTENT_LENGTH=" << getenv("CONTENT_LENGTH") << endl;

		// write the query string to the file
		textFile << "QUERY_STRING=" << query_string << endl;

		// write misc. CGI environment pieces
		textFile << "AUTH_TYPE=" << getAuthType() << endl;
		textFile << "GATEWAY_INTERFACE=" << getGatewayInterface() << endl;
		textFile << "HTTP_ACCEPT=" << getHTTPAccept() << endl;
		textFile << "HTTP_ACCEPT_ENCODING=" << getHTTPAcceptEncoding() << endl;
		textFile << "HTTP_ACCEPT_LANGUAGE=" << getHTTPAcceptLanguage() << endl;
		textFile << "HTTP_CONNECTION=" << getHTTPConnection() << endl;
		textFile << "HTTP_REFERER=" << getHTTPReferer() << endl;
		textFile << "HTTP_USER_AGENT=" << getHTTPUserAgent() << endl;
		textFile << "REMOTE_HOST=" << getRemoteHost() << endl;
		textFile << "REMOTE_ADDRESS=" << getRemoteAddress() << endl;
		textFile << "REMOTE_PORT=" << getRemotePort() << endl;
		textFile << "REQUEST_URI=" << getRequestURI() << endl;
		textFile << "SCRIPT_NAME=" << getScriptName() << endl;
		textFile << "SERVER_ADMIN=" << getServerAdmin() << endl;
		textFile << "SERVER_NAME=" << getServerName() << endl;
		textFile << "SERVER_PORT=" << getServerPort() << endl;
		textFile << "SERVER_PROTOCOL=" << getServerProtocol() << endl;
		textFile << "SERVER_SOFTWARE=" << getServerSoftware() << endl;
	}

	// close the file
	file.close();

}
Beispiel #7
0
void WorldSocket::Open()
{
    cout << "Accept connection from " << getRemoteHost() << ":" << getRemotePort() << endl;

    m_closed = false;

    m_pSendHeader = new PacketHeader(0, 0);

    string serverToClient = "CONNECTION SUCCESS - SERVER TO CLIENT";

    WorldPacket data(MSG_CONNECTION);
    data << serverToClient;

    SendPacket(data);

    data.Initialize(SMSG_AUTH_CHALLENGE, 4);
    data << 0;

    SendPacket(data);
}
Beispiel #8
0
void WorldSocket::ProcessIncomingPacket(WorldPacket *recvPacket)
{
    uint16 msgCode = recvPacket->getMsgCode();

    switch (msgCode)
    {
        case MSG_CONNECTION:
        {
            HandleConnection(*recvPacket);
            break;
        }
        case MSG_PING:
        {
            HandlePing(*recvPacket);
            break;
        }
        case CMSG_AUTH_SESSION:
        {
            if (m_pSession)
            {
                cout << "Client try to auth again!" << endl;
                return;
            }
            HandleAuthSession(*recvPacket);
            break;
        }
        default:
        {
            if (m_pSession)
            {
                const MsgCodeHandler msghandler = msgCodeTable[msgCode];

                (m_pSession->*msghandler.handler)(*recvPacket);
            }
            else
                cout << "ERROR: Client not authed! Remote Host: " << getRemoteHost() << ", MsgCode: "<< msgCode << "(" << LookupMsgCodeName(msgCode) << ")" << endl;
        }
    }

    SAFE_DELETE(recvPacket);
}
Beispiel #9
0
void RemoteManager::on_hosts_itemSelectionChanged()
{
  ui->addUpdateHost->setText(tr("Add"));
  ui->addUpdateHost->setEnabled(true);
  ui->deleteHost->setEnabled(false);
  ui->refreshOne->setEnabled(false);
  ui->hostname->setEnabled(true);
  ui->runCommand->setEnabled(true);

  RDTreeWidgetItem *item = ui->hosts->selectedItem();

  RemoteHost *host = item ? getRemoteHost(item) : NULL;

  ui->runCommand->setText(QString());

  if(host)
  {
    if(ui->refreshAll->isEnabled())
      ui->refreshOne->setEnabled(true);

    ui->runCommand->setText(host->runCommand);
    ui->hostname->setText(host->Name());

    ui->addUpdateHost->setText(tr("Update"));

    if(host->IsLocalhost() || host->IsADB())
    {
      // localhost and android hosts cannot be updated or have their run command changed
      ui->addUpdateHost->setEnabled(false);
      ui->runCommand->setEnabled(false);
    }
    else
    {
      // any other host can be deleted
      ui->deleteHost->setEnabled(true);
    }
  }

  updateConnectButton();
}
Beispiel #10
0
void RemoteManager::updateConnectButton()
{
  RDTreeWidgetItem *item = ui->hosts->selectedItem();

  if(item)
  {
    ui->connect->setEnabled(true);
    ui->connect->setText(tr("Connect to App"));

    RemoteHost *host = getRemoteHost(item);

    if(host)
    {
      if(host->IsLocalhost())
      {
        ui->connect->setText(tr("Run Server"));
        ui->connect->setEnabled(false);
      }
      else if(host->serverRunning)
      {
        ui->connect->setText(tr("Shutdown"));

        if(host->busy && !host->connected)
          ui->connect->setEnabled(false);
      }
      else
      {
        ui->connect->setText(tr("Run Server"));

        if(host->runCommand.isEmpty())
          ui->connect->setEnabled(false);
      }
    }
  }
  else
  {
    ui->connect->setEnabled(false);
  }
}
//----------------------------------------------------------------------
// getRemoteHost -- retrieve remote host's address
//----------------------------------------------------------------------    
void Condor_Auth_Kerberos :: setRemoteAddress()
{
    krb5_error_code  code;
    krb5_address  ** localAddr  = NULL;
    krb5_address  ** remoteAddr = NULL;
    
    // Get remote host's address first
    
    if ((code = krb5_auth_con_getaddrs(krb_context_, 
                                      auth_context_, 
                                      localAddr, 
                                      remoteAddr))) {
        goto error;
    }
    
    if (remoteAddr) {
        struct in_addr in;
        memcpy(&(in.s_addr), (*remoteAddr)[0].contents, sizeof(in_addr));
        setRemoteHost(inet_ntoa(in));
    }
    
    if (localAddr) {
        krb5_free_addresses(krb_context_, localAddr);
    }
    
    if (remoteAddr) {
        krb5_free_addresses(krb_context_, remoteAddr);
    }
    
    dprintf(D_SECURITY, "Remote host is %s\n", getRemoteHost());

    return;

 error:
    dprintf( D_ALWAYS, "KERBEROS: Unable to obtain remote address: %s\n",
			 error_message(code) );
}
Beispiel #12
0
void RemoteManager::on_connect_clicked()
{
  RDTreeWidgetItem *node = ui->hosts->selectedItem();

  if(!node)
    return;

  RemoteConnect connect = getRemoteConnect(node);
  RemoteHost *host = getRemoteHost(node);

  if(connect.ident > 0)
  {
    connectToApp(node);
  }
  else if(host)
  {
    if(host->serverRunning)
    {
      QMessageBox::StandardButton res = RDDialog::question(
          this, tr("Remote server shutdown"),
          tr("Are you sure you wish to shut down running remote server on %1?").arg(host->Name()),
          RDDialog::YesNoCancel);

      if(res == QMessageBox::Cancel || res == QMessageBox::No)
        return;

      // shut down
      if(host->connected)
      {
        m_Ctx.Replay().ShutdownServer();
        setRemoteServerLive(node, false, false);
      }
      else
      {
        IRemoteServer *server = NULL;
        ReplayStatus status =
            RENDERDOC_CreateRemoteServerConnection(host->hostname.c_str(), 0, &server);
        if(server)
          server->ShutdownServerAndConnection();
        setRemoteServerLive(node, false, false);

        if(status != ReplayStatus::Succeeded)
          RDDialog::critical(this, tr("Shutdown error"),
                             tr("Error shutting down remote server: %1").arg(ToQStr(status)));
      }

      updateConnectButton();
    }
    else
    {
      // try to run
      ui->refreshOne->setEnabled(false);
      ui->refreshAll->setEnabled(false);

      m_Lookups.release();

      LambdaThread *th = new LambdaThread([this, node]() { runRemoteServer(node); });
      th->selfDelete(true);
      th->start();

      updateLookupsStatus();
    }
  }
}
Beispiel #13
0
void WorldSocket::HandleReceiveData()
{
    if (m_closed || !m_pSHSocket || m_pSHSocket->disconnected() || m_pSHSocket->nextReadSize() <= 0)
        return;

    try
    {
        uint16 readSize = m_pSHSocket->nextReadSize();
        uint16 readPos  = 0;
        m_recvDataHolder.resize(readSize);
        m_pSHSocket->Read(&m_recvDataHolder[0], readSize);

        cout << "Read From " << getRemoteHost() << ":" << getRemotePort() << ", Data Size: " << readSize << endl;

        while (readSize)
        {
            if (m_missedDataSize)
            {
                uint16 missedSize = m_missedDataSize >= readSize ? readSize : m_missedDataSize;
                m_pRecvPacket->Append(&m_recvDataHolder[0], missedSize);
                readSize         -= missedSize;
                m_missedDataSize -= missedSize;
                readPos          += missedSize;

                if (!m_missedDataSize)
                {
                    ProcessIncomingPacket(m_pRecvPacket);
                    m_pRecvPacket = NULL;
                }
            }
            else
            {
                if (readSize < 4)
                    throw SHException(SHException::SH_EXCEPTION_OUT_OF_RANGE, "Missed packet header info!");

                uint32 size    = ((m_recvDataHolder[readPos++] & 0xFF) << 8) | (m_recvDataHolder[readPos++] & 0xFF);
                uint16 msgCode = ((m_recvDataHolder[readPos++] & 0xFF) << 8) | (m_recvDataHolder[readPos++] & 0xFF);

                readSize -= 4;

                m_pRecvPacket = new WorldPacket(msgCode, size);

                if (size > readSize)
                {
                    m_missedDataSize  = size - readSize;
                    if (readSize)
                    {
                        m_pRecvPacket->Append(&m_recvDataHolder[readPos], readSize);
                        readPos  += readSize;
                        readSize -= readSize;
                    }
                }
                else
                {
                    m_pRecvPacket->Append(&m_recvDataHolder[readPos], size);
                    readPos  += size;
                    readSize -= size;

                    ProcessIncomingPacket(m_pRecvPacket);
                    m_pRecvPacket = NULL;
                }
            }
        }

        m_recvDataHolder.clear();
    }
    catch (SHException e)
    {
        m_recvDataHolder.clear();

        cout << e.what() << endl;
    }
}
Beispiel #14
0
void RemoteManager::refreshHost(RDTreeWidgetItem *node)
{
  RemoteHost *host = getRemoteHost(node);

  if(!host)
    return;

  // this function looks up the remote connections and for each one open
  // queries it for the API, target (usually executable name) and if any user is already connected
  LambdaThread *th = new LambdaThread([this, node, host]() {
    QByteArray username = GetSystemUsername().toUtf8();

    host->CheckStatus();

    GUIInvoke::call(
        [this, node, host]() { setRemoteServerLive(node, host->serverRunning, host->busy); });

    uint32_t nextIdent = 0;

    for(;;)
    {
      // just a sanity check to make sure we don't hit some unexpected case and infinite loop
      uint32_t prevIdent = nextIdent;

      nextIdent = RENDERDOC_EnumerateRemoteTargets(host->hostname.c_str(), nextIdent);

      if(nextIdent == 0 || prevIdent >= nextIdent)
        break;

      ITargetControl *conn =
          RENDERDOC_CreateTargetControl(host->hostname.c_str(), nextIdent, username.data(), false);

      if(conn)
      {
        QString target = QString::fromUtf8(conn->GetTarget());
        QString api = QString::fromUtf8(conn->GetAPI());
        QString busy = QString::fromUtf8(conn->GetBusyClient());

        QString running;

        if(!busy.isEmpty())
          running = tr("Running %1, %2 is connected").arg(api).arg(busy);
        else
          running = tr("Running %1").arg(api);

        RemoteConnect tag(host->hostname, host->Name(), nextIdent);

        GUIInvoke::call([this, node, target, running, tag]() {
          RDTreeWidgetItem *child = new RDTreeWidgetItem({target, running});
          setRemoteConnect(child, tag);
          node->addChild(child);
          ui->hosts->expandItem(node);
        });

        conn->Shutdown();
      }
    }

    GUIInvoke::call([node]() { node->setItalic(false); });

    m_Lookups.acquire();

    GUIInvoke::call([this]() { updateStatus(); });
  });
  th->selfDelete(true);
  th->start();
}
int Condor_Auth_Kerberos :: authenticate_server_kerberos()
{
    krb5_error_code   code;
    krb5_flags        flags = 0;
    krb5_data         request, reply;
    priv_state        priv;
    krb5_keytab       keytab = 0;
    int               message, rc = FALSE;
    krb5_ticket *     ticket = NULL;

    request.data = 0;
    reply.data   = 0;
    
    keytabName_ = param(STR_KERBEROS_SERVER_KEYTAB);

    //------------------------------------------
    // Getting keytab info
    //------------------------------------------
    if (keytabName_) {
        code = krb5_kt_resolve(krb_context_, keytabName_, &keytab);
    }
    else {
        code = krb5_kt_default(krb_context_, &keytab);
    }
    
    if (code) {
        dprintf( D_ALWAYS, "1: Kerberos server authentication error:%s\n",
				 error_message(code) );
        goto error;
    }
    
    //------------------------------------------
    // Get te KRB_AP_REQ message
    //------------------------------------------
    if(read_request(&request) == FALSE) {
        dprintf( D_ALWAYS, "KERBEROS: Server is unable to read request\n" );
        goto error;
    }
    
	dprintf( D_SECURITY, "Reading kerberos request object (krb5_rd_req)\n");

	dprintf_krb5_principal( D_FULLDEBUG, "KERBEROS: krb_principal_ is '%s'\n", krb_principal_);

 priv = set_root_priv();   // Get the old privilige
    
    if ((code = krb5_rd_req(krb_context_,
                           &auth_context_,
                           &request,
                           //krb_principal_,
						   NULL,
                           keytab,
                           &flags,
                           &ticket))) {
        set_priv(priv);   // Reset
        dprintf( D_ALWAYS, "2: Kerberos server authentication error:%s\n",
				 error_message(code) );
        goto error;
    }
    set_priv(priv);   // Reset
    
	dprintf ( D_FULLDEBUG, "KERBEROS: krb5_rd_req done.\n");

    //------------------------------------------
    // See if mutual authentication is required
    //------------------------------------------
    if (flags & AP_OPTS_MUTUAL_REQUIRED) {
        if ((code = krb5_mk_rep(krb_context_, auth_context_, &reply))) {
            dprintf( D_ALWAYS, "3: Kerberos server authentication error:%s\n",
					 error_message(code) );
            goto error;
        }

        mySock_->encode();
        message = KERBEROS_MUTUAL;
        if (!mySock_->code(message) || !mySock_->end_of_message()) {
            goto error;
        }

        // send the message
        if (send_request(&reply) != KERBEROS_GRANT) {
            goto cleanup;
        }
    }
    
    //------------------------------------------
    // extract client addresses
    //------------------------------------------
    if (ticket->enc_part2->caddrs) {
        struct in_addr in;
        memcpy(&(in.s_addr), ticket->enc_part2->caddrs[0]->contents, sizeof(in_addr));
        
        setRemoteHost(inet_ntoa(in));
    
        dprintf(D_SECURITY, "Client address is %s\n", getRemoteHost());
    }    

    // First, map the name, this has to take place before receive_tgt_creds!
    if (!map_kerberos_name(&(ticket->enc_part2->client))) {
        dprintf(D_SECURITY, "Unable to map Kerberos name\n");
        goto error;
    }

    // copy the session key
    if ((code = krb5_copy_keyblock(krb_context_, 
                                  ticket->enc_part2->session, 
                                  &sessionKey_))){
        dprintf(D_SECURITY, "4: Kerberos server authentication error:%s\n", error_message(code));
        goto error;
    }
    
    // Next, see if we need client to forward the credential as well
    if (receive_tgt_creds(ticket)) {
        goto cleanup;
    }
    
    //------------------------------------------
    // We are now authenticated!
    //------------------------------------------
    dprintf(D_SECURITY, "User %s is now authenticated!\n", getRemoteUser());
    
    rc = TRUE;
    
    goto cleanup;
    
 error:
    message = KERBEROS_DENY;
    
    mySock_->encode();
    if ((!mySock_->code(message)) || (!mySock_->end_of_message())) {
        dprintf( D_ALWAYS, "KERBEROS: Failed to send response message!\n" );
    }
    
 cleanup:
    
    //------------------------------------------
    // Free up some stuff
    //------------------------------------------
    if (ticket) {
        krb5_free_ticket(krb_context_, ticket);
    }
    
    if (keytab) {
        krb5_kt_close(krb_context_, keytab);
    }
    //------------------------------------------
    // Free it for now, in the future, we might 
    // need this for future secure transctions.
    //------------------------------------------
    if (request.data) {
        free(request.data);
    }
    
    if (reply.data) {
        free(reply.data);
    }

    return rc;
}
Beispiel #16
0
int Cconfigurator::saveConfigAs(QByteArray path, QByteArray filename)
{
  unsigned int i;

  // try QSettings
  QSettings conf(path + filename, QSettings::IniFormat);

  conf.beginGroup("General");
  conf.setValue("mapFile", getBaseFile());
  conf.setValue("windowRect", renderer_window->geometry() );
  conf.setValue("alwaysOnTop", getAlwaysOnTop() );
  conf.setValue("startupMode", getStartupMode() );
  conf.endGroup();

  conf.beginGroup("Networking");
  conf.setValue("localPort", getLocalPort() );
  conf.setValue("remoteHost", getRemoteHost() );
  conf.setValue("remotePort", getRemotePort() );
  conf.endGroup();

  conf.beginGroup("OpenGL");
  conf.setValue("texturesVisibility", getTextureVisibility() );
  conf.setValue("detailsVisibility", getDetailsVisibility() );
  conf.setValue("visibleLayers", getVisibleLayers() );
  conf.setValue("showNotes", getShowNotesRenderer() );
  conf.setValue("showRegions", getShowRegionsInfo() );
  conf.setValue("displayRegions", getDisplayRegionsRenderer() );
  conf.setValue("multisampling", getMultisampling() );
  conf.setValue("selectOnAnyLayer", getSelectOAnyLayer());
  conf.setValue("angleX", (double) angleX );
  conf.setValue("angleY", (double) angleY );
  conf.setValue("angleZ", (double) angleZ );
  conf.setValue("userX", (double) userX );
  conf.setValue("userY", (double) userY );
  conf.setValue("userZ", (double) userZ );
  conf.setValue("noteColor", getNoteColor() );
  conf.setValue("drawPrespam", getDrawPrespam());

  conf.endGroup();

  conf.beginGroup("Engine");
  conf.setValue("checkExits", getExitsCheck() );
  conf.setValue("checkTerrain", getTerrainCheck() );
  conf.setValue("briefmode", getBriefMode() );
  conf.setValue("autoMerge", getAutomerge() );
  conf.setValue("angryLinker", getAngrylinker() );
  conf.setValue("dualLinker", getDuallinker() );
  conf.setValue("autoRefresh", getAutorefresh() );
  conf.setValue("roomNameQuote", getNameQuote() );
  conf.setValue("descQuote", getDescQuote() );
  conf.setValue("mactionUsesPrespam", getMactionUsesPrespam());
  conf.setValue("prespamTTL", getPrespamTTL());
  conf.endGroup();

  conf.beginGroup("Patterns");
  conf.setValue("exitsPattern", getExitsPattern());
  conf.setValue("spellsEffectPattern", spells_pattern);
  conf.setValue( "scorePattern", getScorePattern() );
  conf.setValue( "scorePatternShort", getShortScorePattern() );
  conf.endGroup();



  conf.beginGroup("GroupManager");
  conf.setValue("remoteHost", getGroupManagerHost() );
  conf.setValue("remotePort", getGroupManagerRemotePort() );
  conf.setValue("localServerPort", getGroupManagerLocalPort() );
  conf.setValue("charName", getGroupManagerCharName() );
  conf.setValue("charColor", getGroupManagerColor().name() );
  conf.setValue("showSelf", getGroupManagerShowSelf() );
  conf.setValue("notifyArm", getGroupManagerNotifyArmour() );
  conf.setValue("notifySanc", getGroupManagerNotifySanc() );
  conf.setValue("notifyBash", getGroupManagerNotifyBash() );
  conf.setValue("showGroupManager", getGroupManagerShowManager() );

  conf.setValue("windowRect", renderer_window->getGroupManagerRect() );

  conf.endGroup();


  conf.beginWriteArray("Spells");
  for (unsigned int i = 0; i < spells.size(); ++i) {
	  conf.setArrayIndex(i);
	  conf.setValue("addon", spells[i].addon);
	  conf.setValue("name", spells[i].name);
	  conf.setValue("upMessage", spells[i].up_mes);
	  conf.setValue("refreshMessage", spells[i].refresh_mes);
	  conf.setValue("downMessage", spells[i].down_mes);
  }
  conf.endArray();



  conf.beginGroup("Movement tracking");
  conf.beginWriteArray("Cancel Patterns");
  for (int i = 0; i < moveCancelPatterns.size(); ++i) {
	  conf.setArrayIndex(i);
	  conf.setValue("pattern", moveCancelPatterns.at(i));
  }
  conf.endArray();
  conf.beginWriteArray("Force Patterns");
  for (int i = 0; i < moveForcePatterns.size(); ++i) {
	  conf.setArrayIndex(i);
	  conf.setValue("pattern", moveForcePatterns.at(i));
  }
  conf.endArray();
  conf.endGroup();


  conf.beginWriteArray("Debug Settings");
  i = 0;
  while (debug_data[i].name) {
	  conf.setArrayIndex(i);
	  conf.setValue("name", debug_data[i].name);
	  conf.setValue("state", debug_data[i].state);

      i++;
  }
  conf.endArray();

  configFile = filename;
  configPath = path;

  setConfigModified(false);
  return true;
}
Beispiel #17
0
void AtDrv::startClient(uint8_t sock, const char *host, uint16_t port, uint8_t protMode)
{
	// if we enable CHECK_TCP_STATE feature, always call reConnect(), or we won't get right
	// tcp port status, since we disable tcp auto reconnect.
#ifndef CHECK_TCP_STATE
	bool needReConn = false;
#else
	bool needReConn = true;
#endif
	int curMode;
	char curHostBuf[MAX_HOST_NAME_BUF_SIZE];
	uint8_t curProtocol;
	uint16_t curPort;
	uint16_t curLocalPort;
	uint32_t curTimeout;
	bool curTcpAuto;

	// clear uart buffer first
	stopClient(sock);

	if(!isAtMode()) {
		if(!switchToAtMode()) {
			INFO1("Can't switch to at mode");
			goto end;
		}
	}
	
	if(!getMode(sock, &curMode) || curMode != MODE_CLIENT) {
		needReConn = true;
		INFO1("curMode != MODE_CLIENT");
		if(!setMode(sock, MODE_CLIENT)) {
			INFO1("Can't set mode");
			goto end;			
		}
	}

	if(!getRemoteHost(sock, curHostBuf) || (strcmp(curHostBuf,  host) != 0)) {
		needReConn = true;
		INFO1("curHostBuf != host");
		if(!setRemoteHost(sock, host)) {
			INFO1("Can't set host");
			goto end;	
		}
	}
	
	if(!getProtocol(sock, &curProtocol) || curProtocol != protMode) {
		needReConn = true;
		INFO1("curProtocol != protMode");
		if(!setProtocol(sock, protMode)) {
			INFO1("Can't set protocol");
			goto end;	
		}
	}
	
	if(!getRemotePort(sock, &curPort) || curPort != port) {
		needReConn = true;
		INFO1("curPort != port");
		if(!setPort(sock, port)) {
			INFO1("Can't set port");
			goto end;	
		}
	}
	
	if(!getTcpAuto(sock, &curTcpAuto) || curTcpAuto != false) {
		needReConn = true;
		INFO1("curTcpAuto != false");	
		if(!setTcpAuto(sock, false)) {
			INFO1("Can't set tcp auto");
			goto end;	
		}
	}	
	
	if(!getLocalPort(sock, &curLocalPort) || curLocalPort != localSockPort[sock]) {
		needReConn = true;
		INFO1("curLocalPort != port");
		if(!setLocalPort(sock, localSockPort[sock])) {
			INFO1("Can't set port");
			goto end;	
		}
	}	
	
	if(needReConn) {
		if(!reConnect()) {
			INFO1("Can't reconnect");
			goto end;	
		}
	}	

	sockPort[sock] = localSockPort[sock];
	sockConnected[sock] = true;

end:
	return;
}
Beispiel #18
0
void deleteItemAndHost(RDTreeWidgetItem *item)
{
  delete getRemoteHost(item);
  delete item;
}
Beispiel #19
0
bool RemoteManager::isRemoteServerLive(RDTreeWidgetItem *node)
{
  RemoteHost *host = getRemoteHost(node);
  return host && host->serverRunning;
}