private void remPortException()
 {
     if (FirewallUtility.HasVistaFirewall)
     {
         FirewallUtility.RemoveAppFromVistaFirewall(FW_EXCEPTION_NAME);
     }
     else if (FirewallUtility.HasSp2Firewall)
     {
         FirewallUtility.RemovePortExceptionFromSP2Firewall(this.port, NetFwTypeLib.NET_FW_IP_PROTOCOL_.NET_FW_IP_PROTOCOL_UDP);
     }
     else
     {
         FirewallUtility.RemoveOldFirewallPort(FW_EXCEPTION_NAME, (ushort)this.port, System.Net.Sockets.ProtocolType.Udp);
     }
 }
 private void addPortException()
 {
     if (FirewallUtility.HasVistaFirewall)
     {
         FirewallUtility.AddPortExceptionToVistaFirewall(FW_EXCEPTION_NAME, this.port.ToString(), NetFwTypeLib.NET_FW_IP_PROTOCOL_.NET_FW_IP_PROTOCOL_UDP);
     }
     else if (FirewallUtility.HasSp2Firewall)
     {
         FirewallUtility.AddPortExceptionToSP2Firewall(FW_EXCEPTION_NAME, this.port, NetFwTypeLib.NET_FW_IP_PROTOCOL_.NET_FW_IP_PROTOCOL_UDP);
     }
     else
     {
         FirewallUtility.AddOldFirewallPort(FW_EXCEPTION_NAME, (ushort)this.port, System.Net.Sockets.ProtocolType.Udp);
     }
 }
Exemplo n.º 3
0
        public Task ConfigureMachineForHosting()
        {
            TaskCompletionSource <object> taskCompletionSource = new TaskCompletionSource <object>();

            void NatUtilityDeviceFound(object sender, DeviceEventArgs e)
            {
                NatUtility.StopDiscovery();
                NatUtility.DeviceFound -= NatUtilityDeviceFound;

                Setup(e.Device);

                FirewallUtility.OpenPort(NetworkPort, "SharePlay");

                taskCompletionSource.SetResult(null);
            }

            NatUtility.DeviceFound += NatUtilityDeviceFound;
            NatUtility.StartDiscovery();

            return(taskCompletionSource.Task);
        }
Exemplo n.º 4
0
 private void Dispose(bool disposing)
 {
     _mainNatDevice?.DeletePortMap(PortMap);
     FirewallUtility.ClosePort(NetworkPort);
 }