Example #1
0
 public AccessControlInfo(
     OutputStreamType accepts,
     bool auth_required,
     AuthenticationKey key)
 {
     this.Accepts = accepts;
     this.AuthorizationRequired = auth_required;
     this.AuthenticationKey     = key;
 }
Example #2
0
 /// <summary>
 /// 指定したエンドポイントで接続待ち受けをするOutputListenerを初期化します
 /// </summary>
 /// <param name="peercast">所属するPeerCastオブジェクト</param>
 /// <param name="ip">待ち受けをするエンドポイント</param>
 /// <param name="local_accepts">リンクローカルな接続先に許可する出力ストリームタイプ</param>
 /// <param name="global_accepts">リンクグローバルな接続先に許可する出力ストリームタイプ</param>
 internal OutputListener(
     PeerCast peercast,
     IPEndPoint ip,
     OutputStreamType local_accepts,
     OutputStreamType global_accepts)
 {
     this.PeerCast                    = peercast;
     this.localOutputAccepts          = local_accepts;
     this.globalOutputAccepts         = global_accepts;
     this.LocalAuthorizationRequired  = false;
     this.GlobalAuthorizationRequired = true;
     this.AuthenticationKey           = AuthenticationKey.Generate();
     server = new TcpListener(ip);
     server.Server.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
     server.Start();
     listenerThread      = new Thread(ListenerThreadFunc);
     listenerThread.Name = String.Format("OutputListenerThread:{0}", ip);
     listenerThread.Start(server);
 }
 public AccessControlInfo(
   OutputStreamType accepts,
   bool auth_required,
   AuthenticationKey key)
 {
   this.Accepts                = accepts;
   this.AuthorizationRequired  = auth_required;
   this.AuthenticationKey      = key;
 }
 private IOutputStreamFactory FindMatchedFactory(
     RemoteType remote_type,
     NetworkStream stream,
     out List<byte> header,
     out Guid channel_id,
     out AuthenticationKey auth_key)
 {
     var output_factories = PeerCast.OutputStreamFactories.OrderBy(factory => factory.Priority);
       header = new List<byte>();
       channel_id = Guid.Empty;
       auth_key = null;
       bool eos = false;
       while (!eos && header.Count<=4096) {
     try {
       do {
     var val = stream.ReadByte();
     if (val < 0) {
       eos = true;
     }
     else {
       header.Add((byte)val);
     }
       } while (stream.DataAvailable);
     }
     catch (System.IO.IOException) {
       eos = true;
     }
     var header_ary = header.ToArray();
     foreach (var factory in output_factories) {
       if (remote_type==RemoteType.SiteLocal && (factory.OutputStreamType & this.LocalOutputAccepts )==0) continue;
       if (remote_type==RemoteType.Global    && (factory.OutputStreamType & this.GlobalOutputAccepts)==0) continue;
       var cid = factory.ParseChannelID(header_ary);
       if (cid.HasValue) {
     channel_id = cid.Value;
     switch (remote_type) {
     case RemoteType.Loopback:  auth_key = null; break;
     case RemoteType.SiteLocal: auth_key = LocalAuthorizationRequired  ? AuthenticationKey : null; break;
     case RemoteType.Global:    auth_key = GlobalAuthorizationRequired ? AuthenticationKey : null; break;
     }
     return factory;
       }
     }
       }
       return null;
 }
Example #5
0
 public void ResetAuthenticationKey()
 {
     this.AuthenticationKey = AuthenticationKey.Generate();
 }
Example #6
0
        private IOutputStreamFactory FindMatchedFactory(
            RemoteType remote_type,
            NetworkStream stream,
            out List <byte> header,
            out Guid channel_id,
            out AuthenticationKey auth_key)
        {
            var output_factories = PeerCast.OutputStreamFactories.OrderBy(factory => factory.Priority);

            header     = new List <byte>();
            channel_id = Guid.Empty;
            auth_key   = null;
            bool eos = false;

            while (!eos && header.Count <= 4096)
            {
                try {
                    do
                    {
                        var val = stream.ReadByte();
                        if (val < 0)
                        {
                            eos = true;
                        }
                        else
                        {
                            header.Add((byte)val);
                        }
                    } while (stream.DataAvailable);
                }
                catch (System.IO.IOException) {
                    eos = true;
                }
                var header_ary = header.ToArray();
                foreach (var factory in output_factories)
                {
                    if (remote_type == RemoteType.SiteLocal && (factory.OutputStreamType & this.LocalOutputAccepts) == 0)
                    {
                        continue;
                    }
                    if (remote_type == RemoteType.Global && (factory.OutputStreamType & this.GlobalOutputAccepts) == 0)
                    {
                        continue;
                    }
                    var cid = factory.ParseChannelID(header_ary);
                    if (cid.HasValue)
                    {
                        channel_id = cid.Value;
                        switch (remote_type)
                        {
                        case RemoteType.Loopback:  auth_key = null; break;

                        case RemoteType.SiteLocal: auth_key = LocalAuthorizationRequired  ? AuthenticationKey : null; break;

                        case RemoteType.Global:    auth_key = GlobalAuthorizationRequired ? AuthenticationKey : null; break;
                        }
                        return(factory);
                    }
                }
            }
            return(null);
        }
 public AccessControlInfo(AuthenticationKey key)
 {
     this.AuthenticationKey = key;
 }
Example #8
0
 public AccessControlInfo(AuthenticationKey key)
 {
     this.AuthenticationKey = key;
 }