Ejemplo n.º 1
0
        private async Task StartSocket(Models.SocketType socketType)
        {
            if (!Spoofers.ContainsKey(socketType))
            {
                return;
            }

            // Get all local ip addresses
            socketType.IPEndPoint = new IPEndPoint(IPAddress.Any, socketType.Port);

            var result = new Socket(
                AddressFamily.InterNetwork,
                System.Net.Sockets.SocketType.Dgram,
                ProtocolType.Udp);

            // Bind the socket to start receiving
            result.Bind(socketType.IPEndPoint);

            if (socketType.MulticastAddress != null)
            {
                var multicastOption = new MulticastOption(socketType.MulticastAddress, IPAddress.Any);

                result.SetSocketOption(
                    SocketOptionLevel.IP,
                    SocketOptionName.AddMembership,
                    multicastOption);
            }

            socketType.Socket = result;

            await Task.CompletedTask;
        }
Ejemplo n.º 2
0
        private void AddSpoofer(Models.SocketType socketType, ISpoofer spoofer, bool run)
        {
            if (!run)
            {
                return;
            }

            if (!Spoofers.ContainsKey(socketType))
            {
                SocketTypes.Add(socketType);
                Spoofers.Add(socketType, new List <ISpoofer>());
            }

            var socketRef = Spoofers[socketType];

            socketRef.Add(spoofer);
        }