Ejemplo n.º 1
0
        static public bool ModifySourcePort(SourcePort sourcePort)
        {
            var    optionsBuilder   = new DbContextOptionsBuilder <Context>();
            string databaseLocation = "Data Source=";

            databaseLocation += System.AppDomain.CurrentDomain.BaseDirectory;
            databaseLocation += "malo.db";
            optionsBuilder.UseSqlite(databaseLocation);
            using (Context context = new Context(optionsBuilder.Options))
            {
                try
                {
                    var sourcePortToUpdate = context.SourcePorts.First(s => s.FileName == sourcePort.FileName);
                    sourcePortToUpdate.Name = sourcePort.Name;
                    sourcePortToUpdate.MaximumCompatibility = sourcePort.MaximumCompatibility;
                    context.SourcePorts.Update(sourcePortToUpdate);
                    context.SaveChanges();
                }
                catch
                {
                    return(false);
                }
            }
            return(true);
        }
Ejemplo n.º 2
0
        public CommandLine(SourcePort sourcePort, Iwad iwad, List <Pwad> pwads)
        {
            SourcePort = sourcePort;
            Iwad       = iwad;
            Pwads      = pwads;
            var launchGame = new ProcessStartInfo();

            launchGame.WorkingDirectory = sourcePort.FileFolder;
            launchGame.FileName         = sourcePort.FileLocation;
            launchGame.Arguments       += "-iwad \"" + iwad.FileLocation + "\"";
            //if (!String.IsNullOrEmpty(sourcePort.ConfigFileLocation))
            //{
            //    launchGame.Arguments += " -config \"" + sourcePort.ConfigFileLocation + "\"";
            //}

            if (Pwads.Any()) // PWADs are optional.  If launched without PWADs, the command line doesn't need the -file argument.
            {
                command += " -file ";
                foreach (Pwad p in Pwads)
                {
                    command += "\"" + p.FileLocation + "\" "; // encloses file path and name in quotes
                }
                command = command.Remove(command.Length - 1); //just getting rid of that trailing space at the end
                launchGame.Arguments += command;
            }
            Debug.WriteLine(launchGame.Arguments);
            Process.Start(launchGame);
        }
Ejemplo n.º 3
0
        public static List <ISourcePort> GetSourcePortsData(IDataSourceAdapter adapter)
        {
            List <ISourcePort> sourcePorts = adapter.GetSourcePorts().ToList();
            SourcePort         noPort      = new SourcePort();

            noPort.Name         = "N/A";
            noPort.SourcePortID = -1;
            sourcePorts.Insert(0, noPort);
            return(sourcePorts);
        }
Ejemplo n.º 4
0
        public void SetSourcePort(PortModel port)
        {
            if (SourcePort == port)
            {
                return;
            }

            SourcePort.RemoveLink(this);
            SourcePort = port;
            SourcePort.AddLink(this);
            SourcePortChanged?.Invoke();
        }
Ejemplo n.º 5
0
        private void OnDestroy()
        {
            if (SourcePort)
            {
                SourcePort.Unbind();
            }

            if (DestinationPort)
            {
                DestinationPort.Unbind();
            }
        }
Ejemplo n.º 6
0
        static public bool CheckIfSourcePortExistsByFileLocation(SourcePort sourcePort)
        {
            var    optionsBuilder   = new DbContextOptionsBuilder <Context>();
            string databaseLocation = "Data Source=";

            databaseLocation += System.AppDomain.CurrentDomain.BaseDirectory;
            databaseLocation += "malo.db";
            optionsBuilder.UseSqlite(databaseLocation);
            using (Context context = new Context(optionsBuilder.Options))
            {
                return(context.SourcePorts.Any <SourcePort>(s => s.FileLocation == sourcePort.FileLocation)); // returns true if file location match found; false if not.
            }
        }
Ejemplo n.º 7
0
        public void SetSourcePort(PortModel port)
        {
            if (SourcePort == port)
            {
                return;
            }

            var old = SourcePort;

            SourcePort?.RemoveLink(this);
            SourcePort = port;
            SourcePort.AddLink(this);
            SourcePortChanged?.Invoke(this, old, SourcePort);
        }
Ejemplo n.º 8
0
        public override int GetHashCode()
        {
            var hashCode = 561579234;

            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(ThreatName);

            hashCode = hashCode * -1521134295 + EqualityComparer <IPAddress> .Default.GetHashCode(SourceIp);

            hashCode = hashCode * -1521134295 + SourcePort.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer <IPAddress> .Default.GetHashCode(TargetIp);

            hashCode = hashCode * -1521134295 + TargetPort.GetHashCode();
            return(hashCode);
        }
Ejemplo n.º 9
0
        private static void CreateSourcePort(IDataSourceAdapter adapter, string name, string addfiles)
        {
            SourcePort sourcePort = new SourcePort
            {
                Executable          = name,
                Name                = name,
                Directory           = new LauncherPath("SourcePorts"),
                SupportedExtensions = ".wad",
                FileOption          = "-file",
                SettingsFiles       = addfiles
            };

            adapter.InsertSourcePort(sourcePort);
        }
Ejemplo n.º 10
0
        /// <summary cref="Packet.ToString(StringOutputType)" />
        public override string ToString(StringOutputType outputFormat)
        {
            var    buffer      = new StringBuilder();
            string color       = "";
            string colorEscape = "";

            if (outputFormat == StringOutputType.Colored || outputFormat == StringOutputType.VerboseColored)
            {
                color       = Color;
                colorEscape = AnsiEscapeSequences.Reset;
            }

            if (outputFormat == StringOutputType.Normal || outputFormat == StringOutputType.Colored)
            {
                buffer.AppendFormat("{0}[UDPPacket: SourcePort={2}, DestinationPort={3}]{1}",
                                    color,
                                    colorEscape,
                                    SourcePort,
                                    DestinationPort);
            }

            if (outputFormat == StringOutputType.Verbose || outputFormat == StringOutputType.VerboseColored)
            {
                // collect the properties and their value
                Dictionary <string, string> properties = new Dictionary <string, string>();
                properties.Add("source", SourcePort.ToString());
                properties.Add("destination", DestinationPort.ToString());
                properties.Add("length", Length.ToString());
                properties.Add("checksum", "0x" + Checksum.ToString("x") + " [" + (ValidUDPChecksum ? "valid" : "invalid") + "]");

                // calculate the padding needed to right-justify the property names
                int padLength = Utils.RandomUtils.LongestStringLength(new List <string>(properties.Keys));

                // build the output string
                buffer.AppendLine("UDP:  ******* UDP - \"User Datagram Protocol\" - offset=? length=" + TotalPacketLength);
                buffer.AppendLine("UDP:");
                foreach (var property in properties)
                {
                    buffer.AppendLine("UDP: " + property.Key.PadLeft(padLength) + " = " + property.Value);
                }
                buffer.AppendLine("UDP:");
            }

            // append the base string output
            buffer.Append(base.ToString(outputFormat));

            return(buffer.ToString());
        }
Ejemplo n.º 11
0
        public void SetData(IDataSourceAdapter adapter, IGameFile gameFile)
        {
            m_adapter = adapter;

            cmbEngine.ValueMember   = "SourcePortID";
            cmbEngine.DisplayMember = "Name";
            List <ISourcePort> sourcePorts = adapter.GetSourcePorts().ToList();
            SourcePort         noPort      = new SourcePort();

            noPort.SourcePortID = 0;
            noPort.Name         = "N/A";
            sourcePorts.Insert(0, noPort);
            cmbEngine.DataSource = sourcePorts;

            cmbGame.ValueMember   = "IWadID";
            cmbGame.DisplayMember = "Name";
            cmbGame.DataSource    = GetIwads(adapter);
            cmbGame.SelectedIndex = 0;

            if (gameFile != null)
            {
                if (gameFile.SourcePortID.HasValue)
                {
                    cmbEngine.SelectedValue = gameFile.SourcePortID.Value;
                }
                txtTile.Text     = gameFile.Title;
                txtFilename.Text = gameFile.FileName;
                if (gameFile.ReleaseDate.HasValue)
                {
                    dtRelease.Value = gameFile.ReleaseDate.Value;
                }
                txtAuthor.Text      = gameFile.Author;
                txtDescription.Text = gameFile.Description;
                if (gameFile.MapCount.HasValue)
                {
                    numLevels.Value = gameFile.MapCount.Value;
                }
                if (gameFile.Map != null)
                {
                    txtMaps.Text = GetMapString(gameFile.Map);
                }
                if (gameFile.IWadID.HasValue)
                {
                    cmbGame.SelectedValue = gameFile.IWadID.Value;
                }
            }
        }
Ejemplo n.º 12
0
        private void lnkSpecific_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            SpecificFilesForm form = new SpecificFilesForm();

            form.StartPosition = FormStartPosition.CenterParent;

            List <IGameFile> gameFiles = new List <IGameFile>();

            gameFiles.AddRange(GetAdditionalFiles());

            form.Initialize(m_appConfig.GameFileDirectory, gameFiles, SourcePort.GetSupportedExtensions(SelectedSourcePort), SpecificFiles);

            if (form.ShowDialog(this) == DialogResult.OK)
            {
                SpecificFiles = form.GetSpecificFiles();
            }
        }
Ejemplo n.º 13
0
        private static ISourcePort CreateSourcePortDataSource(DataTable dt, DataRow dr)
        {
            SourcePort sourcePort = new SourcePort();

            sourcePort.Directory  = new LauncherPath((string)dr["Directory"]);
            sourcePort.Executable = (string)dr["Executable"];
            sourcePort.Name       = (string)dr["Name"];
            if (dt.Columns.Contains("SettingsFiles"))
            {
                sourcePort.SettingsFiles = (string)CheckDBNull(dr["SettingsFiles"], string.Empty);
            }
            sourcePort.SourcePortID        = Convert.ToInt32(dr["SourcePortID"]);
            sourcePort.SupportedExtensions = (string)CheckDBNull(dr["SupportedExtensions"], string.Empty);
            sourcePort.LaunchType          = (SourcePortLaunchType)Convert.ToInt32(dr["LaunchType"]);
            sourcePort.FileOption          = (string)CheckDBNull(dr["FileOption"], string.Empty);
            sourcePort.ExtraParameters     = (string)CheckDBNull(dr["ExtraParameters"], string.Empty);

            return(sourcePort);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Produce a byte array containing only the headers.
        /// </summary>
        /// <returns>Byte array.</returns>
        public byte[] ToHeaderBytes()
        {
            string header = "";

            if (!String.IsNullOrEmpty(Id))
            {
                header += "Id: " + Id + Environment.NewLine;
            }
            header += "SyncRequest: " + SyncRequest + Environment.NewLine;
            header += "SyncResponse: " + SyncResponse + Environment.NewLine;
            header += "TimeoutMs: " + TimeoutMs.ToString() + Environment.NewLine;
            header += "SourceIp: " + SourceIp + Environment.NewLine;
            header += "SourcePort: " + SourcePort.ToString() + Environment.NewLine;
            header += "DestinationIp: " + DestinationIp + Environment.NewLine;
            header += "Type: " + Type.ToString() + Environment.NewLine;
            header += "ContentLength: " + ContentLength.ToString() + Environment.NewLine;
            header += Environment.NewLine;

            return(Encoding.UTF8.GetBytes(header));
        }
Ejemplo n.º 15
0
        public override int GetHashCode()
        {
            var hashCode = 1818777531;

            hashCode = hashCode * -1521134295 + Timestamp.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(FlowId);

            hashCode = hashCode * -1521134295 + PcapCnt.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(EventType);

            hashCode = hashCode * -1521134295 + EqualityComparer <IPAddress> .Default.GetHashCode(SourceIp);

            hashCode = hashCode * -1521134295 + SourcePort.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer <IPAddress> .Default.GetHashCode(TargetIp);

            hashCode = hashCode * -1521134295 + TargetPort.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Protocol);

            hashCode = hashCode * -1521134295 + EqualityComparer <DnsEve> .Default.GetHashCode(Dns);

            return(hashCode);
        }
Ejemplo n.º 16
0
        static public bool AddNewSourcePort(SourcePort sourcePort)
        {
            sourcePort.IsConfigured = true;

            var    optionsBuilder   = new DbContextOptionsBuilder <Context>();
            string databaseLocation = "Data Source=";

            databaseLocation += System.AppDomain.CurrentDomain.BaseDirectory;
            databaseLocation += "malo.db";
            optionsBuilder.UseSqlite(databaseLocation);
            using (Context context = new Context(optionsBuilder.Options))
            {
                try
                {
                    context.SourcePorts.Add(sourcePort);
                    context.SaveChanges();
                }
                catch (Exception)
                {
                    return(false);
                }
            }
            return(true);
        }
Ejemplo n.º 17
0
        public override int GetHashCode()
        {
            var hashCode = -1042383050;

            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(ThreatName);

            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(ThreatType);

            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(ThreatSubType);

            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Level);

            hashCode = hashCode * -1521134295 + EqualityComparer <IPAddress> .Default.GetHashCode(SourceIp);

            hashCode = hashCode * -1521134295 + SourcePort.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer <IPAddress> .Default.GetHashCode(TargetIp);

            hashCode = hashCode * -1521134295 + TargetPort.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(SourceInterface);

            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(TargetInterface);

            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(AppProtocol);

            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Action);

            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(SecurityStrategy);

            hashCode = hashCode * -1521134295 + StartTime.GetHashCode();
            hashCode = hashCode * -1521134295 + EndTime.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(TestEngine);

            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Comment);

            return(hashCode);
        }
Ejemplo n.º 18
0
        private void btnNew_Click(object sender, EventArgs e)
        {
            SourcePortEditForm editForm = new SourcePortEditForm(m_adapter, m_tabViews, m_launchType);

            if (m_launchType == SourcePortLaunchType.SourcePort)
            {
                editForm.SetSupportedExtensions(string.Format(".wad,{0},.deh,.bex", Util.GetPkExtensionsCsv()));
            }
            else
            {
                editForm.SetSupportedExtensions(string.Format(".wad,{0}", Util.GetPkExtensionsCsv()));
            }

            editForm.StartPosition = FormStartPosition.CenterParent;

            if (editForm.ShowDialog(this) == DialogResult.OK)
            {
                SourcePort sourcePort = new SourcePort();
                editForm.UpdateDataSource(sourcePort);
                sourcePort.LaunchType = m_launchType;
                m_adapter.InsertSourcePort(sourcePort);
                ResetData();
            }
        }
Ejemplo n.º 19
0
 private void Spv_MakeActive(object sender, SourcePort sourcePort)
 {
     GameService.Game?.LoadSourcePort(sourcePort);
 }
Ejemplo n.º 20
0
 public virtual void Disconnect()
 {
     TargetPort.Disconnect(this);
     SourcePort.Disconnect(this);
 }
Ejemplo n.º 21
0
        public bool IsMatch(EthernetPacket packet)
        {
            var validationStack = new Stack <Func <bool> >();

            if (SourceMac != null)
            {
                validationStack.Push(() => SourceMac.Equals(packet.SourceHardwareAddress));
            }

            if (DestinationMac != null)
            {
                validationStack.Push(() => DestinationMac.Equals(packet.DestinationHardwareAddress));
            }

            var arp = packet.Extract <ArpPacket>();

            if (arp != null && RuleProtocol.Equals(Protocol.Arp))
            {
                return(resolveValidationStack(validationStack));
            }

            var lldp = packet.Extract <LldpPacket>();

            if (lldp != null && RuleProtocol.Equals(Protocol.Lldp))
            {
                return(resolveValidationStack(validationStack));
            }


            var ipv4 = packet.Extract <IPv4Packet>();

            if (ipv4 != null)
            {
                if (SourceIp != null)
                {
                    validationStack.Push(() => SourceIp.Equals(ipv4.SourceAddress));
                }

                if (DestinationIp != null)
                {
                    validationStack.Push(() => DestinationIp.Equals(ipv4.DestinationAddress));
                }

                if (RuleProtocol.Equals(Protocol.Ipv4))
                {
                    return(resolveValidationStack(validationStack));
                }
            }

            var ipv6 = packet.Extract <IPv6Packet>();

            if (ipv6 != null)
            {
                if (SourceIp != null)
                {
                    validationStack.Push(() => SourceIp.Equals(ipv6.SourceAddress));
                }

                if (DestinationIp != null)
                {
                    validationStack.Push(() => DestinationIp.Equals(ipv6.DestinationAddress));
                }

                if (RuleProtocol.Equals(Protocol.Ipv6))
                {
                    return(resolveValidationStack(validationStack));
                }
            }

            var icmpv4 = packet.Extract <IcmpV4Packet>();

            if (icmpv4 != null && RuleProtocol.Equals(Protocol.Icmpv4))
            {
                if (DestinationPort != null)
                {
                    validationStack.Push(() => (((ushort)icmpv4.TypeCode) / 256) == DestinationPort);
                }

                return(resolveValidationStack(validationStack));
            }

            var icmpv6 = packet.Extract <IcmpV4Packet>();

            if (icmpv6 != null && RuleProtocol.Equals(Protocol.Icmpv6))
            {
                if (DestinationPort != null)
                {
                    validationStack.Push(() => (((ushort)icmpv6.TypeCode) / 256) == DestinationPort);
                }

                return(resolveValidationStack(validationStack));
            }

            var tcp = packet.Extract <TcpPacket>();

            if (tcp != null && RuleProtocol.Equals(Protocol.Tcp))
            {
                if (SourcePort != null)
                {
                    validationStack.Push(() => SourcePort.Equals(tcp.SourcePort));
                }

                if (DestinationPort != null)
                {
                    validationStack.Push(() => DestinationPort.Equals(tcp.DestinationPort));
                }

                return(resolveValidationStack(validationStack));
            }

            var udp = packet.Extract <UdpPacket>();

            if (udp != null && RuleProtocol.Equals(Protocol.Udp))
            {
                if (SourcePort != null)
                {
                    validationStack.Push(() => SourcePort.Equals(udp.SourcePort));
                }

                if (DestinationPort != null)
                {
                    validationStack.Push(() => DestinationPort.Equals(udp.DestinationPort));
                }

                return(resolveValidationStack(validationStack));
            }

            return(false);
        }
Ejemplo n.º 22
0
        public bool RunUtility(IGameFile gameFile)
        {
            SpecificFilesForm form = new SpecificFilesForm();

            form.AutoCheckSupportedExtensions(false);
            form.ShowPkContentsCheckBox(true);
            form.Initialize(m_config.GameFileDirectory, new IGameFile[] { gameFile }, SourcePort.GetSupportedExtensions(m_utility),
                            new string[] { }, m_config.TempDirectory);
            form.StartPosition = FormStartPosition.CenterParent;

            if (form.ShowDialog(m_parent) == DialogResult.OK)
            {
                var files = form.GetPathedSpecificFiles();

                GameFilePlayAdapter adapter = new GameFilePlayAdapter();
                StringBuilder       sb      = new StringBuilder();
                adapter.HandleGameFile(gameFile, sb, m_config.GameFileDirectory, m_config.TempDirectory, m_utility, files); //this checks File.Exists and might not be same file

                try
                {
                    if (!string.IsNullOrEmpty(m_utility.ExtraParameters))
                    {
                        sb.Append(" " + m_utility.ExtraParameters);
                    }

                    Process.Start(m_utility.GetFullExecutablePath(), sb.ToString().Trim());
                }
                catch
                {
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 23
0
 private string[] GetSupportedFiles(IGameFile gameFile)
 {
     return(SpecificFilesForm.GetSupportedFiles(m_appConfig.GameFileDirectory.GetFullPath(), gameFile, SourcePort.GetSupportedExtensions(SelectedSourcePort)));
 }
Ejemplo n.º 24
0
        public ModifySourcePort(SourcePort sourcePort)
        {
            InitializeComponent();

            sourcePortInProgress = sourcePort;
        }
Ejemplo n.º 25
0
        /// <summary cref="Packet.ToString(StringOutputType)" />
        public override string ToString(StringOutputType outputFormat)
        {
            var    buffer      = new StringBuilder();
            string color       = "";
            string colorEscape = "";

            if (outputFormat == StringOutputType.Colored || outputFormat == StringOutputType.VerboseColored)
            {
                color       = Color;
                colorEscape = AnsiEscapeSequences.Reset;
            }

            if (outputFormat == StringOutputType.Normal || outputFormat == StringOutputType.Colored)
            {
                // build flagstring
                string flags = "{";
                if (Urg)
                {
                    flags += "urg[0x" + System.Convert.ToString(UrgentPointer, 16) + "]|";
                }
                if (Ack)
                {
                    flags += "ack[" + AcknowledgmentNumber + " (0x" + System.Convert.ToString(AcknowledgmentNumber, 16) + ")]|";
                }
                if (Psh)
                {
                    flags += "psh|";
                }
                if (Rst)
                {
                    flags += "rst|";
                }
                if (Syn)
                {
                    flags += "syn[0x" + System.Convert.ToString(SequenceNumber, 16) + "," + SequenceNumber + "]|";
                }
                flags  = flags.TrimEnd('|');
                flags += "}";

                // build the output string
                buffer.AppendFormat("{0}[TCPPacket: SourcePort={2}, DestinationPort={3}, Flags={4}]{1}",
                                    color,
                                    colorEscape,
                                    SourcePort,
                                    DestinationPort,
                                    flags);
            }

            if (outputFormat == StringOutputType.Verbose || outputFormat == StringOutputType.VerboseColored)
            {
                // collect the properties and their value
                Dictionary <string, string> properties = new Dictionary <string, string>();
                properties.Add("source port", SourcePort.ToString());
                properties.Add("destination port", DestinationPort.ToString());
                properties.Add("sequence number", SequenceNumber.ToString() + " (0x" + SequenceNumber.ToString("x") + ")");
                properties.Add("acknowledgement number", AcknowledgmentNumber.ToString() + " (0x" + AcknowledgmentNumber.ToString("x") + ")");
                // TODO: Implement a HeaderLength property for TCPPacket
                //properties.Add("header length", HeaderLength.ToString());
                properties.Add("flags", "(0x" + AllFlags.ToString("x") + ")");
                string flags = Convert.ToString(AllFlags, 2).PadLeft(8, '0');
                properties.Add("", flags[0] + "... .... = [" + flags[0] + "] congestion window reduced");
                properties.Add(" ", "." + flags[1] + ".. .... = [" + flags[1] + "] ECN - echo");
                properties.Add("  ", ".." + flags[2] + ". .... = [" + flags[2] + "] urgent");
                properties.Add("   ", "..." + flags[3] + " .... = [" + flags[3] + "] acknowledgement");
                properties.Add("    ", ".... " + flags[4] + "... = [" + flags[4] + "] push");
                properties.Add("     ", ".... ." + flags[5] + ".. = [" + flags[5] + "] reset");
                properties.Add("      ", ".... .." + flags[6] + ". = [" + flags[6] + "] syn");
                properties.Add("       ", ".... ..." + flags[7] + " = [" + flags[7] + "] fin");
                properties.Add("window size", WindowSize.ToString());
                properties.Add("checksum", "0x" + Checksum.ToString() + " [" + (ValidChecksum ? "valid" : "invalid") + "]");
                properties.Add("options", "0x" + BitConverter.ToString(Options).Replace("-", "").PadLeft(12, '0'));
                var parsedOptions = OptionsCollection;
                if (parsedOptions != null)
                {
                    for (int i = 0; i < parsedOptions.Count; i++)
                    {
                        properties.Add("option" + (i + 1).ToString(), parsedOptions[i].ToString());
                    }
                }

                // calculate the padding needed to right-justify the property names
                int padLength = Utils.RandomUtils.LongestStringLength(new List <string>(properties.Keys));

                // build the output string
                buffer.AppendLine("TCP:  ******* TCP - \"Transmission Control Protocol\" - offset=? length=" + TotalPacketLength);
                buffer.AppendLine("TCP:");
                foreach (var property in properties)
                {
                    if (property.Key.Trim() != "")
                    {
                        buffer.AppendLine("TCP: " + property.Key.PadLeft(padLength) + " = " + property.Value);
                    }
                    else
                    {
                        buffer.AppendLine("TCP: " + property.Key.PadLeft(padLength) + "   " + property.Value);
                    }
                }
                buffer.AppendLine("TCP:");
            }

            // append the base class output
            buffer.Append(base.ToString(outputFormat));

            return(buffer.ToString());
        }
Ejemplo n.º 26
0
        public EstablishDummyData()
        {
            var    optionsBuilder   = new DbContextOptionsBuilder <Context>();
            string databaseLocation = "Data Source=";

            databaseLocation += System.AppDomain.CurrentDomain.BaseDirectory;
            databaseLocation += "malo.db";
            Debug.WriteLine(databaseLocation);
            optionsBuilder.UseSqlite(databaseLocation);
            using (Context context = new Context(optionsBuilder.Options))
            {
                //test data goes here

                Pwad scythe = new Pwad
                {
                    FileName     = "scythe.zip",
                    Name         = "Scythe",
                    Description  = "Scythe by Erik Alm",
                    FileLocation = "C:\\DOOM\\scythe.wad",
                    IsALevelPack = true,
                    IsAMod       = false
                };
                context.Pwads.Add(scythe);
                Pwad tenSector = new Pwad
                {
                    FileName     = "10sector.zip",
                    Name         = "10 Sectors",
                    Description  = "Ten Sectors",
                    FileLocation = "C:\\DOOM\\10sector.zip",
                    IsALevelPack = true,
                    IsAMod       = false
                };
                context.Pwads.Add(tenSector);

                Iwad doom2Iwad = new Iwad
                {
                    FileName        = "doom2.wad",
                    Name            = "Doom II",
                    DescriptiveName = "Doom II v1.9",
                    FileLocation    = "C:\\DOOM\\doom2.wad"
                };
                context.Iwads.Add(doom2Iwad);

                SourcePort crispyDoom = new SourcePort
                {
                    FileName             = "crispy-doom.exe",
                    Name                 = "Crispy Doom",
                    FileLocation         = "C:\\DOOM\\crispy-doom.exe",
                    ConfigFileLocation   = "C:\\DOOM\\crispy-doom.cfg",
                    HasCompLevel         = false,
                    MaximumCompatibility = Compatibility.LimitRemoving
                };
                context.SourcePorts.Add(crispyDoom);

                context.SaveChanges();

                var readwad = context.Pwads.ToList();
                foreach (Pwad p in readwad)
                {
                    Debug.WriteLine($"PWAD PK ID number {p.Id}");
                    Debug.WriteLine($"Name: {p.Name}");
                    Debug.WriteLine($"Description: {p.Description}");
                    Debug.WriteLine("---");
                }

                new CommandLine(crispyDoom, doom2Iwad, new List <Pwad> {
                    scythe
                });
            }
        }
Ejemplo n.º 27
0
 public override string Description()
 {
     return("[" + SourcePort.ToString() + "] -> [" + DestPort.ToString() + "]" + " Seq: " + SequenceNumber.ToString() + " Ack: " + AcknowledgementNumber.ToString() + " WindowSize: " + WindowSize.ToString());
 }
Ejemplo n.º 28
0
 public override string Description()
 {
     return("[" + SourcePort.ToString() + "] -> [" + DestPort.ToString() + "]");
 }
Ejemplo n.º 29
0
 public SourcePortOptions(SourcePort sourcePort)
 {
     sourcePortInProgress = sourcePort;
     InitializeComponent();
 }
Ejemplo n.º 30
0
 private async void Spv_Download(object sender, SourcePort sourcePort)
 {
     if (sourcePort.Token.State is not ProgressToken.ProgressState.NotStarted or ProgressToken.ProgressState.Failed)
     {
         return;
     }