本文整理汇总了C#中ISSHChannelEventReceiver类的典型用法代码示例。如果您正苦于以下问题:C# ISSHChannelEventReceiver类的具体用法?C# ISSHChannelEventReceiver怎么用?C# ISSHChannelEventReceiver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ISSHChannelEventReceiver类属于命名空间,在下文中一共展示了ISSHChannelEventReceiver类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: RegisterChannelEventReceiver
public Entry RegisterChannelEventReceiver(SSHChannel ch, ISSHChannelEventReceiver r) {
lock (this) {
Entry e = new Entry(ch, r, _channel_sequence++);
if (_first == null)
_first = e;
else {
e.Next = _first;
_first = e;
}
_count++;
return e;
}
}
开发者ID:PavelTorgashov,项目名称:nfx,代码行数:15,代码来源:ChannelCollection.cs
示例2: DoExecCommand
// open new channel for SCP
public override SSHChannel DoExecCommand(ISSHChannelEventReceiver receiver, string command) {
return DoExecCommandInternal(receiver, ChannelType.ExecCommand, command, "executing " + command);
}
开发者ID:RSchwoerer,项目名称:Terminals,代码行数:4,代码来源:SSH2Connection.cs
示例3: OpenShell
public override SSHChannel OpenShell(ISSHChannelEventReceiver receiver)
{
if (_shellID != -1)
throw new SSHException("A shell is opened already");
_shellID = _channel_collection.RegisterChannelEventReceiver(null, receiver).LocalID;
SendRequestPTY();
_executingShell = true;
return new SSH1Channel(this, ChannelType.Shell, _shellID);
}
开发者ID:yiyi99,项目名称:poderosa,代码行数:9,代码来源:SSH1Connection.cs
示例4: DoExecCommand
// sending exec command for SCP
// TODO: まだ実装中です
public override SSHChannel DoExecCommand(ISSHChannelEventReceiver receiver, string command)
{
//_executingExecCmd = true;
SendExecCommand();
return null;
}
开发者ID:yiyi99,项目名称:poderosa,代码行数:8,代码来源:SSH1Connection.cs
示例5: OpenShell
public override SSHChannel OpenShell(ISSHChannelEventReceiver receiver)
{
//open channel
SSH2DataWriter wr = new SSH2DataWriter();
wr.WritePacketType(PacketType.SSH_MSG_CHANNEL_OPEN);
wr.Write("session");
int local_channel = this.RegisterChannelEventReceiver(null, receiver)._localID;
wr.Write(local_channel);
wr.Write(_param.WindowSize); //initial window size
int windowsize = _param.WindowSize;
wr.Write(_param.MaxPacketSize); //max packet size
SSH2Channel channel = new SSH2Channel(this, ChannelType.Shell, local_channel);
TransmitPacket(wr.ToByteArray());
return channel;
}
开发者ID:ehazlett,项目名称:sshconsole,代码行数:17,代码来源:SSH2Connection.cs
示例6: ReceivePortForwardingResponse
private void ReceivePortForwardingResponse(ISSHChannelEventReceiver receiver, PacketType pt, SSH2DataReader reader)
{
if(_negotiationStatus==1) {
if(pt!=PacketType.SSH_MSG_CHANNEL_OPEN_CONFIRMATION) {
if(pt!=PacketType.SSH_MSG_CHANNEL_OPEN_FAILURE)
receiver.OnChannelError(null, "opening channel failed; packet type="+pt);
else {
int errcode = reader.ReadInt32();
string msg = Encoding.ASCII.GetString(reader.ReadString());
receiver.OnChannelError(null, msg);
}
Close();
}
else {
_remoteID = reader.ReadInt32();
_serverMaxPacketSize = reader.ReadInt32();
_negotiationStatus = 0;
receiver.OnChannelReady();
}
}
else
Debug.Assert(false);
}
开发者ID:ehazlett,项目名称:sshconsole,代码行数:23,代码来源:SSH2Connection.cs
示例7: ProcessPacket
internal void ProcessPacket(ISSHChannelEventReceiver receiver, PacketType pt, int data_length, SSH2DataReader re)
{
//NOTE: the offset of 're' is next to 'receipiant channel' field
_leftWindowSize -= data_length;
while(_leftWindowSize <= _windowSize) {
SSH2DataWriter adj = new SSH2DataWriter();
adj.WritePacketType(PacketType.SSH_MSG_CHANNEL_WINDOW_ADJUST);
adj.Write(_remoteID);
adj.Write(_windowSize);
TransmitPacket(adj.ToByteArray());
_leftWindowSize += _windowSize;
//Debug.WriteLine("Window size is adjusted to " + _leftWindowSize);
}
if(pt==PacketType.SSH_MSG_CHANNEL_WINDOW_ADJUST) {
int w = re.ReadInt32();
//Debug.WriteLine(String.Format("Window Adjust +={0}",w));
}
else if(_negotiationStatus!=0) { //when the negotiation is not completed
if(_type==ChannelType.Shell)
OpenShell(receiver, pt, re);
else if(_type==ChannelType.ForwardedLocalToRemote)
ReceivePortForwardingResponse(receiver, pt, re);
else if(_type==ChannelType.Session)
EstablishSession(receiver, pt, re);
}
else {
switch(pt) {
case PacketType.SSH_MSG_CHANNEL_DATA: {
int len = re.ReadInt32();
receiver.OnData(re.Image, re.Offset, len);
}
break;
case PacketType.SSH_MSG_CHANNEL_EXTENDED_DATA: {
int t = re.ReadInt32();
byte[] data = re.ReadString();
receiver.OnExtendedData(t, data);
}
break;
case PacketType.SSH_MSG_CHANNEL_REQUEST: {
string request = Encoding.ASCII.GetString(re.ReadString());
bool reply = re.ReadBool();
if(request=="exit-status") {
int status = re.ReadInt32();
}
else if(reply) { //we reject unknown requests including keep-alive check
SSH2DataWriter wr = new SSH2DataWriter();
wr.Write((byte)PacketType.SSH_MSG_CHANNEL_FAILURE);
wr.Write(_remoteID);
TransmitPacket(wr.ToByteArray());
}
}
break;
case PacketType.SSH_MSG_CHANNEL_EOF:
receiver.OnChannelEOF();
break;
case PacketType.SSH_MSG_CHANNEL_CLOSE:
_connection.UnregisterChannelEventReceiver(_localID);
receiver.OnChannelClosed();
break;
case PacketType.SSH_MSG_CHANNEL_FAILURE:
case PacketType.SSH_MSG_CHANNEL_SUCCESS:
receiver.OnMiscPacket((byte)pt, re.Image, re.Offset, re.Rest);
break;
default:
receiver.OnMiscPacket((byte)pt, re.Image, re.Offset, re.Rest);
Debug.WriteLine("Unknown Packet "+pt);
break;
}
}
}
开发者ID:ehazlett,项目名称:sshconsole,代码行数:72,代码来源:SSH2Connection.cs
示例8: Entry
public Entry(SSHChannel ch, ISSHChannelEventReceiver r, int seq) {
_channel = ch;
_receiver = r;
_localID = seq;
}
开发者ID:PavelTorgashov,项目名称:nfx,代码行数:5,代码来源:ChannelCollection.cs
示例9: OpenShellOrSubsystem
private void OpenShellOrSubsystem(ISSHChannelEventReceiver receiver, PacketType pt, SSH2DataReader reader, string scheme) {
if(_negotiationStatus==NegotiationStatus.WaitingChannelConfirmation) {
if(pt!=PacketType.SSH_MSG_CHANNEL_OPEN_CONFIRMATION) {
if(pt!=PacketType.SSH_MSG_CHANNEL_OPEN_FAILURE)
receiver.OnChannelError(new SSHException("opening channel failed; packet type="+pt));
else {
int errcode = reader.ReadInt32();
string msg = Encoding.ASCII.GetString(reader.ReadString());
receiver.OnChannelError(new SSHException(msg));
}
Close();
}
else {
_remoteID = reader.ReadInt32();
_allowedDataSize = reader.ReadInt32();
_serverMaxPacketSize = reader.ReadInt32();
//open pty
SSH2DataWriter wr = new SSH2DataWriter();
SSHConnectionParameter param = _connection.Param;
wr.WritePacketType(PacketType.SSH_MSG_CHANNEL_REQUEST);
wr.Write(_remoteID);
wr.Write("pty-req");
wr.Write(true);
wr.Write(param.TerminalName);
wr.Write(param.TerminalWidth);
wr.Write(param.TerminalHeight);
wr.Write(param.TerminalPixelWidth);
wr.Write(param.TerminalPixelHeight);
wr.WriteAsString(new byte[0]);
if(_connection.IsEventTracerAvailable)
_connection.TraceTransmissionEvent(PacketType.SSH_MSG_CHANNEL_REQUEST, "pty-req", "terminal={0} width={1} height={2}", param.TerminalName, param.TerminalWidth, param.TerminalHeight);
TransmitPayload(wr.ToByteArray());
_negotiationStatus = NegotiationStatus.WaitingPtyReqConfirmation;
}
}
else if(_negotiationStatus==NegotiationStatus.WaitingPtyReqConfirmation) {
if(pt!=PacketType.SSH_MSG_CHANNEL_SUCCESS) {
receiver.OnChannelError(new SSHException("opening pty failed"));
Close();
}
else {
//agent request (optional)
if(_connection.Param.AgentForward!=null) {
SSH2DataWriter wr = new SSH2DataWriter();
wr.WritePacketType(PacketType.SSH_MSG_CHANNEL_REQUEST);
wr.Write(_remoteID);
wr.Write("[email protected]");
wr.Write(true);
_connection.TraceTransmissionEvent(PacketType.SSH_MSG_CHANNEL_REQUEST, "auth-agent-req", "");
TransmitPayload(wr.ToByteArray());
_negotiationStatus = NegotiationStatus.WaitingAuthAgentReqConfirmation;
}
else {
OpenScheme(scheme);
_negotiationStatus = NegotiationStatus.WaitingShellConfirmation;
}
}
}
else if(_negotiationStatus==NegotiationStatus.WaitingAuthAgentReqConfirmation) {
if(pt!=PacketType.SSH_MSG_CHANNEL_SUCCESS && pt!=PacketType.SSH_MSG_CHANNEL_FAILURE) {
receiver.OnChannelError(new SSHException("auth-agent-req error"));
Close();
}
else { //auth-agent-req is optional
_connection.SetAgentForwardConfirmed(pt==PacketType.SSH_MSG_CHANNEL_SUCCESS);
_connection.TraceReceptionEvent(pt, "auth-agent-req");
OpenScheme(scheme);
_negotiationStatus = NegotiationStatus.WaitingShellConfirmation;
}
}
else if(_negotiationStatus==NegotiationStatus.WaitingShellConfirmation) {
if(pt!=PacketType.SSH_MSG_CHANNEL_SUCCESS) {
receiver.OnChannelError(new SSHException("Opening shell failed: packet type="+pt.ToString()));
Close();
}
else {
receiver.OnChannelReady();
_negotiationStatus = NegotiationStatus.Ready; //goal!
}
}
}
开发者ID:RSchwoerer,项目名称:Terminals,代码行数:84,代码来源:SSH2Connection.cs
示例10: ProcessChannelLocalData
private void ProcessChannelLocalData(ISSHChannelEventReceiver receiver, PacketType pt, SSH2DataReader re) {
switch(pt) {
case PacketType.SSH_MSG_CHANNEL_DATA: {
int len = re.ReadInt32();
receiver.OnData(re.Image, re.Offset, len);
}
break;
case PacketType.SSH_MSG_CHANNEL_EXTENDED_DATA: {
int t = re.ReadInt32();
byte[] data = re.ReadString();
receiver.OnExtendedData(t, data);
}
break;
case PacketType.SSH_MSG_CHANNEL_REQUEST: {
string request = Encoding.ASCII.GetString(re.ReadString());
bool reply = re.ReadBool();
if(request=="exit-status") {
int status = re.ReadInt32();
}
else if(reply) { //we reject unknown requests including keep-alive check
SSH2DataWriter wr = new SSH2DataWriter();
wr.WritePacketType(PacketType.SSH_MSG_CHANNEL_FAILURE);
wr.Write(_remoteID);
TransmitPayload(wr.ToByteArray());
}
}
break;
case PacketType.SSH_MSG_CHANNEL_EOF:
receiver.OnChannelEOF();
break;
case PacketType.SSH_MSG_CHANNEL_CLOSE:
_connection.ChannelCollection.UnregisterChannelEventReceiver(_localID);
receiver.OnChannelClosed();
break;
case PacketType.SSH_MSG_CHANNEL_FAILURE:
receiver.OnMiscPacket((byte)pt, re.Image, re.Offset, re.Rest);
break;
default:
receiver.OnMiscPacket((byte)pt, re.Image, re.Offset, re.Rest);
Debug.WriteLine("Unknown Packet "+pt);
break;
}
}
开发者ID:RSchwoerer,项目名称:Terminals,代码行数:43,代码来源:SSH2Connection.cs
示例11: ProgressChannelNegotiation
//Progress the state of this channel establishment negotiation
private void ProgressChannelNegotiation(ISSHChannelEventReceiver receiver, PacketType pt, SSH2DataReader re) {
if(_type==ChannelType.Shell)
OpenShellOrSubsystem(receiver, pt, re, "shell");
else if(_type==ChannelType.ForwardedLocalToRemote)
ReceivePortForwardingResponse(receiver, pt, re);
else if(_type==ChannelType.Session)
EstablishSession(receiver, pt, re);
else if(_type==ChannelType.ExecCommand) // for SCP
ExecCommand(receiver, pt, re);
else if(_type==ChannelType.Subsystem)
OpenShellOrSubsystem(receiver, pt, re, "subsystem");
}
开发者ID:RSchwoerer,项目名称:Terminals,代码行数:13,代码来源:SSH2Connection.cs
示例12: ProcessPacket
internal void ProcessPacket(ISSHChannelEventReceiver receiver, PacketType pt, int data_length, SSH2DataReader re) {
//NOTE: the offset of 're' is next to 'receipiant channel' field
AdjustWindowSize(pt, data_length);
//SSH_MSG_CHANNEL_WINDOW_ADJUST comes before the complete of channel establishment
if(pt==PacketType.SSH_MSG_CHANNEL_WINDOW_ADJUST) {
int w = re.ReadInt32();
//some servers may not send SSH_MSG_CHANNEL_WINDOW_ADJUST.
//it is dangerous to wait this message in send procedure
_allowedDataSize += w;
if(_connection.IsEventTracerAvailable)
_connection.TraceReceptionEvent("SSH_MSG_CHANNEL_WINDOW_ADJUST", "adjusted to {0} by increasing {1}", _allowedDataSize, w);
return;
}
if(_negotiationStatus!=NegotiationStatus.Ready) //when the negotiation is not completed
ProgressChannelNegotiation(receiver, pt, re);
else
ProcessChannelLocalData(receiver, pt, re);
}
开发者ID:RSchwoerer,项目名称:Terminals,代码行数:21,代码来源:SSH2Connection.cs
示例13: ForwardPort
public override SSHChannel ForwardPort(ISSHChannelEventReceiver receiver, string remote_host, int remote_port, string originator_host, int originator_port) {
SSH2DataWriter wr = OpenTransmissionPacket();
wr.WritePacketType(PacketType.SSH_MSG_CHANNEL_OPEN);
wr.Write("direct-tcpip");
int local_id = this.ChannelCollection.RegisterChannelEventReceiver(null, receiver).LocalID;
wr.Write(local_id);
wr.Write(_param.WindowSize); //initial window size
int windowsize = _param.WindowSize;
wr.Write(_param.MaxPacketSize); //max packet size
wr.Write(remote_host);
wr.Write(remote_port);
wr.Write(originator_host);
wr.Write(originator_port);
SSH2Channel channel = new SSH2Channel(this, ChannelType.ForwardedLocalToRemote, local_id, null);
TraceTransmissionEvent(PacketType.SSH_MSG_CHANNEL_OPEN, "opening a forwarded port : host={0} port={1}", remote_host, remote_port);
TransmitPacket(wr);
return channel;
}
开发者ID:RSchwoerer,项目名称:Terminals,代码行数:21,代码来源:SSH2Connection.cs
示例14: DoExecCommandInternal
//open channel
private SSHChannel DoExecCommandInternal(ISSHChannelEventReceiver receiver, ChannelType channel_type, string command, string message) {
SSH2DataWriter wr = OpenTransmissionPacket();
wr.WritePacketType(PacketType.SSH_MSG_CHANNEL_OPEN);
wr.Write("session");
int local_channel = this.ChannelCollection.RegisterChannelEventReceiver(null, receiver).LocalID;
wr.Write(local_channel);
wr.Write(_param.WindowSize); //initial window size
int windowsize = _param.WindowSize;
wr.Write(_param.MaxPacketSize); //max packet size
SSH2Channel channel = new SSH2Channel(this, channel_type, local_channel, command);
TraceTransmissionEvent(PacketType.SSH_MSG_CHANNEL_OPEN, "executing command");
TransmitPacket(wr);
return channel;
}
开发者ID:RSchwoerer,项目名称:Terminals,代码行数:17,代码来源:SSH2Connection.cs
示例15: OpenSubsystem
// open subsystem such as NETCONF
public SSHChannel OpenSubsystem(ISSHChannelEventReceiver receiver, string subsystem) {
return DoExecCommandInternal(receiver, ChannelType.Subsystem, subsystem, "subsystem " + subsystem);
}
开发者ID:RSchwoerer,项目名称:Terminals,代码行数:4,代码来源:SSH2Connection.cs
示例16: OpenShell
/**
* opens a pseudo terminal
*/
public abstract SSHChannel OpenShell(ISSHChannelEventReceiver receiver);
开发者ID:rfyiamcool,项目名称:solrex,代码行数:4,代码来源:ConnectionRoot.cs
示例17: RegisterChannelEventReceiver
protected ChannelEntry RegisterChannelEventReceiver(SSHChannel ch, ISSHChannelEventReceiver r)
{
lock(this) {
ChannelEntry e = new ChannelEntry();
e._channel = ch;
e._receiver = r;
e._localID = _channel_sequence++;
for(int i=0; i<_channel_entries.Count; i++) {
if(_channel_entries[i]==null) {
_channel_entries[i] = e;
return e;
}
}
_channel_entries.Add(e);
return e;
}
}
开发者ID:rfyiamcool,项目名称:solrex,代码行数:18,代码来源:ConnectionRoot.cs
示例18: ExecCommand
// sending "exec" service for SCP protocol.
private void ExecCommand(ISSHChannelEventReceiver receiver, PacketType pt, SSH2DataReader reader) {
if(_negotiationStatus==NegotiationStatus.WaitingChannelConfirmation) {
if(pt!=PacketType.SSH_MSG_CHANNEL_OPEN_CONFIRMATION) {
if(pt!=PacketType.SSH_MSG_CHANNEL_OPEN_FAILURE)
receiver.OnChannelError(new SSHException("opening channel failed; packet type="+pt));
else {
int errcode = reader.ReadInt32();
string msg = Encoding.ASCII.GetString(reader.ReadString());
receiver.OnChannelError(new SSHException(msg));
}
Close();
}
else {
_remoteID = reader.ReadInt32();
_allowedDataSize = reader.ReadInt32();
_serverMaxPacketSize = reader.ReadInt32();
// exec command
SSH2DataWriter wr = new SSH2DataWriter();
SSHConnectionParameter param = _connection.Param;
wr.WritePacketType(PacketType.SSH_MSG_CHANNEL_REQUEST);
wr.Write(_remoteID);
wr.Write("exec"); // "exec"
wr.Write(false); // want confirm is disabled. (*)
wr.Write(_command);
if (_connection.IsEventTracerAvailable)
_connection.TraceTransmissionEvent("exec command","cmd={0}", _command);
TransmitPayload(wr.ToByteArray());
//confirmation is omitted
receiver.OnChannelReady();
_negotiationStatus = NegotiationStatus.Ready; //goal!
}
}
else if(_negotiationStatus==NegotiationStatus.WaitingExecCmdConfirmation) {
if(pt!=PacketType.SSH_MSG_CHANNEL_DATA) {
receiver.OnChannelError(new SSHException("exec command failed"));
Close();
}
else {
receiver.OnChannelReady();
_negotiationStatus = NegotiationStatus.Ready; //goal!
}
}
else
throw new SSHException("internal state error");
}
开发者ID:RSchwoerer,项目名称:Terminals,代码行数:49,代码来源:SSH2Connection.cs
示例19: EstablishSession
private void EstablishSession(ISSHChannelEventReceiver receiver, PacketType pt, SSH2DataReader reader) {
if(_negotiationStatus==NegotiationStatus.WaitingChannelConfirmation) {
if(pt!=PacketType.SSH_MSG_CHANNEL_OPEN_CONFIRMATION) {
if(pt!=PacketType.SSH_MSG_CHANNEL_OPEN_FAILURE)
receiver.OnChannelError(new SSHException("opening channel failed; packet type="+pt));
else {
int remote_id = reader.ReadInt32();
int errcode = reader.ReadInt32();
string msg = Encoding.ASCII.GetString(reader.ReadString());
receiver.OnChannelError(new SSHException(msg));
}
Close();
}
else {
_remoteID = reader.ReadInt32();
_serverMaxPacketSize = reader.ReadInt32();
_negotiationStatus = NegotiationStatus.Ready;
receiver.OnChannelReady();
}
}
else
throw new SSHException("internal state error");
}
开发者ID:RSchwoerer,项目名称:Terminals,代码行数:23,代码来源:SSH2Connection.cs
示例20: DoExecCommand
public override SSHChannel DoExecCommand(ISSHChannelEventReceiver receiver, string command)
{
throw new Exception("The method or operation is not implemented.");
}
开发者ID:yiyi99,项目名称:poderosa,代码行数:4,代码来源:SCPChannelStreamTest.cs
注:本文中的ISSHChannelEventReceiver类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论