Exemple #1
0
        public void ServerThread()
        {
            var pipeServer = new NamedPipeServerStream("FTPbox Server", PipeDirection.InOut, 5);
            var threadID   = Thread.CurrentThread.ManagedThreadId;

            pipeServer.WaitForConnection();

            logger.Debug("Client connected, id: {0}", threadID);

            try
            {
                var ss = new StreamString(pipeServer);

                ss.WriteString("ftpbox");
                var args = ss.ReadString();

                var fReader = new ReadMessageSent(ss, "All done!");

/*
 *              logger.Debug(String.Format("named-pipe server thread exiting...
 *              Reading file: \n {0} \non thread [{1}] as user {2}.", args, threadID,
 *                  pipeServer.GetImpersonationUserName()));
 */

                CheckClientArgs(ReadCombinedParameters(args).ToArray());

                pipeServer.RunAsClient(fReader.Start);
            }
            catch (IOException e)
            {
                Common.LogError(e);
            }
            pipeServer.Close();
        }
Exemple #2
0
        private static void RunClient(string[] args, string param)
        {
            if (!IsServerRunning)
            {
                logger.Error("FTPbox must be running to run the client");
                return;
            }

            var pipeClient = new NamedPipeClientStream(".", "FTPbox Server", PipeDirection.InOut, PipeOptions.None, System.Security.Principal.TokenImpersonationLevel.Impersonation);

            logger.Debug("Connecting client...");
            pipeClient.Connect();

            var ss = new StreamString(pipeClient);

            if (ss.ReadString() == "ftpbox")
            {
                var p = CombineParameters(args, param);
                ss.WriteString(p);
                logger.Debug(ss.ReadString());
            }
            else
            {
                logger.Debug("Server couldnt be verified.");
            }
            pipeClient.Close();
            Thread.Sleep(4000);

            Process.GetCurrentProcess().Kill();
        }
 public ReadMessageSent(StreamString str, string data)
 {
     _data = data;
     _ss   = str;
 }