static int Main(string[] args) { ShellSocket SS; #if !(NETSTANDARD2_0 || NETCOREAPP2_0 || NETCOREAPP2_1 || NETCOREAPP2_2) if (IsOSPlatform(OSPlatform.Linux) || IsOSPlatform(OSPlatform.FreeBSD) || IsOSPlatform(OSPlatform.OSX)) #else if (IsOSPlatform(OSPlatform.Linux) || IsOSPlatform(OSPlatform.OSX)) #endif { SS = new ShellSocket("bash -c \"yes hi 1>&2\"", "hi"); } else { SS = new ShellSocket("cmd", " /c \"echo hi 1>&2\""); } System.Console.WriteLine("Starting..."); SS.RedirectErrorsToConsole = true; SS.Start(); Stream S = SS.GetStream(); System.Console.WriteLine("ShellSocket created..."); pair P = new pair(new StreamReader(Console.OpenStandardInput()), new StreamWriter(Console.OpenStandardOutput())); System.Console.WriteLine("Pair created..."); System.Console.WriteLine("{0}", new StreamWriter(Console.OpenStandardOutput())); System.Console.WriteLine("Binding..."); System.Console.WriteLine("P:{0} S:{1}", P, S); Rishi.PairStream.pair.BindStreams(P, S); return(0); }
///<summary> ///Start the connection. ///</summary> public void Start() { if (Method != "4" && Method != "5" && Method != "connect") { System.Console.WriteLine($"Warning: Supported protocols are 4 (SOCKS v.4), 5 (SOCKS v.5) and connect (HTTPS proxy). If the protocol is not specified, SOCKS version 5 is used. Got: {Method}."); } string NCatProxyType; string PrCommand; string ClArgs; if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { NCatProxyType = ""; switch (Method) { case "4": NCatProxyType = "socks4"; break; case "5": NCatProxyType = "socks5"; break; case "connect": NCatProxyType = "http"; break; } PrCommand = $"./nc.exe"; ClArgs = $" -X {Method} -x {ProxyServerName}:{ProxyPort} {HostName} {Port}"; } else { PrCommand = $"nc"; ClArgs = $" -X {Method} -x {ProxyServerName}:{ProxyPort} {HostName} {Port}"; } if (Unbuffer == null) { SS = new ShellSocket(PrCommand, ClArgs, Unbuffer, Unbuffer_Args); } else { SS = new ShellSocket(PrCommand, ClArgs); } if (AutoConfigure) { SS.AutoConfigure = true; SS.PackageName = "NC"; } if (VERBOSE) { SetColour(5, 0); System.Console.Error.WriteLine(PrCommand + " " + ClArgs); ResetColour(); } SS.Start(); S = SS.GetStream(); }
private void MonitorChannels() { var poll = ZPollItem.CreateReceiver(); ZMessage incoming; ZError error; while (!_monitorChannnelsCts.IsCancellationRequested) { if (_monitorChannnelsCts.IsCancellationRequested) { break; } if (StdInSocket.PollIn(poll, out incoming, out error, TimeSpan.FromMilliseconds(100))) { ProcessMessage(incoming, error); } if (_monitorChannnelsCts.IsCancellationRequested) { break; } if (IoPubSocket.PollIn(poll, out incoming, out error, TimeSpan.FromMilliseconds(100))) { ProcessMessage(incoming, error); } if (_monitorChannnelsCts.IsCancellationRequested) { break; } if (ShellSocket.PollIn(poll, out incoming, out error, TimeSpan.FromMilliseconds(100))) { ProcessMessage(incoming, error); } if (_monitorChannnelsCts.IsCancellationRequested) { break; } if (ControlSocket.PollIn(poll, out incoming, out error, TimeSpan.FromMilliseconds(100))) { ProcessMessage(incoming, error); } } ContinueShutdown.Set(); }
///<summary> ///Start the connection. ///</summary> public void Start() { string psk_hex = BitConverter.ToString(PSK).Replace("-", String.Empty); string PrCommand = ""; if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { if (!ShellSocket.CheckExecutableExistence("openssl.exe")) { PrCommand = $"./openssl.exe"; } } else { PrCommand = $"openssl"; } string ClArguments = $"s_client -dtls -connect {HostName}:{Port} -psk {psk_hex} -quiet"; if (Unbuffer == null) { SS = new ShellSocket(PrCommand, ClArguments, Unbuffer, Unbuffer_Args); } else { SS = new ShellSocket(PrCommand, ClArguments); } if (VERBOSE) { SetColour(5, 0); System.Console.Error.WriteLine(PrCommand + " " + ClArguments); ResetColour(); } if (AutoConfigure) { SS.AutoConfigure = true; SS.PackageName = "OpenSSL"; } SS.Start(); }
public JupyterMessage Execute(string code) { FlushMessages(); CurrentState = KernelState.busy; SendShell( JupyterMessage.Header.MsgType.execute_request, new JupyterMessage.ExecuteRequestContent { code = code, silent = false, store_history = true, user_expressions = null, allow_stdin = true, stop_on_error = false }, null); var poll = ZPollItem.CreateReceiver(); ZMessage incoming; ZError error; while (CurrentState != KernelState.idle) { if (StdInSocket.PollIn(poll, out incoming, out error, TimeSpan.FromMilliseconds(100))) { ProcessMessage(incoming, error); } if (IoPubSocket.PollIn(poll, out incoming, out error, TimeSpan.FromMilliseconds(100))) { ProcessMessage(incoming, error); } } var replyMessage = ShellSocket.ReceiveMessage(); return(ParseMessage(replyMessage)); }