public SshHelper(string host, string username, string password) { this.host = host; JSch jsch=new JSch(); Session session=jsch.getSession(username, host, 22); session.setPassword( password ); Hashtable config=new Hashtable(); config.Add("StrictHostKeyChecking", "no"); session.setConfig(config); session.connect(); channel=(ChannelShell)session.openChannel("shell"); writer_po = new PipedOutputStream(); PipedInputStream writer_pi = new PipedInputStream( writer_po ); PipedInputStream reader_pi = new PipedInputStream(); PipedOutputStream reader_po = new PipedOutputStream( reader_pi ); reader = new StreamReader (reader_pi,Encoding.UTF8); channel.setInputStream( writer_pi ); channel.setOutputStream( reader_po ); channel.connect(); channel.setPtySize(132, 132, 1024, 768); }
public SshHelper(string Host, string UserName, string Password) { host = Host; var jsch = new JSch(); session = jsch.getSession(UserName, host, 22); session.setPassword(Password); var config = new Hashtable { { "StrictHostKeyChecking", "no" } }; session.setConfig(config); session.connect(); channel = (ChannelShell)session.openChannel("shell"); writer_po = new PipedOutputStream(); var writer_pi = new PipedInputStream(writer_po); var reader_pi = new PipedInputStream(); var reader_po = new PipedOutputStream(reader_pi); reader = new StreamReader(reader_pi, Encoding.UTF8); channel.setInputStream(writer_pi); channel.setOutputStream(reader_po); channel.connect(); channel.setPtySize(132, 132, 1024, 768); }
public virtual void connect(PipedInputStream snk) { if (snk == null) { throw new NullReferenceException(); } else if (sink != null || snk.connected) { throw new IOException("Already connected"); } sink = snk; snk.m_in = -1; snk.m_out = 0; snk.connected = true; }
public virtual void connect(PipedInputStream snk) { if (snk == null) { throw new NullReferenceException(); } else if (sink != null || snk.connected) { throw new IOException("Already connected"); } sink = snk; snk.m_in = -1; snk.m_out = 0; snk.connected = true; //int t=0; }
internal PassiveOutputStream(PipedInputStream In) :base(In) { }
internal PassiveOutputStream(PipedInputStream ins) : base(ins) { }
public virtual Stream getInputStream() { PipedInputStream ins=new PipedInputStream(); io.setOutputStream(new PassiveOutputStream(ins)); return ins; }
public PipedStream(PipedInputStream pins, PipedOutputStream pouts) { this.pins = pins; this.pouts = pouts; }
/** * Creates a piped output stream connected to the specified piped * input stream. Data bytes written to this stream will then be * available as input from <code>snk</code>. * * @param snk The piped input stream to connect to. * @exception IOException if an I/O error occurs. */ public PipedOutputStream(PipedInputStream snk) { connect(snk); }
public InternalLocalPushConnection(TransportLocal transport) : base(transport) { Repository dst; try { dst = new Repository(transport.remoteGitDir); } catch (IOException) { throw new TransportException(uri, "Not a Git directory"); } PipedInputStream in_r; PipedOutputStream in_w; PipedInputStream out_r; PipedOutputStream out_w; try { in_r = new PipedInputStream(); in_w = new PipedOutputStream(in_r); out_r = new PipedInputStream(); out_w = new PipedOutputStream(out_r); } catch (IOException ex) { dst.Close(); throw new TransportException(uri, "Cannot connect pipes", ex); } worker = new Thread(() => { try { ReceivePack rp = new ReceivePack(dst); rp.receive(out_r, in_w, null); } catch (IOException) { // Client side of the pipes should report the problem. } catch (Exception) { // Clients side will notice we went away, and report. } finally { try { out_r.close(); } catch (IOException) { // Ignore close failure, we probably crashed above. } try { in_w.close(); } catch (IOException) { // Ignore close failure, we probably crashed above. } dst.Close(); } }); worker.Name = "JGit-Receive-Pack"; worker.Start(); init(in_r, out_w); readAdvertisedRefs(); }
public Stream get(String src, SftpProgressMonitor monitor, int mode) { if(mode==RESUME) { throw new SftpException(SSH_FX_FAILURE, "faile to resume from "+src); } if(!src.StartsWith("/")){ src=cwd+"/"+src; } try { ArrayList v=glob_remote(src); if(v.Count!=1) { throw new SftpException(SSH_FX_FAILURE, v.ToString()); } src=(String)(v[0]); SftpATTRS attr=stat(src); PipedInputStream pis=new PipedInputStream(); PipedOutputStream pos=new PipedOutputStream(pis); ChannelSftp channel=this; String _src=src; if(attr.getSize()<=0) { try{ pos.Close(); } catch{}//(Exception ee){} return pis; } Exception[] closed=new Exception[1]; closed[0]=null; runnable2 runnable2 = new runnable2(channel, pos, _src, monitor, mode, closed); (new Thread(new ThreadStart(runnable2.run))).Start(); while(true) { if(pis.available()!=0)break; if(closed[0]!=null) { throw closed[0]; } // System.outs.println("pis wait"); Thread.Sleep(1000); } return pis; } catch(Exception e) { if(e is SftpException) throw (SftpException)e; throw new SftpException(SSH_FX_FAILURE, ""); } }