コード例 #1
0
ファイル: TCPClient.cs プロジェクト: carcarjg/Uszka
        internal void receiveData(IPV4.TCP.TCPPacket packet)
        {
            byte[]        data   = packet.TCP_Data;
            IPV4.EndPoint source = new IPV4.EndPoint(packet.SourceIP, packet.SourcePort);

            Console.WriteLine("\nReceived TCP Packet (" + data.Length + "bytes) from " + source.ToString());
            Console.WriteLine("Content: " + Encoding.ASCII.GetString(data));

            this.rxBuffer.Enqueue(new DataGram(data, source));
        }
コード例 #2
0
        //from ip, port, incoming bool, outcoming bool
        //192.168.1.1, 25565, true, true

        public static bool TCPIncomingFilter(IPV4.TCP.TCPPacket packet)
        {
            IPV4.Address IPSource = packet.SourceIP;
            ushort       Port     = packet.SourcePort;

            for (int i = 0; i < TCPFilterList.Count; i++)
            {
                if (TCPFilterList[i].Contains(IPSource.ToString() + "," + Port.ToString() + ",true"))
                {
                    //string[] FilterList = TCPFilterList[i].Split(',');
                    //bool INCOMING = bool.Parse(FilterList[2]);

                    return(true);
                }
                if (TCPFilterList[i].Contains(IPSource.ToString() + ",*,true"))
                {
                    //string[] FilterList = TCPFilterList[i].Split(',');
                    //bool INCOMING = bool.Parse(FilterList[2]);

                    return(true);
                }
            }
            return(false);
        }