Beispiel #1
0
        /// <summary>
        /// Creates a new DirectIM connection
        /// </summary>
        /// <param name="method">The <see cref="DirectConnectionMethod"/> to use for the transfer</param>
        /// <param name="role">The <see cref="DirectConnectRole"/> of the local client in the transfer</param>
        public DirectIMConnection CreateNewDirectIMConnection(DirectConnectionMethod method, DirectConnectRole role)
        {
            DirectIMConnection retval = new DirectIMConnection(_parent, _id++, method, role);

            _directconnections.Add(retval);
            return(retval);
        }
Beispiel #2
0
 /// <summary>
 /// Initializes a new FileTransferConnection
 /// </summary>
 public FileTransferConnection(Session parent, int id, DirectConnectionMethod dcmethod, DirectConnectRole role)
     : base(parent, id, dcmethod, role)
 {
     Logging.WriteString("Creating new FTC (id " + id.ToString() + ")");
     base.DirectConnectionFailed += new DirectConnectionFailed(FileTransferConnection_DirectConnectionFailed);
     base.DirectConnectionReady  += new DirectConnectionReady(FileTransferConnection_DirectConnectionReady);
 }
Beispiel #3
0
        /// <summary>
        /// Creates a new Direct Connection
        /// </summary>
        /// <param name="parent">The <see cref="Session"/> that owns this connection</param>
        /// <param name="id">The connection's unique ID</param>
        /// <param name="dcmethod">The method (direct or proxied) that the connection is to use</param>
        /// <param name="role">The role of this connection in a Rendezvous session</param>
        public DirectConnection(Session parent, int id,
                                DirectConnectionMethod dcmethod, DirectConnectRole role)
            : base(parent, id)
        {
            directConnectionMethod = dcmethod;
            directConnectRole      = role;

            // Generate a random ICBM cookie
            Cookie = Cookie.CreateNullTerminatedCookieForSending();

            // Get the local IP

            //ClientIP = Dns.GetHostEntry(Dns.GetHostName()).AddressList[0].ToString();
            IPAddress[] addresses = Dns.GetHostEntry(Dns.GetHostName()).AddressList;
            foreach (IPAddress address in addresses)
            {
                if (address.AddressFamily == AddressFamily.InterNetwork)
                {
                    ClientIP = address.ToString();
                    break;
                }
            }

            if (String.IsNullOrEmpty(ClientIP))
            {
                throw new Exception("Local host does not have an IPv4 address bound to it");
            }
        }
 /// <summary>
 /// Initializes a new FileTransferConnection
 /// </summary>
 public FileTransferConnection(Session parent, int id, DirectConnectionMethod dcmethod, DirectConnectRole role)
     : base(parent, id, dcmethod, role)
 {
     Logging.WriteString("Creating new FTC (id " + id.ToString() + ")");
     base.DirectConnectionFailed += new DirectConnectionFailed(FileTransferConnection_DirectConnectionFailed);
     base.DirectConnectionReady += new DirectConnectionReady(FileTransferConnection_DirectConnectionReady);
 }
Beispiel #5
0
 /// <summary>
 /// Initializes a new DirectIMConnection
 /// </summary>
 public DirectIMConnection(Session parent, int id, DirectConnectionMethod method, DirectConnectRole role)
     : base(parent, id, method, role)
 {
     _messagetimer = new Timer(new TimerCallback(MessageSendCallback), null, Timeout.Infinite, Timeout.Infinite);
     base.DirectConnectionReady  += new DirectConnectionReady(DirectIMConnection_DirectConnectionReady);
     base.DirectConnectionFailed += new DirectConnectionFailed(DirectIMConnection_DirectConnectionFailed);
 }
Beispiel #6
0
        /// <summary>
        /// Creates a new file transfer connection
        /// </summary>
        /// <param name="method">The <see cref="DirectConnectionMethod"/> to use for the transfer</param>
        /// <param name="role">The <see cref="DirectConnectRole"/> of the local client in the transfer</param>
        public FileTransferConnection CreateNewFileTransferConnection(DirectConnectionMethod method,
                                                                      DirectConnectRole role)
        {
            FileTransferConnection retval = new FileTransferConnection(_parent, _id++, method, role);

            _directconnections.Add(retval);
            return(retval);
        }
Beispiel #7
0
        /// <summary>
        /// Direct connection to the sender has failed, attempt a proxy redirect
        /// </summary>
        private void FallbackToStage2Connection()
        {
            directConnectionMethod = DirectConnectionMethod.Proxied;
            _sequence = RendezvousSequence.Stage2;
            ProxySocketConnector connector = new ProxySocketConnector(parent, parent.ServerSettings.IcqProxyServer, parent.ServerSettings.LoginPort, Ssl);

            connector.ConnectionFailed += delegate
            {
                Logging.WriteString("FallbackToStage2Connection failed");
                DisconnectFromServer(true);
            };
            connector.ConnectionComplete += delegate(object sender, EventArgs e)
            {
                this.socket = (sender as ProxySocketConnector).Socket;
                InitAolProxyConnectFinished();
            };
            connector.BeginConnect();
        }
Beispiel #8
0
        /// <summary>
        /// Sets up a direct connection's sockets
        /// </summary>
        private string SetupRendezvousConnection(RendezvousData rd, DirectConnectionMethod method)
        {
            string retval = _parent.Rendezvous.CacheRendezvousData(rd);

            // Get the client IP
            string localhost = Dns.GetHostName();

            rd.ClientIP = Dns.GetHostEntry(localhost).AddressList[0].ToString();

            if (method == DirectConnectionMethod.Direct)
            {
                rd.UseProxy = false;
                StartSendThroughDirectConnection(rd);
            }
            else if (method == DirectConnectionMethod.Proxied)
            {
                rd.UseProxy = true;
                StartSendThroughProxy(rd);
            }

            // Return the key to the caller
            return(retval);
        }
Beispiel #9
0
 /// <summary>
 /// Send a file to the specified recipient via the specified method
 /// </summary>
 /// <param name="recipient">The screenname to which to send the file</param>
 /// <param name="filename">The path of the file to send</param>
 /// <param name="method">The <see cref="DirectConnectionMethod"/> to use when negotiating the file transfer</param>
 /// <returns>A unique key used to reference this file transfer</returns>
 public string SendFile(string recipient, string filename, DirectConnectionMethod method)
 {
     RendezvousData rd = CreateSendFileData(recipient, filename);
       return SetupRendezvousConnection(rd, method);
 }
Beispiel #10
0
        /// <summary>
        /// Sets up a direct connection's sockets
        /// </summary>
        private string SetupRendezvousConnection(RendezvousData rd, DirectConnectionMethod method)
        {
            string retval = _parent.Rendezvous.CacheRendezvousData(rd);

              // Get the client IP
              string localhost = Dns.GetHostName();
              rd.ClientIP = Dns.GetHostEntry(localhost).AddressList[0].ToString();

              if (method == DirectConnectionMethod.Direct)
              {
            rd.UseProxy = false;
            StartSendThroughDirectConnection(rd);
              }
              else if (method == DirectConnectionMethod.Proxied)
              {
            rd.UseProxy = true;
            StartSendThroughProxy(rd);
              }

              // Return the key to the caller
              return retval;
        }
Beispiel #11
0
 /// <summary>
 /// Start a DirectImage session with the specified recipient
 /// </summary>
 /// <param name="receipient">The screenname to which to send the image</param>
 /// <param name="method">The <see cref="DirectConnectionMethod"/> to use when negotiating the file transfer</param>
 /// <returns>A unique key used to reference this direct image session</returns>
 public string StartDirectImage(string receipient, DirectConnectionMethod method)
 {
     RendezvousData rd = CreateDirectIMData(receipient);
       return SetupRendezvousConnection(rd, method);
 }
Beispiel #12
0
 /// <summary>
 /// Direct connection to the sender has failed, attempt a proxy redirect
 /// </summary>
 private void FallbackToStage2Connection()
 {
     directConnectionMethod = DirectConnectionMethod.Proxied;
     _sequence = RendezvousSequence.Stage2;
     ProxySocketConnector connector = new ProxySocketConnector(parent, parent.ServerSettings.IcqProxyServer, parent.ServerSettings.LoginPort, Ssl);
     connector.ConnectionFailed += delegate
     {
         Logging.WriteString("FallbackToStage2Connection failed");
         DisconnectFromServer(true);
     };
     connector.ConnectionComplete += delegate(object sender, EventArgs e)
     {
         this.socket = (sender as ProxySocketConnector).Socket;
         InitAolProxyConnectFinished();
     };
     connector.BeginConnect();
 }
Beispiel #13
0
        /// <summary>
        /// Creates a new Direct Connection
        /// </summary>
        /// <param name="parent">The <see cref="Session"/> that owns this connection</param>
        /// <param name="id">The connection's unique ID</param>
        /// <param name="dcmethod">The method (direct or proxied) that the connection is to use</param>
        /// <param name="role">The role of this connection in a Rendezvous session</param>
        public DirectConnection(Session parent, int id,
                                DirectConnectionMethod dcmethod, DirectConnectRole role)
            : base(parent, id)
        {
            directConnectionMethod = dcmethod;
            directConnectRole = role;

            // Generate a random ICBM cookie
            Cookie = Cookie.CreateNullTerminatedCookieForSending();

            // Get the local IP

            //ClientIP = Dns.GetHostEntry(Dns.GetHostName()).AddressList[0].ToString();
            IPAddress[] addresses = Dns.GetHostEntry(Dns.GetHostName()).AddressList;
            foreach (IPAddress address in addresses)
            {
                if (address.AddressFamily == AddressFamily.InterNetwork)
                {
                    ClientIP = address.ToString();
                    break;
                }
            }

            if (String.IsNullOrEmpty(ClientIP))
            {
                throw new Exception("Local host does not have an IPv4 address bound to it");
            }
        }
Beispiel #14
0
 /// <summary>
 /// Creates a new file transfer connection
 /// </summary>
 /// <param name="method">The <see cref="DirectConnectionMethod"/> to use for the transfer</param>
 /// <param name="role">The <see cref="DirectConnectRole"/> of the local client in the transfer</param>
 public FileTransferConnection CreateNewFileTransferConnection(DirectConnectionMethod method,
                                                               DirectConnectRole role)
 {
     FileTransferConnection retval = new FileTransferConnection(_parent, _id++, method, role);
     _directconnections.Add(retval);
     return retval;
 }
Beispiel #15
0
 /// <summary>
 /// Creates a new DirectIM connection
 /// </summary>
 /// <param name="method">The <see cref="DirectConnectionMethod"/> to use for the transfer</param>
 /// <param name="role">The <see cref="DirectConnectRole"/> of the local client in the transfer</param>
 public DirectIMConnection CreateNewDirectIMConnection(DirectConnectionMethod method, DirectConnectRole role)
 {
     DirectIMConnection retval = new DirectIMConnection(_parent, _id++, method, role);
     _directconnections.Add(retval);
     return retval;
 }
Beispiel #16
0
 /// <summary>
 /// Initializes a new DirectIMConnection
 /// </summary>
 public DirectIMConnection(Session parent, int id, DirectConnectionMethod method, DirectConnectRole role)
     : base(parent, id, method, role)
 {
     _messagetimer = new Timer(new TimerCallback(MessageSendCallback), null, Timeout.Infinite, Timeout.Infinite);
     base.DirectConnectionReady += new DirectConnectionReady(DirectIMConnection_DirectConnectionReady);
     base.DirectConnectionFailed += new DirectConnectionFailed(DirectIMConnection_DirectConnectionFailed);
 }
Beispiel #17
0
        /// <summary>
        /// Send a file to the specified recipient via the specified method
        /// </summary>
        /// <param name="recipient">The screenname to which to send the file</param>
        /// <param name="filename">The path of the file to send</param>
        /// <param name="method">The <see cref="DirectConnectionMethod"/> to use when negotiating the file transfer</param>
        /// <returns>A unique key used to reference this file transfer</returns>
        public string SendFile(string recipient, string filename, DirectConnectionMethod method)
        {
            RendezvousData rd = CreateSendFileData(recipient, filename);

            return(SetupRendezvousConnection(rd, method));
        }
Beispiel #18
0
        /// <summary>
        /// Start a DirectImage session with the specified recipient
        /// </summary>
        /// <param name="receipient">The screenname to which to send the image</param>
        /// <param name="method">The <see cref="DirectConnectionMethod"/> to use when negotiating the file transfer</param>
        /// <returns>A unique key used to reference this direct image session</returns>
        public string StartDirectImage(string receipient, DirectConnectionMethod method)
        {
            RendezvousData rd = CreateDirectIMData(receipient);

            return(SetupRendezvousConnection(rd, method));
        }