示例#1
0
        private RaSofOperation StartRemoteDesktop(RaSofOperation operation)
        {
            Logger.Info("Starting remote desktop.");

            try
            {
                operation.Api = RaUrn.RdResults + "|||" + HttpMethods.Post;
                //operation.RequestMethod = HttpMethods.Post;

                bool tightRunning = false;

                string localPort = Tunnel.GetAvailablePort();

                if (localPort != String.Empty)
                {
                    RemoteDesktop.StopService();
                    tightRunning = RemoteDesktop.StartService(localPort.ToString());
                }
                else
                {
                    operation.Success = false;
                    operation.Error   = "No local port available. How did this happen?!";
                }

                if (tightRunning)
                {
                    if (operation.TunnelNeeded)
                    {
                        tunnelCreated = Tunnel.CreateReverseTunnel(
                            localPort,
                            operation.HostPort,
                            Settings.GetServerAddress,
                            operation.SSHPort
                            );

                        if (!tunnelCreated)
                        {
                            operation.Success = false;
                            operation.Error   = "Could not create tunnel. Please see agent log for more details.";
                            RemoteDesktop.StopService();
                        }
                    }
                }
                else
                {
                    operation.Success = false;
                    operation.Error   = "Could not start VNC server. Please see agent log for more details.";
                }

                operation.Success = tightRunning && tunnelCreated;
            }
            catch (Exception e)
            {
                string msg = "Unable to start remote desktop.";
                operation.Success = false;
                operation.Error   = String.Format("{0}. {1}", msg, e.ToString());

                Logger.Error(msg);
                Logger.Exception(e);
            }

            operation.RawResult = RaFormatter.StartRemoteResult(operation);

            Logger.Info("Done.");
            return(operation);
        }
示例#2
0
 public RAPlugin()
 {
     Logger.Log("Loaded RA Plugin.", LogLevel.Info);
     Tunnel.CreateKeyPair();
     RemoteDesktop.InstallTightService();
 }