<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
    <title></title>
    <link rel="self" type="application/atom+xml" href="https://jasonish.org/atom.xml"/>
    <link rel="alternate" type="text/html" href="https://jasonish.org"/>
    <generator uri="https://www.getzola.org/">Zola</generator>
    <updated>2025-10-15T00:00:00+00:00</updated>
    <id>https://jasonish.org/atom.xml</id>
    <entry xml:lang="en">
        <title>Quick Guide to Building and Testing Suricata on Linux</title>
        <published>2025-10-15T00:00:00+00:00</published>
        <updated>2025-10-15T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://jasonish.org/blog/quick-guide-building-testing-suricata-linux/"/>
        <id>https://jasonish.org/blog/quick-guide-building-testing-suricata-linux/</id>
        
        <content type="html" xml:base="https://jasonish.org/blog/quick-guide-building-testing-suricata-linux/">&lt;h3 id=&quot;target-audience&quot;&gt;Target Audience&lt;&#x2F;h3&gt;
&lt;p&gt;This quick guide is intended for those who would like to develop
and&#x2F;or make changes to Suricata. These instructions are not suitable
for a live or production installation of Suricata.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;requirements&quot;&gt;Requirements&lt;&#x2F;h3&gt;
&lt;ul&gt;
&lt;li&gt;Fedora 42 or Ubuntu 24.04: Inside WSL is OK. Other versions of
Fedora and Ubuntu might need the package installation commands
modified.&lt;&#x2F;li&gt;
&lt;li&gt;Root access via &lt;code&gt;sudo&lt;&#x2F;code&gt;.&lt;&#x2F;li&gt;
&lt;li&gt;Basic familiarity with the Linux command line, &lt;code&gt;git&lt;&#x2F;code&gt; and GitHub.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h3 id=&quot;install-dependencies&quot;&gt;Install Dependencies&lt;&#x2F;h3&gt;
&lt;p&gt;Before building Suricata, let&#x27;s get a basic set of system dependencies
installed for building and developing Suricata.&lt;&#x2F;p&gt;
&lt;div class=&quot;alert alert-info&quot; role=&quot;alert&quot;&gt;
  ℹ️ This is the only part of the guide that is specific to your Linux
distribution. Use the package installation commands for your
distribution of Linux.
&lt;&#x2F;div&gt;&lt;h4 id=&quot;for-fedora-42&quot;&gt;For Fedora 42&lt;&#x2F;h4&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span&gt; dnf&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt; -y&lt;&#x2F;span&gt;&lt;span&gt; install autoconf automake bindgen cargo-vendor cbindgen diffutils dpdk-devel file-devel gcc git hwloc-devel jansson-devel jq libasan libcap-ng-devel libnet-devel libnetfilter_queue-devel libnfnetlink-devel libpcap-devel libtool libyaml-devel lz4-devel make numactl-devel pcre2-devel pkgconfig python3-devel python3-sphinx python3-yaml rust cargo which zlib-devel
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h4 id=&quot;for-ubuntu-24-04&quot;&gt;For Ubuntu 24.04&lt;&#x2F;h4&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span&gt; apt update &amp;amp;&amp;amp; &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span&gt; DEBIAN_FRONTEND=noninteractive apt&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt; -y&lt;&#x2F;span&gt;&lt;span&gt; install autoconf automake bindgen build-essential cargo cbindgen curl git jq libcap-ng-dev libhyperscan-dev libjansson-dev libmagic-dev libnet1-dev libnetfilter-queue-dev libnetfilter-queue1 libnfnetlink-dev libnfnetlink0 libnuma-dev libpcap-dev libpcre2-dev libtool libyaml-dev make python-is-python3 python3-yaml rustc software-properties-common zlib1g zlib1g-dev
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h3 id=&quot;checkout-suricata-and-suricata-verify&quot;&gt;Checkout Suricata and Suricata-Verify&lt;&#x2F;h3&gt;
&lt;p&gt;Now it&#x27;s time to check out Suricata:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;To keep this guide brief, we are cloning from the OISF GitHub
repositories. If you plan to contribute back to Suricata, you should
first create your own forks of these repositories on GitHub then
check out your forks.&lt;&#x2F;li&gt;
&lt;li&gt;This guide assumes the use of the directory &lt;code&gt;~&#x2F;suridev&lt;&#x2F;code&gt; for your
Suricata development. Change as needed.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;mkdir -p ~&lt;&#x2F;span&gt;&lt;span&gt;&#x2F;suridev
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#96b5b4;&quot;&gt;cd &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;~&lt;&#x2F;span&gt;&lt;span&gt;&#x2F;suridev
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;git&lt;&#x2F;span&gt;&lt;span&gt; clone https:&#x2F;&#x2F;github.com&#x2F;OISF&#x2F;suricata
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;git&lt;&#x2F;span&gt;&lt;span&gt; clone https:&#x2F;&#x2F;github.com&#x2F;OISF&#x2F;suricata-verify
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h3 id=&quot;build-suricata-for-development&quot;&gt;Build Suricata for Development&lt;&#x2F;h3&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#96b5b4;&quot;&gt;cd &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;~&lt;&#x2F;span&gt;&lt;span&gt;&#x2F;suridev&#x2F;suricata
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;.&#x2F;autogen.sh
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;CFLAGS&lt;&#x2F;span&gt;&lt;span&gt;=&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;-fsanitize=address&lt;&#x2F;span&gt;&lt;span&gt;&amp;quot; &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;.&#x2F;configure --enable-unittests
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;make -j4
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Notes:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;-j4&lt;&#x2F;code&gt; option to &lt;code&gt;make&lt;&#x2F;code&gt; specifies the parallelization level. If
you have 16 cores to spare, feel free to run &lt;code&gt;make -j16&lt;&#x2F;code&gt;, and so on.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h3 id=&quot;run-unit-tests&quot;&gt;Run Unit Tests&lt;&#x2F;h3&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;.&#x2F;src&#x2F;suricata -l&lt;&#x2F;span&gt;&lt;span&gt; .&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt; -u
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Notes:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;To run a subset of tests, use the &lt;code&gt;-U&lt;&#x2F;code&gt; command-line option with a
regular expression or substring, for example: &lt;code&gt;-U DNS&lt;&#x2F;code&gt;.&lt;&#x2F;li&gt;
&lt;li&gt;To quit immediately after a unit test fails, provide
&lt;code&gt;--fatal-unittests&lt;&#x2F;code&gt; on the command line.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h3 id=&quot;run-verification-tests&quot;&gt;Run Verification Tests&lt;&#x2F;h3&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;..&#x2F;suricata-verify&#x2F;run.py -q
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Notes:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;It can take many minutes to run all the verification tests.&lt;&#x2F;li&gt;
&lt;li&gt;To run only tests whose name matches your filter, add a test name (or
partial name) to the command line, for example:
&lt;code&gt;..&#x2F;suricata-verify&#x2F;run.py -q dns&lt;&#x2F;code&gt;.&lt;&#x2F;li&gt;
&lt;li&gt;Leave off the &lt;code&gt;-q&lt;&#x2F;code&gt; to see a line item for each test.&lt;&#x2F;li&gt;
&lt;li&gt;To quit immediately after a test fails, add &lt;code&gt;--fail&lt;&#x2F;code&gt;.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h3 id=&quot;demo&quot;&gt;Demo&lt;&#x2F;h3&gt;
&lt;p&gt;Demo of the above commands on Ubuntu 24.04.&lt;&#x2F;p&gt;
&lt;script src=&quot;https:&#x2F;&#x2F;asciinema.org&#x2F;a&#x2F;Lm2N0faDskirySyVOM00pEmyB.js&quot; id=&quot;asciicast-Lm2N0faDskirySyVOM00pEmyB&quot; async=&quot;true&quot;&gt;&lt;&#x2F;script&gt;
&lt;p&gt;Alternative versions:
&lt;a href=&quot;&#x2F;images&#x2F;fast-guide-building-testing-suricata-ubuntu&#x2F;suricata-build-testing-demo.mp4&quot;&gt;mp4&lt;&#x2F;a&gt;
&lt;a href=&quot;&#x2F;images&#x2F;fast-guide-building-testing-suricata-ubuntu&#x2F;suricata-build-testing-demo.gif&quot;&gt;gif&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3 id=&quot;next-steps&quot;&gt;Next Steps&lt;&#x2F;h3&gt;
&lt;h4 id=&quot;break-a-suricata-verify-test&quot;&gt;Break a Suricata-Verify Test&lt;&#x2F;h4&gt;
&lt;ul&gt;
&lt;li&gt;Modify a Suricata source file such that the output will change. For
example, in &lt;code&gt;rust&#x2F;src&#x2F;ike&#x2F;logger.rs&lt;&#x2F;code&gt;, remove &lt;code&gt;init_spi&lt;&#x2F;code&gt; from the
output (hint: look for &lt;code&gt;jb.set_string(&quot;init_spi&quot;&lt;&#x2F;code&gt;).&lt;&#x2F;li&gt;
&lt;li&gt;Re-build Suricata: &lt;code&gt;make&lt;&#x2F;code&gt;&lt;&#x2F;li&gt;
&lt;li&gt;Run the IKE Suricata-Verify tests: &lt;code&gt;..&#x2F;suricata-verify&#x2F;run.py ike&lt;&#x2F;code&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;Notice how the test fails because we changed the output from what the
verification test expects.&lt;&#x2F;p&gt;
&lt;h4 id=&quot;create-your-own-suricata-verify-test&quot;&gt;Create Your Own Suricata-Verify Test&lt;&#x2F;h4&gt;
&lt;p&gt;A good way to start here is to make a copy of an existing test that is
similar to what you are working on. Any test will do for the sake of
example:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#96b5b4;&quot;&gt;cd &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;~&lt;&#x2F;span&gt;&lt;span&gt;&#x2F;suridev&#x2F;suricata-verify&#x2F;tests
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;cp -a&lt;&#x2F;span&gt;&lt;span&gt; alert-testmyids my-awesome-test
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Now run your new test:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#96b5b4;&quot;&gt;cd &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;~&lt;&#x2F;span&gt;&lt;span&gt;&#x2F;suridev&#x2F;suricata
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;..&#x2F;suricata-verify&#x2F;run.py&lt;&#x2F;span&gt;&lt;span&gt; my-awesome-test
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Quick Guide to Building and Testing Suricata on Ubuntu</title>
        <published>2025-10-14T00:00:00+00:00</published>
        <updated>2025-10-14T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://jasonish.org/blog/quick-guide-building-testing-suricata-ubuntu/"/>
        <id>https://jasonish.org/blog/quick-guide-building-testing-suricata-ubuntu/</id>
        
        <content type="html" xml:base="https://jasonish.org/blog/quick-guide-building-testing-suricata-ubuntu/">&lt;div class=&quot;alert alert-info&quot; role=&quot;alert&quot;&gt;
  &lt;strong&gt;Note:&lt;&#x2F;strong&gt; This guide has been superseded by &lt;a href=&quot;&#x2F;blog&#x2F;quick-guide-building-testing-suricata-linux&quot;&gt;Quick Guide to Building and Testing Suricata on Linux&lt;&#x2F;a&gt;, which covers both Ubuntu and Fedora distributions.
&lt;&#x2F;div&gt;&lt;h3 id=&quot;target-audience&quot;&gt;Target Audience&lt;&#x2F;h3&gt;
&lt;p&gt;This quick guide is intended for those who would like to develop
and&#x2F;or make changes to Suricata. These instructions are not suitable
for a live or production installation of Suricata.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;requirements&quot;&gt;Requirements&lt;&#x2F;h3&gt;
&lt;ul&gt;
&lt;li&gt;Ubuntu 24.04 (inside WSL is &lt;strong&gt;OK&lt;&#x2F;strong&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;Root access via &lt;code&gt;sudo&lt;&#x2F;code&gt;.&lt;&#x2F;li&gt;
&lt;li&gt;Basic familiarity with the Linux command line, &lt;code&gt;git&lt;&#x2F;code&gt; and GitHub.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h3 id=&quot;install-dependencies&quot;&gt;Install Dependencies&lt;&#x2F;h3&gt;
&lt;p&gt;Before building Suricata, let&#x27;s get a basic set of system dependencies
installed for building and developing Suricata.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span&gt; apt update &amp;amp;&amp;amp; &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span&gt; DEBIAN_FRONTEND=noninteractive apt&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt; -y&lt;&#x2F;span&gt;&lt;span&gt; install autoconf automake bindgen build-essential cargo cbindgen curl git jq libcap-ng-dev libhyperscan-dev libjansson-dev libmagic-dev libnet1-dev libnetfilter-queue-dev libnetfilter-queue1 libnfnetlink-dev libnfnetlink0 libnuma-dev libpcap-dev libpcre2-dev libtool libyaml-dev make python-is-python3 python3-yaml rustc software-properties-common zlib1g zlib1g-dev
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h3 id=&quot;checkout-suricata-and-suricata-verify&quot;&gt;Checkout Suricata and Suricata-Verify&lt;&#x2F;h3&gt;
&lt;p&gt;Now it&#x27;s time to check out Suricata:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;To keep this guide brief, we are cloning from the OISF GitHub
repositories. If you plan to contribute back to Suricata, you should
first create your own forks of these repositories on GitHub then
check out your forks.&lt;&#x2F;li&gt;
&lt;li&gt;This guide assumes the use of the directory &lt;code&gt;~&#x2F;suridev&lt;&#x2F;code&gt; for your
Suricata development. Change as needed.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;mkdir -p ~&lt;&#x2F;span&gt;&lt;span&gt;&#x2F;suridev
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#96b5b4;&quot;&gt;cd &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;~&lt;&#x2F;span&gt;&lt;span&gt;&#x2F;suridev
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;git&lt;&#x2F;span&gt;&lt;span&gt; clone https:&#x2F;&#x2F;github.com&#x2F;OISF&#x2F;suricata
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;git&lt;&#x2F;span&gt;&lt;span&gt; clone https:&#x2F;&#x2F;github.com&#x2F;OISF&#x2F;suricata-verify
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h3 id=&quot;build-suricata-for-development&quot;&gt;Build Suricata for Development&lt;&#x2F;h3&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#96b5b4;&quot;&gt;cd &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;~&lt;&#x2F;span&gt;&lt;span&gt;&#x2F;suridev&#x2F;suricata
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;.&#x2F;autogen.sh
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;CFLAGS&lt;&#x2F;span&gt;&lt;span&gt;=&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;-fsanitize=address&lt;&#x2F;span&gt;&lt;span&gt;&amp;quot; &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;.&#x2F;configure --enable-unittests
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;make -j4
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Notes:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;-j4&lt;&#x2F;code&gt; option to &lt;code&gt;make&lt;&#x2F;code&gt; specifies the parallelization level. If
you have 16 cores to spare, feel free to run &lt;code&gt;make -j16&lt;&#x2F;code&gt;, and so on.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h3 id=&quot;run-unit-tests&quot;&gt;Run Unit Tests&lt;&#x2F;h3&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;ASAN_OPTIONS&lt;&#x2F;span&gt;&lt;span&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;detect_leaks=0 &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;.&#x2F;src&#x2F;suricata -l&lt;&#x2F;span&gt;&lt;span&gt; .&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt; -u
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Notes:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;To run a subset of tests, use the &lt;code&gt;-U&lt;&#x2F;code&gt; command-line option with a
regular expression or substring, for example: &lt;code&gt;-U DNS&lt;&#x2F;code&gt;.&lt;&#x2F;li&gt;
&lt;li&gt;To quit immediately after a unit test fails, provide
&lt;code&gt;--fatal-unittests&lt;&#x2F;code&gt; on the command line.&lt;&#x2F;li&gt;
&lt;li&gt;We hope to eliminate the need for &lt;code&gt;ASAN_OPTIONS=detect_leaks=0&lt;&#x2F;code&gt;
soon.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h3 id=&quot;run-verification-tests&quot;&gt;Run Verification Tests&lt;&#x2F;h3&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;..&#x2F;suricata-verify&#x2F;run.py -q
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Notes:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;It can take many minutes to run all the verification tests.&lt;&#x2F;li&gt;
&lt;li&gt;To run only tests whose name matches your filter, add a test name (or
partial name) to the command line, for example:
&lt;code&gt;..&#x2F;suricata-verify&#x2F;run.py -q dns&lt;&#x2F;code&gt;.&lt;&#x2F;li&gt;
&lt;li&gt;Leave off the &lt;code&gt;-q&lt;&#x2F;code&gt; to see a line item for each test.&lt;&#x2F;li&gt;
&lt;li&gt;To quit immediately after a test fails, add &lt;code&gt;--fail&lt;&#x2F;code&gt;.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h3 id=&quot;demo&quot;&gt;Demo&lt;&#x2F;h3&gt;
&lt;script src=&quot;https:&#x2F;&#x2F;asciinema.org&#x2F;a&#x2F;Lm2N0faDskirySyVOM00pEmyB.js&quot; id=&quot;asciicast-Lm2N0faDskirySyVOM00pEmyB&quot; async=&quot;true&quot;&gt;&lt;&#x2F;script&gt;
&lt;p&gt;Alternative versions:
&lt;a href=&quot;&#x2F;images&#x2F;fast-guide-building-testing-suricata-ubuntu&#x2F;suricata-build-testing-demo.mp4&quot;&gt;mp4&lt;&#x2F;a&gt;
&lt;a href=&quot;&#x2F;images&#x2F;fast-guide-building-testing-suricata-ubuntu&#x2F;suricata-build-testing-demo.gif&quot;&gt;gif&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3 id=&quot;next-steps&quot;&gt;Next Steps&lt;&#x2F;h3&gt;
&lt;h4 id=&quot;break-a-suricata-verify-test&quot;&gt;Break a Suricata-Verify Test&lt;&#x2F;h4&gt;
&lt;ul&gt;
&lt;li&gt;Modify a Suricata source file such that the output will change. For
example, in &lt;code&gt;rust&#x2F;src&#x2F;ike&#x2F;logger.rs&lt;&#x2F;code&gt;, remove &lt;code&gt;init_spi&lt;&#x2F;code&gt; from the
output (hint: look for &lt;code&gt;jb.set_string(&quot;init_spi&quot;&lt;&#x2F;code&gt;).&lt;&#x2F;li&gt;
&lt;li&gt;Re-build Suricata: &lt;code&gt;make&lt;&#x2F;code&gt;&lt;&#x2F;li&gt;
&lt;li&gt;Run the IKE Suricata-Verify tests: &lt;code&gt;..&#x2F;suricata-verify&#x2F;run.py ike&lt;&#x2F;code&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;Notice how the test fails because we changed the output from what the
verification test expects.&lt;&#x2F;p&gt;
&lt;h4 id=&quot;create-your-own-suricata-verify-test&quot;&gt;Create Your Own Suricata-Verify Test&lt;&#x2F;h4&gt;
&lt;p&gt;A good way to start here is to make a copy of an existing test that is
similar to what you are working on. Any test will do for the sake of
example:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#96b5b4;&quot;&gt;cd &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;~&lt;&#x2F;span&gt;&lt;span&gt;&#x2F;suridev&#x2F;suricata-verify&#x2F;tests
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;cp -a&lt;&#x2F;span&gt;&lt;span&gt; alert-testmyids my-awesome-test
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Now run your new test:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#96b5b4;&quot;&gt;cd &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;~&lt;&#x2F;span&gt;&lt;span&gt;&#x2F;suridev&#x2F;suricata
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;..&#x2F;suricata-verify&#x2F;run.py&lt;&#x2F;span&gt;&lt;span&gt; my-awesome-test
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Suricata Test Builders</title>
        <published>2017-11-23T18:43:32+00:00</published>
        <updated>2017-11-23T18:43:32+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://jasonish.org/blog/suricata-test-builders/"/>
        <id>https://jasonish.org/blog/suricata-test-builders/</id>
        
        <content type="html" xml:base="https://jasonish.org/blog/suricata-test-builders/">&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
  This post is out of date and references images and links that no longer exist.
&lt;&#x2F;div&gt;
&lt;p&gt;Do your Suricata modifications build for you but fail on the &lt;a href=&quot;https:&#x2F;&#x2F;travis-ci.org&#x2F;OISF&#x2F;suricata&quot;&gt;Suricata
Travis-CI&lt;&#x2F;a&gt;? &lt;img
alt=&quot;travis-suricata-failed-jobs&quot;
src=&quot;&#x2F;images&#x2F;travis-suricata-failed-jobs.png&quot;
height=&quot;409&quot; width=&quot;833&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Or does your PR get rejected
for not building on the private build servers? Try
&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;jasonish&#x2F;suricata-test-builders&quot;&gt;suricata-test-builders&lt;&#x2F;a&gt;,
an unofficial set of Docker and Vagrant build environments that
perform a variety of builds across a variety of Linux distributions
(with Docker) and other operating systems with Vagrant and
VirtualBox. The idea is to run these builders from your current
working directory to exercise a variety of build environment including
CentOS, Fedora, Debian, Ubuntu, FreeBSD and OpenBSD with an option of
providing you a shell for further debugging. As Docker and
Vagrant&#x2F;VirtualBox are used it is limited to x86 and x64 systems that
can run under Docker and VirtualBox. Most testing has been done on
Linux, but it should also work on MacOS provided VirtualBox, Vagrant
and Docker are installed and
working. &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;jasonish&#x2F;suricata-test-builders&quot;&gt;https:&#x2F;&#x2F;github.com&#x2F;jasonish&#x2F;suricata-test-builders&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>EveBox Oneshot Demo</title>
        <published>2017-07-18T20:15:26+00:00</published>
        <updated>2017-07-18T20:15:26+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://jasonish.org/blog/evebox-oneshot-demo/"/>
        <id>https://jasonish.org/blog/evebox-oneshot-demo/</id>
        
        <content type="html" xml:base="https://jasonish.org/blog/evebox-oneshot-demo/">&lt;p&gt;Following up on EveBox support for
&lt;a href=&quot;http:&#x2F;&#x2F;blog.jasonish.org&#x2F;2017&#x2F;04&#x2F;03&#x2F;evebox-with-sqlite&#x2F;&quot;&gt;SQLite&lt;&#x2F;a&gt;, I&#x27;ve created
a screencast demo of &lt;a href=&quot;http:&#x2F;&#x2F;evebox.readthedocs.io&#x2F;en&#x2F;latest&#x2F;server-oneshot.html&quot;&gt;oneshot
&lt;&#x2F;a&gt;mode.&lt;&#x2F;p&gt;
&lt;p&gt;Oneshot is an interactive run of EveBox to process a single eve.json file and
view it in the EveBox UI.&lt;&#x2F;p&gt;
&lt;div style=&quot;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&quot;&gt;
  &lt;iframe src=&quot;https:&#x2F;&#x2F;www.youtube.com&#x2F;embed&#x2F;nbWhci3ed80&quot; title=&quot;YouTube video player&quot; frameborder=&quot;0&quot; allow=&quot;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture&quot; allowfullscreen style=&quot;position: absolute; top: 0; left: 0; width: 100%; height: 100%;&quot;&gt;&lt;&#x2F;iframe&gt;
&lt;&#x2F;div&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>EveBox with SQLite</title>
        <published>2017-04-03T22:50:48+00:00</published>
        <updated>2017-04-03T22:50:48+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://jasonish.org/blog/evebox-with-sqlite/"/>
        <id>https://jasonish.org/blog/evebox-with-sqlite/</id>
        
        <content type="html" xml:base="https://jasonish.org/blog/evebox-with-sqlite/">&lt;p&gt;The latest builds of EveBox support an embedded SQLite database that allow it to be used without Elastic Search for lighter loads. The SQLite support was added to support two use cases that may be of interest to some.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;one-shot-mode&quot;&gt;One Shot Mode&lt;&#x2F;h3&gt;
&lt;p&gt;One shot mode is the loading of a single eve.json into a temporary database and allowing the user to work with it, then cleaning up on exit. Probably most useful for loading up the Suricata log file after running over a PCAP, or just trying out EveBox for the first time. Example usage:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;color:#c0c5ce;&quot;&gt;&lt;code&gt;&lt;span&gt;.&#x2F;evebox oneshot &#x2F;path&#x2F;to&#x2F;eve.json
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;If all goes well your browser should eventually open up and display the EveBox Inbox.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;self-contained-mode&quot;&gt;Self Contained Mode&lt;&#x2F;h3&gt;
&lt;p&gt;For lack of a better name, self contained mode is the usage of EveBox without any external dependencies. This is suitable for lighter loads when running EveBox on the same machine that is running Suricata. Example usage:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;color:#c0c5ce;&quot;&gt;&lt;code&gt;&lt;span&gt;.&#x2F;evebox server --datastore sqlite --input &#x2F;var&#x2F;log&#x2F;suricata&#x2F;eve.log
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;The idea here is just a simple way to get a GUI for your Suricata events without messing around with any configuration or databases. However, you may want to create a &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;jasonish&#x2F;evebox&#x2F;blob&#x2F;0.6.1&#x2F;evebox.yaml.example&quot;&gt;configuration file&lt;&#x2F;a&gt; and setup a &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;jasonish&#x2F;evebox&#x2F;blob&#x2F;0.6.1&#x2F;evebox.yaml.example#L34&quot;&gt;retention period&lt;&#x2F;a&gt; to keep your SQLite database size in check (more documentation coming soon). If you have multiple Suricata instances, and believe the load to be light, you can configure an &lt;a href=&quot;http:&#x2F;&#x2F;evebox.readthedocs.io&#x2F;en&#x2F;latest&#x2F;agent.html&quot;&gt;EveBox agent&lt;&#x2F;a&gt; to send events to the SQLite enabled server, but your mileage will vary as you add more load.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;using-elastic-search&quot;&gt;Using Elastic Search?&lt;&#x2F;h3&gt;
&lt;p&gt;If using Elastic Search the &lt;a href=&quot;http:&#x2F;&#x2F;evebox.readthedocs.io&#x2F;en&#x2F;latest&#x2F;agent.html&quot;&gt;agent&lt;&#x2F;a&gt; and&#x2F;or the &lt;em&gt;&lt;strong&gt;--input&lt;&#x2F;strong&gt;&lt;&#x2F;em&gt; option may still be interesting as alternatives for shipping eve logs to Elastic Search, and open up future options for dealing with the real time event feeds from your Suricata instances. Download &lt;a href=&quot;https:&#x2F;&#x2F;evebox.org&#x2F;&quot;&gt;here&lt;&#x2F;a&gt;. &lt;img alt=&quot;inbox&quot; src=&quot;&#x2F;images&#x2F;inbox.png&quot; height=&quot;740&quot; width=&quot;885&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>EveBox - Stable Repositories</title>
        <published>2017-03-16T15:44:23+00:00</published>
        <updated>2017-03-16T15:44:23+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://jasonish.org/blog/evebox-stable-repositories/"/>
        <id>https://jasonish.org/blog/evebox-stable-repositories/</id>
        
        <content type="html" xml:base="https://jasonish.org/blog/evebox-stable-repositories/">&lt;p&gt;I&#x27;ve been asked a few times now for &quot;stable&quot; APT and Yum repositories as the current ones are marked &quot;development&quot;, in fact they contain the packages created on &lt;a href=&quot;https:&#x2F;&#x2F;travis-ci.org&#x2F;jasonish&#x2F;evebox&#x2F;branches&quot;&gt;Travis-CI&lt;&#x2F;a&gt; runs of the master branch. So I&#x27;ve added stable repos for Yum and Apt. For the short term they still contain builds out of the master branch, but uploaded by me instead of the output CI, and they will transition to only tagged releases after the next release, 0.6.0 which I will probably tag soon.&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;jasonish&#x2F;evebox&#x2F;wiki&#x2F;EveBox-RPM-Repository&quot;&gt;Yum&#x2F;DNF RPM Repository Setup&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;jasonish&#x2F;evebox&#x2F;wiki&#x2F;EveBox-Debian-Repository&quot;&gt;Apt Repository Setup&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;The builds in the repos above should work with any modern x86_64 Fedora, CentOS, EL, Debian or Ubuntu distribution. And if you&#x27;d rather just get at the files, I&#x27;ve made it a little easier than the Bintray URLs make it -- &lt;a href=&quot;https:&#x2F;&#x2F;evebox.org&#x2F;files&#x2F;development&#x2F;&quot;&gt;https:&#x2F;&#x2F;evebox.org&#x2F;files&#x2F;development&#x2F;&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>eve2pcap - Eve Packet and Payload Conversion to pcap</title>
        <published>2015-10-01T22:42:53+00:00</published>
        <updated>2015-10-01T22:42:53+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://jasonish.org/blog/eve2pcap-eve-packet-and-payload-conversion-to-pcap/"/>
        <id>https://jasonish.org/blog/eve2pcap-eve-packet-and-payload-conversion-to-pcap/</id>
        
        <content type="html" xml:base="https://jasonish.org/blog/eve2pcap-eve-packet-and-payload-conversion-to-pcap/">&lt;p&gt;I&#x27;ve added a new tool to my &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;jasonish&#x2F;py-idstools&quot;&gt;idstools&lt;&#x2F;a&gt; package to convert the packets (or the payloads) found in Suricata eve logs to a pcap file. To just grab the script, download &lt;a href=&quot;https:&#x2F;&#x2F;raw.githubusercontent.com&#x2F;jasonish&#x2F;py-idstools&#x2F;master&#x2F;idstools&#x2F;scripts&#x2F;eve2pcap.py&quot;&gt;eve2pcap.py&lt;&#x2F;a&gt; and make it executable, or to install the complete idstools package (will install as &lt;em&gt;idstools-eve2pcap&lt;&#x2F;em&gt;):&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;pip install --upgrade idstools&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;Usage is pretty simple:&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;.&#x2F;eve2pcap.py -o output.pcap &#x2F;path&#x2F;to&#x2F;eve.json&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;Or to use the payload field instead of the packet field:&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;.&#x2F;eve2pcap.py -o output.pcap --payload &#x2F;path&#x2F;to&#x2F;eve.json&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;For straight packet conversion no dependencies are required other than Python and libpcap. Scapy is used for conversion of the payload field, so make sure to install it before trying to convert the payload. It is also important to note that eve logs do not contain all the information to recreate the packet headers, so when converting payloads to pcap the headers are &quot;manufactured&quot; and may not always produce the best packet for the payload, so YMMV.&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Suricata Quick Start for Fedora 21 and 22</title>
        <published>2015-06-01T22:47:36+00:00</published>
        <updated>2015-06-01T22:47:36+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://jasonish.org/blog/suricata-quick-start-for-fedora-21-and-22/"/>
        <id>https://jasonish.org/blog/suricata-quick-start-for-fedora-21-and-22/</id>
        
        <content type="html" xml:base="https://jasonish.org/blog/suricata-quick-start-for-fedora-21-and-22/">&lt;p&gt;Fedora Linux 21 and 22 have Suricata 2.0.8 in their default repositories making it very easy to get started. The following was done on Fedora 22, but should be applicable to Fedora 21 as well.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;install-suricata&quot;&gt;Install Suricata&lt;&#x2F;h3&gt;
&lt;pre style=&quot;background-color:#2b303b;color:#c0c5ce;&quot;&gt;&lt;code&gt;&lt;span&gt;yum install suricata
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h3 id=&quot;configure-interface&quot;&gt;Configure Interface&lt;&#x2F;h3&gt;
&lt;p&gt;By default, Suricata will be configured to run on eth0, if you need to change this, edit &lt;em&gt;&#x2F;etc&#x2F;sysconfig&#x2F;suricata&lt;&#x2F;em&gt; and change &lt;em&gt;eth0&lt;&#x2F;em&gt; to your desired interface.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;start-suricata&quot;&gt;Start Suricata&lt;&#x2F;h3&gt;
&lt;p&gt;To start Suricata one time:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;color:#c0c5ce;&quot;&gt;&lt;code&gt;&lt;span&gt;systemctl start suricata
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;To have it restarted on each boot:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;color:#c0c5ce;&quot;&gt;&lt;code&gt;&lt;span&gt;systemctl enable suricata
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;But you&#x27;ll probably want to have it started &lt;strong&gt;after&lt;&#x2F;strong&gt; your network is ready. This can be done by including &lt;em&gt;network-online.target&lt;&#x2F;em&gt; in the unit file &lt;em&gt;&#x2F;usr&#x2F;lib&#x2F;systemd&#x2F;system&#x2F;suricata.service&lt;&#x2F;em&gt;&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;color:#c0c5ce;&quot;&gt;&lt;code&gt;&lt;span&gt;[Unit]
&lt;&#x2F;span&gt;&lt;span&gt;Description=Suricata Intrusion Detection Service
&lt;&#x2F;span&gt;&lt;span&gt;After=syslog.target network-online.target
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;[Service]
&lt;&#x2F;span&gt;&lt;span&gt;ExecStart=&#x2F;sbin&#x2F;suricata -c &#x2F;etc&#x2F;suricata&#x2F;suricata.yaml $OPTIONS
&lt;&#x2F;span&gt;&lt;span&gt;EnvironmentFile=-&#x2F;etc&#x2F;sysconfig&#x2F;suricata
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;[Install]
&lt;&#x2F;span&gt;&lt;span&gt;WantedBy=multi-user.target
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h3 id=&quot;verify-that-suricata-is-running&quot;&gt;Verify That Suricata is Running&lt;&#x2F;h3&gt;
&lt;p&gt;Even though we have not downloaded any rules yet, Suricata will still log HTTP requests, DNS requests, TLS certificates and SSH connection by default. These can be observed by monitoring &lt;em&gt;&#x2F;var&#x2F;log&#x2F;suricata&#x2F;eve.log&lt;&#x2F;em&gt;.&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;color:#c0c5ce;&quot;&gt;&lt;code&gt;&lt;span&gt;tail -f &#x2F;var&#x2F;log&#x2F;suricata&#x2F;eve.log
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h3 id=&quot;download-some-rules&quot;&gt;Download Some Rules&lt;&#x2F;h3&gt;
&lt;p&gt;To get the most out of Suricata you will want to download some rules. The Emerging Threats Open rules are freely available and can be installed with the following commands:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;color:#c0c5ce;&quot;&gt;&lt;code&gt;&lt;span&gt;cd &#x2F;etc&#x2F;suricata
&lt;&#x2F;span&gt;&lt;span&gt;curl http:&#x2F;&#x2F;rules.emergingthreats.net&#x2F;open&#x2F;suricata-2.0&#x2F;emerging.rules.tar.gz | tar zxvf -
&lt;&#x2F;span&gt;&lt;span&gt;systemctl restart suricata
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Another IDS rule downloader - rulecat</title>
        <published>2015-05-27T23:23:00+00:00</published>
        <updated>2015-05-27T23:23:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://jasonish.org/blog/another-ids-rule-downloader-rulecat/"/>
        <id>https://jasonish.org/blog/another-ids-rule-downloader-rulecat/</id>
        
        <content type="html" xml:base="https://jasonish.org/blog/another-ids-rule-downloader-rulecat/">&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt; July 21, 2021 -- This
tool is no longer maintained. Instead you should look at
Suricata-Update which is the successor to this tool. &lt;a
href=&quot;https:&#x2F;&#x2F;github.com&#x2F;OISF&#x2F;suricata-update&quot;&gt;https:&#x2F;&#x2F;github.com&#x2F;OISF&#x2F;suricata-update&lt;&#x2F;a&gt;
&lt;&#x2F;div&gt;
&lt;p&gt;I didn&#x27;t mean to do it, but I created yet another tool to download IDS
rules, with a specific focus on Suricata. Like some other people, I&#x27;ve
always used my own scripts for downloading rules instead of using
existing tools, and I finally pulled some of that together and dropped
it into my &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;jasonish&#x2F;py-idstools&quot;&gt;idstools&lt;&#x2F;a&gt;
project.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;installation&quot;&gt;Installation&lt;&#x2F;h3&gt;
&lt;p&gt;With pip (as its written in Python):&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;color:#c0c5ce;&quot;&gt;&lt;code&gt;&lt;span&gt;pip install idstools
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;From
source, &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;jasonish&#x2F;py-idstools&#x2F;releases&#x2F;download&#x2F;0.5.0&#x2F;idstools-0.5.0.tar.gz&quot;&gt;https:&#x2F;&#x2F;github.com&#x2F;jasonish&#x2F;py-idstools&#x2F;releases&#x2F;download&#x2F;0.5.0&#x2F;idstools-0.5.0.tar.gz&lt;&#x2F;a&gt;,
where idstools-rulecat can be run from the exploded tarball without
installing (also works with a git clone).&lt;&#x2F;p&gt;
&lt;h3 id=&quot;usage&quot;&gt;Usage&lt;&#x2F;h3&gt;
&lt;p&gt;Probably the simplest usage, assuming you have Suricata already
installed is something like:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;color:#c0c5ce;&quot;&gt;&lt;code&gt;&lt;span&gt;idstools-rulecat --rules-dir &#x2F;etc&#x2F;suricata&#x2F;rules
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This will download the ET Open rules for your version of Suricata and
drop them in &#x2F;etc&#x2F;suricata&#x2F;rules. Other useful output options include:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;--merged&lt;&#x2F;em&gt;  to merge all the rules into a single file making it easier to include into your suricata.yaml.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;em&gt;--yaml-fragment&lt;&#x2F;em&gt;  to dump a fragment of YAML for inclusion in your suricata.yaml that lists each rule file downloaded.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;Of course you can also disable, enable and modify rules. To get sample configuration files for doing so, run:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;color:#c0c5ce;&quot;&gt;&lt;code&gt;&lt;span&gt;idstools-rulecat --dump-sample-configs
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;which will drop the following files into your current directory:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;disable.conf&lt;&#x2F;em&gt; - allows disabling of rules by ID or regular expression.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;em&gt;enable.conf&lt;&#x2F;em&gt; - allows enabling of rules by ID or regular expression.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;em&gt;modify.conf&lt;&#x2F;em&gt; - rule modifications&lt;&#x2F;li&gt;
&lt;li&gt;&lt;em&gt;threshold.in&lt;&#x2F;em&gt; - an input threshold.conf that idstools-rulecat will expand (experimental)&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;As with many Python programs using the
&lt;a href=&quot;https:&#x2F;&#x2F;docs.python.org&#x2F;2&#x2F;library&#x2F;argparse.html&quot;&gt;argparse&lt;&#x2F;a&gt; module, a
configuration file can be created by dropping command line arguments
in a file and calling &lt;em&gt;idstools-rulecat&lt;&#x2F;em&gt; like:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;color:#c0c5ce;&quot;&gt;&lt;code&gt;&lt;span&gt;idstools-rulecat @&#x2F;path&#x2F;to&#x2F;rulecat.conf
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;For example, I use a &lt;em&gt;rulecat.conf&lt;&#x2F;em&gt; like:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;color:#c0c5ce;&quot;&gt;&lt;code&gt;&lt;span&gt;--suricata=&#x2F;usr&#x2F;bin&#x2F;suricata
&lt;&#x2F;span&gt;&lt;span&gt;--merged=rules&#x2F;merged.rules
&lt;&#x2F;span&gt;&lt;span&gt;--disable=disable.conf
&lt;&#x2F;span&gt;&lt;span&gt;--enable=enable.conf
&lt;&#x2F;span&gt;&lt;span&gt;--modify=modify.conf
&lt;&#x2F;span&gt;&lt;span&gt;--threshold-in=threshold.in
&lt;&#x2F;span&gt;&lt;span&gt;--threshold-out=etc&#x2F;threshold.config
&lt;&#x2F;span&gt;&lt;span&gt;--post-hook=sudo kill -USR2 $(cat &#x2F;var&#x2F;run&#x2F;suricata.pid)
&lt;&#x2F;span&gt;&lt;span&gt;--etpro=ETPRO_CODE
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Note the &lt;em&gt;--etpro&lt;&#x2F;em&gt; which will ET Pro rules instead of the ET Open
rules. For full usage, head over to
&lt;a href=&quot;http:&#x2F;&#x2F;idstools.readthedocs.org&#x2F;en&#x2F;latest&#x2F;tools&#x2F;rulecat.html&quot;&gt;http:&#x2F;&#x2F;idstools.readthedocs.org&#x2F;en&#x2F;latest&#x2F;tools&#x2F;rulecat.html&lt;&#x2F;a&gt;. This
is a work in progress, and is primarily being developed to satisfy my
needs, perhaps it will be useful to others as well.&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Suricata Beta (2.1beta3) RPMs for EL7</title>
        <published>2015-01-30T23:48:32+00:00</published>
        <updated>2015-01-30T23:48:32+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://jasonish.org/blog/suricata-beta-2-1beta3-rpms-for-el7/"/>
        <id>https://jasonish.org/blog/suricata-beta-2-1beta3-rpms-for-el7/</id>
        
        <content type="html" xml:base="https://jasonish.org/blog/suricata-beta-2-1beta3-rpms-for-el7/">&lt;p&gt;&lt;strong&gt;If you got here looking for Suricata RPMs, please head over &lt;a href=&quot;https:&#x2F;&#x2F;forum.suricata.io&#x2F;t&#x2F;guide-suricata-rpms-for-centos-and-fedora&#x2F;752&quot;&gt;https:&#x2F;&#x2F;forum.suricata.io&#x2F;t&#x2F;guide-suricata-rpms-for-centos-and-fedora&#x2F;752&lt;&#x2F;a&gt;&lt;&#x2F;strong&gt;&lt;&#x2F;p&gt;
&lt;p&gt;&lt;del&gt;I have created a Suricata Beta yum repository for CentOS&#x2F;EL 7 to accompany the
&lt;a href=&quot;http:&#x2F;&#x2F;blog.jasonish.org&#x2F;2014&#x2F;12&#x2F;04&#x2F;suricata-rpm-for-el-and-centos-7&#x2F;&quot;&gt;stable
repo&lt;&#x2F;a&gt;
which includes the just released Suricata 2.1beta3. Head
to &lt;a href=&quot;http:&#x2F;&#x2F;codemonkey.net&#x2F;suricata-rpms&#x2F;&quot;&gt;http:&#x2F;&#x2F;codemonkey.net&#x2F;suricata-rpms&#x2F;&lt;&#x2F;a&gt; for
further details on installing the RPMs. Please let me know if you&#x27;d like to see
the same for Fedora.&lt;&#x2F;del&gt;&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Suricata with EveBox on a Honeypot</title>
        <published>2015-01-26T19:22:03+00:00</published>
        <updated>2015-01-26T19:22:03+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://jasonish.org/blog/suricata-wevebox-on-a-honeypot/"/>
        <id>https://jasonish.org/blog/suricata-wevebox-on-a-honeypot/</id>
        
        <content type="html" xml:base="https://jasonish.org/blog/suricata-wevebox-on-a-honeypot/">&lt;p&gt;I recently installed some honeypot software and am logging the traffic with
Suricata into Elastic Search with Logstash. I know its a bit of a risk to expose
Elastic Search like this, but I thought it could make a good demo for
&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;jasonish&#x2F;evebox&quot;&gt;EveBox&lt;&#x2F;a&gt;. To check it out head over to
&lt;a href=&quot;https:&#x2F;&#x2F;demo.evebox.org&#x2F;&quot;&gt;https:&#x2F;&#x2F;demo.evebox.org&#x2F;&lt;&#x2F;a&gt; with the username &quot;evebox&quot;
with the same as the password. This probably won&#x27;t be up for too long, it will
depend on how useful the honeypot is to me at this time.&lt;&#x2F;p&gt;
&lt;p&gt;Update - 2017-11-24: Update URL to point to the EveBox demo.&lt;&#x2F;p&gt;
&lt;p&gt;Update - 2021-07-11: This demo no longer exists.&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Suricata RPM for EL 7 Updated to 2.0.5</title>
        <published>2014-12-12T17:36:16+00:00</published>
        <updated>2014-12-12T17:36:16+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://jasonish.org/blog/suricata-rpm-for-el-7-updated-to-2-0-5/"/>
        <id>https://jasonish.org/blog/suricata-rpm-for-el-7-updated-to-2-0-5/</id>
        
        <content type="html" xml:base="https://jasonish.org/blog/suricata-rpm-for-el-7-updated-to-2-0-5/">&lt;p&gt;I&#x27;ve updated the Suricata RPM for EL 7 to &lt;a href=&quot;http:&#x2F;&#x2F;suricata-ids.org&#x2F;2014&#x2F;12&#x2F;12&#x2F;suricata-2-0-5-available&#x2F;&quot;&gt;2.0.5&lt;&#x2F;a&gt;. If you have the repo configured just yum update, otherwise see this &lt;a href=&quot;http:&#x2F;&#x2F;blog.jasonish.org&#x2F;2014&#x2F;12&#x2F;04&#x2F;suricata-rpm-for-el-and-centos-7&#x2F;&quot;&gt;post&lt;&#x2F;a&gt; for more information.&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Suricata RPM for EL and CentOS 7</title>
        <published>2014-12-05T00:47:12+00:00</published>
        <updated>2014-12-05T00:47:12+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://jasonish.org/blog/suricata-rpm-for-el-and-centos-7/"/>
        <id>https://jasonish.org/blog/suricata-rpm-for-el-and-centos-7/</id>
        
        <content type="html" xml:base="https://jasonish.org/blog/suricata-rpm-for-el-and-centos-7/">&lt;p&gt;[2016-07-25: This information is no longer valid, header over to https:&#x2F;&#x2F;codemonkey.net&#x2F;suricata-rpms&#x2F; for up to date links.] I&#x27;ve taken the Suricata package as found in Fedora and rebuilt it for CentOS 7. This should be similar to how the package would exist in EPEL (and hopefully it makes its way there). To get the package with yum, first install the yum repository package (note: you must already have &lt;a href=&quot;https:&#x2F;&#x2F;fedoraproject.org&#x2F;wiki&#x2F;EPEL&quot;&gt;EPEL&lt;&#x2F;a&gt; installed):&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;color:#c0c5ce;&quot;&gt;&lt;code&gt;&lt;span&gt;~~rpm -Uvh http:&#x2F;&#x2F;codemonkey.net&#x2F;files&#x2F;rpm&#x2F;suricata&#x2F;el7&#x2F;suricata-release-el-7-1.el7.noarch.rpm~~
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;then install Suricata:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;color:#c0c5ce;&quot;&gt;&lt;code&gt;&lt;span&gt;yum install suricata
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;del&gt;To just get the package, head over to &lt;a href=&quot;http:&#x2F;&#x2F;codemonkey.net&#x2F;files&#x2F;rpm&#x2F;suricata&#x2F;el7&#x2F;&quot;&gt;http:&#x2F;&#x2F;codemonkey.net&#x2F;files&#x2F;rpm&#x2F;suricata&#x2F;el7&#x2F;&lt;&#x2F;a&gt;.&lt;&#x2F;del&gt;&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Suricata + ELK in Docker</title>
        <published>2014-09-12T17:32:14+00:00</published>
        <updated>2014-09-12T17:32:14+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://jasonish.org/blog/suricata-elk-in-docker/"/>
        <id>https://jasonish.org/blog/suricata-elk-in-docker/</id>
        
        <content type="html" xml:base="https://jasonish.org/blog/suricata-elk-in-docker/">&lt;p&gt;While getting familiar the very popular &lt;a href=&quot;http:&#x2F;&#x2F;www.docker.com&quot;&gt;Docker&lt;&#x2F;a&gt; Linux container tool, I went against best practice and put Suricata, Logstash, Elastic Search and Kibana into a container that is looking promising for demonstration purposes. If you already run this stack on one machine, it might be suitable for real use as well. What you get is a very simple to run application container that abstracts all the tools above into a single application. Assuming you have Docker already &lt;a href=&quot;https:&#x2F;&#x2F;docs.docker.com&#x2F;installation&#x2F;&quot;&gt;installed&lt;&#x2F;a&gt;, you can get a feel for Suricata + ELK with a couple commands:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;color:#c0c5ce;&quot;&gt;&lt;code&gt;&lt;span&gt;git pull https:&#x2F;&#x2F;github.com&#x2F;jasonish&#x2F;docker-suricata-elk.git
&lt;&#x2F;span&gt;&lt;span&gt;cd docker-suricata-elk
&lt;&#x2F;span&gt;&lt;span&gt;.&#x2F;launcher start -i eth0
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;The first time &lt;em&gt;.&#x2F;launcher start&lt;&#x2F;em&gt; is run, Docker will pull down the container file system layers so it may take a while. Subsequent starts will be much quicker. Once it looks like it is up and running, point your browser at http:&#x2F;&#x2F;localhost:7777. A few notes:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;Docker containers are more or less stateless. Changes to the filesystem inside the container are not persisted over a restart. Instead any data that needs to be persisted will end up in the .&#x2F;data directory where you started the launcher.&lt;&#x2F;li&gt;
&lt;li&gt;This container uses host networking instead of the usual isolated network you find with Docker containers. This is to give the container access to your physical interfaces. This alone has me questioning Docker for network monitoring deployments.&lt;&#x2F;li&gt;
&lt;li&gt;As host networking is used, the container will probably fail if you have existing applications bound to port 7777 or 9200. Making these ports configurable is on the todo.&lt;&#x2F;li&gt;
&lt;li&gt;The containers log directory is available from the host system. Take a look in .&#x2F;data&#x2F;log.&lt;&#x2F;li&gt;
&lt;li&gt;Suricata is built from git master.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;.&#x2F;launcher enter&lt;&#x2F;code&gt; will give you a shell inside the running container. This is useful to take a look around the runtime environment. Just remember that any changes you make will not be persistent.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;.&#x2F;launcher bash&lt;&#x2F;code&gt; will start a new container with the bash shell and nothing running. This is mostly useul for development.&lt;&#x2F;li&gt;
&lt;li&gt;If running a VM, allocate 2GB of memory and&#x2F;or create a swap file. These are not lightweight applications.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;Project links:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;jasonish&#x2F;docker-suricata-elk&quot;&gt;https:&#x2F;&#x2F;github.com&#x2F;jasonish&#x2F;docker-suricata-elk&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;registry.hub.docker.com&#x2F;u&#x2F;jasonish&#x2F;suricata-elk&#x2F;&quot;&gt;https:&#x2F;&#x2F;registry.hub.docker.com&#x2F;u&#x2F;jasonish&#x2F;suricata-elk&#x2F;&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>EveBox - An &quot;eve&quot; Event Viewer for Suricata&#x2F;ElasticSearch</title>
        <published>2014-05-23T00:56:51+00:00</published>
        <updated>2014-05-23T00:56:51+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://jasonish.org/blog/evebox-an-eve-event-viewer-for-suricataelasticsearch/"/>
        <id>https://jasonish.org/blog/evebox-an-eve-event-viewer-for-suricataelasticsearch/</id>
        
        <content type="html" xml:base="https://jasonish.org/blog/evebox-an-eve-event-viewer-for-suricataelasticsearch/">&lt;p&gt;&lt;a href=&quot;http:&#x2F;&#x2F;www.elasticsearch.org&#x2F;overview&#x2F;kibana&#x2F;&quot;&gt;Kibana&lt;&#x2F;a&gt; is really good for getting a high level overview of your Suricata events, but I didn&#x27;t find it very useful for reviewing individual events, and I&#x27;m not really sure if Kibana is really built around that idea, so I created EveBox, a web based event viewer for Suricata events being logged to Elastic Search in &quot;eve&quot; format with a focus on keyboard navigation: &lt;a href=&quot;&#x2F;images&#x2F;evebox-inbox-dark-ee33fd8442792fed1e8ad1486325611f.png&quot;&gt;&lt;img alt=&quot;evebox&quot; src=&quot;&#x2F;images&#x2F;evebox-inbox-dark-ee33fd8442792fed1e8ad1486325611f.png?w=660&quot; height=&quot;303&quot; width=&quot;660&quot; &#x2F;&gt;&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Yes, forgive the &quot;yet another bootstrap app&quot; looks, but I&#x27;m not a designer nor do I pretend to be. If you log thousands, or even hundreds of events per second, then EveBox is probably not for you, the &quot;inbox&quot; will be unmanageable. However, if you run a highly tuned ruleset, EveBox gives you full keyboard navigation review of those events.&lt;&#x2F;p&gt;
&lt;p&gt;Its still a little crude in some areas, for example, if you open an event to get further details you are just going to see the JSON as returned by Elastic Search, personally I like this but I think something a little easier on the eyes is needed.&lt;&#x2F;p&gt;
&lt;p&gt;It will also be more useful with eve logs the alert packet, but for now it pivot to &lt;a href=&quot;&#x2F;blog&#x2F;new-dumpy-release-multiple-spools-and-single-binary-install&quot;&gt;Dumpy&lt;&#x2F;a&gt; (a rather basic daemonlogger spool directory frontend) to get a packet capture of the alert triggering data.&lt;&#x2F;p&gt;
&lt;p&gt;I&#x27;ve also learned that while Elastic Search is great (well, more like awesome) for searching, its not the best tool for mass updates of records such as &quot;tagging&quot; every entry that matches a query.&lt;&#x2F;p&gt;
&lt;p&gt;For such cases it might be useful to introduce a backend at some point so the HTML5 application can hand off some of the grunt work to a backend server that can handle the batch tasks.&lt;&#x2F;p&gt;
&lt;p&gt;PostgreSQL 9.4 with its new JSON(b) column could also prove to a very capable data store for Suricata eve events (Cassandra might be another option as well).&lt;&#x2F;p&gt;
&lt;p&gt;If you would like to try, go get the latest &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;jasonish&#x2F;evebox&#x2F;releases&quot;&gt;release&lt;&#x2F;a&gt; and drop it on a web server.&lt;&#x2F;p&gt;
&lt;p&gt;For now its just straight up HTML like Kibana, so its basically a 0 effort install.&lt;&#x2F;p&gt;
&lt;p&gt;If that sounds to hard head over to &lt;a href=&quot;http:&#x2F;&#x2F;codemonkey.net&#x2F;evebox&#x2F;&quot;&gt;http:&#x2F;&#x2F;codemonkey.net&#x2F;evebox&lt;&#x2F;a&gt;, click on settings and enter the URL to your Elastic Search server. The &quot;inbox&quot; won&#x27;t be there until you configure Logstash accordingly, but you can still review events under &quot;All&#x27;.&lt;&#x2F;p&gt;
&lt;p&gt;NOTE: My server will not connect to your Elastic Search, the settings only tell the HTML5 application where to connect to Elastic Search).&lt;&#x2F;p&gt;
&lt;p&gt;If you are not yet using Suricata, Snort can easily be used instead.&lt;&#x2F;p&gt;
&lt;p&gt;For more info on sending Snort events to Elastic Search in &quot;eve&quot; format see my post &lt;a href=&quot;&#x2F;blog&#x2F;snort-logstash-elastic-search-and-kibana&#x2F;&quot;&gt;Snort, Logstash, Elastic Search and Kibana...&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;jasonish&#x2F;evebox&quot;&gt;EveBox on Github&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>New Dumpy Release - Multiple Spools and Single Binary Install</title>
        <published>2014-05-07T21:01:23+00:00</published>
        <updated>2014-05-07T21:01:23+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://jasonish.org/blog/new-dumpy-release-multiple-spools-and-single-binary-install/"/>
        <id>https://jasonish.org/blog/new-dumpy-release-multiple-spools-and-single-binary-install/</id>
        
        <content type="html" xml:base="https://jasonish.org/blog/new-dumpy-release-multiple-spools-and-single-binary-install/">&lt;p&gt;I&#x27;ve made some changes to my simple to install and use PCAP spool web
frontend
&lt;a href=&quot;http:&#x2F;&#x2F;blog.jasonish.org&#x2F;2012&#x2F;12&#x2F;dumpy-a-simple-pcap-spool-file-frontend.html&quot;&gt;Dumpy&lt;&#x2F;a&gt; including:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;A rewrite in Go, mostly for entertainment purposes, but the really
easy to use concurrency, and single binary installation make Go a
good choice for small applications like this.&lt;&#x2F;li&gt;
&lt;li&gt;Multiple spool directory support.&lt;&#x2F;li&gt;
&lt;li&gt;A decoder for translating a Suricata JSON style event to a pcap
filter (in additions to the existing &quot;fast&quot; style event decoding).&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;Check it out over here &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;jasonish&#x2F;dumpy&quot;&gt;https:&#x2F;&#x2F;github.com&#x2F;jasonish&#x2F;dumpy&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Snort, Logstash, Elastic Search and Kibana...</title>
        <published>2014-04-17T03:39:00+00:00</published>
        <updated>2014-04-17T03:39:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://jasonish.org/blog/snort-logstash-elastic-search-and-kibana/"/>
        <id>https://jasonish.org/blog/snort-logstash-elastic-search-and-kibana/</id>
        
        <content type="html" xml:base="https://jasonish.org/blog/snort-logstash-elastic-search-and-kibana/">&lt;p&gt;After having fun with Suricata&#x27;s new eve&#x2F;json logging format and the Logstash&#x2F;Elastic Search&#x2F;Kibana combination (see &lt;a href=&quot;https:&#x2F;&#x2F;home.regit.org&#x2F;2014&#x2F;01&#x2F;a-bit-of-logstash-cooking&#x2F;&quot;&gt;this&lt;&#x2F;a&gt; and &lt;a href=&quot;http:&#x2F;&#x2F;blog.inliniac.net&#x2F;2014&#x2F;03&#x2F;25&#x2F;suricata-2-0-and-beyond&#x2F;&quot;&gt;this&lt;&#x2F;a&gt;), I wanted to get my Snort events into Elastic Search as well. Using my &lt;a href=&quot;https:&#x2F;&#x2F;pypi.python.org&#x2F;pypi&#x2F;idstools&quot;&gt;idstools&lt;&#x2F;a&gt; python library I wrote &lt;a href=&quot;http:&#x2F;&#x2F;idstools.readthedocs.org&#x2F;en&#x2F;0.4.0&#x2F;u2json.html&quot;&gt;u2json&lt;&#x2F;a&gt;, a tool that will process a unified2 spool directory (much like barnyard) and convert the events to Suricata-style JSON.&lt;&#x2F;p&gt;
&lt;p&gt;Usage is relatively simple, assuming Snort is logging to &#x2F;var&#x2F;log&#x2F;snort, the following command line should do:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;color:#c0c5ce;&quot;&gt;&lt;code&gt;&lt;span&gt;  idstools-u2json -c &#x2F;etc&#x2F;snort&#x2F;snort.conf   
&lt;&#x2F;span&gt;&lt;span&gt;    --directory &#x2F;var&#x2F;log&#x2F;snort  
&lt;&#x2F;span&gt;&lt;span&gt;    --prefix unified2.log  
&lt;&#x2F;span&gt;&lt;span&gt;    --follow --bookmark  
&lt;&#x2F;span&gt;&lt;span&gt;    --output &#x2F;var&#x2F;log&#x2F;snort&#x2F;alerts.json  
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;As the output is in the same format as Suricata&#x27;s you can refer to this &lt;a href=&quot;https:&#x2F;&#x2F;redmine.openinfosecfoundation.org&#x2F;projects&#x2F;suricata&#x2F;wiki&#x2F;_Logstash_Kibana_and_Suricata_JSON_output&quot;&gt;guide&lt;&#x2F;a&gt; for the Logstash setup.&lt;&#x2F;p&gt;
&lt;p&gt;One extra step I did was use Logstash to add an &quot;engine&quot; field to each entry. This can be accomplished by adapting the following Logstash configuration:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;color:#c0c5ce;&quot;&gt;&lt;code&gt;&lt;span&gt;input {  
&lt;&#x2F;span&gt;&lt;span&gt;  file {  
&lt;&#x2F;span&gt;&lt;span&gt;    path =&amp;gt; [&amp;quot;&#x2F;var&#x2F;log&#x2F;suricata&#x2F;eve.json&amp;quot;]  
&lt;&#x2F;span&gt;&lt;span&gt;    codec =&amp;gt; json  
&lt;&#x2F;span&gt;&lt;span&gt;    type =&amp;gt; &amp;quot;suricata-json&amp;quot;  
&lt;&#x2F;span&gt;&lt;span&gt;  }  
&lt;&#x2F;span&gt;&lt;span&gt;  file {  
&lt;&#x2F;span&gt;&lt;span&gt;    path =&amp;gt; [&amp;quot;&#x2F;var&#x2F;log&#x2F;snort&#x2F;alerts.json&amp;quot;]  
&lt;&#x2F;span&gt;&lt;span&gt;    codec =&amp;gt; json  
&lt;&#x2F;span&gt;&lt;span&gt;    type =&amp;gt; &amp;quot;snort-json&amp;quot;  
&lt;&#x2F;span&gt;&lt;span&gt;  }  
&lt;&#x2F;span&gt;&lt;span&gt;}  
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;filter {  
&lt;&#x2F;span&gt;&lt;span&gt;  if [type] == &amp;quot;suricata-json&amp;quot; {  
&lt;&#x2F;span&gt;&lt;span&gt;    mutate {  
&lt;&#x2F;span&gt;&lt;span&gt;      add_field =&amp;gt; {  
&lt;&#x2F;span&gt;&lt;span&gt;        &amp;quot;engine&amp;quot; =&amp;gt; &amp;quot;suricata&amp;quot;  
&lt;&#x2F;span&gt;&lt;span&gt;      }  
&lt;&#x2F;span&gt;&lt;span&gt;    }  
&lt;&#x2F;span&gt;&lt;span&gt;  }  
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;  if [type] == &amp;quot;snort-json&amp;quot; {  
&lt;&#x2F;span&gt;&lt;span&gt;    mutate {  
&lt;&#x2F;span&gt;&lt;span&gt;      add_field =&amp;gt; {  
&lt;&#x2F;span&gt;&lt;span&gt;        &amp;quot;engine&amp;quot; =&amp;gt; &amp;quot;snort&amp;quot;  
&lt;&#x2F;span&gt;&lt;span&gt;      }  
&lt;&#x2F;span&gt;&lt;span&gt;    }  
&lt;&#x2F;span&gt;&lt;span&gt;  }  
&lt;&#x2F;span&gt;&lt;span&gt;}  
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Checkout out the &lt;a href=&quot;http:&#x2F;&#x2F;idstools.readthedocs.org&#x2F;en&#x2F;0.4.0&#x2F;u2json.html&quot;&gt;documentation&lt;&#x2F;a&gt; for information.&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Easy Unified2 File Reading in Python</title>
        <published>2013-07-20T04:04:00+00:00</published>
        <updated>2013-07-20T04:04:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://jasonish.org/blog/easy-unified2-file-reading-in-python/"/>
        <id>https://jasonish.org/blog/easy-unified2-file-reading-in-python/</id>
        
        <content type="html" xml:base="https://jasonish.org/blog/easy-unified2-file-reading-in-python/">&lt;p&gt;I recently consolidated my Python code bits for dealing with Snort and Suricata unified2 log files into a project called &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;jasonish&#x2F;idstools.py&quot;&gt;idstools&lt;&#x2F;a&gt;. While I&#x27;ll be adding more than just unified2 reading support, that is about it for now. While it can be installed with pip (pip install idstools), if you just want to play around with it I suggest cloning the repo (git clone https:&#x2F;&#x2F;github.com&#x2F;jasonish&#x2F;idstools.py). You can then use the REPL or write test scripts from within the idstools.py directory without having to install the library (yeah, basic stuff for Python developers). idstools does come with a few example programs that demonstrate unified2 file reading, namely, &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;jasonish&#x2F;idstools.py&#x2F;blob&#x2F;master&#x2F;examples&#x2F;u2fast.py&quot;&gt;u2fast.py&lt;&#x2F;a&gt;, &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;jasonish&#x2F;idstools.py&#x2F;blob&#x2F;master&#x2F;examples&#x2F;u2tail.py&quot;&gt;u2tail.py&lt;&#x2F;a&gt; and &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;jasonish&#x2F;idstools.py&#x2F;blob&#x2F;master&#x2F;examples&#x2F;u2spewfoo.py&quot;&gt;u2spewfoo.py&lt;&#x2F;a&gt; (a simple clone of the Snort provided u2spewfoo).&lt;&#x2F;p&gt;
&lt;h3 id=&quot;basic-unified2-file-reading&quot;&gt;Basic Unified2 File Reading&lt;&#x2F;h3&gt;
&lt;pre style=&quot;background-color:#2b303b;color:#c0c5ce;&quot;&gt;&lt;code&gt;&lt;span&gt;from idstools import unified2
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;reader = unified2.FileEventReader(&amp;quot;tests&#x2F;merged.log&amp;quot;)
&lt;&#x2F;span&gt;&lt;span&gt;for event in reader:
&lt;&#x2F;span&gt;&lt;span&gt;    print(&amp;quot;Event:n%s&amp;quot; % str(event))
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This few lines of code will iterate through each record in the specified unified2 log files, aggregate the records into events and return each event as a dict. If straight up record is reading is more what you are after then check out &lt;a href=&quot;https:&#x2F;&#x2F;idstools.readthedocs.org&#x2F;en&#x2F;latest&#x2F;api-unified2.html#idstools.unified2.FileRecordReader&quot;&gt;unified2.FileRecordReader&lt;&#x2F;a&gt;, or the lower level &lt;a href=&quot;https:&#x2F;&#x2F;idstools.readthedocs.org&#x2F;en&#x2F;latest&#x2F;api-unified2.html#idstools.unified2.read_record&quot;&gt;unified2.read_record&lt;&#x2F;a&gt; function. Each event is represented as a &lt;em&gt;dict&lt;&#x2F;em&gt; containing the fields of a unified2 event record, with the associated packets represented as a list in &lt;em&gt;event[&quot;packets&quot;]&lt;&#x2F;em&gt; and extra data records represented as a list in &lt;em&gt;event[&quot;extra-data&quot;]&lt;&#x2F;em&gt;.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;resolving-event-message-and-classification-names&quot;&gt;Resolving Event Message and Classification Names&lt;&#x2F;h3&gt;
&lt;p&gt;To make event reading just a little more useful, code to map signature and classifications IDs to descriptions is provided.&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;color:#c0c5ce;&quot;&gt;&lt;code&gt;&lt;span&gt;from idstools import maps
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;# Create and populate the signature message map.
&lt;&#x2F;span&gt;&lt;span&gt;sigmap = maps.MsgMap()
&lt;&#x2F;span&gt;&lt;span&gt;sigmap.load_genmsg_file(&amp;quot;gen-msg.map&amp;quot;)
&lt;&#x2F;span&gt;&lt;span&gt;sigmap.load_sidmsg_file(&amp;quot;sid-msg.map&amp;quot;)
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;# Get the description for 1:498.
&lt;&#x2F;span&gt;&lt;span&gt;print(&amp;quot;Message for 1:498: %s&amp;quot; % (sigmap.get(1, 498).msg))
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;# Create and populate the classification map.
&lt;&#x2F;span&gt;&lt;span&gt;classmap = maps.ClassificationMap()
&lt;&#x2F;span&gt;&lt;span&gt;classmap.load_classification_file(&amp;quot;classification.config&amp;quot;)
&lt;&#x2F;span&gt;&lt;span&gt;print(&amp;quot;The description for classification id 9 is %s, with priority %d.&amp;quot; % (
&lt;&#x2F;span&gt;&lt;span&gt;        classmap.get(9).description, classmap.get(9).priority))
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;The example program &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;jasonish&#x2F;py-idstools&#x2F;blob&#x2F;0.3.1&#x2F;idstools&#x2F;scripts&#x2F;u2fast.py&quot;&gt;u2fast.py&lt;&#x2F;a&gt; is a complete example of reading events from one or more files, resolving event descriptions and classification names and printing the event in a &quot;fast&quot; like style.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;spool-reading&quot;&gt;Spool Reading&lt;&#x2F;h3&gt;
&lt;p&gt;idstools also contains a spool reader for processing a unified2 spool directory as commonly used by Snort and Suricata. It supports bookmarking, deleting files, and open and close hooks which can be used to implement custom archiving.&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;color:#c0c5ce;&quot;&gt;&lt;code&gt;&lt;span&gt;from idstools import spool
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;def my_open_hook(reader, filename):
&lt;&#x2F;span&gt;&lt;span&gt;    print(&amp;quot;File %s has been opened.&amp;quot; % (filename))
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;def my_close_hook(reader, filename):
&lt;&#x2F;span&gt;&lt;span&gt;    print(&amp;quot;File %s has been closed.&amp;quot; % (filename))
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;reader = spool.Unified2EventSpoolReader(
&lt;&#x2F;span&gt;&lt;span&gt;    &amp;quot;&#x2F;var&#x2F;log&#x2F;snort&amp;quot;, &amp;quot;merged.log&amp;quot;, delete_on_close=False,
&lt;&#x2F;span&gt;&lt;span&gt;    bookmark=True,
&lt;&#x2F;span&gt;&lt;span&gt;    open_hook=my_open_hook,
&lt;&#x2F;span&gt;&lt;span&gt;    close_hook=my_close_hook)
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;for event in reader:
&lt;&#x2F;span&gt;&lt;span&gt;    print(&amp;quot;Read event with generator-id %d, signature-id %d.&amp;quot; % (
&lt;&#x2F;span&gt;&lt;span&gt;            event[&amp;quot;signature-id&amp;quot;], event[&amp;quot;generator-id&amp;quot;]))
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;To see a more complete directory spool process, check out the &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;jasonish&#x2F;py-idstools&#x2F;blob&#x2F;0.3.1&#x2F;idstools&#x2F;scripts&#x2F;u2tail.py&quot;&gt;u2tail.py&lt;&#x2F;a&gt; example program.To learn more checkout &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;jasonish&#x2F;idstools.py&quot;&gt;idstools over at GitHub&lt;&#x2F;a&gt;, &lt;a href=&quot;https:&#x2F;&#x2F;pypi.python.org&#x2F;pypi&#x2F;idstools&quot;&gt;PyPI&lt;&#x2F;a&gt;, or the work-in-progress documentation on &lt;a href=&quot;https:&#x2F;&#x2F;idstools.readthedocs.org&#x2F;en&#x2F;latest&#x2F;&quot;&gt;Read the Docs&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Dumpy - A Simple PCAP Spool File Frontend</title>
        <published>2012-12-18T23:33:00+00:00</published>
        <updated>2012-12-18T23:33:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://jasonish.org/blog/dumpy-a-simple-pcap-spool-file-frontend/"/>
        <id>https://jasonish.org/blog/dumpy-a-simple-pcap-spool-file-frontend/</id>
        
        <content type="html" xml:base="https://jasonish.org/blog/dumpy-a-simple-pcap-spool-file-frontend/">&lt;p&gt;Sometimes the best way to try out a new framework or language is to
apply it to a domain you already know very well, even if it does
happen to reinvent the
wheel. &lt;a href=&quot;http:&#x2F;&#x2F;www.tornadoweb.org&#x2F;&quot;&gt;Tornado&lt;&#x2F;a&gt; and &lt;a href=&quot;http:&#x2F;&#x2F;twitter.github.com&#x2F;bootstrap&#x2F;&quot;&gt;Twitter
Bootstrap&lt;&#x2F;a&gt; are two such
frameworks I&#x27;ve been meaning to play with for a while now. The result
is &lt;a href=&quot;http:&#x2F;&#x2F;dumpy&#x2F;&quot;&gt;Dumpy&lt;&#x2F;a&gt;, a web front-end to pcap spool files as
created by &lt;a href=&quot;http:&#x2F;&#x2F;www.tcpdump.org&#x2F;&quot;&gt;tcpdump&lt;&#x2F;a&gt;,
&lt;a href=&quot;http:&#x2F;&#x2F;www.snort.org&#x2F;snort-downloads&#x2F;additional-downloads&quot;&gt;daemonlogger&lt;&#x2F;a&gt;,
or &lt;a href=&quot;http:&#x2F;&#x2F;netsniff-ng.org&#x2F;&quot;&gt;netsniff-ng&lt;&#x2F;a&gt; with a very simple
configuration and user interface:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;images&#x2F;dumpy-screenshot.png&quot; alt=&quot;Dumpy screenshot&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Requirements are minimal, Python 2.6 (so it will run on CentOS 6 with
little hassle), Tornado and py-bcrypt which are both trivially
installed with pip. It provides its own http server with SSL support,
and does not require a database. Usage is also simple. Simply enter a
pcap filter, or paste in a Snort or Suricata event in &quot;fast&quot; format,
choose start and end times (or simply offsets) and hit download. If
interested, start a pcap spool (ie: &lt;code&gt;sudo tcpdump -i eth0 -C 1000 -W10 -G 3600 -w &#x2F;tmp&#x2F;eth0.log.%Y%m%d.&lt;&#x2F;code&gt;) then check out Dumpy over
here &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;jasonishish&#x2F;dumpy&quot;&gt;https:&#x2F;&#x2F;github.com&#x2F;jasonish&#x2F;dumpy&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>SpringMVC with Embedded Jetty and Thymeleaf</title>
        <published>2012-12-13T22:16:00+00:00</published>
        <updated>2012-12-13T22:16:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://jasonish.org/blog/springmvc-with-embedded-jetty-and-thymeleaf/"/>
        <id>https://jasonish.org/blog/springmvc-with-embedded-jetty-and-thymeleaf/</id>
        
        <content type="html" xml:base="https://jasonish.org/blog/springmvc-with-embedded-jetty-and-thymeleaf/">&lt;p&gt;As mentioned in my previous post on using &lt;a href=&quot;http:&#x2F;&#x2F;blog.unx.ca&#x2F;2012&#x2F;12&#x2F;springmvc-with-embedded-jetty.html&quot;&gt;embedded Jetty with SpringMVC&lt;&#x2F;a&gt;, I was going to look at simplifying the application by using &lt;a href=&quot;http:&#x2F;&#x2F;www.thymeleaf.org&#x2F;&quot;&gt;Thymeleaf&lt;&#x2F;a&gt; instead of JSPs as a view technology.&lt;&#x2F;p&gt;
&lt;p&gt;Well, it turns out that it is much more straightforward.&lt;&#x2F;p&gt;
&lt;p&gt;First we can remove the JSPC plugin from our pom.xml. Second we can completely remove the web.xml file.&lt;&#x2F;p&gt;
&lt;p&gt;Bootstrapping Jetty is much simpler now. We do not have to hook into the Jetty startup process with a lifecycle listener, instead we can directly create the dispatcher servlet and add it to a ServletContextHandler like we would any other servlet:&lt;&#x2F;p&gt;
&lt;p&gt;From &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;jasonish&#x2F;jetty-springmvc-thymeleaf-template&#x2F;blob&#x2F;20121213&#x2F;src&#x2F;main&#x2F;java&#x2F;config&#x2F;JettyConfiguration.java&quot;&gt;JettyConfiguration.java&lt;&#x2F;a&gt;:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;color:#c0c5ce;&quot;&gt;&lt;code&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;@Bean  
&lt;&#x2F;span&gt;&lt;span&gt;public ServletHolder dispatcherServlet() {  
&lt;&#x2F;span&gt;&lt;span&gt;    AnnotationConfigWebApplicationContext ctx =   
&lt;&#x2F;span&gt;&lt;span&gt;        new AnnotationConfigWebApplicationContext();  
&lt;&#x2F;span&gt;&lt;span&gt;    ctx.setParent(applicationContext);  
&lt;&#x2F;span&gt;&lt;span&gt;    ctx.register(MvcConfiguration.class);  
&lt;&#x2F;span&gt;&lt;span&gt;    DispatcherServlet servlet = new DispatcherServlet(ctx);  
&lt;&#x2F;span&gt;&lt;span&gt;    ServletHolder holder = new ServletHolder(&amp;quot;dispatcher-servlet&amp;quot;, servlet);  
&lt;&#x2F;span&gt;&lt;span&gt;    holder.setInitOrder(1);  
&lt;&#x2F;span&gt;&lt;span&gt;    return holder;  
&lt;&#x2F;span&gt;&lt;span&gt;}  
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;@Bean  
&lt;&#x2F;span&gt;&lt;span&gt;public ServletContextHandler servletContext() throws IOException {  
&lt;&#x2F;span&gt;&lt;span&gt;    ServletContextHandler handler = new ServletContextHandler();  
&lt;&#x2F;span&gt;&lt;span&gt;    handler.setContextPath(&amp;quot;&#x2F;&amp;quot;);  
&lt;&#x2F;span&gt;&lt;span&gt;    handler.setResourceBase(  
&lt;&#x2F;span&gt;&lt;span&gt;        new ClassPathResource(&amp;quot;webapp&amp;quot;).getURI().toString());  
&lt;&#x2F;span&gt;&lt;span&gt;    handler.addServlet(AdminServlet.class, &amp;quot;&#x2F;metrics&#x2F;*&amp;quot;);  
&lt;&#x2F;span&gt;&lt;span&gt;    handler.addServlet(dispatcherServlet(), &amp;quot;&#x2F;&amp;quot;);  
&lt;&#x2F;span&gt;&lt;span&gt;    return handler;  
&lt;&#x2F;span&gt;&lt;span&gt;}  
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;@Bean(initMethod = &amp;quot;start&amp;quot;, destroyMethod = &amp;quot;stop&amp;quot;)  
&lt;&#x2F;span&gt;&lt;span&gt;public Server jettyServer() throws IOException {  
&lt;&#x2F;span&gt;&lt;span&gt;    Server server = new Server();  
&lt;&#x2F;span&gt;&lt;span&gt;    server.setHandler(servletContext());  
&lt;&#x2F;span&gt;&lt;span&gt;    server.setConnectors(jettyConnectors());  
&lt;&#x2F;span&gt;&lt;span&gt;    return server;  
&lt;&#x2F;span&gt;&lt;span&gt;}  
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This is much more straightforward, everything wired up with Spring without any lifecycle callback hooks.&lt;&#x2F;p&gt;
&lt;p&gt;The setup for Spring to render the Thymeleaf views, is a little more complex, but not fussy. What we do is replace:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;color:#c0c5ce;&quot;&gt;&lt;code&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;@Bean  
&lt;&#x2F;span&gt;&lt;span&gt;public InternalResourceViewResolver configureInternalResourceViewResolver() {  
&lt;&#x2F;span&gt;&lt;span&gt;    InternalResourceViewResolver resolver =   
&lt;&#x2F;span&gt;&lt;span&gt;        new InternalResourceViewResolver();  
&lt;&#x2F;span&gt;&lt;span&gt;    resolver.setPrefix(&amp;quot;&#x2F;WEB-INF&#x2F;views&#x2F;&amp;quot;);  
&lt;&#x2F;span&gt;&lt;span&gt;    resolver.setSuffix(&amp;quot;.jsp&amp;quot;);  
&lt;&#x2F;span&gt;&lt;span&gt;    return resolver;  
&lt;&#x2F;span&gt;&lt;span&gt;}  
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;with&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;color:#c0c5ce;&quot;&gt;&lt;code&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;@Bean  
&lt;&#x2F;span&gt;&lt;span&gt;public ServletContextTemplateResolver thymeleafTemplateResolver() {  
&lt;&#x2F;span&gt;&lt;span&gt;    ServletContextTemplateResolver resolver =   
&lt;&#x2F;span&gt;&lt;span&gt;        new ServletContextTemplateResolver();  
&lt;&#x2F;span&gt;&lt;span&gt;    resolver.setPrefix(&amp;quot;&#x2F;WEB-INF&#x2F;thymeleaf&#x2F;&amp;quot;);  
&lt;&#x2F;span&gt;&lt;span&gt;    resolver.setSuffix(&amp;quot;.html&amp;quot;);  
&lt;&#x2F;span&gt;&lt;span&gt;    resolver.setTemplateMode(&amp;quot;HTML5&amp;quot;);  
&lt;&#x2F;span&gt;&lt;span&gt;    resolver.setCacheable(true);  
&lt;&#x2F;span&gt;&lt;span&gt;    return resolver;  
&lt;&#x2F;span&gt;&lt;span&gt;}  
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;@Bean  
&lt;&#x2F;span&gt;&lt;span&gt;public SpringTemplateEngine thymeleafTemplateEngine() {  
&lt;&#x2F;span&gt;&lt;span&gt;    SpringTemplateEngine engine = new SpringTemplateEngine();  
&lt;&#x2F;span&gt;&lt;span&gt;    engine.setTemplateResolver(thymeleafTemplateResolver());  
&lt;&#x2F;span&gt;&lt;span&gt;    return engine;  
&lt;&#x2F;span&gt;&lt;span&gt;}  
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;@Bean  
&lt;&#x2F;span&gt;&lt;span&gt;public ThymeleafViewResolver thymeleafViewResolver() {  
&lt;&#x2F;span&gt;&lt;span&gt;    ThymeleafViewResolver resolver = new ThymeleafViewResolver();  
&lt;&#x2F;span&gt;&lt;span&gt;    resolver.setTemplateEngine(thymeleafTemplateEngine());  
&lt;&#x2F;span&gt;&lt;span&gt;    return resolver;  
&lt;&#x2F;span&gt;&lt;span&gt;}  
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;in &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;jasonish&#x2F;jetty-springmvc-thymeleaf-template&#x2F;blob&#x2F;20121213&#x2F;src&#x2F;main&#x2F;java&#x2F;config&#x2F;MvcConfiguration.java&quot;&gt;MvcConfiguration.java&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;Our templates now look a lot more like plain HTML, and will render better when loaded directly in a browser:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;color:#c0c5ce;&quot;&gt;&lt;code&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;&amp;lt;!DOCTYPE html&amp;gt;  
&lt;&#x2F;span&gt;&lt;span&gt;&amp;lt;html xmlns:th=&amp;quot;http:&#x2F;&#x2F;www.thymeleaf.org&amp;quot;&amp;gt;  
&lt;&#x2F;span&gt;&lt;span&gt;&amp;lt;head&amp;gt;  
&lt;&#x2F;span&gt;&lt;span&gt;    &amp;lt;title&amp;gt;Home&amp;lt;&#x2F;title&amp;gt;  
&lt;&#x2F;span&gt;&lt;span&gt;&amp;lt;&#x2F;head&amp;gt;  
&lt;&#x2F;span&gt;&lt;span&gt;&amp;lt;body&amp;gt;  
&lt;&#x2F;span&gt;&lt;span&gt;&amp;lt;h1&amp;gt;Hello World!&amp;lt;&#x2F;h1&amp;gt;  
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;&amp;lt;p&amp;gt;Server time: &amp;lt;span th:text=&amp;quot;${serverTime}&amp;quot;&amp;gt;&amp;lt;&#x2F;span&amp;gt;&amp;lt;&#x2F;p&amp;gt;  
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;&amp;lt;p&amp;gt;Here are some items:&amp;lt;&#x2F;p&amp;gt;  
&lt;&#x2F;span&gt;&lt;span&gt;&amp;lt;ul&amp;gt;  
&lt;&#x2F;span&gt;&lt;span&gt;    &amp;lt;li th:each=&amp;quot;item : ${someItems}&amp;quot; th:text=&amp;quot;${item}&amp;quot;&amp;gt;&amp;lt;&#x2F;li&amp;gt;  
&lt;&#x2F;span&gt;&lt;span&gt;&amp;lt;&#x2F;ul&amp;gt;  
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;&amp;lt;p&amp;gt;Do we have a message from the dummy service:&amp;lt;&#x2F;p&amp;gt;  
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;&amp;lt;div th:if=&amp;quot;${dummyService == null}&amp;quot;&amp;gt;  
&lt;&#x2F;span&gt;&lt;span&gt;    &amp;lt;p&amp;gt;No, dummy service is null.&amp;lt;&#x2F;p&amp;gt;  
&lt;&#x2F;span&gt;&lt;span&gt;&amp;lt;&#x2F;div&amp;gt;  
&lt;&#x2F;span&gt;&lt;span&gt;&amp;lt;div th:if=&amp;quot;${dummyService != null}&amp;quot;&amp;gt;  
&lt;&#x2F;span&gt;&lt;span&gt;    &amp;lt;p&amp;gt;Yes: &amp;lt;span th:text=&amp;quot;${dummyService.getMessage()}&amp;quot;&amp;gt;&amp;lt;&#x2F;span&amp;gt;&amp;lt;&#x2F;p&amp;gt;  
&lt;&#x2F;span&gt;&lt;span&gt;&amp;lt;&#x2F;div&amp;gt;  
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;&amp;lt;p&amp;gt;&amp;lt;a href=&amp;quot;resources&#x2F;static.txt&amp;quot;&amp;gt;A static file.&amp;lt;&#x2F;a&amp;gt;&amp;lt;&#x2F;p&amp;gt;  
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;&amp;lt;p&amp;gt;&amp;lt;a href=&amp;quot;metrics&amp;quot;&amp;gt;Yammer Metrics&amp;lt;&#x2F;a&amp;gt;&amp;lt;&#x2F;p&amp;gt;  
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;&amp;lt;&#x2F;body&amp;gt;  
&lt;&#x2F;span&gt;&lt;span&gt;&amp;lt;&#x2F;html&amp;gt;  
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;With the build process being simple (no dependence on maven plugins) we can switch to a much less verbose &lt;a href=&quot;http:&#x2F;&#x2F;www.gradle.org&#x2F;&quot;&gt;Gradle&lt;&#x2F;a&gt; build file:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;color:#c0c5ce;&quot;&gt;&lt;code&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;apply plugin:&amp;#39;java&amp;#39;  
&lt;&#x2F;span&gt;&lt;span&gt;apply plugin:&amp;#39;application&amp;#39;  
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;version = &amp;#39;0.0.1-SNAPSHOT&amp;#39;  
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;mainClassName = &amp;quot;ca.unx.template.Main&amp;quot;  
&lt;&#x2F;span&gt;&lt;span&gt;applicationName = &amp;quot;jetty-springmvc-thymeleaf-template&amp;quot;  
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;repositories {  
&lt;&#x2F;span&gt;&lt;span&gt;    mavenCentral()  
&lt;&#x2F;span&gt;&lt;span&gt;}  
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;dependencies {  
&lt;&#x2F;span&gt;&lt;span&gt;    compile(&amp;quot;org.springframework:spring-webmvc:3.1.3.RELEASE&amp;quot;) {  
&lt;&#x2F;span&gt;&lt;span&gt;        &#x2F;&#x2F; Commons-logging excluded in favour of SLF4j.  
&lt;&#x2F;span&gt;&lt;span&gt;        exclude module: &amp;#39;commons-logging&amp;#39;  
&lt;&#x2F;span&gt;&lt;span&gt;    }  
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;    compile &amp;quot;cglib:cglib:2.2.2&amp;quot;  
&lt;&#x2F;span&gt;&lt;span&gt;    compile &amp;quot;org.thymeleaf:thymeleaf-spring3:2.0.14&amp;quot;  
&lt;&#x2F;span&gt;&lt;span&gt;    compile &amp;quot;org.eclipse.jetty:jetty-webapp:8.1.8.v20121106&amp;quot;  
&lt;&#x2F;span&gt;&lt;span&gt;    compile &amp;quot;com.yammer.metrics:metrics-servlet:2.2.0&amp;quot;  
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;    &#x2F;* Logging. *&#x2F;  
&lt;&#x2F;span&gt;&lt;span&gt;    def slf4jVersion = &amp;quot;1.7.1&amp;quot;  
&lt;&#x2F;span&gt;&lt;span&gt;    compile &amp;quot;ch.qos.logback:logback-classic:1.0.9&amp;quot;  
&lt;&#x2F;span&gt;&lt;span&gt;    compile &amp;quot;org.slf4j:slf4j-api:$slf4jVersion&amp;quot;  
&lt;&#x2F;span&gt;&lt;span&gt;    compile &amp;quot;org.slf4j:jcl-over-slf4j:$slf4jVersion&amp;quot;  
&lt;&#x2F;span&gt;&lt;span&gt;    compile &amp;quot;org.codehaus.groovy:groovy:1.8.6&amp;quot;  
&lt;&#x2F;span&gt;&lt;span&gt;}  
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;A complete template project can be found &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;jasonish&#x2F;jetty-springmvc-thymeleaf-template&#x2F;tree&#x2F;20121213&quot;&gt;here&lt;&#x2F;a&gt;. Note that this links to tag which is the state of the code at the time of this writing.&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>SpringMVC with Embedded Jetty</title>
        <published>2012-12-08T01:46:00+00:00</published>
        <updated>2012-12-08T01:46:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://jasonish.org/blog/springmvc-with-embedded-jetty/"/>
        <id>https://jasonish.org/blog/springmvc-with-embedded-jetty/</id>
        
        <content type="html" xml:base="https://jasonish.org/blog/springmvc-with-embedded-jetty/">&lt;p&gt;As an accidental Java developer I&#x27;ve never been comfortable deploying applications &lt;em&gt;into&lt;&#x2F;em&gt; a container, especially when the web interface is secondary to the primary purpose of the application. Instead I prefer to programatically create and manage the web interface rather than have it manage me. Currently SpringMVC is my Java web framework of choice (due to company convention more than anything else) and it is built around the idea of being managed by a container such as Jetty or Tomcat.&lt;&#x2F;p&gt;
&lt;p&gt;While there is no shortage of existing posts on using SpringMVC with embedded Jetty, they fail for me due to the following reasons:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;They embed Jetty just enough to bootstrap something that looks like a classic Java web application - not what I want!&lt;&#x2F;li&gt;
&lt;li&gt;They don&#x27;t address JSPs - the default view technology used by SpringMVC.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h3 id=&quot;compile-those-jsps&quot;&gt;Compile Those JSPs&lt;&#x2F;h3&gt;
&lt;p&gt;By compiling the JSPs prior to deployment we can save ourselves from the hassle of classpath issues, especially relating to tag libs.&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;color:#c0c5ce;&quot;&gt;&lt;code&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;&amp;lt;plugin&amp;gt;  
&lt;&#x2F;span&gt;&lt;span&gt;  &amp;lt;groupId&amp;gt;org.mortbay.jetty&amp;lt;&#x2F;groupId&amp;gt;  
&lt;&#x2F;span&gt;&lt;span&gt;  &amp;lt;artifactId&amp;gt;jetty-jspc-maven-plugin&amp;lt;&#x2F;artifactId&amp;gt;  
&lt;&#x2F;span&gt;&lt;span&gt;  &amp;lt;version&amp;gt;${jetty.version}&amp;lt;&#x2F;version&amp;gt;  
&lt;&#x2F;span&gt;&lt;span&gt;  &amp;lt;executions&amp;gt;  
&lt;&#x2F;span&gt;&lt;span&gt;    &amp;lt;execution&amp;gt;  
&lt;&#x2F;span&gt;&lt;span&gt;      &amp;lt;phase&amp;gt;compile&amp;lt;&#x2F;phase&amp;gt;  
&lt;&#x2F;span&gt;&lt;span&gt;      &amp;lt;id&amp;gt;jspc&amp;lt;&#x2F;id&amp;gt;  
&lt;&#x2F;span&gt;&lt;span&gt;      &amp;lt;goals&amp;gt;  
&lt;&#x2F;span&gt;&lt;span&gt;        &amp;lt;goal&amp;gt;jspc&amp;lt;&#x2F;goal&amp;gt;  
&lt;&#x2F;span&gt;&lt;span&gt;      &amp;lt;&#x2F;goals&amp;gt;  
&lt;&#x2F;span&gt;&lt;span&gt;      &amp;lt;configuration&amp;gt;  
&lt;&#x2F;span&gt;&lt;span&gt;        &amp;lt;webAppSourceDirectory&amp;gt;  
&lt;&#x2F;span&gt;&lt;span&gt;          ${basedir}&#x2F;src&#x2F;main&#x2F;resources&#x2F;webapp  
&lt;&#x2F;span&gt;&lt;span&gt;        &amp;lt;&#x2F;webAppSourceDirectory&amp;gt;  
&lt;&#x2F;span&gt;&lt;span&gt;        &amp;lt;webXml&amp;gt;  
&lt;&#x2F;span&gt;&lt;span&gt;          ${basedir}&#x2F;src&#x2F;main&#x2F;resources&#x2F;webapp&#x2F;WEB-INF&#x2F;web.xml  
&lt;&#x2F;span&gt;&lt;span&gt;        &amp;lt;&#x2F;webXml&amp;gt;  
&lt;&#x2F;span&gt;&lt;span&gt;        &amp;lt;webXmlFragment&amp;gt;  
&lt;&#x2F;span&gt;&lt;span&gt;          ${basedir}&#x2F;target&#x2F;classes&#x2F;webapp&#x2F;WEB-INF&#x2F;web.xml-frag  
&lt;&#x2F;span&gt;&lt;span&gt;        &amp;lt;&#x2F;webXmlFragment&amp;gt;  
&lt;&#x2F;span&gt;&lt;span&gt;      &amp;lt;&#x2F;configuration&amp;gt;  
&lt;&#x2F;span&gt;&lt;span&gt;    &amp;lt;&#x2F;execution&amp;gt;  
&lt;&#x2F;span&gt;&lt;span&gt;  &amp;lt;&#x2F;executions&amp;gt;  
&lt;&#x2F;span&gt;&lt;span&gt;&amp;lt;&#x2F;plugin&amp;gt;  
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This plugin will compile all the JSPs found under src&#x2F;main&#x2F;resources&#x2F;webapp and modify the existing web.xml to direct requests for the JSPs to the pre-compiled versions. This avoids compiling them at runtime and speeds up the time it takes to respond to the first request for a JSP.&lt;&#x2F;p&gt;
&lt;p&gt;You may also notice that the JSPs are under src&#x2F;main&#x2F;resources&#x2F;webapp instead of the more common src&#x2F;main&#x2F;webapp. This is to avoid extra lines in the pom.xml to pull in webapp as a resource, as we are packaging as a jar.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;bootstrapping-jetty&quot;&gt;Bootstrapping Jetty&lt;&#x2F;h3&gt;
&lt;p&gt;I use Spring annotations to configure Jetty and import its &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;jasonish&#x2F;jetty-springmvc-jsp-template&#x2F;tree&#x2F;20121207&#x2F;src&#x2F;main&#x2F;java&#x2F;config&#x2F;JettyConfiguration.java&quot;&gt;@Configuration class&lt;&#x2F;a&gt; into my &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;jasonish&#x2F;jetty-springmvc-jsp-template&#x2F;tree&#x2F;20121207&#x2F;src&#x2F;main&#x2F;java&#x2F;config&#x2F;RootConfiguration.java&quot;&gt;root context configuration&lt;&#x2F;a&gt; class. In order for the SpringMVC dispatcher servlet to access beans created in the root context, this class needs to be application context aware:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;color:#c0c5ce;&quot;&gt;&lt;code&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;@Configuration  
&lt;&#x2F;span&gt;&lt;span&gt;public class JettyConfiguration implements ApplicationContextAware {  
&lt;&#x2F;span&gt;&lt;span&gt;    private ApplicationContext applicationContext;  
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;    @Override  
&lt;&#x2F;span&gt;&lt;span&gt;    public void setApplicationContext(ApplicationContext applicationContext)  
&lt;&#x2F;span&gt;&lt;span&gt;            throws BeansException {  
&lt;&#x2F;span&gt;&lt;span&gt;        this.applicationContext = applicationContext;  
&lt;&#x2F;span&gt;&lt;span&gt;    }  
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;this is used as the parent context for the new context that will be created for the SpringMVC dispatcher servlet:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;color:#c0c5ce;&quot;&gt;&lt;code&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;@Bean  
&lt;&#x2F;span&gt;&lt;span&gt;public ServletHolder dispatcherServlet() {  
&lt;&#x2F;span&gt;&lt;span&gt;    AnnotationConfigWebApplicationContext ctx =   
&lt;&#x2F;span&gt;&lt;span&gt;        new AnnotationConfigWebApplicationContext();  
&lt;&#x2F;span&gt;&lt;span&gt;    ctx.setParent(applicationContext);  
&lt;&#x2F;span&gt;&lt;span&gt;    ctx.register(MvcConfiguration.class);  
&lt;&#x2F;span&gt;&lt;span&gt;    DispatcherServlet servlet = new DispatcherServlet(ctx);  
&lt;&#x2F;span&gt;&lt;span&gt;    ServletHolder holder = new ServletHolder(&amp;quot;dispatcher-servlet&amp;quot;,   
&lt;&#x2F;span&gt;&lt;span&gt;        servlet);  
&lt;&#x2F;span&gt;&lt;span&gt;    holder.setInitOrder(1);  
&lt;&#x2F;span&gt;&lt;span&gt;    return holder;  
&lt;&#x2F;span&gt;&lt;span&gt;}  
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;There are still a few more tricks required to get the dispatcher servlet registered without defining it in your web.xml. We must also create a Jetty web application context, this creates the JSP servlet as well as a &lt;em&gt;default&lt;&#x2F;em&gt; servlet as would be created during the instantiation of a classic war based application:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;color:#c0c5ce;&quot;&gt;&lt;code&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;@Bean  
&lt;&#x2F;span&gt;&lt;span&gt;public WebAppContext jettyWebAppContext() throws IOException {  
&lt;&#x2F;span&gt;&lt;span&gt;    WebAppContext ctx = new WebAppContext();  
&lt;&#x2F;span&gt;&lt;span&gt;    ctx.setContextPath(&amp;quot;&#x2F;&amp;quot;);  
&lt;&#x2F;span&gt;&lt;span&gt;    ctx.setWar(new ClassPathResource(&amp;quot;webapp&amp;quot;).getURI().toString());  
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;     &#x2F;* We can add the Metrics servlet right away. *&#x2F;  
&lt;&#x2F;span&gt;&lt;span&gt;    ctx.addServlet(AdminServlet.class, &amp;quot;&#x2F;metrics&#x2F;*&amp;quot;);  
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;    return ctx;  
&lt;&#x2F;span&gt;&lt;span&gt;}  
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Notice that I&#x27;ve added the metrics servlet, but have yet to add the dispatcher servlet. For some reason, adding the dispatcher servlet here causes JSP views to fail. One option is to fall back to defining the dispatcher servlet in your web.xml (which may be the cleanest option), or you can register the dispatcher servlet in the Jetty lifeCycleStarted callback which we&#x27;ll do here:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;color:#c0c5ce;&quot;&gt;&lt;code&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;@Bean  
&lt;&#x2F;span&gt;&lt;span&gt;public LifeCycle.Listener lifeCycleStartedListener() {  
&lt;&#x2F;span&gt;&lt;span&gt;    return new AbstractLifeCycle.AbstractLifeCycleListener() {  
&lt;&#x2F;span&gt;&lt;span&gt;        @Override  
&lt;&#x2F;span&gt;&lt;span&gt;        public void lifeCycleStarted(LifeCycle event) {  
&lt;&#x2F;span&gt;&lt;span&gt;            try {  
&lt;&#x2F;span&gt;&lt;span&gt;                ServletHolder dispatcherServlet = dispatcherServlet();  
&lt;&#x2F;span&gt;&lt;span&gt;                jettyWebAppContext().getServletHandler()  
&lt;&#x2F;span&gt;&lt;span&gt;                        .addServletWithMapping(dispatcherServlet, &amp;quot;&#x2F;&amp;quot;);  
&lt;&#x2F;span&gt;&lt;span&gt;                dispatcherServlet.start();  
&lt;&#x2F;span&gt;&lt;span&gt;            } catch (Exception e) {  
&lt;&#x2F;span&gt;&lt;span&gt;                logger.error(  
&lt;&#x2F;span&gt;&lt;span&gt;                        &amp;quot;Failed to start Spring MVC dispatcher servlet&amp;quot;, e);  
&lt;&#x2F;span&gt;&lt;span&gt;            }  
&lt;&#x2F;span&gt;&lt;span&gt;        }  
&lt;&#x2F;span&gt;&lt;span&gt;    };  
&lt;&#x2F;span&gt;&lt;span&gt;}  
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;@Bean(initMethod = &amp;quot;start&amp;quot;, destroyMethod = &amp;quot;stop&amp;quot;)  
&lt;&#x2F;span&gt;&lt;span&gt;public Server jettyServer() throws IOException {  
&lt;&#x2F;span&gt;&lt;span&gt;    Server server = new Server();  
&lt;&#x2F;span&gt;&lt;span&gt;    server.setHandler(jettyWebAppContext());  
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;    &#x2F;* Add a life cycle listener so we can register the SpringMVC dispatcher  
&lt;&#x2F;span&gt;&lt;span&gt;     * servlet after the web application context has been started. *&#x2F;  
&lt;&#x2F;span&gt;&lt;span&gt;    server.addLifeCycleListener(lifeCycleStartedListener());  
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;    server.setConnectors(jettyConnectors());  
&lt;&#x2F;span&gt;&lt;span&gt;    return server;  
&lt;&#x2F;span&gt;&lt;span&gt;}  
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;In summary, this is just another variation of James Ward&#x27;s post on &lt;a href=&quot;http:&#x2F;&#x2F;www.jamesward.com&#x2F;2012&#x2F;08&#x2F;13&#x2F;containerless-spring-mvc&quot;&gt;Containerless Spring MVC&lt;&#x2F;a&gt;. The complete code for this project (which I use as a template) can be at &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;jasonish&#x2F;jetty-springmvc-jsp-template&quot;&gt;https:&#x2F;&#x2F;github.com&#x2F;jasonish&#x2F;jetty-springmvc-jsp-template&lt;&#x2F;a&gt;. The code as referenced in this post can be found in the &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;jasonish&#x2F;jetty-springmvc-jsp-template&#x2F;tree&#x2F;20121207&quot;&gt;20121207&lt;&#x2F;a&gt; tag.&lt;&#x2F;p&gt;
&lt;p&gt;Next - As I&#x27;m not really a fan of JSPs, or the extra hoops required to make this work right I&#x27;ll probably look at updating the template with &lt;a href=&quot;http:&#x2F;&#x2F;www.thymeleaf.org&#x2F;&quot;&gt;Thymeleaf&lt;&#x2F;a&gt; support, which should greatly simplify things.&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Some NSM type RPMs.</title>
        <published>2012-04-13T13:13:00+00:00</published>
        <updated>2012-04-13T13:13:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://jasonish.org/blog/some-nsm-type-rpms/"/>
        <id>https://jasonish.org/blog/some-nsm-type-rpms/</id>
        
        <content type="html" xml:base="https://jasonish.org/blog/some-nsm-type-rpms/">&lt;p&gt;&lt;strong&gt;Note: These RPMs no longer exist. The GitHub repo remains for now: &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;jasonish&#x2F;nsm-rpms&quot;&gt;https:&#x2F;&#x2F;github.com&#x2F;jasonish&#x2F;nsm-rpms&lt;&#x2F;a&gt;&lt;&#x2F;strong&gt;&lt;&#x2F;p&gt;
&lt;p&gt;I&#x27;ve always maintained more or less up to date Snort RPMs for RHEL for personal use and have recently added Suricata. As they may be useful for others I have cleaned them up a little and made a YUM repository for EL6 i386 and x86_64. See the &lt;a href=&quot;http:&#x2F;&#x2F;nsm-rpms.unx.ca&#x2F;&quot;&gt;http:&#x2F;&#x2F;nsm-rpms.unx.ca&#x2F;&lt;&#x2F;a&gt; for more info.&lt;&#x2F;p&gt;
&lt;p&gt;A few things to note:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;These RPMs use a prefix of &#x2F;opt&#x2F;nsm to prevent conflict with similar RPMs you may have installed, its a little bit out of the norm for RPMs and I&#x27;m open to comments...&lt;&#x2F;li&gt;
&lt;li&gt;Snort and Suricata packages will never be automatically upgraded as often upgrading to a new version requires some administration work such as updating your configuration files. To facilitate this the packages have their version as part of the name and &quot;-latest&quot; pseudo-packages are provided which will always install the latest RPM but you will have to &quot;snort-select&quot; or &quot;suricata-select&quot; the new version to make it active. I&#x27;ll probably have to add some more detailed documentation about this on the wiki.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;As I&#x27;m also a regular Fedora user I&#x27;ll probably add Fedora builds at some point as its little effort to me. If Fedora builds would be useful to you please let me know and I may do it sooner than later.&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Libevent Examples</title>
        <published>2011-03-08T15:42:00+00:00</published>
        <updated>2011-03-08T15:42:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://jasonish.org/blog/libevent-examples/"/>
        <id>https://jasonish.org/blog/libevent-examples/</id>
        
        <content type="html" xml:base="https://jasonish.org/blog/libevent-examples/">&lt;p&gt;Just looked at my web stats for the first time in a long time and I see that one of the most requested resources are my &lt;a href=&quot;http:&#x2F;&#x2F;monkey.org&#x2F;~provos&#x2F;libevent&#x2F;&quot;&gt;libevent&lt;&#x2F;a&gt; examples, which no longer exist here. The code however does still exist:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;jasonish&#x2F;libevent-examples&quot;&gt;https:&#x2F;&#x2F;github.com&#x2F;jasonish&#x2F;libevent-examples&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Back to the Mac</title>
        <published>2010-04-22T10:28:00+00:00</published>
        <updated>2010-04-22T10:28:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://jasonish.org/blog/back-to-the-mac/"/>
        <id>https://jasonish.org/blog/back-to-the-mac/</id>
        
        <content type="html" xml:base="https://jasonish.org/blog/back-to-the-mac/">&lt;p&gt;Recent issues with Linux on a laptop has given me the desire to try working on a Mac again. Even though I have a pretty well supported laptop (Lenovo x61), its the little issues that have begun to bother me which include not great sleep&#x2F;suspend support, wireless and audio issues and an almost never ending stream of updates. Yes, you Linux people may say it works fine, but if you&#x27;ve ever used a Mac before you&#x27;ll know its not as good as a could be, by far.&lt;&#x2F;p&gt;
&lt;p&gt;I&#x27;ve also found that its really nice to have the real Microsoft Office handy when you swap documents with other non-Linux using people (yeah, OpenOffice doesn&#x27;t quite cut it when taking turns editing documents) which meant often having a Windows VM running.&lt;&#x2F;p&gt;
&lt;p&gt;The other factor that helps the Mac be a viable option is the majority of the software I develop already builds and installs on a Mac, or can do so with very minor modifications. The stuff that doesn&#x27;t is so tied to a specific environment that it really requires a virtual machine even when running Linux as the host operating system. This really makes the Mac sound like an ideal system.&lt;&#x2F;p&gt;
&lt;p&gt;So yesterday while heading out just before dinner to grab some hamburger buns I walked by the local Mac retailer (hey, its about 20 steps from Safeway) and grabbed a high-res 15&quot; MacBook with the Core i5 2.53ghz processor. They weren&#x27;t able to upgrade the ram to 8GB on the spot but I decided I couldn&#x27;t wait.&lt;&#x2F;p&gt;
&lt;p&gt;Aesthetically its a beautiful machine. The display is about the best computer display I&#x27;ve ever seen. The 3 primary pieces of software I work on compile out of the box. Its also nice to have Microsoft Office running natively. The thing that drove me away from the Mac before was some of the UI behaviours, like Cmd-Tab switching applications, not just windows of applications. But I&#x27;m going to give this a true go and may update this blog now and then with issues that I run into as a developer, developing network-level apps primarily for Linux, making the shift to Mac as a development platform.&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>FVWM: Moving a Window to Another Screen</title>
        <published>2009-10-07T13:34:00+00:00</published>
        <updated>2009-10-07T13:34:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://jasonish.org/blog/fvwm-moving-a-window-to-another-screen/"/>
        <id>https://jasonish.org/blog/fvwm-moving-a-window-to-another-screen/</id>
        
        <content type="html" xml:base="https://jasonish.org/blog/fvwm-moving-a-window-to-another-screen/">&lt;p&gt;Probably the most lacking feature in most multi-screen setups is the ability to move a window from one screen to another with a keyboard shortcut. I do this to bring the window I&#x27;m currently working on into my centre monitor so its directly in front of me. There are 2 ways to go about this. The first is moving a window to a specific display and the second is to move (shift) the window to the left or right display (which would just be back and forth in a dual monitor setup).&lt;&#x2F;p&gt;
&lt;p&gt;For the first case you could define the following function:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;color:#c0c5ce;&quot;&gt;&lt;code&gt;&lt;span&gt;# This function will move a window to the X screen provided in the  
&lt;&#x2F;span&gt;&lt;span&gt;# first argument. If the window is in the maximized it will be taken  
&lt;&#x2F;span&gt;&lt;span&gt;# out of the maximized state before moving. If we don&amp;#39;t do this it  
&lt;&#x2F;span&gt;&lt;span&gt;# will be moved back to the original screen when the maximized state  
&lt;&#x2F;span&gt;&lt;span&gt;# is toggled.  
&lt;&#x2F;span&gt;&lt;span&gt;#  
&lt;&#x2F;span&gt;&lt;span&gt;# If you do not want the pointer to be moved to the windows new  
&lt;&#x2F;span&gt;&lt;span&gt;# location then comment out the line containing WarpToWindow.  
&lt;&#x2F;span&gt;&lt;span&gt;DestroyFunc MoveWindowToScreen  
&lt;&#x2F;span&gt;&lt;span&gt;AddToFunc MoveWindowToScreen  
&lt;&#x2F;span&gt;&lt;span&gt;\+ I Current (Maximized) Maximize  
&lt;&#x2F;span&gt;&lt;span&gt;\+ I SetEnv PWX $[pointer.wx]  
&lt;&#x2F;span&gt;&lt;span&gt;\+ I Setenv PWY $[pointer.wy]  
&lt;&#x2F;span&gt;&lt;span&gt;\+ I MoveToScreen $[0]  
&lt;&#x2F;span&gt;&lt;span&gt;\+ I WindowId $[w.id] WarpToWindow $[PWX]p $[PWY]p  
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;And then add the following to your window operations menu:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;color:#c0c5ce;&quot;&gt;&lt;code&gt;&lt;span&gt;\+ &amp;quot;&amp;amp;1 Move to Screen 1&amp;quot; MoveWindowToScreen 2  
&lt;&#x2F;span&gt;&lt;span&gt;\+ &amp;quot;&amp;amp;2 Move to Screen 2&amp;quot; MoveWindowToScreen 0  
&lt;&#x2F;span&gt;&lt;span&gt;\+ &amp;quot;&amp;amp;3 Move to Screen 3&amp;quot; MoveWindowToScreen 1  
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Note that the argument you provide to the MoveWindowToScreen function takes the X display number which may not directly map to the order of the screens on your desk.&lt;&#x2F;p&gt;
&lt;p&gt;The second method is to move the screen to the left or the right. Or in the case of a dual monitor setup you could just continually move right to have the window flip&#x2F;flop between your 2 screens.&lt;&#x2F;p&gt;
&lt;p&gt;First download the following file and save it to ~&#x2F;.fvwm&#x2F;ShiftToScreen.py: &lt;a href=&quot;http:&#x2F;&#x2F;ishbits.googlecode.com&#x2F;svn&#x2F;trunk&#x2F;fvwm&#x2F;ShiftToScreen.py&quot;&gt;ShiftToScreen.py&lt;&#x2F;a&gt;&lt;br &#x2F;&gt;
You will also need to update variables &lt;em&gt;screenWidth&lt;&#x2F;em&gt; and &lt;em&gt;screens&lt;&#x2F;em&gt; in ShiftToScreen.py as they are currently setup for my configuration of 3 screens with a width of 1920 pixels each.&lt;&#x2F;p&gt;
&lt;p&gt;Then define the following function:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;color:#c0c5ce;&quot;&gt;&lt;code&gt;&lt;span&gt;# This function will move a window to the left or right screen  
&lt;&#x2F;span&gt;&lt;span&gt;# depending on the first argument which should be on of &amp;quot;left&amp;quot; or  
&lt;&#x2F;span&gt;&lt;span&gt;# &amp;quot;right&amp;quot;. It depends on the auxiliary python script  
&lt;&#x2F;span&gt;&lt;span&gt;# ShiftToScreen.py.  
&lt;&#x2F;span&gt;&lt;span&gt;DestroyFunc ShiftToScreen  
&lt;&#x2F;span&gt;&lt;span&gt;AddToFunc ShiftToScreen  
&lt;&#x2F;span&gt;&lt;span&gt;\+ I Current (Maximized) Maximize  
&lt;&#x2F;span&gt;&lt;span&gt;\+ I SetEnv PWX $[pointer.wx]  
&lt;&#x2F;span&gt;&lt;span&gt;\+ I Setenv PWY $[pointer.wy]  
&lt;&#x2F;span&gt;&lt;span&gt;\+ I PipeRead &amp;quot;python $.&#x2F;ShiftToScreen.py $[0] $[w.x]&amp;quot;  
&lt;&#x2F;span&gt;&lt;span&gt;\+ I WindowId $[w.id] WarpToWindow $[PWX]p $[PWY]p  
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;You could then add the following to your windows operations menu:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;color:#c0c5ce;&quot;&gt;&lt;code&gt;&lt;span&gt;\+ &amp;quot;&amp;amp;Left Screen&amp;quot; ShiftToScreen left  
&lt;&#x2F;span&gt;&lt;span&gt;\+ &amp;quot;&amp;amp;Right Screen&amp;quot;	ShiftToScreen right  
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;or define some keyboard shortcuts. For example I have bound Shift-Alt-Left and Shift-Alt-Right to shift the window to the left or right screen:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;color:#c0c5ce;&quot;&gt;&lt;code&gt;&lt;span&gt;Key Left WTSF12468 SM ShiftToScreen left  
&lt;&#x2F;span&gt;&lt;span&gt;Key Right WTSF12468 SM ShiftToScreen right  
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;If you are only working with 2 screens you will only need to define one shortcut to get flip&#x2F;flop like behaviour as shifting left beyond the leftmost screen will wrap the window around to the right most screen.&lt;&#x2F;p&gt;
&lt;p&gt;Enjoy.&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Ideal Multi-Monitor Setup</title>
        <published>2009-09-22T14:36:00+00:00</published>
        <updated>2009-09-22T14:36:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://jasonish.org/blog/ideal-multi-monitor-setup/"/>
        <id>https://jasonish.org/blog/ideal-multi-monitor-setup/</id>
        
        <content type="html" xml:base="https://jasonish.org/blog/ideal-multi-monitor-setup/">&lt;p&gt;Multi-monitor configurations are great but I think they leave out some usability aspects that could really make life easier for the keyboard user. When I was just using dual displays I really wanted keyboard shortcuts to do the following:&lt;&#x2F;p&gt;
&lt;p&gt;* Move a window from one screen to the other.&lt;br &#x2F;&gt;
* Swap what is seen on each display.&lt;&#x2F;p&gt;
&lt;p&gt;When I moved to 3 monitors my needs changed a little.&lt;&#x2F;p&gt;
&lt;p&gt;* Shift a window to the screen to the left or the right, rotating around.&lt;br &#x2F;&gt;
* Swap a display with the one to the left or the right.&lt;br &#x2F;&gt;
* Shift all displays to the left or the right.&lt;&#x2F;p&gt;
&lt;p&gt;This would make it extremely fast to move the window you are currently working on to your primary display, then push it back to where it came from. Or swap the contents of your right screen with your centre screen if you need to shift your work focus for a while.&lt;&#x2F;p&gt;
&lt;p&gt;As far as I know this is not possible with Windows, Mac or most Linux configurations. However, I believe using FVWM as your Linux (ok, *nix) window manager will make this all possible, at least my experiments with dual screens have been positive. I&#x27;ll update this blog with various functions that should make all of the above achievable.&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Making that Caps-Lock key an extra Control key</title>
        <published>2009-03-16T23:05:00+00:00</published>
        <updated>2009-03-16T23:05:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://jasonish.org/blog/making-that-caps-lock-key-an-extra-control-key/"/>
        <id>https://jasonish.org/blog/making-that-caps-lock-key-an-extra-control-key/</id>
        
        <content type="html" xml:base="https://jasonish.org/blog/making-that-caps-lock-key-an-extra-control-key/">&lt;p&gt;Yes, covered everywhere and I&#x27;ve done it enough time I should know it off by heart now... I used to swap caps and control, but now I just make the caps an additional control and leave the original control as is...&lt;&#x2F;p&gt;
&lt;p&gt;~&#x2F;.xmodmap snippet:&lt;&#x2F;p&gt;
&lt;p&gt;remove Lock = Caps_Lock&lt;br &#x2F;&gt;
keysym Caps_Lock = Control_L&lt;br &#x2F;&gt;
add Control = Control_L&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>TAILQ Example</title>
        <published>2006-08-19T10:43:00+00:00</published>
        <updated>2006-08-19T10:43:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://jasonish.org/blog/tailq-example/"/>
        <id>https://jasonish.org/blog/tailq-example/</id>
        
        <content type="html" xml:base="https://jasonish.org/blog/tailq-example/">&lt;p&gt;I plan to use this blog to post codebits that I find myself sending to people
over and over again. The first example is how to use a TAILQ from sys&#x2F;queue.h
found on the BSDs. Many Linux distributions also have sys&#x2F;queue.h but may be
missing certain macros such as TAILQ_FOREACH(). At the very least I hope this
enticies some newer C programmer to use queue.h rather than rolling their own
linked list. I’ll jump directly to the code as I feel it is more or less self
explanatory.&lt;&#x2F;p&gt;
&lt;p&gt;The following code can be downloaded &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;jasonish&#x2F;tailq-example&quot;&gt;here&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;c&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-c &quot;&gt;&lt;code class=&quot;language-c&quot; data-lang=&quot;c&quot;&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;&#x2F;*
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt; * TAILQ example program.
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt; *&#x2F;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;#include &lt;&#x2F;span&gt;&lt;span&gt;&amp;lt;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;stdlib.h&lt;&#x2F;span&gt;&lt;span&gt;&amp;gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;#include &lt;&#x2F;span&gt;&lt;span&gt;&amp;lt;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;stdio.h&lt;&#x2F;span&gt;&lt;span&gt;&amp;gt;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;&#x2F;*
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt; * On many OpenBSD&#x2F;NetBSD&#x2F;FreeBSD you could include &amp;lt;sys&#x2F;queue.h&amp;gt;, but
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt; * for portability we&amp;#39;ll include the local copy.
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt; *&#x2F;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;#include &lt;&#x2F;span&gt;&lt;span&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;queue.h&lt;&#x2F;span&gt;&lt;span&gt;&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;&#x2F;*
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt; * This structure defines each item in our tail queue.  It must also
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt; * contain an item (TAILQ_ENTRY) that points to the next and previous
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt; * items in the tail queue.
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt; *
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt; * For simplicity, we will be creating a list of integers.
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt; *&#x2F;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;struct &lt;&#x2F;span&gt;&lt;span&gt;tailq_entry {
&lt;&#x2F;span&gt;&lt;span&gt;	&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;int&lt;&#x2F;span&gt;&lt;span&gt; value;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;	&lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;&#x2F;*
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;	 * This holds the pointers to the next and previous entries in
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;	 * the tail queue.
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;	 *&#x2F;
&lt;&#x2F;span&gt;&lt;span&gt;	&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;TAILQ_ENTRY&lt;&#x2F;span&gt;&lt;span&gt;(tailq_entry) entries;
&lt;&#x2F;span&gt;&lt;span&gt;};
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;&#x2F;*
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt; * Our tail queue requires a head, this is defined using the
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt; * TAILQ_HEAD macro.
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt; *&#x2F;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;TAILQ_HEAD&lt;&#x2F;span&gt;&lt;span&gt;(, tailq_entry) my_tailq_head;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;int
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#8fa1b3;&quot;&gt;main&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;int &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;argc&lt;&#x2F;span&gt;&lt;span&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;char &lt;&#x2F;span&gt;&lt;span&gt;**&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;argv&lt;&#x2F;span&gt;&lt;span&gt;)
&lt;&#x2F;span&gt;&lt;span&gt;{
&lt;&#x2F;span&gt;&lt;span&gt;	&lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;&#x2F;* Define a pointer to an item in the tail queue. *&#x2F;
&lt;&#x2F;span&gt;&lt;span&gt;	&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;struct&lt;&#x2F;span&gt;&lt;span&gt; tailq_entry *item;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;&#x2F;* In some cases we have to track a temporary item. *&#x2F;
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;struct&lt;&#x2F;span&gt;&lt;span&gt; tailq_entry *tmp_item;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;	&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;int&lt;&#x2F;span&gt;&lt;span&gt; i;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;	&lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;&#x2F;* Initialize the tail queue. *&#x2F;
&lt;&#x2F;span&gt;&lt;span&gt;	&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;TAILQ_INIT&lt;&#x2F;span&gt;&lt;span&gt;(&amp;amp;my_tailq_head);
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;	&lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;&#x2F;* Add 10 items to the tailq queue. *&#x2F;
&lt;&#x2F;span&gt;&lt;span&gt;	&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;for &lt;&#x2F;span&gt;&lt;span&gt;(i = &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span&gt;; i &amp;lt; &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;10&lt;&#x2F;span&gt;&lt;span&gt;; i++) {
&lt;&#x2F;span&gt;&lt;span&gt;		&lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;&#x2F;*
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;		 * Each item we want to add to the tail queue must be
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;		 * allocated.
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;		 *&#x2F;
&lt;&#x2F;span&gt;&lt;span&gt;		item = &lt;&#x2F;span&gt;&lt;span style=&quot;color:#96b5b4;&quot;&gt;malloc&lt;&#x2F;span&gt;&lt;span&gt;(sizeof(*item));
&lt;&#x2F;span&gt;&lt;span&gt;		&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;if &lt;&#x2F;span&gt;&lt;span&gt;(item == &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;NULL&lt;&#x2F;span&gt;&lt;span&gt;) {
&lt;&#x2F;span&gt;&lt;span&gt;			&lt;&#x2F;span&gt;&lt;span style=&quot;color:#96b5b4;&quot;&gt;perror&lt;&#x2F;span&gt;&lt;span&gt;(&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;malloc failed&lt;&#x2F;span&gt;&lt;span&gt;&amp;quot;);
&lt;&#x2F;span&gt;&lt;span&gt;			&lt;&#x2F;span&gt;&lt;span style=&quot;color:#96b5b4;&quot;&gt;exit&lt;&#x2F;span&gt;&lt;span&gt;(EXIT_FAILURE);
&lt;&#x2F;span&gt;&lt;span&gt;		}
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;		&lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;&#x2F;* Set the value. *&#x2F;
&lt;&#x2F;span&gt;&lt;span&gt;		item-&amp;gt;value = i;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;		&lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;&#x2F;*
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;		 * Add our item to the end of tail queue. The first
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;		 * argument is a pointer to the head of our tail
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;		 * queue, the second is the item we want to add, and
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;		 * the third argument is the name of the struct
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;		 * variable that points to the next and previous items
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;		 * in the tail queue.
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;		 *&#x2F;
&lt;&#x2F;span&gt;&lt;span&gt;		&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;TAILQ_INSERT_TAIL&lt;&#x2F;span&gt;&lt;span&gt;(&amp;amp;my_tailq_head, item, entries);
&lt;&#x2F;span&gt;&lt;span&gt;	}
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;	&lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;&#x2F;* Traverse the tail queue forward. *&#x2F;
&lt;&#x2F;span&gt;&lt;span&gt;	&lt;&#x2F;span&gt;&lt;span style=&quot;color:#96b5b4;&quot;&gt;printf&lt;&#x2F;span&gt;&lt;span&gt;(&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;Forward traversal: &lt;&#x2F;span&gt;&lt;span&gt;&amp;quot;);
&lt;&#x2F;span&gt;&lt;span&gt;	&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;TAILQ_FOREACH&lt;&#x2F;span&gt;&lt;span&gt;(item, &amp;amp;my_tailq_head, entries) {
&lt;&#x2F;span&gt;&lt;span&gt;		&lt;&#x2F;span&gt;&lt;span style=&quot;color:#96b5b4;&quot;&gt;printf&lt;&#x2F;span&gt;&lt;span&gt;(&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;%d &lt;&#x2F;span&gt;&lt;span&gt;&amp;quot;, item-&amp;gt;value);
&lt;&#x2F;span&gt;&lt;span&gt;	}
&lt;&#x2F;span&gt;&lt;span&gt;	&lt;&#x2F;span&gt;&lt;span style=&quot;color:#96b5b4;&quot;&gt;printf&lt;&#x2F;span&gt;&lt;span&gt;(&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#96b5b4;&quot;&gt;\n&lt;&#x2F;span&gt;&lt;span&gt;&amp;quot;);
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;	&lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;&#x2F;* Insert a new item after the item with value 5. *&#x2F;
&lt;&#x2F;span&gt;&lt;span&gt;	&lt;&#x2F;span&gt;&lt;span style=&quot;color:#96b5b4;&quot;&gt;printf&lt;&#x2F;span&gt;&lt;span&gt;(&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;Adding new item after 5: &lt;&#x2F;span&gt;&lt;span&gt;&amp;quot;);
&lt;&#x2F;span&gt;&lt;span&gt;	&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;TAILQ_FOREACH&lt;&#x2F;span&gt;&lt;span&gt;(item, &amp;amp;my_tailq_head, entries) {
&lt;&#x2F;span&gt;&lt;span&gt;		&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;if &lt;&#x2F;span&gt;&lt;span&gt;(item-&amp;gt;value == &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;5&lt;&#x2F;span&gt;&lt;span&gt;) {
&lt;&#x2F;span&gt;&lt;span&gt;			&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;struct&lt;&#x2F;span&gt;&lt;span&gt; tailq_entry *new_item =
&lt;&#x2F;span&gt;&lt;span&gt;			    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#96b5b4;&quot;&gt;malloc&lt;&#x2F;span&gt;&lt;span&gt;(sizeof(*new_item));
&lt;&#x2F;span&gt;&lt;span&gt;			&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;if &lt;&#x2F;span&gt;&lt;span&gt;(new_item == &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;NULL&lt;&#x2F;span&gt;&lt;span&gt;) {
&lt;&#x2F;span&gt;&lt;span&gt;				&lt;&#x2F;span&gt;&lt;span style=&quot;color:#96b5b4;&quot;&gt;perror&lt;&#x2F;span&gt;&lt;span&gt;(&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;malloc failed&lt;&#x2F;span&gt;&lt;span&gt;&amp;quot;);
&lt;&#x2F;span&gt;&lt;span&gt;				&lt;&#x2F;span&gt;&lt;span style=&quot;color:#96b5b4;&quot;&gt;exit&lt;&#x2F;span&gt;&lt;span&gt;(EXIT_FAILURE);
&lt;&#x2F;span&gt;&lt;span&gt;			}
&lt;&#x2F;span&gt;&lt;span&gt;			new_item-&amp;gt;value = &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;10&lt;&#x2F;span&gt;&lt;span&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;			&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;TAILQ_INSERT_AFTER&lt;&#x2F;span&gt;&lt;span&gt;(&amp;amp;my_tailq_head, item, new_item,
&lt;&#x2F;span&gt;&lt;span&gt;			    entries);
&lt;&#x2F;span&gt;&lt;span&gt;			&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;break&lt;&#x2F;span&gt;&lt;span&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;		}
&lt;&#x2F;span&gt;&lt;span&gt;	}
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;&#x2F;* Do another forward traversal to show the newly added item. *&#x2F;
&lt;&#x2F;span&gt;&lt;span&gt;	&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;TAILQ_FOREACH&lt;&#x2F;span&gt;&lt;span&gt;(item, &amp;amp;my_tailq_head, entries) {
&lt;&#x2F;span&gt;&lt;span&gt;		&lt;&#x2F;span&gt;&lt;span style=&quot;color:#96b5b4;&quot;&gt;printf&lt;&#x2F;span&gt;&lt;span&gt;(&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;%d &lt;&#x2F;span&gt;&lt;span&gt;&amp;quot;, item-&amp;gt;value);
&lt;&#x2F;span&gt;&lt;span&gt;	}
&lt;&#x2F;span&gt;&lt;span&gt;	&lt;&#x2F;span&gt;&lt;span style=&quot;color:#96b5b4;&quot;&gt;printf&lt;&#x2F;span&gt;&lt;span&gt;(&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#96b5b4;&quot;&gt;\n&lt;&#x2F;span&gt;&lt;span&gt;&amp;quot;);
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;	&lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;&#x2F;*
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;         * Delete the item with the value 3.
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;         *
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;         * We can&amp;#39;t use TAILQ_FOREACH here as TAILQ_FOREACH is not
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;         * safe against deletions during the traversal.  Some variants
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;         * of queue.h have TAILQ_FOREACH_MUTABLE or TAILQ_FOREACH_SAFE
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;         * which are safe against deletions.
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;         *&#x2F;
&lt;&#x2F;span&gt;&lt;span&gt;	&lt;&#x2F;span&gt;&lt;span style=&quot;color:#96b5b4;&quot;&gt;printf&lt;&#x2F;span&gt;&lt;span&gt;(&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;Deleting item with value 3: &lt;&#x2F;span&gt;&lt;span&gt;&amp;quot;);
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;for &lt;&#x2F;span&gt;&lt;span&gt;(item = &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;TAILQ_FIRST&lt;&#x2F;span&gt;&lt;span&gt;(&amp;amp;my_tailq_head); item != &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;NULL&lt;&#x2F;span&gt;&lt;span&gt;; item = tmp_item)
&lt;&#x2F;span&gt;&lt;span&gt;        {
&lt;&#x2F;span&gt;&lt;span&gt;		tmp_item = &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;TAILQ_NEXT&lt;&#x2F;span&gt;&lt;span&gt;(item, entries);
&lt;&#x2F;span&gt;&lt;span&gt;		&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;if &lt;&#x2F;span&gt;&lt;span&gt;(item-&amp;gt;value == &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;3&lt;&#x2F;span&gt;&lt;span&gt;) {
&lt;&#x2F;span&gt;&lt;span&gt;			&lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;&#x2F;* Remove the item from the tail queue. *&#x2F;
&lt;&#x2F;span&gt;&lt;span&gt;			&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;TAILQ_REMOVE&lt;&#x2F;span&gt;&lt;span&gt;(&amp;amp;my_tailq_head, item, entries);
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;			&lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;&#x2F;* Free the item as we don&amp;#39;t need it anymore. *&#x2F;
&lt;&#x2F;span&gt;&lt;span&gt;			&lt;&#x2F;span&gt;&lt;span style=&quot;color:#96b5b4;&quot;&gt;free&lt;&#x2F;span&gt;&lt;span&gt;(item);
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;			&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;break&lt;&#x2F;span&gt;&lt;span&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;		}
&lt;&#x2F;span&gt;&lt;span&gt;	}
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;	&lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;&#x2F;* Another forward traversal to show that the value 3 is now gone. *&#x2F;
&lt;&#x2F;span&gt;&lt;span&gt;	&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;TAILQ_FOREACH&lt;&#x2F;span&gt;&lt;span&gt;(item, &amp;amp;my_tailq_head, entries) {
&lt;&#x2F;span&gt;&lt;span&gt;		&lt;&#x2F;span&gt;&lt;span style=&quot;color:#96b5b4;&quot;&gt;printf&lt;&#x2F;span&gt;&lt;span&gt;(&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;%d &lt;&#x2F;span&gt;&lt;span&gt;&amp;quot;, item-&amp;gt;value);
&lt;&#x2F;span&gt;&lt;span&gt;	}
&lt;&#x2F;span&gt;&lt;span&gt;	&lt;&#x2F;span&gt;&lt;span style=&quot;color:#96b5b4;&quot;&gt;printf&lt;&#x2F;span&gt;&lt;span&gt;(&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#96b5b4;&quot;&gt;\n&lt;&#x2F;span&gt;&lt;span&gt;&amp;quot;);
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;	&lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;&#x2F;* Free the entire tail queue. *&#x2F;
&lt;&#x2F;span&gt;&lt;span&gt;	&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;while &lt;&#x2F;span&gt;&lt;span&gt;(item = &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;TAILQ_FIRST&lt;&#x2F;span&gt;&lt;span&gt;(&amp;amp;my_tailq_head)) {
&lt;&#x2F;span&gt;&lt;span&gt;		&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;TAILQ_REMOVE&lt;&#x2F;span&gt;&lt;span&gt;(&amp;amp;my_tailq_head, item, entries);
&lt;&#x2F;span&gt;&lt;span&gt;		&lt;&#x2F;span&gt;&lt;span style=&quot;color:#96b5b4;&quot;&gt;free&lt;&#x2F;span&gt;&lt;span&gt;(item);
&lt;&#x2F;span&gt;&lt;span&gt;	}
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;	&lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;&#x2F;* The tail queue should now be empty. *&#x2F;
&lt;&#x2F;span&gt;&lt;span&gt;	&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;if &lt;&#x2F;span&gt;&lt;span&gt;(!&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;TAILQ_EMPTY&lt;&#x2F;span&gt;&lt;span&gt;(&amp;amp;my_tailq_head))
&lt;&#x2F;span&gt;&lt;span&gt;		&lt;&#x2F;span&gt;&lt;span style=&quot;color:#96b5b4;&quot;&gt;printf&lt;&#x2F;span&gt;&lt;span&gt;(&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;tail queue is NOT empty!&lt;&#x2F;span&gt;&lt;span style=&quot;color:#96b5b4;&quot;&gt;\n&lt;&#x2F;span&gt;&lt;span&gt;&amp;quot;);
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;	&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;return &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;}
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
</content>
        
    </entry>
</feed>
