public void Telnet1() { TelnetParameter p1 = new TelnetParameter(); p1.SetTerminalName("TERMINAL"); p1.Port = 80; p1.Destination = "DESTINATION"; StructuredText t = _telnetSerializer.Serialize(p1); TelnetParameter p2 = (TelnetParameter)_telnetSerializer.Deserialize(t); Assert.AreEqual(80, p2.Port); Assert.AreEqual("TERMINAL", p2.TerminalType); Assert.AreEqual("DESTINATION", p2.Destination); }
public ITerminalConnection Connect() { lock (_lockObject) { if (_localPort == 0) PrepareListener(); } string cygtermPath = GetCygtermPath(); if (cygtermPath == null) throw new LocalShellUtilException(PEnv.Strings.GetString("Message.CygwinUtil.CygtermExeNotFound")); ITerminalParameter term = (ITerminalParameter)_param.GetAdapter(typeof(ITerminalParameter)); string args = String.Format("-p {0} -v HOME=\"{1}\" -v TERM=\"{2}\" -s \"{3}\"", _localPort, _param.Home, term.TerminalType, _param.ShellName); ProcessStartInfo psi = new ProcessStartInfo(cygtermPath, args); PrepareEnv(psi, _param); psi.CreateNoWindow = true; psi.ErrorDialog = true; psi.UseShellExecute = false; psi.WindowStyle = ProcessWindowStyle.Hidden; try { _process = Process.Start(psi); } catch (System.ComponentModel.Win32Exception ex) { throw new LocalShellUtilException(PEnv.Strings.GetString("Message.CygwinUtil.FailedToRunCygterm") + ": " + cygtermPath, ex); } while (true) { List<Socket> chk = new List<Socket>(); chk.Add(_listener); Socket.Select(chk, null, null, 100); if (_interrupted) return null; if (chk.Count > 0) break; } Socket sock = _listener.Accept(); if (_interrupted) return null; TelnetNegotiator neg = new TelnetNegotiator(term.TerminalType, term.InitialWidth, term.InitialHeight); TelnetParameter shellparam = new TelnetParameter(); shellparam.Destination = "localhost"; shellparam.SetTerminalName(term.TerminalType); shellparam.SetTerminalSize(term.InitialWidth, term.InitialHeight); TelnetTerminalConnection r = new TelnetTerminalConnection(shellparam, neg, new PlainPoderosaSocket(sock)); r.Destination = (ITerminalParameter)_param.GetAdapter(typeof(ITerminalParameter)); //TelnetでなくオリジナルのCygwinParamで上書き r.UsingSocks = false; return r; }
public ITerminalConnection Connect() { lock (_lockObject) { if (_localPort == 0) { PrepareListener(); } } //string cygtermPath = "cygterm\\"+(IsCygwin(_param)? "cygterm.exe" : "sfuterm.exe"); //string connectionName = IsCygwin(_param)? "Cygwin" : "SFU"; string cygtermPath = String.Format("{0}cygterm\\cygterm.exe", ProtocolUtil.ProtocolsPluginHomeDir); //string connectionName = "Cygwin"; ITerminalParameter term = (ITerminalParameter)_param.GetAdapter(typeof(ITerminalParameter)); //mwg: Construct args for cygterm.exe System.Text.StringBuilder args = new System.Text.StringBuilder(); args.AppendFormat(" -p {0}", _localPort); args.AppendFormat(" -v HOME=\"{0}\"", _param.Home); args.AppendFormat(" -v TERM=\"{0}\"", term.TerminalType); args.AppendFormat(" -s \"{0}\"", _param.ShellName); args.AppendFormat(" -v ROSATERM=\"{0}\"", "rosaterm"); ProcessStartInfo psi = new ProcessStartInfo(cygtermPath, args.ToString()); PrepareEnv(psi, _param); psi.CreateNoWindow = true; psi.ErrorDialog = true; psi.UseShellExecute = false; psi.WindowStyle = ProcessWindowStyle.Hidden; //mwg: Set working directory/mwg string wdir = _param.Home; if (wdir.StartsWith("/")) { wdir = wdir.Substring(1); } wdir = System.IO.Path.Combine(CygwinUtil.GuessRootDirectory(_param.CygwinDir), wdir); psi.WorkingDirectory = wdir; try { _process = Process.Start(psi); }catch (System.ComponentModel.Win32Exception ex) { throw new LocalShellUtilException(PEnv.Strings.GetString("Message.CygwinUtil.FailedToRunCygterm") + ": " + cygtermPath, ex); } while (true) { List <Socket> chk = new List <Socket>(); chk.Add(_listener); Socket.Select(chk, null, null, 100); if (_interrupted) { return(null); } if (chk.Count > 0) { break; } } Socket sock = _listener.Accept(); if (_interrupted) { return(null); } TelnetNegotiator neg = new TelnetNegotiator(term.TerminalType, term.InitialWidth, term.InitialHeight); TelnetParameter shellparam = new TelnetParameter(); shellparam.Destination = "localhost"; shellparam.SetTerminalName(term.TerminalType); shellparam.SetTerminalSize(term.InitialWidth, term.InitialHeight); TelnetTerminalConnection r = new TelnetTerminalConnection(shellparam, neg, new PlainPoderosaSocket(sock)); r.Destination = (ITerminalParameter)_param.GetAdapter(typeof(ITerminalParameter)); //TelnetでなくオリジナルのCygwinParamで上書き r.UsingSocks = false; return(r); }
public ITerminalConnection Connect() { lock (_lockObject) { if (_localPort == 0) { PrepareListener(); } } string cygtermPath = GetCygtermPath(); if (cygtermPath == null) { throw new LocalShellUtilException(PEnv.Strings.GetString("Message.CygwinUtil.CygtermExeNotFound")); } ITerminalParameter term = (ITerminalParameter)_param.GetAdapter(typeof(ITerminalParameter)); string args = String.Format("-p {0} -v HOME=\"{1}\" -v TERM=\"{2}\" -s \"{3}\"", _localPort, _param.Home, term.TerminalType, _param.ShellName); ProcessStartInfo psi = new ProcessStartInfo(cygtermPath, args); PrepareEnv(psi, _param); psi.CreateNoWindow = true; psi.ErrorDialog = true; psi.UseShellExecute = false; psi.WindowStyle = ProcessWindowStyle.Hidden; try { _process = Process.Start(psi); } catch (System.ComponentModel.Win32Exception ex) { throw new LocalShellUtilException(PEnv.Strings.GetString("Message.CygwinUtil.FailedToRunCygterm") + ": " + cygtermPath, ex); } while (true) { List <Socket> chk = new List <Socket>(); chk.Add(_listener); Socket.Select(chk, null, null, 100); if (_interrupted) { return(null); } if (chk.Count > 0) { break; } } Socket sock = _listener.Accept(); if (_interrupted) { return(null); } TelnetNegotiator neg = new TelnetNegotiator(term.TerminalType, term.InitialWidth, term.InitialHeight); TelnetParameter shellparam = new TelnetParameter(); shellparam.Destination = "localhost"; shellparam.SetTerminalName(term.TerminalType); shellparam.SetTerminalSize(term.InitialWidth, term.InitialHeight); TelnetTerminalConnection r = new TelnetTerminalConnection(shellparam, neg, new PlainPoderosaSocket(sock)); r.Destination = (ITerminalParameter)_param.GetAdapter(typeof(ITerminalParameter)); //TelnetでなくオリジナルのCygwinParamで上書き r.UsingSocks = false; return(r); }