示例#1
0
        public void OnConnect()
        {
            Stream = new IrcStream(Socket)
            {
                AutoFlush = true
            };
            Channels     = new List <IrcChannel>();
            Mode         = new IrcUserMode();
            ChannelModes = new Dictionary <IrcChannel, IrcChannelUserMode>();
            Idle         = DateTime.Now;

            IrcServer.NewClient(this);
            Write(new IrcMessage()
            {
                Prefix  = IrcServer.Hostname,
                Command = "NOTICE",
                Params  = "AUTH,***Looking up your hostname.".Split(',')
            });
            Task.Factory.StartNew(() =>
            {
                System.Net.IPHostEntry ip = System.Net.Dns.GetHostEntry(((IPEndPoint)Socket.RemoteEndPoint).Address);
                Host = ip.HostName;
                Write(new IrcMessage()
                {
                    Prefix  = IrcServer.Hostname,
                    Command = "NOTICE",
                    Params  = "AUTH,***Found your hostname.".Split(',')
                });
            });
            Task.Factory.StartNew(() =>
            {
                Write(new IrcMessage()
                {
                    Prefix  = IrcServer.Hostname,
                    Command = "NOTICE",
                    Params  = "AUTH,***CHECKING IDENT".Split(',')
                });
                try
                {
                    TcpClient tcp = new TcpClient();
                    tcp.Connect(new IPEndPoint(((IPEndPoint)Socket.RemoteEndPoint).Address, 113));
                    var writer = new StreamWriter(tcp.GetStream());
                    var reader = new StreamReader(tcp.GetStream());
                    writer.WriteLine("{0}, {1}", ((IPEndPoint)Socket.RemoteEndPoint).Port, 6667);
                    writer.Flush();
                    if (reader.ReadLine().Contains("USERID"))
                    {
                        Write(new IrcMessage()
                        {
                            Prefix  = IrcServer.Hostname,
                            Command = "NOTICE",
                            Params  = "AUTH,***IDENT SUCCESSFUL".Split(',')
                        });
                    }
                }
                catch
                {
                    Write(new IrcMessage()
                    {
                        Prefix  = IrcServer.Hostname,
                        Command = "NOTICE",
                        Params  = "AUTH,***IDENT FAILED.  CONTINUE.".Split(',')
                    });
                }
            });
            _network = new Thread(Read)
            {
                IsBackground = true
            };
            _network.Start();
        }
示例#2
0
        public void OnConnect()
        {
            Stream = new IrcStream(Socket) { AutoFlush = true };
            Channels = new List<IrcChannel>();
            Mode = new IrcUserMode();
            ChannelModes = new Dictionary<IrcChannel, IrcChannelUserMode>();
            Idle = DateTime.Now;

            IrcServer.NewClient(this);
            Write(new IrcMessage()
            {
                Prefix = IrcServer.Hostname,
                Command = "NOTICE",
                Params = "AUTH,***Looking up your hostname.".Split(',')
            });
            Task.Factory.StartNew(() =>
            {
                System.Net.IPHostEntry ip = System.Net.Dns.GetHostEntry(((IPEndPoint)Socket.RemoteEndPoint).Address);
                Host = ip.HostName;
                Write(new IrcMessage()
                {
                    Prefix = IrcServer.Hostname,
                    Command = "NOTICE",
                    Params = "AUTH,***Found your hostname.".Split(',')
                });
            });
            Task.Factory.StartNew(() =>
            {
                Write(new IrcMessage()
                {
                    Prefix = IrcServer.Hostname,
                    Command = "NOTICE",
                    Params = "AUTH,***CHECKING IDENT".Split(',')
                });
                try
                {
                    TcpClient tcp = new TcpClient();
                    tcp.Connect(new IPEndPoint(((IPEndPoint)Socket.RemoteEndPoint).Address, 113));
                    var writer = new StreamWriter(tcp.GetStream());
                    var reader = new StreamReader(tcp.GetStream());
                    writer.WriteLine("{0}, {1}", ((IPEndPoint)Socket.RemoteEndPoint).Port, 6667);
                    writer.Flush();
                    if (reader.ReadLine().Contains("USERID"))
                    {
                        Write(new IrcMessage()
                        {
                            Prefix = IrcServer.Hostname,
                            Command = "NOTICE",
                            Params = "AUTH,***IDENT SUCCESSFUL".Split(',')
                        });
                    }
                }
                catch
                {
                    Write(new IrcMessage()
                    {
                        Prefix = IrcServer.Hostname,
                        Command = "NOTICE",
                        Params = "AUTH,***IDENT FAILED.  CONTINUE.".Split(',')
                    });
                }
            });
            _network = new Thread(Read) { IsBackground = true };
            _network.Start();
        }