Exemple #1
0
 public void CheckPort()
 {
     PortCheckStatus = PortCheckStatus.Checking;
     CheckPortAsync().ContinueWith(prev => {
         if (prev.IsCanceled || prev.IsFaulted)
         {
             PortCheckStatus   = PortCheckStatus.Failed;
             PortCheckV6Status = PortCheckStatus.Failed;
         }
         else
         {
             PortCheckStatus   = prev.Result.ResultV4;
             PortCheckV6Status = prev.Result.ResultV6;
         }
     });
 }
        public void PortCheck()
        {
            var ports = peerCast.OutputListeners
                        .Where(listener => (listener.GlobalOutputAccepts & OutputStreamType.Relay) != 0)
                        .Select(listener => listener.LocalEndPoint.Port);
            Uri target_uri;

            if (!AppSettingsReader.TryGetUri("PCPPortChecker", out target_uri))
            {
                return;
            }
            var checker = new PeerCastStation.UI.PCPPortChecker(peerCast.SessionID, target_uri, ports);

            checker.PortCheckCompleted += checker_PortCheckCompleted;
            checker.RunAsync();
            PortCheckStatus = PortCheckStatus.Checking;
        }
 void checker_PortCheckCompleted(object sender, UI.PortCheckCompletedEventArgs args)
 {
     if (args.Success)
     {
         var status = PortCheckStatus.Closed;
         foreach (var port in ports)
         {
             port.IsOpen = args.Ports.Contains(port.Port);
             if (port.IsOpen.HasValue && port.IsOpen.Value)
             {
                 status = PortCheckStatus.Opened;
             }
         }
         PortCheckStatus = status;
     }
     else
     {
         PortCheckStatus = PortCheckStatus.Failed;
     }
 }
Exemple #4
0
        public void Apply()
        {
            if (!IsModified)
            {
                return;
            }
            IsModified = false;

            ChannelCleaner.Mode                 = channelCleanupMode;
            ChannelCleaner.InactiveLimit        = channelCleanupInactiveLimit * 60000;
            peerCast.AccessController.MaxRelays = maxRelays;
            peerCast.AccessController.MaxRelaysPerBroadcastChannel = maxRelaysPerBroadcastChannel;
            peerCast.AccessController.MaxRelaysPerRelayChannel     = maxRelaysPerRelayChannel;
            peerCast.AccessController.MaxPlays = maxPlays;
            peerCast.AccessController.MaxPlaysPerBroadcastChannel        = maxPlaysPerBroadcastChannel;
            peerCast.AccessController.MaxPlaysPerRelayChannel            = maxPlaysPerRelayChannel;
            peerCast.AccessController.MaxUpstreamRate                    = maxUpstreamRate;
            peerCast.AccessController.MaxUpstreamRateIPv6                = maxUpstreamRateIPv6;
            peerCast.AccessController.MaxUpstreamRatePerBroadcastChannel = maxUpstreamRatePerBroadcastChannel;
            peerCast.AccessController.MaxUpstreamRatePerRelayChannel     = maxUpstreamRatePerRelayChannel;
            pecaApp.Settings.Get <WPFSettings>().ShowWindowOnStartup     = isShowWindowOnStartup;
            pecaApp.Settings.Get <WPFSettings>().ShowNotifications       = isShowNotifications;
            pecaApp.Settings.Get <WPFSettings>().RemoteNodeName          = remoteNodeName;
            if (IsListenersModified)
            {
                foreach (var listener in peerCast.OutputListeners.ToArray())
                {
                    peerCast.StopListen(listener);
                }
                foreach (var listener in ports)
                {
                    var newlistener = peerCast.StartListen(listener.EndPoint, listener.LocalAccepts, listener.GlobalAccepts);
                    newlistener.GlobalAuthorizationRequired = listener.GlobalAuthRequired;
                    newlistener.LocalAuthorizationRequired  = listener.LocalAuthRequired;
                    newlistener.AuthenticationKey           = listener.AuthenticationKey;
                }
                isListenersModified = false;
            }
            if (IsYellowPagesModified)
            {
                foreach (var yp in peerCast.YellowPages.ToArray())
                {
                    peerCast.RemoveYellowPage(yp);
                }
                foreach (var yp in yellowPages)
                {
                    if (String.IsNullOrEmpty(yp.Name))
                    {
                        continue;
                    }
                    if (String.IsNullOrEmpty(yp.AnnounceUri) && String.IsNullOrEmpty(yp.ChannelsUri))
                    {
                        continue;
                    }
                    Uri announce_uri = String.IsNullOrEmpty(yp.AnnounceUri) ? null : new Uri(yp.AnnounceUri, UriKind.Absolute);
                    Uri channels_uri = String.IsNullOrEmpty(yp.ChannelsUri) ? null : new Uri(yp.ChannelsUri, UriKind.Absolute);
                    peerCast.AddYellowPage(yp.Protocol.Protocol, yp.Name, announce_uri, channels_uri);
                }
                isYellowPagesModified = false;
            }
            var port_mapper = pecaApp.Plugins.GetPlugin <PeerCastStation.UI.PortMapperPlugin>();

            if (port_mapper != null)
            {
                port_mapper.Enabled = portMapperEnabled;
                port_mapper.DiscoverAsync()
                .ContinueWith(prev => OnPropertyChanged("PortMapperExternalAddresses"));
            }
            PortCheckStatus   = PortCheckStatus.Checking;
            PortCheckV6Status = PortCheckStatus.Checking;
            CheckPortAsync().ContinueWith(prev => {
                if (prev.IsCanceled || prev.IsFaulted)
                {
                    PortCheckStatus   = PortCheckStatus.Failed;
                    PortCheckV6Status = PortCheckStatus.Failed;
                }
                else
                {
                    PortCheckStatus   = prev.Result.ResultV4;
                    PortCheckV6Status = prev.Result.ResultV6;
                    peerCast.SetPortStatus(System.Net.Sockets.AddressFamily.InterNetwork, prev.Result.ResultV4 == PortCheckStatus.Opened ? PortStatus.Open : PortStatus.Firewalled);
                    peerCast.SetPortStatus(System.Net.Sockets.AddressFamily.InterNetworkV6, prev.Result.ResultV6 == PortCheckStatus.Opened ? PortStatus.Open : PortStatus.Firewalled);
                }
            });
            pecaApp.SaveSettings();
        }
 void checker_PortCheckCompleted(object sender, UI.PortCheckCompletedEventArgs args)
 {
   if (args.Success) {
     var status = PortCheckStatus.Closed;
     foreach (var port in ports) {
       port.IsOpen = args.Ports.Contains(port.Port);
       if (port.IsOpen.HasValue && port.IsOpen.Value) {
         status = PortCheckStatus.Opened;
       }
     }
     PortCheckStatus = status;
   }
   else {
     PortCheckStatus = PortCheckStatus.Failed;
   }
 }
 public void PortCheck()
 {
   var ports = peerCast.OutputListeners
     .Where( listener => (listener.GlobalOutputAccepts & OutputStreamType.Relay)!=0)
     .Select(listener => listener.LocalEndPoint.Port);
   Uri target_uri;
   if (!AppSettingsReader.TryGetUri("PCPPortChecker", out target_uri)) return;
   var checker = new PeerCastStation.UI.PCPPortChecker(peerCast.SessionID, target_uri, ports);
   checker.PortCheckCompleted += checker_PortCheckCompleted;
   checker.RunAsync();
   PortCheckStatus = PortCheckStatus.Checking;
 }
    public void Apply()
    {
      if (!IsModified) return;
      IsModified = false;

      ChannelCleaner.Mode = channelCleanupMode;
      ChannelCleaner.InactiveLimit = channelCleanupInactiveLimit*60000;
      peerCast.AccessController.MaxRelays = maxRelays;
      peerCast.AccessController.MaxRelaysPerChannel = maxRelaysPerChannel;
      peerCast.AccessController.MaxPlays = maxPlays;
      peerCast.AccessController.MaxPlaysPerChannel = maxPlaysPerChannel;
      peerCast.AccessController.MaxUpstreamRate = maxUpstreamRate;
      peerCast.AccessController.MaxUpstreamRatePerChannel = maxUpstreamRatePerChannel;
      pecaApp.Settings.Get<WPFSettings>().ShowWindowOnStartup = isShowWindowOnStartup;
      if (IsListenersModified) {
        foreach (var listener in peerCast.OutputListeners.ToArray()) {
          peerCast.StopListen(listener);
        }
        foreach (var listener in ports) {
          var newlistener = peerCast.StartListen(listener.EndPoint, listener.LocalAccepts, listener.GlobalAccepts);
          newlistener.GlobalAuthorizationRequired = listener.GlobalAuthRequired;
          newlistener.LocalAuthorizationRequired = listener.LocalAuthRequired;
          newlistener.AuthenticationKey = listener.AuthenticationKey;
        }
        isListenersModified = false;
      }
      if (IsYellowPagesModified) {
        foreach (var yp in peerCast.YellowPages.ToArray()) {
          peerCast.RemoveYellowPage(yp);
        }
        foreach (var yp in yellowPages) {
          if (String.IsNullOrEmpty(yp.Name)) continue;
          if (String.IsNullOrEmpty(yp.AnnounceUri) && String.IsNullOrEmpty(yp.ChannelsUri)) continue;
          Uri announce_uri = String.IsNullOrEmpty(yp.AnnounceUri) ? null : new Uri(yp.AnnounceUri, UriKind.Absolute);
          Uri channels_uri = String.IsNullOrEmpty(yp.ChannelsUri) ? null : new Uri(yp.ChannelsUri, UriKind.Absolute);
          peerCast.AddYellowPage(yp.Protocol.Protocol, yp.Name, announce_uri, channels_uri);
        }
        isYellowPagesModified = false;
      }
      var port_mapper = pecaApp.Plugins.GetPlugin<PeerCastStation.UI.PortMapperPlugin>();
      if (port_mapper!=null) {
        port_mapper.Enabled = portMapperEnabled;
        port_mapper.DiscoverAsync()
          .ContinueWith(prev => OnPropertyChanged("PortMapperExternalAddresses"));
      }
      PortCheckStatus = PortCheckStatus.Checking;
      CheckPortAsync().ContinueWith(prev => {
        if (prev.IsCanceled || prev.IsFaulted) {
          PortCheckStatus = PortCheckStatus.Failed;
        }
        else {
          PortCheckStatus = prev.Result;
          peerCast.IsFirewalled = prev.Result!=PortCheckStatus.Opened;
        }
      });
      pecaApp.SaveSettings();
    }
 public void CheckPort()
 {
   PortCheckStatus = PortCheckStatus.Checking;
   CheckPortAsync().ContinueWith(prev => {
     if (prev.IsCanceled || prev.IsFaulted) {
       PortCheckStatus = PortCheckStatus.Failed;
     }
     else {
       PortCheckStatus = prev.Result;
     }
   });
 }