コード例 #1
0
        //終了のハンドリング 非同期に別スレッドから呼ばれるので注意
        public void ConnectionClosed(ISSHConnection connection)
        {
            IDictionaryEnumerator e = _profileToConnection.GetEnumerator();

            while (e.MoveNext())
            {
                if (connection == e.Value)
                {
                    ChannelProfile prof = (ChannelProfile)e.Key;
                    _profileToConnection.Remove(e.Key);
                    bool manual = false;
                    lock (this) {
                        manual = _manualClosingConnections.Contains(connection);
                        if (manual)
                        {
                            _manualClosingConnections.Remove(connection);
                        }
                    }

                    if (!manual)
                    {
                        Util.InterThreadWarning(Env.Strings.GetString("Message.ConnectionManager.Disconnected"));
                    }

                    Env.MainForm.Invoke(new RefreshProfileStatusDelegate(Env.MainForm.RefreshProfileStatus), prof);

                    break;
                }
            }
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: yueker/poderosa
        public void RefreshProfileStatus(ChannelProfile prof)
        {
            ListViewItem li = FindItem(prof);

            Debug.Assert(li != null);
            li.SubItems[6].Text = Util.GetProfileStatusString(prof);
        }
コード例 #3
0
ファイル: channelprofile.cs プロジェクト: yueker/poderosa
        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);
                }
            }
        }
コード例 #4
0
        //profに対応したSSHConnectionを返す。接続がなければparentを親に認証ダイアログを出して認証する
        public ISSHConnection GetOrCreateConnection(ChannelProfile prof, Form parent)
        {
            //ホスト名とアカウントのペアからコネクションを共有する仕組みがあるとよいかも
            ISSHConnection c = _profileToConnection[prof] as ISSHConnection;

            if (c != null)
            {
                return(c);
            }

            SSHShortcutLoginDialog dlg = new SSHShortcutLoginDialog(prof);

            if (dlg.ShowDialog(parent) == DialogResult.OK)
            {
                c = dlg.Result.Connection;
                try {
                    dlg.Result.WaitRequest();
                }
                catch (Exception ex) {
                    Debug.WriteLine(ex.StackTrace);
                    Util.Warning(parent, ex.Message);
                    c.Close();
                    return(null);
                }
                _profileToConnection[prof] = c;
                Env.MainForm.RefreshProfileStatus(prof);
            }

            return(c);
        }
コード例 #5
0
ファイル: ConnectionLog.cs プロジェクト: FNKGino/poderosa
        public void LogConnectionClosed(ChannelProfile prof, int id)
        {
            string t = String.Format("{0} {1} connection closed; id={2}", DateTime.Now.ToString(), prof.ProtocolType.ToString(), id);

            _strm.WriteLine(t);
            _strm.Flush();
        }
コード例 #6
0
        public void LogConnectionClosed(ChannelProfile prof, int id)
        {
            string t = String.Format("{0} {1} connection closed; id={2}", DateTime.Now.ToString(), prof.ProtocolType.ToString(), id);

            _strm.WriteLine(t);
            _strm.Flush();
        }
コード例 #7
0
ファイル: commands.cs プロジェクト: Ricordanza/poderosa
 public void RemoveProfile(ChannelProfile prof) {
     if (Env.Connections.IsConnected(prof)) {
         Util.Warning(Env.MainForm, Env.Strings.GetString("Message.Commands.CannotDeleteConnectedProfile"));
         return;
     }
     Env.Profiles.RemoveProfile(prof);
     Env.MainForm.RefreshAllProfiles();
 }
コード例 #8
0
ファイル: commands.cs プロジェクト: Ricordanza/poderosa
 public void MoveProfileDown(ChannelProfile prof) {
     int index = Env.Profiles.IndexOf(prof);
     if (index < Env.Profiles.Count - 1) {
         Env.Profiles.RemoveProfile(prof);
         Env.Profiles.InsertAt(index + 1, prof);
         Env.MainForm.RefreshAllProfiles();
         Env.MainForm.SetSelectedIndex(index + 1);
     }
 }
コード例 #9
0
ファイル: commands.cs プロジェクト: Ricordanza/poderosa
 public void MoveProfileUp(ChannelProfile prof) {
     int index = Env.Profiles.IndexOf(prof);
     if (index > 0) {
         Env.Profiles.RemoveProfile(prof);
         Env.Profiles.InsertAt(index - 1, prof);
         Env.MainForm.RefreshAllProfiles();
         Env.MainForm.SetSelectedIndex(index - 1);
     }
 }
コード例 #10
0
 public static SocketWithTimeout StartNewConnection(ISocketWithTimeoutClient client, ChannelProfile prof, string password, HostKeyCheckCallback keycheck) {
     SocketWithTimeout swt;
     swt = new SSHConnector(prof, password, keycheck);
     /*
     if (Env.Options.UseSocks)
         swt.AsyncConnect(client, CreateSocksParam(prof.SSHHost, prof.SSHPort));
     else*/
     swt.AsyncConnect(client, prof.SSHHost, prof.SSHPort);
     return swt;
 }
コード例 #11
0
ファイル: commands.cs プロジェクト: takano32/poderosa
 public void RemoveProfile(ChannelProfile prof)
 {
     if (Env.Connections.IsConnected(prof))
     {
         Util.Warning(Env.MainForm, Env.Strings.GetString("Message.Commands.CannotDeleteConnectedProfile"));
         return;
     }
     Env.Profiles.RemoveProfile(prof);
     Env.MainForm.RefreshAllProfiles();
 }
コード例 #12
0
ファイル: ConnectionLog.cs プロジェクト: SyaaS/poderosa
        public void LogConnectionOpened(ChannelProfile prof, int id) {
            string t = String.Format("{0} {1} connection opened; id={2}", DateTime.Now.ToString(), prof.ProtocolType.ToString(), id);
            if (prof is LocalToRemoteChannelProfile)
                t = String.Format("{0}; from=localhost:{1}; to={2}:{3}", t, prof.ListenPort, prof.DestinationHost, prof.DestinationPort);
            else
                t = String.Format("{0}; from={1}:{2}; to={3}:{4}", t, prof.SSHHost, prof.ListenPort, prof.DestinationHost, prof.DestinationPort);

            _strm.WriteLine(t);
            _strm.Flush();
        }
コード例 #13
0
 public static IPAddress ChannelProfileToListeningAddress(ChannelProfile prof)
 {
     if (prof.UseIPv6)
     {
         return(prof.AllowsForeignConnection ? IPAddress.IPv6Any : IPAddress.IPv6Loopback);
     }
     else
     {
         return(prof.AllowsForeignConnection ? IPAddress.Any : IPAddress.Loopback);
     }
 }
コード例 #14
0
ファイル: MainForm.cs プロジェクト: yueker/poderosa
        private void OnListViewDoubleClicked(object sender, EventArgs args)
        {
            ChannelProfile prof = GetSelectedProfile();

            if (prof == null)
            {
                return;
            }

            Env.Commands.ConnectProfile(prof);
        }
コード例 #15
0
ファイル: MainForm.cs プロジェクト: yueker/poderosa
 private ListViewItem FindItem(ChannelProfile prof)
 {
     foreach (ListViewItem li in _list.Items)
     {
         if (li.Tag == prof)
         {
             return(li);
         }
     }
     return(null);
 }
コード例 #16
0
 public static string GetProfileTypeString(ChannelProfile prof)
 {
     if (prof is LocalToRemoteChannelProfile)
     {
         return(Env.Strings.GetString("Caption.Util.Local"));
     }
     else
     {
         return(Env.Strings.GetString("Caption.Util.Remote"));
     }
 }
コード例 #17
0
ファイル: commands.cs プロジェクト: Ricordanza/poderosa
        public void EditProfile(ChannelProfile prof) {
            if (Env.Connections.IsConnected(prof)) {
                Util.Warning(Env.MainForm, Env.Strings.GetString("Message.Commands.CannotEditConnectedProfile"));
                return;
            }

            ProfileEdit dlg = new ProfileEdit(prof);
            if (dlg.ShowDialog(Env.MainForm) == DialogResult.OK) {
                Env.Profiles.ReplaceProfile(prof, dlg.ResultProfile);
                Env.MainForm.RefreshAllProfiles();
            }
        }
コード例 #18
0
ファイル: connectionmanager.cs プロジェクト: SyaaS/poderosa
        /*
        private static Socks CreateSocksParam(string dest_host, int dest_port) {
            Socks s = new Socks();
            s.DestName = dest_host;
            s.DestPort = (short)dest_port;
            s.Account = Env.Options.SocksAccount;
            s.Password = Env.Options.SocksPassword;
            s.ServerName = Env.Options.SocksServer;
            s.ServerPort = (short)Env.Options.SocksPort;
            s.ExcludingNetworks = Env.Options.SocksNANetworks;
            return s;
        }
        */
        public void ManualClose(ChannelProfile prof) {
            if (!IsConnected(prof)) {
                Debug.WriteLine("ManualClose - Not connected");
                return;
            }

            lock (this) {
                SSHConnection c = (SSHConnection)_profileToConnection[prof];
                _manualClosingConnections.Add(c);
                c.Disconnect("");
            }
        }
コード例 #19
0
ファイル: MainForm.cs プロジェクト: yueker/poderosa
        private void OnListViewMouseUp(object sender, MouseEventArgs args)
        {
            ChannelProfile prof = GetSelectedProfile();

            if (args.Button != MouseButtons.Right || prof == null)
            {
                return;
            }

            AdjustMenu(_listViewContextMenu.Items, prof);
            _listViewContextMenu.Show(this, new Point(args.X, args.Y));
        }
コード例 #20
0
ファイル: ProfileEdit.cs プロジェクト: Ricordanza/poderosa
        public ProfileEdit(ChannelProfile prof) {
            //
            // Windows フォーム デザイナ サポートに必要です。
            //
            InitializeComponent();
            InitializeText();

            //
            // TODO: InitializeComponent 呼び出しの後に、コンストラクタ コードを追加してください。
            //
            InitUI(prof);
        }
コード例 #21
0
ファイル: commands.cs プロジェクト: takano32/poderosa
        public void MoveProfileDown(ChannelProfile prof)
        {
            int index = Env.Profiles.IndexOf(prof);

            if (index < Env.Profiles.Count - 1)
            {
                Env.Profiles.RemoveProfile(prof);
                Env.Profiles.InsertAt(index + 1, prof);
                Env.MainForm.RefreshAllProfiles();
                Env.MainForm.SetSelectedIndex(index + 1);
            }
        }
コード例 #22
0
ファイル: commands.cs プロジェクト: takano32/poderosa
        public void MoveProfileUp(ChannelProfile prof)
        {
            int index = Env.Profiles.IndexOf(prof);

            if (index > 0)
            {
                Env.Profiles.RemoveProfile(prof);
                Env.Profiles.InsertAt(index - 1, prof);
                Env.MainForm.RefreshAllProfiles();
                Env.MainForm.SetSelectedIndex(index - 1);
            }
        }
コード例 #23
0
ファイル: ProfileEdit.cs プロジェクト: rfyiamcool/solrex
        public ProfileEdit(ChannelProfile prof)
        {
            //
            // Windows �t�H�[�� �f�U�C�i �T�|�[�g�ɕK�v�ł��B
            //
            InitializeComponent();
            InitializeText();

            //
            // TODO: InitializeComponent �Ăяo���̌�ɁA�R���X�g���N�^ �R�[�h��lj����Ă��������B
            //
            InitUI(prof);
        }
コード例 #24
0
ファイル: ProfileEdit.cs プロジェクト: takano32/poderosa
        public ProfileEdit(ChannelProfile prof)
        {
            //
            // Windows フォーム デザイナ サポートに必要です。
            //
            InitializeComponent();
            InitializeText();

            //
            // TODO: InitializeComponent 呼び出しの後に、コンストラクタ コードを追加してください。
            //
            InitUI(prof);
        }
コード例 #25
0
        public SSHShortcutLoginDialog(ChannelProfile profile) {
            //
            // Windows フォーム デザイナ サポートに必要です。
            //
            InitializeComponent();
            InitializeText();

            //
            // TODO: InitializeComponent 呼び出しの後に、コンストラクタ コードを追加してください。
            //
            _profile = profile;
            InitUI();
        }
コード例 #26
0
        /*
         * private static Socks CreateSocksParam(string dest_host, int dest_port) {
         *  Socks s = new Socks();
         *  s.DestName = dest_host;
         *  s.DestPort = (short)dest_port;
         *  s.Account = Env.Options.SocksAccount;
         *  s.Password = Env.Options.SocksPassword;
         *  s.ServerName = Env.Options.SocksServer;
         *  s.ServerPort = (short)Env.Options.SocksPort;
         *  s.ExcludingNetworks = Env.Options.SocksNANetworks;
         *  return s;
         * }
         */
        public void ManualClose(ChannelProfile prof)
        {
            if (!IsConnected(prof))
            {
                Debug.WriteLine("ManualClose - Not connected");
                return;
            }

            lock (this) {
                ISSHConnection c = (ISSHConnection)_profileToConnection[prof];
                _manualClosingConnections.Add(c);
                c.Disconnect(DisconnectionReasonCode.ByApplication, "close by application");
            }
        }
コード例 #27
0
ファイル: MainForm.cs プロジェクト: yueker/poderosa
        //コンテキストメニューと双方で使用する
        private void AdjustMenu(ToolStripItemCollection items, ChannelProfile prof)
        {
            bool connected = prof != null && Env.Connections.IsConnected(prof);

            ConvertMenuItem(items, _menuProfileConnect).Enabled    = prof != null && !connected;
            ConvertMenuItem(items, _menuProfileDisconnect).Enabled = prof != null && connected;
            ConvertMenuItem(items, _menuProfileRemove).Enabled     = prof != null && !connected;
            ConvertMenuItem(items, _menuProfileProperty).Enabled   = prof != null && !connected;

            int index = prof == null ? -1 : Env.Profiles.IndexOf(prof);

            ConvertMenuItem(items, _menuProfileUp).Enabled   = prof != null && index > 0;
            ConvertMenuItem(items, _menuProfileDown).Enabled = prof != null && index < Env.Profiles.Count - 1;
        }
コード例 #28
0
        /*
         * private static Socks CreateSocksParam(string dest_host, int dest_port) {
         *  Socks s = new Socks();
         *  s.DestName = dest_host;
         *  s.DestPort = (short)dest_port;
         *  s.Account = Env.Options.SocksAccount;
         *  s.Password = Env.Options.SocksPassword;
         *  s.ServerName = Env.Options.SocksServer;
         *  s.ServerPort = (short)Env.Options.SocksPort;
         *  s.ExcludingNetworks = Env.Options.SocksNANetworks;
         *  return s;
         * }
         */
        public void ManualClose(ChannelProfile prof)
        {
            if (!IsConnected(prof))
            {
                Debug.WriteLine("ManualClose - Not connected");
                return;
            }

            lock (this) {
                SSHConnection c = (SSHConnection)_profileToConnection[prof];
                _manualClosingConnections.Add(c);
                c.Disconnect("");
            }
        }
コード例 #29
0
        public SSHShortcutLoginDialog(ChannelProfile profile)
        {
            //
            // Windows フォーム デザイナ サポートに必要です。
            //
            InitializeComponent();
            InitializeText();

            //
            // TODO: InitializeComponent 呼び出しの後に、コンストラクタ コードを追加してください。
            //
            _profile = profile;
            InitUI();
        }
コード例 #30
0
        public SSHShortcutLoginDialog(ChannelProfile profile)
        {
            //
            // Windows �t�H�[�� �f�U�C�i �T�|�[�g�ɕK�v�ł��B
            //
            InitializeComponent();
            InitializeText();

            //
            // TODO: InitializeComponent �Ăяo���̌�ɁA�R���X�g���N�^ �R�[�h��lj����Ă��������B
            //
            _profile = profile;
            InitUI();
        }
コード例 #31
0
        public void LogConnectionOpened(ChannelProfile prof, int id)
        {
            string t = String.Format("{0} {1} connection opened; id={2}", DateTime.Now.ToString(), prof.ProtocolType.ToString(), id);

            if (prof is LocalToRemoteChannelProfile)
            {
                t = String.Format("{0}; from=localhost:{1}; to={2}:{3}", t, prof.ListenPort, prof.DestinationHost, prof.DestinationPort);
            }
            else
            {
                t = String.Format("{0}; from={1}:{2}; to={3}:{4}", t, prof.SSHHost, prof.ListenPort, prof.DestinationHost, prof.DestinationPort);
            }

            _strm.WriteLine(t);
            _strm.Flush();
        }
コード例 #32
0
ファイル: commands.cs プロジェクト: takano32/poderosa
        public void EditProfile(ChannelProfile prof)
        {
            if (Env.Connections.IsConnected(prof))
            {
                Util.Warning(Env.MainForm, Env.Strings.GetString("Message.Commands.CannotEditConnectedProfile"));
                return;
            }

            ProfileEdit dlg = new ProfileEdit(prof);

            if (dlg.ShowDialog(Env.MainForm) == DialogResult.OK)
            {
                Env.Profiles.ReplaceProfile(prof, dlg.ResultProfile);
                Env.MainForm.RefreshAllProfiles();
            }
        }
コード例 #33
0
ファイル: channel.cs プロジェクト: takano32/poderosa
 public static ChannelFactory Create(ChannelProfile prof)
 {
     /*
      * if(prof.ProtocolType==ProtocolType.Udp)
      *  return new UdpChannelFactory(prof);
      * else
      */
     if (prof is LocalToRemoteChannelProfile)
     {
         return(new LocalToRemoteChannelFactory((LocalToRemoteChannelProfile)prof));
     }
     else
     {
         return(new RemoteToLocalChannelFactory((RemoteToLocalChannelProfile)prof));
     }
 }
コード例 #34
0
        //profに対応したSSHConnectionを返す。接続がなければparentを親に認証ダイアログを出して認証する
        public SSHConnection GetOrCreateConnection(ChannelProfile prof, Form parent) {
            //ホスト名とアカウントのペアからコネクションを共有する仕組みがあるとよいかも
            SSHConnection c = (SSHConnection)_profileToConnection[prof];
            if (c != null)
                return c;

            SSHShortcutLoginDialog dlg = new SSHShortcutLoginDialog(prof);
            DialogResult result = DialogResult.No;

            //認証設定がない場合はそのまま接続
            if (!prof.Auth)
            {
                // 疑似的にOKボタン押下
                dlg.OnOK(null, EventArgs.Empty);
                // 非同期で接続が行われるので1秒待つ
                System.Threading.Thread.Sleep(1000);
                result = DialogResult.OK;
            }
            // 認証が必要な場合
            else
            {
                // ダイアログによるユーザ認証
                result = dlg.ShowDialog(parent);
            }

            if (result == DialogResult.OK)
            {
                c = dlg.Result.Connection;
                try
                {
                    dlg.Result.WaitRequest();
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.StackTrace);
                    Util.Warning(parent, ex.Message);
                    c.Close();
                    return null;
                }
                _profileToConnection[prof] = c;
                Env.MainForm.RefreshProfileStatus(prof);
            }

            return c;
        }
コード例 #35
0
ファイル: MainForm.cs プロジェクト: yueker/poderosa
 private void OnListViewKeyPress(object sender, KeyPressEventArgs args)
 {
     if (args.KeyChar == '\r')
     {
         ChannelProfile prof = GetSelectedProfile();
         if (prof != null)
         {
             if (Control.ModifierKeys == Keys.Control)
             {
                 Env.Commands.EditProfile(prof);
             }
             else if (!Env.Connections.IsConnected(prof))
             {
                 Env.Commands.ConnectProfile(prof);
             }
         }
     }
 }
コード例 #36
0
ファイル: ProfileEdit.cs プロジェクト: takano32/poderosa
        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();
                }
            }
        }
コード例 #37
0
ファイル: connectionmanager.cs プロジェクト: SyaaS/poderosa
        //profに対応したSSHConnectionを返す。接続がなければparentを親に認証ダイアログを出して認証する
        public SSHConnection GetOrCreateConnection(ChannelProfile prof, Form parent) {
            //ホスト名とアカウントのペアからコネクションを共有する仕組みがあるとよいかも
            SSHConnection c = (SSHConnection)_profileToConnection[prof];
            if (c != null)
                return c;

            SSHShortcutLoginDialog dlg = new SSHShortcutLoginDialog(prof);
            if (dlg.ShowDialog(parent) == DialogResult.OK) {
                c = dlg.Result.Connection;
                try {
                    dlg.Result.WaitRequest();
                }
                catch (Exception ex) {
                    Debug.WriteLine(ex.StackTrace);
                    Util.Warning(parent, ex.Message);
                    c.Close();
                    return null;
                }
                _profileToConnection[prof] = c;
                Env.MainForm.RefreshProfileStatus(prof);
            }

            return c;
        }
コード例 #38
0
ファイル: commands.cs プロジェクト: takano32/poderosa
 public void DisconnectProfile(ChannelProfile prof)
 {
     Env.Connections.ManualClose(prof);
 }
コード例 #39
0
ファイル: channelprofile.cs プロジェクト: rfyiamcool/solrex
 public void InsertAt(int index, ChannelProfile prof)
 {
     _data.Insert(index, prof);
 }
コード例 #40
0
ファイル: ProfileEdit.cs プロジェクト: Ricordanza/poderosa
        private void InitUI(ChannelProfile prof) {
            if (prof == null) {
                _localToRemoteOption.Checked = true;
                _passwordOption.Checked = true;
            }
            else {
                _nameBox.Text = prof.Name;
                _sshHostBox.Text = prof.SSHHost;
                _portBox.Text = prof.SSHPort.ToString();
                _accountBox.Text = prof.SSHAccount;
                _noAuth.Checked = prof.Auth;

                //_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();
                }
            }
        }
コード例 #41
0
ファイル: commands.cs プロジェクト: takano32/poderosa
 public void ConnectProfile(ChannelProfile prof)
 {
     Env.Connections.GetOrCreateConnection(prof, Env.MainForm);
 }
コード例 #42
0
ファイル: channelprofile.cs プロジェクト: yueker/poderosa
 public void ReplaceProfile(ChannelProfile p1, ChannelProfile p2)
 {
     _data[_data.IndexOf(p1)] = p2;
 }
コード例 #43
0
ファイル: ProfileEdit.cs プロジェクト: Ricordanza/poderosa
        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;

                _result.Name = _nameBox.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);
            }

        }
コード例 #44
0
ファイル: channelprofile.cs プロジェクト: rfyiamcool/solrex
 public void AddProfile(ChannelProfile p)
 {
     _data.Add(p);
 }
コード例 #45
0
ファイル: channelprofile.cs プロジェクト: yueker/poderosa
 public void RemoveProfile(ChannelProfile p)
 {
     _data.Remove(p);
 }
コード例 #46
0
ファイル: ProfileEdit.cs プロジェクト: takano32/poderosa
        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);
            }
        }
コード例 #47
0
ファイル: Util.cs プロジェクト: Ricordanza/poderosa
 public static IPAddress ChannelProfileToListeningAddress(ChannelProfile prof) {
     if (prof.UseIPv6)
         return prof.AllowsForeignConnection ? IPAddress.IPv6Any : IPAddress.IPv6Loopback;
     else
         return prof.AllowsForeignConnection ? IPAddress.Any : IPAddress.Loopback;
 }
コード例 #48
0
ファイル: Util.cs プロジェクト: Ricordanza/poderosa
 public static Color GetProfileStatusColor(ChannelProfile prof)
 {
     return Env.Connections.IsConnected(prof) ? Color.GreenYellow : Color.White;
 }
コード例 #49
0
ファイル: Util.cs プロジェクト: Ricordanza/poderosa
 public static string GetProfileStatusString(ChannelProfile prof) {
     return Env.Strings.GetString(Env.Connections.IsConnected(prof) ? "Caption.Util.Connected" : "Caption.Util.Disconnected");
 }
コード例 #50
0
ファイル: Util.cs プロジェクト: Ricordanza/poderosa
 public static string GetProfileTypeString(ChannelProfile prof) {
     if (prof is LocalToRemoteChannelProfile)
         return Env.Strings.GetString("Caption.Util.Local");
     else
         return Env.Strings.GetString("Caption.Util.Remote");
 }
コード例 #51
0
ファイル: channelprofile.cs プロジェクト: rfyiamcool/solrex
 public void ReplaceProfile(ChannelProfile p1, ChannelProfile p2)
 {
     _data[_data.IndexOf(p1)] = p2;
 }
コード例 #52
0
        /*
        private static Socks CreateSocksParam(string dest_host, int dest_port) {
            Socks s = new Socks();
            s.DestName = dest_host;
            s.DestPort = (short)dest_port;
            s.Account = Env.Options.SocksAccount;
            s.Password = Env.Options.SocksPassword;
            s.ServerName = Env.Options.SocksServer;
            s.ServerPort = (short)Env.Options.SocksPort;
            s.ExcludingNetworks = Env.Options.SocksNANetworks;
            return s;
        }
        */
        public void ManualClose(ChannelProfile prof)
        {
            if (!IsConnected(prof)) {
                Debug.WriteLine("ManualClose - Not connected");
                return;
            }

            lock (this) {
                ISSHConnection c = (ISSHConnection)_profileToConnection[prof];
                _manualClosingConnections.Add(c);
                c.Disconnect(DisconnectionReasonCode.ByApplication, "close by application");
            }
        }
コード例 #53
0
ファイル: channelprofile.cs プロジェクト: rfyiamcool/solrex
 public int IndexOf(ChannelProfile p)
 {
     return _data.IndexOf(p);
 }
コード例 #54
0
 public static string GetProfileStatusString(ChannelProfile prof)
 {
     return(Env.Strings.GetString(Env.Connections.IsConnected(prof) ? "Caption.Util.Connected" : "Caption.Util.Disconnected"));
 }
コード例 #55
0
ファイル: channelprofile.cs プロジェクト: rfyiamcool/solrex
 public void RemoveProfile(ChannelProfile p)
 {
     _data.Remove(p);
 }
コード例 #56
0
ファイル: MainForm.cs プロジェクト: Ricordanza/poderosa
        //コンテキストメニューと双方で使用する
        private void AdjustMenu(ToolStripItemCollection items, ChannelProfile prof) {
            bool connected = prof != null && Env.Connections.IsConnected(prof);

            ConvertMenuItem(items, _menuProfileConnect).Enabled = prof != null && !connected;
            ConvertMenuItem(items, _menuProfileDisconnect).Enabled = prof != null && connected;
            ConvertMenuItem(items, _menuProfileRemove).Enabled = prof != null && !connected;
            ConvertMenuItem(items, _menuProfileProperty).Enabled = prof != null && !connected;

            int index = prof == null ? -1 : Env.Profiles.IndexOf(prof);
            ConvertMenuItem(items, _menuProfileUp).Enabled = prof != null && index > 0;
            ConvertMenuItem(items, _menuProfileDown).Enabled = prof != null && index < Env.Profiles.Count - 1;
        }
コード例 #57
0
 public bool IsConnected(ChannelProfile prof)
 {
     return _profileToConnection[prof] != null;
 }
コード例 #58
0
ファイル: MainForm.cs プロジェクト: Ricordanza/poderosa
 private ListViewItem FindItem(ChannelProfile prof) {
     foreach (ListViewItem li in _list.Items) {
         if (li.Tag == prof)
             return li;
     }
     return null;
 }
コード例 #59
0
 public SSHConnector(ChannelProfile prof, string password, VerifySSHHostKeyDelegate keycheck)
 {
     _profile = prof;
     _password = password;
     _keycheck = keycheck;
 }
コード例 #60
0
ファイル: channelprofile.cs プロジェクト: yueker/poderosa
 public int IndexOf(ChannelProfile p)
 {
     return(_data.IndexOf(p));
 }