예제 #1
0
        private void updateTimer_Tick(object sender, EventArgs e)
        {
            listView1.Items[0].SubItems[1].Text = _node.ActiveLocalServicePort.ToString();

            listView1.Items[1].SubItems[1].Text = _node.IPv4DhtTotalNodes.ToString();
            listView1.Items[2].SubItems[1].Text = _node.IPv6DhtTotalNodes.ToString();
            listView1.Items[3].SubItems[1].Text = _node.LanDhtTotalNodes.ToString();
            listView1.Items[4].SubItems[1].Text = _node.TorDhtTotalNodes.ToString();

            listView1.Items[5].SubItems[1].Text = (_node.IsTorRunning ? "Running" : "Stopped");
            listView1.Items[6].SubItems[1].Text = _node.IPv4InternetStatus.ToString();
            listView1.Items[7].SubItems[1].Text = _node.IPv6InternetStatus.ToString();

            listView1.Items[8].SubItems[1].Text = _node.UPnPStatus.ToString();

            IPAddress upnpExternalIP = _node.UPnPExternalIP;
            IPAddress upnpDeviceIP   = _node.UPnPDeviceIP;

            if ((upnpExternalIP == null) || (upnpDeviceIP == null))
            {
                listView1.Items[9].SubItems[1].Text = "";
            }
            else
            {
                listView1.Items[9].SubItems[1].Text = upnpDeviceIP.ToString();
            }

            if (upnpExternalIP == null)
            {
                listView1.Items[10].SubItems[1].Text = "";
            }
            else
            {
                listView1.Items[10].SubItems[1].Text = upnpExternalIP.ToString();
            }

            switch (_node.IPv4InternetStatus)
            {
            case InternetConnectivityStatus.HttpProxyInternetConnection:
            case InternetConnectivityStatus.Socks5ProxyInternetConnection:
                listView1.Items[11].SubItems[1].Text = _node.Proxy.Address + ":" + _node.Proxy.Port;
                listView1.Items[12].SubItems[1].Text = "Incoming connections blocked by proxy";
                break;

            case InternetConnectivityStatus.Identifying:
            case InternetConnectivityStatus.NoInternetConnection:
            case InternetConnectivityStatus.NoProxyInternetConnection:
            case InternetConnectivityStatus.NoTorInternetConnection:
            case InternetConnectivityStatus.ProxyConnectionFailed:
            case InternetConnectivityStatus.TorInternetConnectionFailed:
                listView1.Items[11].SubItems[1].Text = "";
                listView1.Items[12].SubItems[1].Text = "";
                break;

            case InternetConnectivityStatus.TorInternetConnection:
                listView1.Items[11].SubItems[1].Text = "";
                listView1.Items[12].SubItems[1].Text = "Incoming connections blocked by Tor";
                break;

            default:
                listView1.Items[11].SubItems[1].Text = "";

                EndPoint ep = _node.IPv4ExternalEndPoint;

                if (ep == null)
                {
                    listView1.Items[12].SubItems[1].Text = "Incoming connections blocked by NAT/Firewall";
                }
                else
                {
                    listView1.Items[12].SubItems[1].Text = ep.ToString();
                }

                break;
            }

            switch (_node.IPv6InternetStatus)
            {
            case InternetConnectivityStatus.HttpProxyInternetConnection:
            case InternetConnectivityStatus.Socks5ProxyInternetConnection:
                listView1.Items[11].SubItems[1].Text = _node.Proxy.Address + ":" + _node.Proxy.Port;
                listView1.Items[13].SubItems[1].Text = "Incoming connections blocked by proxy";
                break;

            case InternetConnectivityStatus.Identifying:
            case InternetConnectivityStatus.NoInternetConnection:
            case InternetConnectivityStatus.NoProxyInternetConnection:
            case InternetConnectivityStatus.NoTorInternetConnection:
            case InternetConnectivityStatus.ProxyConnectionFailed:
            case InternetConnectivityStatus.TorInternetConnectionFailed:
                listView1.Items[11].SubItems[1].Text = "";
                listView1.Items[13].SubItems[1].Text = "";
                break;

            case InternetConnectivityStatus.TorInternetConnection:
                listView1.Items[11].SubItems[1].Text = "";
                listView1.Items[13].SubItems[1].Text = "Incoming connections blocked by Tor";
                break;

            default:
                listView1.Items[11].SubItems[1].Text = "";

                EndPoint ep = _node.IPv6ExternalEndPoint;

                if (ep == null)
                {
                    listView1.Items[13].SubItems[1].Text = "Incoming connections blocked by Firewall";
                }
                else
                {
                    listView1.Items[13].SubItems[1].Text = ep.ToString();
                }

                break;
            }

            EndPoint torEp = _node.TorHiddenEndPoint;

            if (torEp == null)
            {
                listView1.Items[14].SubItems[1].Text = "";
            }
            else
            {
                listView1.Items[14].SubItems[1].Text = torEp.ToString();
            }

            {
                EndPoint[] tcpRelayNodes = _node.GetIPv4TcpRelayNodes();

                if (tcpRelayNodes.Length > 0)
                {
                    string tmp = "";

                    foreach (EndPoint proxyNodeEP in tcpRelayNodes)
                    {
                        tmp += ", " + proxyNodeEP.ToString();
                    }

                    listView1.Items[15].SubItems[1].Text = tmp.Substring(2);
                }
                else
                {
                    listView1.Items[15].SubItems[1].Text = "";
                }
            }

            {
                EndPoint[] tcpRelayNodes = _node.GetIPv6TcpRelayNodes();

                if (tcpRelayNodes.Length > 0)
                {
                    string tmp = "";

                    foreach (EndPoint proxyNodeEP in tcpRelayNodes)
                    {
                        tmp += ", " + proxyNodeEP.ToString();
                    }

                    listView1.Items[16].SubItems[1].Text = tmp.Substring(2);
                }
                else
                {
                    listView1.Items[16].SubItems[1].Text = "";
                }
            }

            listView1.Items[17].SubItems[1].Text = Program.FirewallEntryExists ? "Allowed" : "Blocked";
        }