public void Load(ConfigNode parent) { ConfigNode n = parent.FindChildConfigNode("profiles"); if (n != null) { foreach (ConfigNode ch in n.Children) { ChannelProfile p = null; if (ch.Name == "local-to-remote") { p = new LocalToRemoteChannelProfile(); } else if (ch.Name == "remote-to-local") { p = new RemoteToLocalChannelProfile(); } else { throw new FormatException(ch.Name + " is invalid channel profile name."); } p.Import(ch); _data.Add(p); } } }
public void Load(ConfigNode parent) { ConfigNode n = parent.FindChildConfigNode("profiles"); if (n != null) { foreach (ConfigNode ch in n.Children) { ChannelProfile p = null; if (ch.Name == "local-to-remote") p = new LocalToRemoteChannelProfile(); else if (ch.Name == "remote-to-local") p = new RemoteToLocalChannelProfile(); else throw new FormatException(ch.Name + " is invalid channel profile name."); p.Import(ch); _data.Add(p); } } }
private void InitUI(ChannelProfile prof) { if (prof == null) { _localToRemoteOption.Checked = true; _passwordOption.Checked = true; } else { _sshHostBox.Text = prof.SSHHost; _portBox.Text = prof.SSHPort.ToString(); _accountBox.Text = prof.SSHAccount; //_udpOption.Checked = prof.ProtocolType==ProtocolType.Udp; if (prof.AuthType == AuthenticationType.Password) { _passwordOption.Checked = true; } else { _publicKeyOption.Checked = true; _privateKeyBox.Text = prof.PrivateKeyFile; } _loopbackOnly.Checked = !prof.AllowsForeignConnection; if (prof is LocalToRemoteChannelProfile) { LocalToRemoteChannelProfile p = (LocalToRemoteChannelProfile)prof; _localToRemoteOption.Checked = true; _LRLocalPortBox.Text = p.ListenPort.ToString(); _LRIPv6.Checked = p.UseIPv6; _LRRemoteHostBox.Text = p.DestinationHost; _LRRemotePortBox.Text = p.DestinationPort.ToString(); } else { RemoteToLocalChannelProfile p = (RemoteToLocalChannelProfile)prof; _remoteToLocalOption.Checked = true; _RLLocalPortBox.Text = p.DestinationPort.ToString(); _RLLocalHostBox.Text = p.DestinationHost; _RLRemotePortBox.Text = p.ListenPort.ToString(); } } }
private void OnOK(object sender, EventArgs args) { this.DialogResult = DialogResult.None; string itemname = null; try { if (_localToRemoteOption.Checked) { _result = new LocalToRemoteChannelProfile(); } else { _result = new RemoteToLocalChannelProfile(); } if (_sshHostBox.Text.Length == 0) { throw new Exception(Env.Strings.GetString("Message.ProfileEdit.EmptySSHServer")); } _result.SSHHost = _sshHostBox.Text; if (_accountBox.Text.Length == 0) { throw new Exception(Env.Strings.GetString("Message.ProfileEdit.EmptyAccount")); } _result.SSHAccount = _accountBox.Text; _result.AuthType = _publicKeyOption.Checked ? AuthenticationType.PublicKey : AuthenticationType.Password; if (_result.AuthType == AuthenticationType.PublicKey) { _result.PrivateKeyFile = _privateKeyBox.Text; } itemname = Env.Strings.GetString("Caption.ProfileEdit.SSHPortNumber"); _result.SSHPort = Util.ParsePort(_portBox.Text); _result.ProtocolType = ProtocolType.Tcp; _result.AllowsForeignConnection = !_loopbackOnly.Checked; if (_localToRemoteOption.Checked) { LocalToRemoteChannelProfile p = (LocalToRemoteChannelProfile)_result; itemname = Env.Strings.GetString("Caption.ProfileEdit.LocalPort"); p.ListenPort = Util.ParsePort(_LRLocalPortBox.Text); if (_LRRemoteHostBox.Text.Length == 0) { throw new Exception(Env.Strings.GetString("Message.ProfileEdit.EmptyRemoveHost")); } p.DestinationHost = _LRRemoteHostBox.Text; itemname = Env.Strings.GetString("Caption.ProfileEdit.DestinationPort"); p.DestinationPort = Util.ParsePort(_LRRemotePortBox.Text); p.UseIPv6 = _LRIPv6.Checked; } else { RemoteToLocalChannelProfile p = (RemoteToLocalChannelProfile)_result; itemname = Env.Strings.GetString("Caption.ProfileEdit.RemotePort"); p.ListenPort = Util.ParsePort(_RLRemotePortBox.Text); itemname = Env.Strings.GetString("Caption.ProfileEdit.DestinationHost"); p.DestinationHost = _RLLocalHostBox.Text; itemname = Env.Strings.GetString("Caption.ProfileEdit.DestinationPort"); p.DestinationPort = Util.ParsePort(_RLLocalPortBox.Text); p.AllowsForeignConnection = !_loopbackOnly.Checked; /* * if(_udpOption.Checked && _loopbackOnly.Checked) { * throw new Exception("リモートからローカルへのUDPの転送をするときはLoopback以外からの接続を許可する必要があります。"); * } */ } this.DialogResult = DialogResult.OK; } catch (FormatException) { Util.Warning(this, String.Format(Env.Strings.GetString("Message.OptionDialog.InvalidItem"), itemname)); } catch (Exception ex) { Util.Warning(this, ex.Message); } }
public LocalToRemoteChannelFactory(LocalToRemoteChannelProfile prof) { _profile = prof; }
public LocalToRemoteChannelFactory(LocalToRemoteChannelProfile prof) { _profile = prof; }