public OutputStreamBase(
            PeerCast peercast,
            Stream input_stream,
            Stream output_stream,
            EndPoint remote_endpoint,
            Channel channel,
            byte[] header)
        {
            this.PeerCast       = peercast;
            this.InputStream    = input_stream;
            this.OutputStream   = output_stream;
            this.RemoteEndPoint = remote_endpoint;
            this.Channel        = channel;
            var ip = remote_endpoint as IPEndPoint;

            this.IsLocal = ip != null?Utils.IsSiteLocal(ip.Address) : true;

            this.IsStopped       = false;
            this.mainThread      = new Thread(MainProc);
            this.mainThread.Name = this.GetType().Name;
            this.SyncContext     = new QueuedSynchronizationContext();
            this.Logger          = new Logger(this.GetType());
            if (header != null)
            {
                this.recvStream.Write(header, 0, header.Length);
            }
        }
Esempio n. 2
0
 public IPEndPoint GetEndPoint(IPAddress remote_addr, OutputStreamType connection_type)
 {
     if (remote_addr == null)
     {
         throw new ArgumentNullException("remote_addr");
     }
     if (Utils.IsSiteLocal(remote_addr))
     {
         return(GetLocalEndPoint(remote_addr.AddressFamily, connection_type));
     }
     else
     {
         return(GetGlobalEndPoint(remote_addr.AddressFamily, connection_type));
     }
 }
Esempio n. 3
0
 private RemoteType GetRemoteType(IPEndPoint remote_endpoint)
 {
     if (remote_endpoint.Address.Equals(IPAddress.Loopback) ||
         remote_endpoint.Address.Equals(IPAddress.IPv6Loopback))
     {
         return(RemoteType.Loopback);
     }
     else if (Utils.IsSiteLocal(remote_endpoint.Address))
     {
         return(RemoteType.SiteLocal);
     }
     else
     {
         return(RemoteType.Global);
     }
 }
Esempio n. 4
0
 public OutputListener FindListener(IPAddress remote_addr, OutputStreamType connection_type)
 {
     if (remote_addr == null)
     {
         throw new ArgumentNullException("remote_addr");
     }
     if (Utils.IsSiteLocal(remote_addr))
     {
         var listener = outputListeners.FirstOrDefault(
             x => x.LocalEndPoint.AddressFamily == remote_addr.AddressFamily &&
             (x.LocalOutputAccepts & connection_type) != 0);
         return(listener);
     }
     else
     {
         var listener = outputListeners.FirstOrDefault(
             x => x.LocalEndPoint.AddressFamily == remote_addr.AddressFamily &&
             (x.GlobalOutputAccepts & connection_type) != 0);
         return(listener);
     }
 }