<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Goran Mekić</title><link>https://meka.rs/</link><description>Recent content on Goran Mekić</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Tue, 15 Jul 2025 00:35:00 +0000</lastBuildDate><atom:link href="https://meka.rs/index.xml" rel="self" type="application/rss+xml"/><item><title>Neural and Impulse Blending</title><link>https://meka.rs/blog/2025/07/15/neural-and-impulse-blending/</link><pubDate>Tue, 15 Jul 2025 00:35:00 +0000</pubDate><guid>https://meka.rs/blog/2025/07/15/neural-and-impulse-blending/</guid><description>&lt;p&gt;The idea of blending is to make two amplifiers and mix them into a single sound. The reason people&#10;do that is because different amplifiers have slightly different sound which combined together sounds&#10;better than any single one of them. It&amp;rsquo;s the same like having a single voice vs choir. With sounds&#10;it is simple: you just mix them. With neural amp modeler, there are few more steps. First you have&#10;to &lt;a href="https://meka.rs/blog/2025/04/15/neural-amp-modeling/"&gt;capture the sweep&lt;/a&gt;. Then you have to mix the captures&#10;into a single track. To do it properly, you need to normalize the captures and lower the track&amp;rsquo;s&#10;volume to -5dB, because when two tracks combine the resulting volume will be bigger. If you mix more&#10;than two tracks, you have to lower their volumes even more. Once you mix the captures into a single&#10;clip, normalize it. After that all you have to do is create NAM profile out of that clip.&lt;/p&gt;&#10;&lt;p&gt;Mixing impulse responses is even easier. You &lt;a href="https://meka.rs/blog/2025/05/11/impulse-response/"&gt;create the impulses&lt;/a&gt;,&#10;mix them into a single clip and that&amp;rsquo;s it. You have to watch out for the volume, that it doesn&amp;rsquo;t&#10;clip and normalize it in the end. Enjoy your sound!&lt;/p&gt;&#10;</description></item><item><title>Impulse Response Sweep</title><link>https://meka.rs/blog/2025/05/12/impulse-response-sweep/</link><pubDate>Mon, 12 May 2025 08:55:00 +0000</pubDate><guid>https://meka.rs/blog/2025/05/12/impulse-response-sweep/</guid><description>&lt;p&gt;There is another way to capture IR, and it is using sweep frequency sound. That&#10;means that the file containing the sweep will have 20Hz to 20kHz frequencies,&#10;starting with low and increasing the frequency. The idea is to capture how the&#10;system, in this case power amp, guitar cabinet and microphone, respond to&#10;different frequencies and create IR based on that. For that purpose you can use&#10;Carla and LSP Profiler. I like to use mono version, but the stereo version is&#10;available if you need it. You need to start Carla and add LSP Profiler as a&#10;plugin. In patch bay of Carla connect it like the following picture.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="https://meka.rs/images/carla.webp" alt="Carla"&gt;&lt;/img&gt;&lt;/p&gt;&#10;&lt;p&gt;In program like QJackCTL connect Carla&amp;rsquo;s IO to the hardware IO. As for the&#10;hardware setup and connections, consult the&#10;&lt;a href="https://meka.rs/blog/2025/05/11/impulse-response/"&gt;previous post about impulse resposes&lt;/a&gt;.&#10;First we need to calibrate the LSP Profiler. That means setting the right sound&#10;levels and latency.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="https://meka.rs/images/profiler.webp" alt="LSP Profiler"&gt;&lt;/img&gt;&lt;/p&gt;&#10;&lt;p&gt;Turn the volume down on your power amp before you enable &lt;code&gt;Calibrator&lt;/code&gt;, as it&#10;sends loud signal, then enable it and turn the volume gradually up until you&#10;get around -3dB. When satisfied with the levels, disable it. Click &lt;code&gt;Measure&lt;/code&gt;&#10;in the &lt;code&gt;Latency Detector&lt;/code&gt;. It will send pulses of sound to figure out what is&#10;the round trip time for the sound. In the &lt;code&gt;Test Signal&lt;/code&gt;, increase &lt;code&gt;Coarse Tuning&lt;/code&gt; to be as long as possible. When all is set, press &lt;code&gt;Profile&lt;/code&gt; button.&#10;It will start with a pulse, then few seconds of silence, then sweep sound&#10;through 20-20000Hz range. Once the LSP Profiler captures the sound from the&#10;microphone, it will need up to few seconds to make an actual IR profile. When&#10;that&amp;rsquo;s done, press &lt;code&gt;Save&lt;/code&gt; and create your .wav file.&lt;/p&gt;&#10;&lt;p&gt;I have to note that quality of such IRs is lower than those I did with Dirac&#10;pulse. As I am still new to this I assume I&amp;rsquo;m not tuning something right as&#10;these two techniques should produce the same result.&lt;/p&gt;&#10;&lt;h3 id="related-posts"&gt;&#10; Related posts&#10;&lt;/h3&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;a href="https://meka.rs/blog/2025/05/11/impulse-response/"&gt;Impulse Response&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://meka.rs/blog/2025/04/15/neural-amp-modeling/"&gt;Neural Amp Modeling&lt;/a&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;</description></item><item><title>Impulse Response</title><link>https://meka.rs/blog/2025/05/11/impulse-response/</link><pubDate>Sun, 11 May 2025 10:56:00 +0000</pubDate><guid>https://meka.rs/blog/2025/05/11/impulse-response/</guid><description>&lt;p&gt;&lt;strong&gt;DANGER!!! THE FOLLOWING PROCEDURE MIGHT CAUSE DAMAGE TO YOUR EQUIPMENT!!!&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;I have power amp that has limiter, short circuit protection and overheating&#10;protection, so I know my gear can handle the procedure, but please don&amp;rsquo;t assume&#10;that every combination of amp/cab is safe to be used! For example, I have no&#10;idea how tube amps react to this procedure and you might burn the tubes. Please&#10;be safe, first!&lt;/p&gt;&#10;&lt;p&gt;There is also a procedure using sweep frequencies, but I&amp;rsquo;ll describe that in&#10;another post. That procedure should be safe for any equipment.&lt;/p&gt;&#10;&lt;h2 id="dirac-pulse"&gt;&#10; Dirac Pulse&#10;&lt;/h2&gt;&#10;&lt;p&gt;Impulse response is used to emulate acoustic characteristic of the system. In&#10;other words, it can emulate the sound of a guitar cabinet. It can also capture&#10;reverb of a place, like hallway or church, but I&amp;rsquo;ll just stick to guitar&#10;cabinet emulation in this post. The core of this technology is in the title as&#10;we will record how system, in our case power amp, cabinet and microphone,&#10;responds when we feed it just a single impulse. That pulse is also called&#10;&amp;ldquo;Dirac pulse&amp;rdquo;. In the wav file, it would be single sample with full amplitude&#10;and all samples before and after it are zero. It is said that such pulse&#10;contains all frequencies with equal amplitude, but the math behind it deserves&#10;a post on its own. Let&amp;rsquo;s first generate such .wav file in audacity. First we&#10;need a track to work on.&lt;/p&gt;&#10;&lt;pre tabindex="0"&gt;&lt;code&gt;Tracks -&amp;gt; Add New -&amp;gt; Mono Track&#10;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Then we need some samples to work on. It&amp;rsquo;s easiest if we generate 1 second of&#10;silence and work with that.&lt;/p&gt;&#10;&lt;pre tabindex="0"&gt;&lt;code&gt;Generate -&amp;gt; Silence&#10;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;You&amp;rsquo;ll need to zoom in as much as possible on X and Y axis. Now raise first&#10;sample to the top and leave the rest on laying on zero. The result should look&#10;like this.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="https://meka.rs/images/dirac.webp" alt="Dirac pulse"&gt;&lt;/img&gt;&lt;/p&gt;&#10;&lt;p&gt;This clip actually has second sample raised and the reason I did that is because&#10;it is hard to see first sample because of the clip edge. Save the project and&#10;export as .wav.&lt;/p&gt;&#10;&lt;h2 id="capturing-impulse-response"&gt;&#10; Capturing Impulse Response&#10;&lt;/h2&gt;&#10;&lt;p&gt;In Ardour we will need two mono tracks. One will have the Dirac pulse we just&#10;generated, second one will capture the output of the microphone directed at the&#10;guitar cabinet. With PC I will mark computer + audio interface, just to make it&#10;shorter.&lt;/p&gt;&#10;&lt;pre tabindex="0"&gt;&lt;code&gt;PC (dirac) -&amp;gt; Power amp -&amp;gt; Cabinet -&amp;gt; Microphone -&amp;gt; PC (impulse response)&#10;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This means that dirac track should have its inputs disconnected and output&#10;connected so it is fed to power amp. The impulse response track should have&#10;all outputs disconnected and input connected only to the microphone.&lt;/p&gt;&#10;&lt;p&gt;There is a catch. To suppress pops and clicks that appear between two clips,&#10;Ardour will add a small fade in to the start of the clip and fade out to the&#10;end of it. This will &amp;ldquo;eat up&amp;rdquo; our Dirac pulse, so we have to disable that. Zoom&#10;as much as possible until the curve for fade in/out is visible. Right-click on&#10;the little square at the end of the curve and click on &lt;code&gt;Deactivate&lt;/code&gt;. You have&#10;to do that on captures, too.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="https://meka.rs/images/clip.webp" alt="Ardour clip"&gt;&lt;/img&gt;&lt;/p&gt;&#10;&lt;p&gt;Do few test captures to check the levels and then start capturing impulse&#10;responses. You can export the capture and open it in Audacity for trimming&#10;start and end if needed. I also like to add very small fade out at the end.&#10;For aligning the start of the clip I use &lt;code&gt;z&lt;/code&gt; shortcut to find the zero crossing&#10;in the clip and I delete the samples before that one. That way no delay is&#10;introduced by impulse response. Save that project and export the .wav file.&#10;That file is your IR! Congratulations, you just made your first IR!&lt;/p&gt;&#10;&lt;h3 id="related-posts"&gt;&#10; Related posts&#10;&lt;/h3&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;a href="https://meka.rs/blog/2025/05/12/impulse-response-sweep/"&gt;Impulse Response Sweep&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://meka.rs/blog/2025/04/15/neural-amp-modeling/"&gt;Neural Amp Modeling&lt;/a&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;</description></item><item><title>Neural Amp Modeling</title><link>https://meka.rs/blog/2025/04/15/neural-amp-modeling/</link><pubDate>Tue, 15 Apr 2025 13:30:00 +0000</pubDate><guid>https://meka.rs/blog/2025/04/15/neural-amp-modeling/</guid><description>&lt;h2 id="re-amping"&gt;&#10; Re-amping&#10;&lt;/h2&gt;&#10;&lt;p&gt;Let&amp;rsquo;s say you&amp;rsquo;re a guitar player and want to record your track of a song.&#10;Typically you would enter the studio with your guitar, amp and cabinet and&#10;record what&amp;rsquo;s needed. But let&amp;rsquo;s say you decide to record your guitar without&#10;any processing by pedals or amps, glue the good takes together and then&#10;process that track with pedals and amps. That process is called re-amping.&lt;/p&gt;&#10;&lt;p&gt;Now let&amp;rsquo;s say you want that guitar track processed by a plugin, not hardware.&#10;The process of recording would be almost the same, but the process of getting&#10;the plugin to sound like an amp is quite a challenge. Today if we want to&#10;emulate the whole rig, it is best if it&amp;rsquo;s done in two parts: NAM and IR. IR is&#10;much older, and it stands for Impulse Response. NAM stands for Neural Amp&#10;Modeler and it&amp;rsquo;s just a few years old. IR is used to capture the sonic&#10;characteristic of reverb and guitar cabinets, the most. It can do other things,&#10;but for now let&amp;rsquo;s just say that IR in our case is used to emulate guitar&#10;cabinets. NAM in our case is used to capture and emulate preamp. It can also&#10;capture full rig but you can&amp;rsquo;t use any effects that are time based, like&#10;reverb or delay. The reason why I like NAM for preamp and IR for cabinet is&#10;because that way I can use IR cabinets captured over past two decades. As NAM&#10;is relatively new, it still doesn&amp;rsquo;t have such a huge ecosystem.&lt;/p&gt;&#10;&lt;h2 id="preamp-and-nam"&gt;&#10; Preamp and NAM&#10;&lt;/h2&gt;&#10;&lt;p&gt;One of the great things that came out of AI hype is &lt;a href="https://www.neuralampmodeler.com/"&gt;Neural Amp Modeler&lt;/a&gt;,&#10;or NAM for short. To capture NAM, you have to separate preamp from the rest of&#10;the gear. As stated before, you can capture NAM of your whole rig, but today I&#10;want to capture just the preamp. In my case it is Engl E570. It&amp;rsquo;s pretty rare&#10;so I&amp;rsquo;d like to be able to replace it with a NAM loader pedal (hardware pedal&#10;that loads NAM and emulates my preamp). If you&amp;rsquo;d like to profile preamp that is&#10;part of amp head or combo, you&amp;rsquo;ll need to use FX loop. To be precise, you&amp;rsquo;ll&#10;use Send on the FX loop as that is the preamp&amp;rsquo;s output. What is needed for that&#10;beside preamp is audio interface, computer and re-amp box. My choice of&#10;operating system is FreeBSD, but once you have JACK configured, the rest is the&#10;same as Linux. On the mentioned computer I will use JACK and Ardour to capture&#10;the sound of preamp. Computer is connected to audio interface via USB, and in&#10;my case it is Presonus AudioBox 1818VSL. It has line level outputs, which is&#10;almost exclusively the case on audio interfaces, so I can&amp;rsquo;t just plug it&amp;rsquo;s&#10;output to the preamp&amp;rsquo;s input. The impedance and signal level of line output do&#10;not match those of the guitar input on the preamp. To convert line to guitar&#10;level, I am using Radial Engineering EXTC-Stereo. It has inputs and outputs on&#10;one side, which are connected to the audio interface, and send and receive on&#10;the other side, which are connected to the preamp. To be precise, audio&#10;interface output is connected to EXTC, send of EXTC is connected to preamp&#10;input and preamp output is connected to audio interface (line in). If I call&#10;computer + audio interface just PC to make it short, this would be the&#10;&amp;ldquo;diagram&amp;rdquo; of connections&lt;/p&gt;&#10;&lt;pre tabindex="0"&gt;&lt;code&gt;PC -&amp;gt; EXTC -&amp;gt; preamp -&amp;gt; PC&#10;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;What we want is to send a signal from the PC, process it with the preamp and&#10;send it back to PC for analysis. To do that, create Ardour session at 48kHz and&#10;create two tracks with names &amp;ldquo;sweep&amp;rdquo; and &amp;ldquo;capture&amp;rdquo;. Both tracks need to be mono.&#10;Connect sweep&amp;rsquo;s JACK output to the output on the interface which is connected to&#10;reamp box. Connect capture&amp;rsquo;s JACK input to the input on the interface which is&#10;connected to the preamp. That way you can record the output of preamp in capture&#10;track and play some signal on the sweep track. Sweep is the term left from IR,&#10;and I will explain why it&amp;rsquo;s called that in the follow up post. For now all you&#10;need to know is that it&amp;rsquo;s not &amp;ldquo;normal&amp;rdquo; sound, it is a signal created so that AI&#10;can learn from it. To be precise, AI will learn from sweep and captured signal&#10;and it will produce information how to digitally transform the sound so it is&#10;the same as if we just did the reamp. Input on sweep track needs to be&#10;disconnected and output on capture track, too. That way we are minimizing causes&#10;of eventual problems. To get the sweep signal, go to &lt;a href="https://tone3000.com/capture"&gt;tone3000&lt;/a&gt;&#10;and download &amp;ldquo;sweep signal&amp;rdquo; from the page (downloaded file will be called&#10;T3K-sweep-v3.wav). Now all you need to do is arm your capture track and record&#10;the output of the preamp while the sweep signal is fed to the preamp&amp;rsquo;s input.&#10;Once that&amp;rsquo;s done, align start and end of sweep and captured clip. Also, set&#10;session start and end to the clip&amp;rsquo;s start and end. Normalize the captured clip.&#10;Now we need to export sweep and capture to separate, mono files at 48kHz and&#10;24bits. To do that, go to&lt;/p&gt;&#10;&lt;pre tabindex="0"&gt;&lt;code&gt;Session -&amp;gt; Export -&amp;gt; Stem Export&#10;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;If you don&amp;rsquo;t already have a format for 48kHz (or session rate) at 24bits,&#10;create one. We need wav files that are in no way further processed. That means&#10;disable trimming and normalization. In the &lt;code&gt;Time Span&lt;/code&gt; tab select &lt;code&gt;session&lt;/code&gt;&#10;range and only that one. In the &lt;code&gt;Channels&lt;/code&gt; tab, select sweep and capture track&#10;and disable &lt;code&gt;Apply track/bus processing&lt;/code&gt;. Now export the track to wav files.&lt;/p&gt;&#10;&lt;p&gt;Go to &lt;a href="https://www.tone3000.com/capture?type=dry-wet"&gt;tone3000&amp;rsquo;s capture&lt;/a&gt; and&#10;upload dry (sweep) and wet (capture) wav files. Follow the form and wait for AI&#10;to process all epochs (100 by default). Once that&amp;rsquo;s done, you&amp;rsquo;ll have NAM file&#10;published on Tone3000 platform. Congrats!&lt;/p&gt;&#10;&lt;h2 id="tips"&gt;&#10; Tips&#10;&lt;/h2&gt;&#10;&lt;p&gt;For better performance I suggest compiling jack from ports with SOSSO library&#10;enabled. It can dramatically reduce DSP usage in JACK/Ardour.&lt;/p&gt;&#10;&lt;p&gt;To test your NAM you can use &lt;code&gt;neuralrack-lv2&lt;/code&gt; to load it together with some IR.&#10;Nice thing is that &lt;a href="https://www.tone3000.com/search?gear=ir"&gt;tone3000 already has some IRs&lt;/a&gt;,&#10;so download some and test it in &lt;code&gt;neuralrack-lv2&lt;/code&gt;.&lt;/p&gt;&#10;&lt;p&gt;While there is also a way to only &lt;a href="https://www.tone3000.com/capture"&gt;upload the capture&lt;/a&gt;,&#10;it never worked for me. The reason is that I couldn&amp;rsquo;t make Ardour produce the&#10;exact same number of samples in the capture file, that the sweep file has. With&#10;stem export, tracks are exported to files with the exact same length. Briefly&#10;talking to Tone3000 support, they told me that input signal should be uploaded&#10;only if custom signal is used to train the AI. I would love to not waste&#10;resources by uploading both files, but I always get an error while producing&#10;the NAM if I upload only the capture.&lt;/p&gt;&#10;&lt;h2 id="update"&gt;&#10; Update&#10;&lt;/h2&gt;&#10;&lt;p&gt;When creating Ardour session, be sure to select &amp;ldquo;Audio Time&amp;rdquo; not &amp;ldquo;Beat Time&amp;rdquo; for &amp;ldquo;Default&#10;time domain&amp;rdquo;. That way capture and sweep will have exact same number of samples, and you&#10;can &lt;a href="https://www.tone3000.com/capture"&gt;just upload the capture&lt;/a&gt;. I didn&amp;rsquo;t find a way to&#10;convert existing session from &amp;ldquo;Beat&amp;rdquo; to &amp;ldquo;Audio&amp;rdquo; time.&lt;/p&gt;&#10;&lt;h3 id="related-posts"&gt;&#10; Related posts&#10;&lt;/h3&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;a href="https://meka.rs/blog/2025/05/11/impulse-response/"&gt;Impulse Response&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://meka.rs/blog/2025/05/12/impulse-response-sweep/"&gt;Impulse Response Sweep&lt;/a&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;</description></item><item><title>Rust and ioctl</title><link>https://meka.rs/blog/2025/03/18/rust-and-ioctl/</link><pubDate>Tue, 18 Mar 2025 22:23:00 +0000</pubDate><guid>https://meka.rs/blog/2025/03/18/rust-and-ioctl/</guid><description>&lt;p&gt;When I explore new programming language, I like to poke audio. Rust is a new language for me and I&#10;need a pet project to learn. As I&amp;rsquo;m also using FreeBSD, that means audio device configuration is&#10;done via &lt;code&gt;ioctl&lt;/code&gt;. Here is the summary of how to handle &lt;code&gt;ioctl&lt;/code&gt; in Rust. Create the project, add&#10;&lt;code&gt;nix&lt;/code&gt; crate enabling &lt;code&gt;ioctl&lt;/code&gt; feature.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ cargo new oss&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ cd oss&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ cargo add --features ioctl nix&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;For now I will just exclude &lt;code&gt;AudioInfo&lt;/code&gt; from the code and show you the rest. The following is an&#10;example of how to handle two &lt;code&gt;ioctl&lt;/code&gt; calls in Rust. One writes integer and one reads structure.&#10;Ignore for now that logicaly, setting channels before getting information about hardware is wrong.&#10;I wanted to show &lt;code&gt;i32&lt;/code&gt; version first, struct later.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-rust" data-lang="rust"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;use&lt;/span&gt; nix::libc;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;use&lt;/span&gt; std::fs;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;use&lt;/span&gt; std::os::fd::AsRawFd;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;const&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;SNDCTL_DSP_MAGIC&lt;/span&gt;: &lt;span style="color:#66d9ef"&gt;u8&lt;/span&gt; &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#e6db74"&gt;b&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#39;P&amp;#39;&lt;/span&gt;;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;const&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;SNDCTL_DSP_CHANNELS&lt;/span&gt;: &lt;span style="color:#66d9ef"&gt;u8&lt;/span&gt; &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;6&lt;/span&gt;;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;nix::&lt;span style="color:#a6e22e"&gt;ioctl_readwrite!&lt;/span&gt;(oss_channels, &lt;span style="color:#66d9ef"&gt;SNDCTL_DSP_MAGIC&lt;/span&gt;, &lt;span style="color:#66d9ef"&gt;SNDCTL_DSP_CHANNELS&lt;/span&gt;, &lt;span style="color:#66d9ef"&gt;i32&lt;/span&gt;);&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;const&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;SNDCTL_INFO_MAGIC&lt;/span&gt;: &lt;span style="color:#66d9ef"&gt;u8&lt;/span&gt; &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#e6db74"&gt;b&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#39;X&amp;#39;&lt;/span&gt;;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;const&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;SNDCTL_ENGINEINFO&lt;/span&gt;: &lt;span style="color:#66d9ef"&gt;u8&lt;/span&gt; &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;12&lt;/span&gt;;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;nix::&lt;span style="color:#a6e22e"&gt;ioctl_readwrite!&lt;/span&gt;(&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; oss_audio_info,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;SNDCTL_INFO_MAGIC&lt;/span&gt;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;SNDCTL_ENGINEINFO&lt;/span&gt;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; AudioInfo&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;);&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;fn&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;main&lt;/span&gt;() {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;let&lt;/span&gt; devpath &lt;span style="color:#f92672"&gt;=&lt;/span&gt; String::from(&lt;span style="color:#e6db74"&gt;&amp;#34;/dev/dsp&amp;#34;&lt;/span&gt;);&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;let&lt;/span&gt; dsp &lt;span style="color:#f92672"&gt;=&lt;/span&gt; fs::File::open(devpath).unwrap();&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;let&lt;/span&gt; fd &lt;span style="color:#f92672"&gt;=&lt;/span&gt; dsp.as_raw_fd();&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;let&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;mut&lt;/span&gt; channels: &lt;span style="color:#66d9ef"&gt;i32&lt;/span&gt; &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;2&lt;/span&gt;;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;let&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;mut&lt;/span&gt; audio_info &lt;span style="color:#f92672"&gt;=&lt;/span&gt; AudioInfo::new();&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;unsafe&lt;/span&gt; {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; oss_channels(fd, &lt;span style="color:#f92672"&gt;&amp;amp;&lt;/span&gt;&lt;span style="color:#66d9ef"&gt;mut&lt;/span&gt; channels).expect(&lt;span style="color:#e6db74"&gt;&amp;#34;Failed to set number of channels&amp;#34;&lt;/span&gt;);&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; oss_audio_info(fd, &lt;span style="color:#f92672"&gt;&amp;amp;&lt;/span&gt;&lt;span style="color:#66d9ef"&gt;mut&lt;/span&gt; audio_info).expect(&lt;span style="color:#e6db74"&gt;&amp;#34;Failed to get info on device&amp;#34;&lt;/span&gt;);&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; }&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;println!&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#34;channels = &lt;/span&gt;&lt;span style="color:#e6db74"&gt;{}&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;, audio_info.max_channels);&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;println!&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#34;rate = &lt;/span&gt;&lt;span style="color:#e6db74"&gt;{}&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;, audio_info.max_rate);&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Let&amp;rsquo;s just concentrate on the three lines after &lt;code&gt;use&lt;/code&gt; block. How did I know what values to use? For&#10;start you have to look in &lt;code&gt;/usr/src/sys/sys/soundcard.h&lt;/code&gt; (assuming that&amp;rsquo;s where your FreeBSD source&#10;tree is). Let&amp;rsquo;s take a look.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-c" data-lang="c"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#define SOUND_PCM_WRITE_CHANNELS&#9;_IOWR(&amp;#39;P&amp;#39;, 6, int)&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#define SNDCTL_DSP_CHANNELS&#9;SOUND_PCM_WRITE_CHANNELS&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;As the call is &lt;code&gt;_IOWR&lt;/code&gt; I know I have to use &lt;code&gt;ioctl_readwrite&lt;/code&gt; macro, and it&amp;rsquo;s obvious where &lt;code&gt;P&lt;/code&gt; and&#10;&lt;code&gt;6&lt;/code&gt; come from. As the third argument to &lt;code&gt;_IOWR&lt;/code&gt; is &lt;code&gt;int&lt;/code&gt; I know I have to use &lt;code&gt;i32&lt;/code&gt; as fourth&#10;argument to &lt;code&gt;ioctl_readwrite&lt;/code&gt;. Also, the first argument to that macro is the function name that is&#10;generated and used later in the code.&lt;/p&gt;&#10;&lt;p&gt;For getting information about underlaying hardware, OSS uses &lt;code&gt;ioctl&lt;/code&gt; with a struct. Let&amp;rsquo;s see how&#10;it&amp;rsquo;s defined in the FreeBSD source&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-c" data-lang="c"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#define SNDCTL_ENGINEINFO&#9;_IOWR(&amp;#39;X&amp;#39;,12, oss_audioinfo)&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;From this I know I have to use &lt;code&gt;ioctl_readwrite&lt;/code&gt;, &lt;code&gt;X&lt;/code&gt; for MAGIC number and &lt;code&gt;12&lt;/code&gt; for the argument.&#10;The last one is to figure out how to work with the struct &lt;code&gt;oss_audioinfo&lt;/code&gt;. Here&amp;rsquo;s that structure.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-c" data-lang="c"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;typedef&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;char&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;oss_longname_t&lt;/span&gt;[&lt;span style="color:#ae81ff"&gt;64&lt;/span&gt;];&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;typedef&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;char&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;oss_label_t&lt;/span&gt;[&lt;span style="color:#ae81ff"&gt;16&lt;/span&gt;];&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;typedef&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;char&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;oss_devnode_t&lt;/span&gt;[&lt;span style="color:#ae81ff"&gt;32&lt;/span&gt;];&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;typedef&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;struct&lt;/span&gt; oss_audioinfo&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;{&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;int&lt;/span&gt;&#9; dev;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;char&lt;/span&gt; name[&lt;span style="color:#ae81ff"&gt;64&lt;/span&gt;];&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;int&lt;/span&gt; busy;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;int&lt;/span&gt; pid;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;int&lt;/span&gt; caps;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;int&lt;/span&gt; iformats;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;int&lt;/span&gt; oformats;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;int&lt;/span&gt;&#9; magic;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;char&lt;/span&gt; cmd[&lt;span style="color:#ae81ff"&gt;64&lt;/span&gt;];&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;int&lt;/span&gt; card_number;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;int&lt;/span&gt; port_number;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;int&lt;/span&gt; mixer_dev;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;int&lt;/span&gt; legacy_device;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;int&lt;/span&gt; enabled;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;int&lt;/span&gt; flags;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;int&lt;/span&gt; min_rate;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;int&lt;/span&gt; max_rate;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;int&lt;/span&gt; min_channels;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;int&lt;/span&gt; max_channels;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;int&lt;/span&gt; binding;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;int&lt;/span&gt; rate_source;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;char&lt;/span&gt; handle[&lt;span style="color:#ae81ff"&gt;32&lt;/span&gt;];&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;unsigned&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;int&lt;/span&gt; nrates;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;unsigned&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;int&lt;/span&gt; rates[&lt;span style="color:#ae81ff"&gt;20&lt;/span&gt;];&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;oss_longname_t&lt;/span&gt; song_name;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;oss_label_t&lt;/span&gt; label;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;int&lt;/span&gt; latency;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;oss_devnode_t&lt;/span&gt; devnode;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;int&lt;/span&gt; next_play_engine;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;int&lt;/span&gt; next_rec_engine;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;int&lt;/span&gt; filler[&lt;span style="color:#ae81ff"&gt;184&lt;/span&gt;];&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;} oss_audioinfo;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The trick in Rust is to use &lt;code&gt;#[repr(C)]&lt;/code&gt;, &lt;code&gt;libc::c_int&lt;/code&gt; and other &lt;code&gt;libc::c_*&lt;/code&gt; types. If you put&#10;this right below &lt;code&gt;use&lt;/code&gt; block, you have the whole code.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-rust" data-lang="rust"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#[repr(C)]&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;struct&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;AudioInfo&lt;/span&gt; {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;pub&lt;/span&gt; dev: &lt;span style="color:#a6e22e"&gt;libc&lt;/span&gt;::c_int,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;pub&lt;/span&gt; name: [libc::c_char; &lt;span style="color:#ae81ff"&gt;64&lt;/span&gt;],&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;pub&lt;/span&gt; busy: &lt;span style="color:#a6e22e"&gt;libc&lt;/span&gt;::c_int,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;pub&lt;/span&gt; pid: &lt;span style="color:#a6e22e"&gt;libc&lt;/span&gt;::c_int,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;pub&lt;/span&gt; caps: &lt;span style="color:#a6e22e"&gt;libc&lt;/span&gt;::c_int,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;pub&lt;/span&gt; iformats: &lt;span style="color:#a6e22e"&gt;libc&lt;/span&gt;::c_int,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;pub&lt;/span&gt; oformats: &lt;span style="color:#a6e22e"&gt;libc&lt;/span&gt;::c_int,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;pub&lt;/span&gt; magic: &lt;span style="color:#a6e22e"&gt;libc&lt;/span&gt;::c_int,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;pub&lt;/span&gt; cmd: [libc::c_char; &lt;span style="color:#ae81ff"&gt;64&lt;/span&gt;],&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;pub&lt;/span&gt; card_number: &lt;span style="color:#a6e22e"&gt;libc&lt;/span&gt;::c_int,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;pub&lt;/span&gt; port_number: &lt;span style="color:#a6e22e"&gt;libc&lt;/span&gt;::c_int,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;pub&lt;/span&gt; mixer_dev: &lt;span style="color:#a6e22e"&gt;libc&lt;/span&gt;::c_int,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;pub&lt;/span&gt; legacy_device: &lt;span style="color:#a6e22e"&gt;libc&lt;/span&gt;::c_int,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;pub&lt;/span&gt; enabled: &lt;span style="color:#a6e22e"&gt;libc&lt;/span&gt;::c_int,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;pub&lt;/span&gt; flags: &lt;span style="color:#a6e22e"&gt;libc&lt;/span&gt;::c_int,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;pub&lt;/span&gt; min_rate: &lt;span style="color:#a6e22e"&gt;libc&lt;/span&gt;::c_int,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;pub&lt;/span&gt; max_rate: &lt;span style="color:#a6e22e"&gt;libc&lt;/span&gt;::c_int,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;pub&lt;/span&gt; min_channels: &lt;span style="color:#a6e22e"&gt;libc&lt;/span&gt;::c_int,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;pub&lt;/span&gt; max_channels: &lt;span style="color:#a6e22e"&gt;libc&lt;/span&gt;::c_int,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;pub&lt;/span&gt; binding: &lt;span style="color:#a6e22e"&gt;libc&lt;/span&gt;::c_int,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;pub&lt;/span&gt; rate_source: &lt;span style="color:#a6e22e"&gt;libc&lt;/span&gt;::c_int,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;pub&lt;/span&gt; handle: [libc::c_char; &lt;span style="color:#ae81ff"&gt;32&lt;/span&gt;],&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;pub&lt;/span&gt; nrates: &lt;span style="color:#a6e22e"&gt;libc&lt;/span&gt;::c_uint,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;pub&lt;/span&gt; rates: [libc::c_uint; &lt;span style="color:#ae81ff"&gt;20&lt;/span&gt;],&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;pub&lt;/span&gt; song_name: [libc::c_char; &lt;span style="color:#ae81ff"&gt;64&lt;/span&gt;],&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;pub&lt;/span&gt; label: [libc::c_char; &lt;span style="color:#ae81ff"&gt;16&lt;/span&gt;],&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;pub&lt;/span&gt; latency: &lt;span style="color:#a6e22e"&gt;libc&lt;/span&gt;::c_int,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;pub&lt;/span&gt; devnode: [libc::c_char; &lt;span style="color:#ae81ff"&gt;32&lt;/span&gt;],&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;pub&lt;/span&gt; next_play_engine: &lt;span style="color:#a6e22e"&gt;libc&lt;/span&gt;::c_int,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;pub&lt;/span&gt; next_rec_engine: &lt;span style="color:#a6e22e"&gt;libc&lt;/span&gt;::c_int,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;pub&lt;/span&gt; filler: [libc::c_int; &lt;span style="color:#ae81ff"&gt;184&lt;/span&gt;],&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Although nobody can give you formula on how to write ioctl code in Rust based on C but there are&#10;some guidelines. Based on C code, you can tell which macro it uses so here&amp;rsquo;s a rough table.&lt;/p&gt;&#10;&lt;table&gt;&#10;&#9;&lt;thead&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;C&lt;/th&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;Rust&lt;/th&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&lt;/thead&gt;&#10;&#9;&lt;tbody&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;_IO&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;ioctl_none&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;_IOR&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;ioctl_read&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;_IOW&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;ioctl_write_*&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;_IOWR&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;ioctl_readwrite&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&lt;/tbody&gt;&#10;&lt;/table&gt;&#10;&lt;p&gt;For a list of &lt;code&gt;ioctl_write_*&lt;/code&gt; macros and full documentation refer to&#10;&lt;a href="https://docs.rs/nix/latest/nix/sys/ioctl"&gt;https://docs.rs/nix/latest/nix/sys/ioctl&lt;/a&gt;. I have to say it is easy to dive into something like this&#10;when you have &lt;a href="https://lists.freebsd.org/archives/freebsd-hackers/2024-January/002823.html"&gt;one of the Rust advocates in FreeBSD&lt;/a&gt;&#10;as a work colleague, as he was really quick to spot my errors and generally guide me to a working&#10;code as a newbie Rustacean.&lt;/p&gt;&#10;</description></item><item><title>New Guitar</title><link>https://meka.rs/blog/2024/09/09/new-guitar/</link><pubDate>Mon, 09 Sep 2024 10:55:00 +0000</pubDate><guid>https://meka.rs/blog/2024/09/09/new-guitar/</guid><description>&lt;p&gt;After 3 years in the making, I finally got my new guitar. I got &lt;a href="https://www.seymourduncan.com/single-product/blackouts-metal"&gt;Seymour Duncan&#10;Blackouts Metal&lt;/a&gt;&#10;for it. That pickup is insanely hot and until my new guitar was done, I used it&#10;in my Les Paul, so pickup is the same in both guitars. Here is a riff from our&#10;upcoming single with Neural Amp Modeler and Impulse Response instead of guitar&#10;amplifier, cabinet and microphone.&lt;/p&gt;&#10;&lt;h2 id="gibson-les-paul-custom"&gt;&#10; Gibson Les Paul Custom&#10;&lt;/h2&gt;&#10;&lt;p&gt;&lt;audio src="https://meka.rs/audio/lp.ogg" controls&gt;&lt;/audio&gt;&lt;/p&gt;&#10;&lt;h2 id="signature-model"&gt;&#10; Signature model&#10;&lt;/h2&gt;&#10;&lt;p&gt;&lt;audio src="https://meka.rs/audio/viper.ogg" controls&gt;&lt;/audio&gt;&lt;/p&gt;&#10;&lt;h2 id="my-impressions"&gt;&#10; My impressions&#10;&lt;/h2&gt;&#10;&lt;p&gt;I love Les Paul Custom for so long and I considered it the best guitar in the&#10;world. Together with EMG 81/85, it is insane. I can&amp;rsquo;t believe that I&amp;rsquo;m saying&#10;this, but there is something better than Les Paul, and it&amp;rsquo;s my new guitar. It is&#10;made by a long time friend of mine and solo guitarist in my band, so he knows&#10;what picking style I use, what bands I like, what amps I&amp;rsquo;m after. With somebody&#10;knowing me so well, he couldn&amp;rsquo;t but make a guitar better than Gibson. I love how&#10;it bites more than Les Paul. It will definitely be my sound on our upcoming&#10;single and album.&lt;/p&gt;&#10;&lt;p&gt;Just in case you&amp;rsquo;re wondering how it looks, it is black ESP Viper with &amp;ldquo;LUST&amp;rdquo;&#10;(the first word of the name of my band) instead of inlays.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="https://meka.rs/images/guitar-raw.webp" alt="guitar raw"&gt;&lt;/img&gt;&#10;&lt;img src="https://meka.rs/images/guitar-painted.webp" alt="guitar painted"&gt;&lt;/img&gt;&#10;&lt;img src="https://meka.rs/images/meka-pop.webp" alt="meka &amp; pop"&gt;&lt;/img&gt;&#10;&lt;img src="https://meka.rs/images/guitar-playing.webp" alt="playing new guitar"&gt;&lt;/img&gt;&lt;/p&gt;&#10;</description></item><item><title>Ratamahatta</title><link>https://meka.rs/blog/2024/09/02/ratamahatta/</link><pubDate>Mon, 02 Sep 2024 10:17:00 +0000</pubDate><guid>https://meka.rs/blog/2024/09/02/ratamahatta/</guid><description>&lt;p&gt;I always mumbled Ratamahatta without understanding what&amp;rsquo;s it about. I did get&#10;literal translation from some friends, but I still didn&amp;rsquo;t understand what was&#10;it about. Nowadays I&amp;rsquo;m lucky that some of my colegues are Brazilians so I could&#10;ask for the deeper meaning of the words. The colegue in question is&#10;&lt;a href="https://www.linkedin.com/in/fernandoseidler/"&gt;Fernando Seidler&lt;/a&gt;.&lt;/p&gt;&#10;&lt;pre tabindex="0"&gt;&lt;code&gt;Biboca, garagem, favela&#10;Biboca, garagem, favela!&#10;Fubanga, maloca, bocada&#10;Fubanga, maloca, bocada!&#10;&#10;Maloca, bocada, fubanga&#10;Maloca, bocada, fubanga!&#10;Favela, garagem, biboca&#10;Favela, garagem, biboca, porra!&#10;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;So, these are words that make reference to slums or simple/dangerous places.&#10;Biboca is a word for a simple, humble place. Garagem is a garage. Favela is&#10;slum. Fubanga is a ugly, non-attractive woman. Maloca is a kind of indigenous&#10;habitation and Bocada is the place where people sell drugs.&lt;/p&gt;&#10;&lt;pre tabindex="0"&gt;&lt;code&gt;Um, dois, três, quatro&#10;Zé Do Caixão, Zumbi, Lampião&#10;Zé Do Caixão, Zumbi, Lampião&#10;Zé Do Caixão, Zumbi, Lampião&#10;Zé Do Caixão, Zumbi, Lampião&#10;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Those 3 are some people from Brazil. Zé do Caixão is the character of a cult&#10;terror/bizarre genre. The actor is considered the father of Brazilian terror&#10;cinema. Zumbi makes reference to &amp;ldquo;Zumbi dos Palmares&amp;rdquo;, a guy who was a leader&#10;for slaves that ran away from their &amp;ldquo;masters&amp;rdquo; (I really hate the word &amp;ldquo;masters&amp;rdquo;&#10;in this context) and went to &amp;ldquo;Quilombo dos Palmares&amp;rdquo;, a settlement for escaped&#10;slaves. And Lampião was a bandit that is almost a myth: for the police he was&#10;a criminal, for the population at the time, a hero, so much that he received&#10;the nickname &amp;ldquo;Robin Hood da Caatinga&amp;rdquo;.&lt;/p&gt;&#10;&lt;pre tabindex="0"&gt;&lt;code&gt;Vamos detonar essa porra&#10;É, porra!&#10;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;In a kind of literal translation:&lt;/p&gt;&#10;&lt;p&gt;&amp;ldquo;Let’s fuck this shit up&lt;br /&gt;&#10;Yeah, fuck it&amp;rdquo;&lt;/p&gt;&#10;&lt;p&gt;For the end, here&amp;rsquo;s one formula: Ratamahatta = Ratos(rats) + Manhattan.&lt;/p&gt;&#10;&lt;p&gt;According to Carlinhos Brown, in an interview with UOL, the song was inspired&#10;by the rats of New York, that is, these animals do not only inhabit unhealthy&#10;places. &amp;ldquo;I had this title &amp;lsquo;Ratamahatta&amp;rsquo; in my head and I needed to finish it.&#10;Max helped me. When I was in Manhattan, I was impressed by their rats. They&#10;look like the opossums here in Bahia. And opossums here go to the pot! But&#10;people said that the rats in Manhattan were not good to eat, because they were&#10;dirtier. That&amp;rsquo;s why the lyrics have the words &amp;ldquo;garagem&amp;rdquo; &amp;ldquo;biboca&amp;rdquo; and &amp;ldquo;favela&amp;rdquo;.&#10;The rat is not present only in the big cities. It is everywhere. It is at&#10;fubanga, maloca, bocada. Who is the rat? He is the recycling boss. This is what&#10;the song means: Talks about a Manhattan rat who goes around the world and&#10;connects with everybody.&lt;/p&gt;&#10;</description></item><item><title>OpenLDAP</title><link>https://meka.rs/blog/2024/04/14/openldap/</link><pubDate>Sun, 14 Apr 2024 17:43:00 +0000</pubDate><guid>https://meka.rs/blog/2024/04/14/openldap/</guid><description>&lt;p&gt;I wanted to achieve 3 things:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Ability to enable/disable account and domain&lt;/li&gt;&#10;&lt;li&gt;Proper groups and membership&lt;/li&gt;&#10;&lt;li&gt;Authorization for services&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;I personally don&amp;rsquo;t like OLC or On-Line Config, as I like to do my things using&#10;Ansible. So here is the slapd.conf:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;include&#9;&#9;/usr/local/etc/openldap/schema/core.schema&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;include&#9;&#9;/usr/local/etc/openldap/schema/cosine.schema&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;include&#9;&#9;/usr/local/etc/openldap/schema/inetorgperson.schema&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;include&#9;&#9;/usr/local/etc/openldap/schema/nis.schema&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;include&#9;&#9;/usr/local/etc/openldap/schema/opendkim.schema&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;include&#9;&#9;/usr/local/etc/openldap/schema/pmi.schema&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;pidfile&#9;&#9;/var/run/openldap/slapd.pid&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;argsfile&#9;/var/run/openldap/slapd.args&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;modulepath&#9;/usr/local/libexec/openldap&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;moduleload&#9;back_mdb&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;moduleload&#9;memberof&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;overlay&#9; &#9;&#9;memberof&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;memberof-group-oc&#9;groupOfUniqueNames&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;memberof-member-ad&#9;uniqueMember&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;memberof-refint&#9;&#9;TRUE&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;TLSCACertificateFile /usr/local/etc/openldap/certs/chain.pem&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;TLSCertificateFile /usr/local/etc/openldap/certs/fullchain.pem&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;TLSCertificateKeyFile /usr/local/etc/openldap/certs/privkey.pem&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;security ssf&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;128&lt;/span&gt; tls&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;access to attrs&lt;span style="color:#f92672"&gt;=&lt;/span&gt;userPassword&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; by self write&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; by anonymous auth&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;access to *&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; by self write&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; by users read&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; by anonymous auth&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;database&#9;mdb&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;suffix&#9;&#9;&lt;span style="color:#e6db74"&gt;&amp;#34;dc=ldap&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;rootdn&#9;&#9;&lt;span style="color:#e6db74"&gt;&amp;#34;cn=root,dc=ldap&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;directory&#9;/var/db/openldap-data&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;index&#9;&#9;objectClass,mail&#9;eq&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;include&#9;&#9;/usr/local/etc/openldap/slapd-secret.conf&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;include&#9;&#9;/usr/local/etc/openldap/slapd-multimaster.conf&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And this is the interesting part of the directory:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;dn: dc&lt;span style="color:#f92672"&gt;=&lt;/span&gt;ldap&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;objectClass: domain&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;dc: ldap&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;dn: dc&lt;span style="color:#f92672"&gt;=&lt;/span&gt;account,dc&lt;span style="color:#f92672"&gt;=&lt;/span&gt;ldap&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;objectClass: domain&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;dc: account&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;dn: ou&lt;span style="color:#f92672"&gt;=&lt;/span&gt;meka.rs,dc&lt;span style="color:#f92672"&gt;=&lt;/span&gt;account,dc&lt;span style="color:#f92672"&gt;=&lt;/span&gt;ldap&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;objectClass: organizationalUnit&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ou: meka.rs&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;dn: uid&lt;span style="color:#f92672"&gt;=&lt;/span&gt;meka,ou&lt;span style="color:#f92672"&gt;=&lt;/span&gt;meka.rs,dc&lt;span style="color:#f92672"&gt;=&lt;/span&gt;account,dc&lt;span style="color:#f92672"&gt;=&lt;/span&gt;ldap&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;objectClass: pilotPerson&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;objectClass: posixAccount&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cn: Goran&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sn: Mekić&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;uidNumber: &lt;span style="color:#ae81ff"&gt;65534&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;gidNumber: &lt;span style="color:#ae81ff"&gt;65534&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;homeDirectory: /var/mail/domains/meka.rs/meka&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mail: meka@meka.rs&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;userClass: enabled&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;uid: meka&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;dn: dc&lt;span style="color:#f92672"&gt;=&lt;/span&gt;group,dc&lt;span style="color:#f92672"&gt;=&lt;/span&gt;ldap&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;objectClass: domain&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;dc: group&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;dn: cn&lt;span style="color:#f92672"&gt;=&lt;/span&gt;mail,dc&lt;span style="color:#f92672"&gt;=&lt;/span&gt;group,dc&lt;span style="color:#f92672"&gt;=&lt;/span&gt;ldap&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;objectClass: groupOfUniqueNames&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cn: mail&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;uniqueMember: uid&lt;span style="color:#f92672"&gt;=&lt;/span&gt;meka,ou&lt;span style="color:#f92672"&gt;=&lt;/span&gt;meka.rs,dc&lt;span style="color:#f92672"&gt;=&lt;/span&gt;account,dc&lt;span style="color:#f92672"&gt;=&lt;/span&gt;ldap&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;dn: dc&lt;span style="color:#f92672"&gt;=&lt;/span&gt;service,dc&lt;span style="color:#f92672"&gt;=&lt;/span&gt;ldap&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;objectClass: domain&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;dc: service&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;dn: cn&lt;span style="color:#f92672"&gt;=&lt;/span&gt;postfix,dc&lt;span style="color:#f92672"&gt;=&lt;/span&gt;service,dc&lt;span style="color:#f92672"&gt;=&lt;/span&gt;ldap&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;objectClass: person&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cn: postfix&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sn: service&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;description: SMTP service&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Let me ignore enable/disable of domain for a bit. Let&amp;rsquo;s just focus on accounts.&#10;In &lt;code&gt;slapd.conf&lt;/code&gt;, every line with &lt;code&gt;memberof&lt;/code&gt; string in it is for groups. By&#10;default, memberof module uses groupOfNames, but I think it is better to use&#10;groupOfUniqueNames, so it needs some extra configuration. Let&amp;rsquo;s see what it&#10;provides.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ldapsearch -x -Z -W -D cn&lt;span style="color:#f92672"&gt;=&lt;/span&gt;root,dc&lt;span style="color:#f92672"&gt;=&lt;/span&gt;ldap memberOf&lt;span style="color:#f92672"&gt;=&lt;/span&gt;cn&lt;span style="color:#f92672"&gt;=&lt;/span&gt;mail,dc&lt;span style="color:#f92672"&gt;=&lt;/span&gt;group,dc&lt;span style="color:#f92672"&gt;=&lt;/span&gt;ldap &lt;span style="color:#e6db74"&gt;&amp;#39;*&amp;#39;&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;memberOf&amp;#39;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;. . .&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;dn: uid&lt;span style="color:#f92672"&gt;=&lt;/span&gt;meka,ou&lt;span style="color:#f92672"&gt;=&lt;/span&gt;meka.rs,dc&lt;span style="color:#f92672"&gt;=&lt;/span&gt;account,dc&lt;span style="color:#f92672"&gt;=&lt;/span&gt;ldap&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;objectClass: pilotPerson&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;objectClass: posixAccount&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cn: Goran&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sn: Mekić&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;uidNumber: &lt;span style="color:#ae81ff"&gt;65534&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;gidNumber: &lt;span style="color:#ae81ff"&gt;65534&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;homeDirectory: /var/mail/domains/meka.rs/meka&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mail: meka@meka.rs&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;userClass: enabled&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;uid: meka&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;memberOf: cn&lt;span style="color:#f92672"&gt;=&lt;/span&gt;mail,dc&lt;span style="color:#f92672"&gt;=&lt;/span&gt;group,dc&lt;span style="color:#f92672"&gt;=&lt;/span&gt;ldap&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;. . .&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;So with &lt;code&gt;memberOf&lt;/code&gt; filter, you can easily get members of a group. Notice that&#10;there&amp;rsquo;s &lt;code&gt;'*' 'memberOf'&lt;/code&gt; at the end. That says &amp;ldquo;give me all attributes of an&#10;object, plus give me &lt;code&gt;memberOf&lt;/code&gt;&amp;rdquo;. If you omit &lt;code&gt;memberOf&lt;/code&gt;, it will not be&#10;displayed, although you requested all attributes. That is because it is dynamic&#10;attribute and it is returned only if explicitly requested. But there are few&#10;cases I found that gave me headache. For example, if you create the group, then&#10;configure &lt;code&gt;slapd.conf&lt;/code&gt; to use it, it won&amp;rsquo;t work. I guess that something is&#10;triggered on creation and/or modification of a group that is not triggered in&#10;this scenario. Another anomaly I found is when I&amp;rsquo;m restoring from backup. For&#10;some reason, groups are created before accounts, so &lt;code&gt;memberOf&lt;/code&gt; doesn&amp;rsquo;t work.&#10;Having &lt;code&gt;dc=group,dc=ldap&lt;/code&gt; separated from &lt;code&gt;dc=account,dc=ldap&lt;/code&gt; allows you to&#10;restore accounts before groups. Also, there is &lt;code&gt;msuser.schema&lt;/code&gt;. I first thought&#10;that I need to include it to be able to use &lt;code&gt;memberOf&lt;/code&gt;, but that is wrong. When&#10;I include this file, it defines memberOf and I guess that&amp;rsquo;s why it doesn&amp;rsquo;t work&#10;the way I wanted.&lt;/p&gt;&#10;&lt;p&gt;Look closely at &lt;code&gt;ldapsearch&lt;/code&gt; output and notice &lt;code&gt;userClass: enabled&lt;/code&gt;. If extend&#10;the previously used filter, you get something like this:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ldapsearch -x -Z -W -D cn&lt;span style="color:#f92672"&gt;=&lt;/span&gt;root,dc&lt;span style="color:#f92672"&gt;=&lt;/span&gt;ldap &lt;span style="color:#f92672"&gt;(&lt;/span&gt;&amp;amp;&lt;span style="color:#f92672"&gt;(&lt;/span&gt;userClass&lt;span style="color:#f92672"&gt;=&lt;/span&gt;enabled&lt;span style="color:#f92672"&gt;)(&lt;/span&gt;memberOf&lt;span style="color:#f92672"&gt;=&lt;/span&gt;cn&lt;span style="color:#f92672"&gt;=&lt;/span&gt;mail,dc&lt;span style="color:#f92672"&gt;=&lt;/span&gt;group,dc&lt;span style="color:#f92672"&gt;=&lt;/span&gt;ldap&lt;span style="color:#f92672"&gt;))&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;*&amp;#39;&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;memberOf&amp;#39;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Output will pretty much be the same, only difference is which accounts will be&#10;listed.&lt;/p&gt;&#10;&lt;p&gt;Enabling or disabling domain is partially working. For example, postfix has a&#10;filter for domains, but dovecot does not, while ejabberd can&amp;rsquo;t use LDAP for list&#10;of domains. Depending on the capabilities of a service, you might or might not&#10;achieve this. For example, solution I use for ejabberd is to have group, just&#10;like for the accounts, but for domains called &lt;code&gt;enabled&lt;/code&gt; and use same &lt;code&gt;memberOf&lt;/code&gt;&#10;filter to get the list. Then I use that info in Ansible to provision&#10;configuration file.&lt;/p&gt;&#10;&lt;p&gt;For authorization of services I chose not to use &lt;code&gt;dc=account,dc=ldap&lt;/code&gt; for base,&#10;but &lt;code&gt;cn=&amp;lt;service&amp;gt;,dc=service,dc=ldap&lt;/code&gt;. That way services can not interfere with&#10;user accounts, but beside different base, those are just like normal accounts.&lt;/p&gt;&#10;&lt;p&gt;For more context on how I use OpenLDAP, take a look at my &lt;a href="https://github.com/mekanix/comms"&gt;set of services for&#10;communication&lt;/a&gt; as it might give you a broader&#10;picture what I&amp;rsquo;m trying to solve.&lt;/p&gt;&#10;</description></item><item><title>DIY Sound</title><link>https://meka.rs/blog/2023/08/12/diy-sound/</link><pubDate>Sat, 12 Aug 2023 10:46:25 +0000</pubDate><guid>https://meka.rs/blog/2023/08/12/diy-sound/</guid><description>&lt;p&gt;Sometimes you just hate what industry has don with the sound and start building&#10;your own stuff. For one, I didn&amp;rsquo;t like open source DAW alternatives as all of&#10;them are missing something: Arour&amp;rsquo;s MIDI is terrible for electronic music, loop&#10;recording is missing in Muse, ZRythm is stereo only and I couldn&amp;rsquo;t find how to&#10;work with QTractor and DrumGizmo. To learn about audio and DSP, I started work&#10;on Maolan. Today Maolan is still extremely experimental, but I learned a lot&#10;and I plan to work on it as free time permits. I could have started with JACK&#10;as first supported backend, but I decided to go with FreeBSD&amp;rsquo;s OSS and really&#10;understand what&amp;rsquo;s going on there. Today I&amp;rsquo;m on the verge of understanding it&#10;all perfectly from user space perspective. I am not as good kernel developer,&#10;but I do intend to optimize FreeBSD&amp;rsquo;s OSS and other code that is part of audio&#10;stack. For example, currently USB audio driver has minimal buffer size of 2&#10;miliseconds. Not bad, but USB docs say it works in 1ms frames with 8 subframes&#10;which are 125us or microseconds. Lowering that will be piece of cake, but I&amp;rsquo;m&#10;waiting for 14-STABLE to branch off so I don&amp;rsquo;t sneak in buffer limit which is&#10;not tested enough. As OSS, at least in FreeBSD, uses double buffer: one user&#10;facing, one hadware facing, it would be interesting to see what optimizations&#10;are possible if we would expose controls for hardware facing buffer. You see&#10;where I&amp;rsquo;m going with this. There&amp;rsquo;s work to be done to make FreeBSD more&#10;real-time.&lt;/p&gt;&#10;&lt;p&gt;But software and PC in general is just a half the story. Audio interface and&#10;hardware audio devices are the other half. Today USB audio is hard to work with&#10;on any operating system. That 1ms frame of USB makes sure that latency is at&#10;least 1ms. Using PCIe lowers that, but developing such card is way too hard for&#10;me. My plan/workaround is to build USB sound card with very high sampling rate.&#10;I will start with 384kHz and some of-the-shelf solutions to support it. List of&#10;items I&amp;rsquo;m waiting to arrive:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;a href="https://www.akm.com/us/en/products/audio/audio-dac/ak4458vn/"&gt;AK4458VN DAC&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://www.akm.com/us/en/products/audio/audio-adc/ak5578en/"&gt;AK5578EN ADC&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://www.ebay.com/p/1839170567?iid=251702918057"&gt;Programming Adapter&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://www.minidsp.com/products/usb-audio-interface/mchstreamer"&gt;MCHStreamer Kit&lt;/a&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;If you look at AD/DA converters, you&amp;rsquo;ll notice that they can do 32bit @ 768kHz.&#10;That will be my next step, after all these parts start working together. The&#10;ultimate goal is to make DIY high end audio interface that has one less digit&#10;in the price. For example, if I didn&amp;rsquo;t need 2 programming adapters, that would&#10;be more than 200e less on the price. The reason I&amp;rsquo;m getting it anyway is&#10;because I can&amp;rsquo;t solder that precisely, yet. I would love to program some MCU&#10;and USB PHY using NuttX and using more general board instead of MCHStreamer,&#10;but I&amp;rsquo;m not there yet. In order to get to 768kHz, I have to replace it anyway,&#10;so I&amp;rsquo;m sure I will get there eventually. If all that work gives latency less&#10;than 6ms, I finally have real-time using USB. Also, if I have all that, how&#10;hard will it be to make PCIe alternative? I know it will be much faster, and&#10;with it I might go to latencies like 2ms which give you freedom to patch things&#10;any way you want, like microphone into the interface, have it recorded and&#10;pushed to output which is connected to hardware vocal processor and then again&#10;back to the interface, and then &amp;hellip; The point is that every time you go through&#10;sound card you add those 2ms which means you can do it 3 times and still be&#10;called real-time. And maybe I won&amp;rsquo;t do that but build digital mixer which will&#10;route sound internally and it won&amp;rsquo;t even need a computer do work. Of course, I&#10;will have USB interface on it, because I do want to record it in the end.&lt;/p&gt;&#10;&lt;p&gt;Reading about AD/DA, I stumbled upon DSD format which they say is superior to&#10;PCM. Let me briefly explain. PCM is what we are usually thought is digital&#10;sampling. It&amp;rsquo;s how CD works, for example. Every 1/44100 of a second, level of&#10;signal is measured and it is represented with a number. That&amp;rsquo;s what the name&#10;stands for: Pulse Code Modulation or PCM for short. DSD works differently. I&#10;only uses one bit to represent the sample. Weird, right? The idea is that one&#10;bit is enough to represent if the current sample is higher or lower than&#10;previous one. Done at a high frequency, for example &amp;gt;10MHz, you can easily see&#10;that it follows audio signal more accurately. At least that what I read on the&#10;Internet. Now here&amp;rsquo;s an idea. If I get my sound interface working in DSD mode,&#10;and write a patch for FreeBSD OSS so it handles DSD natively, and use DSD WAV&#10;files to record the input, I&amp;rsquo;m hoping to capture audio more accurately. I don&amp;rsquo;t&#10;know how much difference it will make but today that&amp;rsquo;s the best what the&#10;industry can offer, yet can&amp;rsquo;t use it as no interface today is built like that.&#10;I mean, I&amp;rsquo;m not the first to come up with this idea, for start Denoy used same&#10;AD/DA until the shortage, so the components are field tested, I&amp;rsquo;m not&#10;interested in revolutionizing anything. What I mean is that the components I&#10;listed are on the market for years and are being used by audio companies for&#10;years, so I know I can do it, it&amp;rsquo;s just my first prototype so I can&amp;rsquo;t really&#10;say how or when.&lt;/p&gt;&#10;&lt;p&gt;My dear reader, I have a question. Would you support such a project by funding&#10;it? If no, why? If yes, what amount? To be more precise, would you fund my work&#10;on everything I just described if I promise that USB audio interface I just&#10;described will cost around 200e (with current prices) if you exclude shipping,&#10;you would have to solder it and get parts but you get the whole KiCAD project,&#10;all code open source and based on NuttX? If you just had &amp;ldquo;yes to all&amp;rdquo; moment,&#10;let me ask additional question. Once all this is done, would you fund work to&#10;make it USB 3 compatible? As USB 3 has much higher bandwidth, the interface&#10;could have much more channels, in or out. I&amp;rsquo;m talking about 32in, 32out, if&#10;your PC can cope with it.&lt;/p&gt;&#10;&lt;p&gt;Please let me know what you think. I prefer email as it&amp;rsquo;s easiest to sort and&#10;archive of all communication channels, but you&amp;rsquo;re free to pick whatever you&#10;like to contact me.&lt;/p&gt;&#10;</description></item><item><title>FreeBSD PF and Dummynet</title><link>https://meka.rs/blog/2022/11/17/freebsd-pf-and-dummynet/</link><pubDate>Thu, 17 Nov 2022 11:57:00 +0000</pubDate><guid>https://meka.rs/blog/2022/11/17/freebsd-pf-and-dummynet/</guid><description>&lt;p&gt;In 14-CURRENT there is now support for dummynet in PF. That means that you can&#10;slow down packets based on some criteria. MacOS users probably know how this&#10;works as that OS got support for PF+dummynet years ago. For example, you can do&#10;the following in /etc/pf.conf:&lt;/p&gt;&#10;&lt;pre tabindex="0"&gt;&lt;code&gt;pass in quick inet from 192.168.1.1 to any dnpipe 1&#10;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;That way all traffic from 192.168.1.1 will go through dummynet pipe. To create&#10;and configure the pipe you use:&lt;/p&gt;&#10;&lt;pre tabindex="0"&gt;&lt;code&gt;dnctl pipe 1 config bw 300KByte/s&#10;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;I gave it a really low bandwidth because I want it to be really noticeable if&#10;packets are going through dummynet or not. You can change the pipe&amp;rsquo;s bandwidth&#10;by using the same command just changing the numbers. Note that K and B have to&#10;be upper case. You can, of course, use all the usual suffixes like M and G but&#10;note that dummynet has a limit on the bandwidth it can configure.&lt;/p&gt;&#10;&lt;p&gt;To see what is configured you can use:&lt;/p&gt;&#10;&lt;pre tabindex="0"&gt;&lt;code&gt;dnctl pipe show&#10;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;With dnctl, show is an alias for list, so you will get the same results using&#10;either.&lt;/p&gt;&#10;&lt;p&gt;I didn&amp;rsquo;t make it so that packets generated on the machine itself be processed&#10;by dummynet, but it might be intentional. What does work is VNET so your jails&#10;can have different PF and dummynet configuration than the host.&lt;/p&gt;&#10;&lt;p&gt;One annoying thing is that there is no dnctl rc.d service, so you will probably&#10;write &lt;code&gt;dnctl&lt;/code&gt; commands in something like &lt;code&gt;rc.local&lt;/code&gt; or something. I do plan to&#10;create rc.d service for myself and when I learn more about dummynet, to publish&#10;it hoping it will become part of base so we can easily configure it.&lt;/p&gt;&#10;&lt;h2 id="update"&gt;&#10; Update&#10;&lt;/h2&gt;&#10;&lt;p&gt;The &lt;a href="https://reviews.freebsd.org/D37451"&gt;dnctl service&lt;/a&gt; is now available. If&#10;enabled it reads /etc/dnctl.conf which has IPFW-like syntax and when only&#10;&lt;code&gt;dummynet&lt;/code&gt; module is loaded, it will issue an error on non-dummynet IPFW&#10;statements.&lt;/p&gt;&#10;</description></item><item><title>FreeBSD Dual Stack Firewall</title><link>https://meka.rs/blog/2022/08/16/freebsd-dual-stack-firewall/</link><pubDate>Tue, 16 Aug 2022 11:11:35 +0000</pubDate><guid>https://meka.rs/blog/2022/08/16/freebsd-dual-stack-firewall/</guid><description>&lt;p&gt;The idea is very simple: everything works. But what is &amp;ldquo;everything&amp;rdquo; in this&#10;case? I want my host and jails to have IPv4 and IPv6 address, register those&#10;addresses in DNS and all to be accessible in the network and via Internet. To&#10;make my life easier, I programmed &lt;a href="https://github.com/cbsd/reggae"&gt;Reggae&lt;/a&gt; to&#10;initialize rtadvd, jail with isc-dhcpd for IPv4 and IPv6 and DNS, pf with the&#10;base configuration.&lt;/p&gt;&#10;&lt;h2 id="host"&gt;&#10; Host&#10;&lt;/h2&gt;&#10;&lt;p&gt;If there were no jails, the configuration would be simple: just use dhcpcd for&#10;everything. There&amp;rsquo;s not even need for some special firewall rules. To do that,&#10;you need to run:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;pkg install dhcpcd&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;echo &lt;span style="color:#e6db74"&gt;&amp;#39;dhclient_program=/usr/local/sbin/dhcpcd&amp;#39;&lt;/span&gt; &amp;gt;/etc/rc.conf.d/network&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;On next reboot or netif start all your DHCP ifaces will use dhcpcd and it will&#10;configure DHCPv4, SLAAC and DHCPv6. Admitedly you will have two IPv6 addresses:&#10;one SLAAC configured and one acquired through DHCPv6. The DHCP addresses will&#10;be registered in DNS. That&amp;rsquo;s basically it.&lt;/p&gt;&#10;&lt;h2 id="jail"&gt;&#10; Jail&#10;&lt;/h2&gt;&#10;&lt;p&gt;In the jail itself it is the same as host: install dhcpcd and use it and DHCP&#10;addresses are registered in DNS. If all you need is some kind of dual stack,&#10;that&amp;rsquo;s it, but if you need it on a server with jails, stuff gets a little bit&#10;more complex. First, to achieve that host and jails get the address from the&#10;same router, you need to bridge your physical interface and epairs.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cloned_interfaces&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;bridge0&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ifconfig_bridge0&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;addm igb0&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ifconfig_bridge0_ipv6&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;inet6 fd10:6c79:8ae5:8b91::5 -ifdisabled auto_linklocal&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The example uses &amp;ldquo;private IP range&amp;rdquo; in IPv4 terms, or unique local addresses as&#10;IPv6 terminology defines them. There are two main problems with this setup:&#10;DHCPv6 will not work and firewall will do too much. For DHCPv6 the reason it&#10;doesn&amp;rsquo;t work is that you have to allow dhcpv6-client messages to arrive. You&#10;didn&amp;rsquo;t need it for host-only setup, but to allow those messages to reach jails,&#10;you need.&lt;/p&gt;&#10;&lt;pre tabindex="0"&gt;&lt;code&gt;pass in quick inet6 proto udp from fe80::/10 port dhcpv6-server to fe80::/10 port dhcpv6-client&#10;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;When you put egress interface (igb0 in my case) into bridge, it will see all&#10;traffic for jails, too, so you have to allow packets which are not destined to&#10;the host. To achieve that, pf offers &lt;self&gt;.&lt;/p&gt;&#10;&lt;pre tabindex="0"&gt;&lt;code&gt;block in log from any to &amp;lt;self&amp;gt;&#10;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;That way you are filtering everything for the host, but leave jail traffic&#10;alone.&lt;/p&gt;&#10;&lt;h2 id="router"&gt;&#10; Router&#10;&lt;/h2&gt;&#10;&lt;p&gt;Maybe the easiest thing to do is converting Reggae setup into your router. All&#10;you need to do is add physical interfaces like re1 and wlan0, to your bridge&#10;and that&amp;rsquo;s it. As all services inside network jail (the one with DHCP and DNS)&#10;are listening on epair which is part of bridge, no other actions is needed.&lt;/p&gt;&#10;&lt;h2 id="reggae"&gt;&#10; Reggae&#10;&lt;/h2&gt;&#10;&lt;p&gt;Reggae will initialize your network, services and network jail in dual stack&#10;mode. You can disable IP version by setting &lt;code&gt;USE_IPV4=no&lt;/code&gt; or &lt;code&gt;USE_IPV6=no&lt;/code&gt;, but&#10;it will issue an error if you disable both. It will also write /etc/pf.conf if&#10;one doesn&amp;rsquo;t already exist and setup local_unbound, so you should be all set&#10;after initializing Reggae the usual way.&lt;/p&gt;&#10;</description></item><item><title>FreeBSD and YubiKey</title><link>https://meka.rs/blog/2022/07/20/freebsd-and-yubikey/</link><pubDate>Wed, 20 Jul 2022 10:27:00 +0000</pubDate><guid>https://meka.rs/blog/2022/07/20/freebsd-and-yubikey/</guid><description>&lt;p&gt;Install and initialize the services as root:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;pkg install ccid opensc pcsc-lite&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sysrc pcscd&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;service pcscd restart&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Start ssh agent and add provider to it as user:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;eval &lt;span style="color:#66d9ef"&gt;$(&lt;/span&gt;ssh-agent&lt;span style="color:#66d9ef"&gt;)&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ssh-add -s /usr/local/lib/opensc-pkcs11.so&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;That&amp;rsquo;s it, SSH should work with YubiKey now.&lt;/p&gt;&#10;</description></item><item><title>FreeBSD Linuxulator</title><link>https://meka.rs/blog/2022/07/01/freebsd-linuxulator/</link><pubDate>Fri, 01 Jul 2022 00:21:00 +0000</pubDate><guid>https://meka.rs/blog/2022/07/01/freebsd-linuxulator/</guid><description>&lt;p&gt;As some applications are Linux-only, it is very handy to have linuxulator&#10;available. In short, I just followed&#10;&lt;a href="https://github.com/mrclksr/linux-browser-installer"&gt;linux browser install&lt;/a&gt; and&#10;added slack and viber with&#10;&lt;a href="https://forums.freebsd.org/threads/linuxulator-how-to-install-brave-linux-app-on-freebsd-13-0.78879/"&gt;pulseaudio setup&lt;/a&gt;.&#10;Although pulseaudio setup contains linux browser install, it is the most&#10;important part. Once the browser was installed I copied the scripts to make&#10;slack and viber working. After download of .deb file, chroot to linux directory&#10;and install it.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cp &amp;lt;slack&amp;gt;.deb /compat/ubuntu&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;chroot /compat/ubuntu /bin/bash&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;dpkg -i &amp;lt;slack&amp;gt;.deb&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;apt-get install -f&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;On host, script is needed in PATH so it can be executed just like a normal&#10;application, so &lt;code&gt;/usr/bin/slack&lt;/code&gt; looks like this:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#!/bin/sh&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;get_pa_sock_path&lt;span style="color:#f92672"&gt;()&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;{&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; PA_SOCK_PATH&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#66d9ef"&gt;$(&lt;/span&gt;sockstat | awk -v me&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#66d9ef"&gt;$(&lt;/span&gt;whoami&lt;span style="color:#66d9ef"&gt;)&lt;/span&gt; -F&lt;span style="color:#e6db74"&gt;&amp;#39;[ \t]+&amp;#39;&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt; $1 == me &amp;amp;&amp;amp; $2 == &amp;#34;pulseaudio&amp;#34; &amp;amp;&amp;amp; $6 ~ /native/ {&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt; print $6;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt; exit 0&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt; }&amp;#39;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;)&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;}&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;get_pa_sock_path&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;[&lt;/span&gt; -S &lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;$PA_SOCK_PATH&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt; &lt;span style="color:#f92672"&gt;]&lt;/span&gt; &lt;span style="color:#f92672"&gt;&amp;amp;&amp;amp;&lt;/span&gt; export PULSE_SERVER&lt;span style="color:#f92672"&gt;=&lt;/span&gt;unix:$PA_SOCK_PATH&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;/compat/ubuntu/bin/slack $@&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Next, we need to create &lt;code&gt;/bin/slack&lt;/code&gt; inside ubuntu chroot:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#!/compat/ubuntu/bin/bash&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# chrome wrapper script from patovm04:&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# https://forums.freebsd.org/threads/linuxulator-how-to-run-google-chrome-linux-binary-on-freebsd.77559/&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;export SLACK_PATH&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;/usr/bin/slack&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;export SLACK_WRAPPER&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;&lt;span style="color:#66d9ef"&gt;$(&lt;/span&gt;readlink -f &lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;$0&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;&lt;span style="color:#66d9ef"&gt;)&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;export LD_LIBRARY_PATH&lt;span style="color:#f92672"&gt;=&lt;/span&gt;/usr/local/steam-utils/lib64/fakeudev&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;export LD_PRELOAD&lt;span style="color:#f92672"&gt;=&lt;/span&gt;/usr/local/steam-utils/lib64/webfix/webfix.so&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;export LIBGL_DRI3_DISABLE&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;exec -a &lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;$0&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;$SLACK_PATH&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt; --no-sandbox --no-zygote --test-type --v&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;0&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;$@&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Final change is to &lt;code&gt;/usr/share/applications/slack.desktop&lt;/code&gt; inside ubuntu chroot:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;[&lt;/span&gt;Desktop Entry&lt;span style="color:#f92672"&gt;]&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Name&lt;span style="color:#f92672"&gt;=&lt;/span&gt;Slack&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;StartupWMClass&lt;span style="color:#f92672"&gt;=&lt;/span&gt;Slack&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Comment&lt;span style="color:#f92672"&gt;=&lt;/span&gt;Slack Desktop&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;GenericName&lt;span style="color:#f92672"&gt;=&lt;/span&gt;Slack Client &lt;span style="color:#66d9ef"&gt;for&lt;/span&gt; Linux&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Exec&lt;span style="color:#f92672"&gt;=&lt;/span&gt;/bin/slack %U&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Icon&lt;span style="color:#f92672"&gt;=&lt;/span&gt;/usr/share/pixmaps/slack.png&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Type&lt;span style="color:#f92672"&gt;=&lt;/span&gt;Application&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;StartupNotify&lt;span style="color:#f92672"&gt;=&lt;/span&gt;true&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Categories&lt;span style="color:#f92672"&gt;=&lt;/span&gt;GNOME;GTK;Network;InstantMessaging;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;MimeType&lt;span style="color:#f92672"&gt;=&lt;/span&gt;x-scheme-handler/slack;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Note: Exec line is wrong by default for linuxulator environment. The&#10;executable needs to be our script &lt;code&gt;/bin/slack&lt;/code&gt;, not the slack binary itself&#10;&lt;code&gt;/usr/bin/slack&lt;/code&gt;.&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;The trick is to execute &lt;code&gt;pulseaudio --daemonize&lt;/code&gt; on FreeBSD host before&#10;starting slack. I got audio and webcam working. Of course, viber setup is the&#10;same.&lt;/p&gt;&#10;</description></item><item><title>FreeBSD Dual Stack Jails</title><link>https://meka.rs/blog/2022/01/22/freebsd-dual-stack-jails/</link><pubDate>Sat, 22 Jan 2022 09:35:00 +0000</pubDate><guid>https://meka.rs/blog/2022/01/22/freebsd-dual-stack-jails/</guid><description>&lt;p&gt;There are 3 ways to have IPv6 in VNET jails that I&amp;rsquo;m going to describe. In terms&#10;of IPv4, those would be:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;private address&lt;/li&gt;&#10;&lt;li&gt;public address&lt;/li&gt;&#10;&lt;li&gt;public address behind router&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;Private addresses in IPv6 world are called &amp;ldquo;unique local&amp;rdquo;, and they start with&#10;&amp;ldquo;fd&amp;rdquo; in hexadecimal notation. Please note that there are also site-local&#10;addresses, but they are deprecated. Something like a MAC address is called &amp;ldquo;link&#10;local address&amp;rdquo; and they start with &amp;ldquo;fe80&amp;rdquo; in hex. In this example, all addresses&#10;starting with 2001 are global or in IPv4 notation, they are public. These are&#10;not the only types of addresses, nor addresses starting with 2001 are the only&#10;global ones. I&amp;rsquo;m just trying to keep it simple by narrowing it down to 3 types.&lt;/p&gt;&#10;&lt;h2 id="jail-setup"&gt;&#10; Jail Setup&#10;&lt;/h2&gt;&#10;&lt;p&gt;As CBSD renames jail&amp;rsquo;s end of epair to eth0 writing rules/config is simplified.&#10;In all jails the setup of /etc/rc.conf is:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-ini" data-lang="ini"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ifconfig_eth0_ipv6&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;inet6 -ifdisabled accept_rtadv auto_linklocal&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;rtsold_enable&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;YES&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;CBSD will run DHCP client before running init, so that part is taken care of if&#10;you choose REALDHCP as address assigning method.&lt;/p&gt;&#10;&lt;h2 id="unique-local-addresses"&gt;&#10; Unique Local Addresses&#10;&lt;/h2&gt;&#10;&lt;p&gt;I use this setup for development as I don&amp;rsquo;t want everything I do to be public&#10;all the time. The principles are the same as with IPv4: assign jails private&#10;addresses and then NAT them to the world. The relevant portion of /etc/rc.conf&#10;is:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-ini" data-lang="ini"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ifconfig_re0&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;DHCP&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ifconfig_re0_ipv6&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;inet6 -ifdisabled auto_linklocal accept_rtadv&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ipv6_gateway_enable&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;YES&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ipv6_defaultrouter&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;fe80::5a9c:fcff:fe10:6c2c%re0&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;rtsold_enable&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;YES&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# CBSD&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ifconfig_bridge0_name&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;cbsd0&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ifconfig_cbsd0&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;inet 172.16.0.254 netmask 255.255.255.0 description lagg0&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ifconfig_cbsd0_alias0&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;inet 172.16.1.254 netmask 255.255.255.0&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ifconfig_cbsd0_ipv6&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;inet6 fd10:6c79:8ae5:8b91::1 -ifdisabled auto_linklocal&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;As I use CBSD and Reggae, I like to create dedicated bridge interface for it&#10;and rename it so it&amp;rsquo;s easier to tell what is what. I also have two IPv4 ranges:&#10;one for DHCP assigned addresses and one for CBSD generated ones. For IPv6 I have&#10;one address from the same range jails get their addresses. The configuration of&#10;/etc/rtadvd.conf:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-ini" data-lang="ini"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;cbsd0:addr&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;fd10:6c79:8ae5:8b91::&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;For NAT /etc/pf.conf is:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-md" data-lang="md"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;# Macros and tables&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ext_if = &amp;#34;lagg0&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;table &amp;lt;cbsd&amp;gt; persist&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;# Options&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;set block-policy drop&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;set skip on lo0&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;# Normalization&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;scrub in all&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;# NAT&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;rdr-anchor &amp;#34;cbsd/*&amp;#34; on $ext_if&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;nat on $ext_if inet from &amp;lt;cbsd&amp;gt; to any -&amp;gt; ($ext_if)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;nat on $ext_if inet6 from cbsd0:network to any -&amp;gt; ($ext_if:0)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;# Quick rules&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;antispoof quick log for ($ext_if)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;# Rules&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;block in log on $ext_if&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;pass out&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;pass proto tcp to any port ssh&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;pass proto { icmp, igmp, icmp6 }&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;There is a bit more than a bare minimum, but the important lines are those&#10;starting with &amp;ldquo;nat&amp;rdquo;. First rule is for IPv4 and it will NAT for all addresses&#10;CBSD/Reggae puts in &lt;cbsd&gt; table. Second rule is for IPv6 and it is important&#10;to use $ext_if:0 not just $ext_if because it will otherwise try to NAT using&#10;all IPv6 addresses. In this case it would use the proper address as well as&#10;link-local one.&lt;/p&gt;&#10;&lt;h2 id="global-unicast-address"&gt;&#10; Global Unicast Address&#10;&lt;/h2&gt;&#10;&lt;p&gt;This setup should be almost the same as the previous one. Keep in mind that in&#10;the following setup re0 and cbsd0 must use same prefix, or in IPv4 terms: they&#10;have to be in the same network. In practice, that means that both interfaces&#10;must have IPv6 address which starts with &lt;code&gt;2001:aaaa:bbbb:cccc:&lt;/code&gt;. Equally&#10;important is to not add re0 to cbsd0 bridge as that would make local DHCP server&#10;running in a jail leak out through re0 towards the rest of the physical network.&lt;/p&gt;&#10;&lt;p&gt;/etc/rc.conf:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-ini" data-lang="ini"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ifconfig_re0&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;DHCP&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ifconfig_re0_ipv6&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;inet6 -ifdisabled auto_linklocal accept_rtadv&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ipv6_gateway_enable&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;YES&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ipv6_defaultrouter&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;fe80::5a9c:fcff:fe10:6c2c%re0&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;rtsold_enable&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;YES&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# CBSD&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ifconfig_bridge0_name&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;cbsd0&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ifconfig_cbsd0&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;inet 172.16.0.254 netmask 255.255.255.0 description lagg0&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ifconfig_cbsd0_alias0&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;inet 172.16.1.254 netmask 255.255.255.0&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ifconfig_cbsd0_ipv6&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;inet6 2001:aaaa:bbbb:cccc::1 -ifdisabled auto_linklocal&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;/etc/rtadvd.conf:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-ini" data-lang="ini"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;cbsd0:addr&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;2001:aaaa:bbbb:cccc::&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;/etc/pf.conf:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-md" data-lang="md"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;# Macros and tables&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ext_if = &amp;#34;lagg0&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;table &amp;lt;cbsd&amp;gt; persist&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;# Options&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;set block-policy drop&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;set skip on lo0&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;# Normalization&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;scrub in all&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;# NAT&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;rdr-anchor &amp;#34;cbsd/*&amp;#34; on $ext_if&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;nat on $ext_if inet from &amp;lt;cbsd&amp;gt; to any -&amp;gt; ($ext_if)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;# Quick rules&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;antispoof quick log for ($ext_if)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;# Rules&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;block in log on $ext_if&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;pass out&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;pass proto tcp to any port ssh&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;pass proto { icmp, igmp, icmp6 }&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="global-unicast-address-behind-router"&gt;&#10; Global Unicast Address Behind Router&#10;&lt;/h2&gt;&#10;&lt;p&gt;This setup is mostly for the server behind a router. The idea is to put all&#10;physical (in this case one) and virtual (in this case epair interfaces) into&#10;the same bridge. Bridge acts like a switch, so the network will behave like we&#10;somehow plugged all physical and virtual interfaces into the same switch.&#10;In practice it means that DHCP and rtadv/rtsol packets will got to/from the&#10;router, directly. As it is a server, all configuration is static, so there&amp;rsquo;s&#10;no rtsold/rtadvd present.&lt;/p&gt;&#10;&lt;p&gt;/etc/rc.conf:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-ini" data-lang="ini"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ifconfig_igb0&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;inet 192.168.111.201 netmask 255.255.255.0&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ifconfig_igb0_ipv6&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;inet6 2001:aaaa:bbbb:cccc::4 -ifdisabled auto_linklocal&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ipv6_defaultrouter&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;fe80::5a9c:fcff:fe10:6c2c%igb0&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;defaultrouter&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;192.168.111.254&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# CBSD&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;cloned_interfaces&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;bridge0&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ifconfig_bridge0_name&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;cbsd0&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ifconfig_cbsd0&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;description igb0 addm igb0&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;/etc/pf.conf:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-md" data-lang="md"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;# Macros and tables&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ext_if = &amp;#34;igb0&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;dhcp_ports = &amp;#34;{ bootps, bootpc }&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;table &amp;lt;cbsd&amp;gt; persist&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;# Options&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;set block-policy drop&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;set skip on lo0&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;# Normalization&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;scrub in all&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;# Rules&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;block in log on $ext_if&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;pass out&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;pass in from &amp;lt;cbsd&amp;gt; to any&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;pass in on $ext_if from any to $ext_if:network&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;pass proto tcp to any port ssh&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;pass proto { icmp, igmp, icmp6 }&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;pass in proto udp from any to any port $dhcp_ports&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Note that in this setup NAT and antispoof are missing while it&amp;rsquo;s essential to&#10;have &lt;code&gt;pass in on $ext_if from any to $ext_if:network&lt;/code&gt;. NAT is not needed as&#10;router will do it in this setup and antispoof is not applicable here because it&#10;practically says &amp;ldquo;any packet with source address from igb0 network coming from&#10;interface other than igb0 should be blocked&amp;rdquo;. That&amp;rsquo;s the problem because VNET&#10;jails will have epair interfaces using the same address range and antispoof&#10;would block those packets as well because they physically pass through igb0 and&#10;are visible. The extra &lt;code&gt;pass&lt;/code&gt; rule is for the same reason.&lt;/p&gt;&#10;&lt;p&gt;&lt;a href="https://meka.rs/blog/2022/01/15/freebsd-dual-stack-network/"&gt;Previous&lt;/a&gt;&lt;/p&gt;&#10;</description></item><item><title>FreeBSD Dual Stack Network</title><link>https://meka.rs/blog/2022/01/15/freebsd-dual-stack-network/</link><pubDate>Sat, 15 Jan 2022 22:55:00 +0000</pubDate><guid>https://meka.rs/blog/2022/01/15/freebsd-dual-stack-network/</guid><description>&lt;p&gt;Idea is to build dual stack network, which means working IPv4 and IPv6. Support&#10;on router and client side is needed for network to work without glitches. For&#10;example, switching from ethernet to WiFi should be seamless. On top, as my ISP&#10;is not providing IPv6, I&amp;rsquo;ll show you how tunnels like Hurricane Electric work,&#10;which in layman terms means &amp;ldquo;how to have public IPv6 addresses on all my devices&#10;although ISP doesn&amp;rsquo;t provide it&amp;rdquo;. If you have native IPv6 support from your&#10;provider, that&amp;rsquo;s great and just use it, otherwise you can use&#10;&lt;a href="https://tunnelbroker.net/"&gt;Huricane Electric Tunnel Broker&lt;/a&gt; to setup IPv6.&lt;/p&gt;&#10;&lt;h2 id="router"&gt;&#10; Router&#10;&lt;/h2&gt;&#10;&lt;p&gt;The following is the simplified picture of a network. There is a switch missing&#10;and WiFi is just one line between laptop and router but it&amp;rsquo;s good enough for&#10;explaining what will be configured. On the left of the router is IPv4 connection&#10;that ISP provides, and on the left is IPv6 connection that HE tunnel provides.&#10;There are few services to keep everyone happy, like DHCP server inside CBSD&#10;based jail, Router Advertisment daemon (rtadvd) to &amp;ldquo;disperse&amp;rdquo; IPv6 addresses,&#10;and so on.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-md" data-lang="md"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;.------. .--------. .---------.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;| IPv4 |&amp;lt;-&amp;gt;| Router |&amp;lt;-&amp;gt;| HE IPv6 |&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;.______. .________. ._________.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; /|\&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; / | \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; / | \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; / | \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; / | \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; / | \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; .--------. .---------. .---------.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; | Laptop | | Seerver | | Desktop |&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; |________| |_________| |_________|&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;There are are 3 ethernet ports on APU and one WiFi interface. One ethernet port&#10;is used for connection to ISP, two remaining ports and WiFi are bridged into&#10;one interface. There are few services on the router to make it work:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Router Advertisment (rtadvd)&lt;/li&gt;&#10;&lt;li&gt;Host AP daemon (hostapd)&lt;/li&gt;&#10;&lt;li&gt;DHCP in jail (isc-dhcpd)&lt;/li&gt;&#10;&lt;li&gt;Unbound for DNS (local_unbound)&lt;/li&gt;&#10;&lt;li&gt;Firewall (pf)&lt;/li&gt;&#10;&lt;li&gt;PPP daemon based on netgraph (mpd5)&lt;/li&gt;&#10;&lt;li&gt;Jail management (cbsd)&lt;/li&gt;&#10;&lt;li&gt;Protection from ssh brute force (blacklistd)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;/etc/rc.conf:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-ini" data-lang="ini"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Network&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;cloned_interfaces&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;bridge0 bridge1&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ifconfig_re0&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;inet 192.168.100.254 netmask 255.255.255.0&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ifconfig_re1&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;up&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ifconfig_re2&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;up&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ifconfig_bridge0_name&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;cbsd0&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ifconfig_bridge1_name&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;lan&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ifconfig_lan&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;addm re1 addm re2 addm wlan0 stp re1 stp re2 stp wlan0&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ifconfig_lan_alias0&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;inet 192.168.111.254 netmask 255.255.255.0&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ifconfig_lan_ipv6&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;inet6 2001:aaaa:bbbb:cccc::3 auto_linklocal -ifdisabled&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;wlans_ath0&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;wlan0&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ifconfig_wlan0_ipv6&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;inet6 -ifdisabled&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;create_args_wlan0&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;wlanmode hostap&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ifconfig_wlan0&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;txpower 50 channel 149 up&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;hostapd_enable&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;YES&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;rtadvd_enable&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;YES&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;gateway_enable&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;YES&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ipv6_gateway_enable&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;YES&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;local_unbound_enable&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;YES&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;local_unbound_tls&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;NO&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# HE IPv6 tunnel&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;gif_interfaces&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;gif0&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;gifconfig_gif0&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;MyIPv4 HE-IPv4&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ifconfig_gif0_ipv6&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;inet6 2001:aaaa:bbbb:cccc::2 2001:aaaa:bbbb:cccc::1 prefixlen 128&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ipv6_defaultrouter&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;2001:aaaa:bbbb:cccc::1&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Firewall&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;pflog_enable&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;YES&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;pf_enable&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;YES&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# CBSD&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ifconfig_cbsd0&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;inet 172.16.0.254 netmask 255.255.255.0 description ng0&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ifconfig_cbsd0_alias0&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;inet 172.16.1.254 netmask 255.255.255.0&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;cbsd_workdir&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;/usr/cbsd&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;cbsdrsyncd_enable&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;YES&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;cbsdrsyncd_flags&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;--config=/usr/cbsd/etc/rsyncd.conf&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;cbsdd_enable&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;YES&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;rcshutdown_timeout&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;900&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The CBSD portion is present on all machines as I use it to manage my jails, but&#10;I won&amp;rsquo;t repeat it in every configuration.&lt;/p&gt;&#10;&lt;p&gt;To turn my WiFi into AP I use hostapd with the following configuration.&lt;/p&gt;&#10;&lt;p&gt;/etc/hostapd.conf&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-ini" data-lang="ini"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;interface&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;wlan0&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;debug&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;1&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ctrl_interface&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;/var/run/hostapd&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ctrl_interface_group&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;wheel&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ssid&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;myssid&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;wpa&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;2&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;wpa_passphrase&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;Secrit&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;wpa_key_mgmt&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;WPA-PSK&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;wpa_pairwise&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;CCMP&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;As my ISP uses PPPoE I have to use mpd5. It performs much faster than PPP&#10;included in base. I could get about 200Mbit/s with the one from base, while I&#10;have full 400Mbit/s with mpd5.&lt;/p&gt;&#10;&lt;p&gt;/usr/local/etc/mpd5/mpd.conf&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-rst" data-lang="rst"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;default:&lt;span style="color:#960050;background-color:#1e0010"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; load mts&lt;span style="color:#960050;background-color:#1e0010"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#960050;background-color:#1e0010"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mts:&lt;span style="color:#960050;background-color:#1e0010"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; create bundle static B1&lt;span style="color:#960050;background-color:#1e0010"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; set iface route default&lt;span style="color:#960050;background-color:#1e0010"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; set iface enable tcpmssfix&lt;span style="color:#960050;background-color:#1e0010"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; set ipcp ranges 0.0.0.0/0 0.0.0.0/0&lt;span style="color:#960050;background-color:#1e0010"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#960050;background-color:#1e0010"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; create link static L1 pppoe&lt;span style="color:#960050;background-color:#1e0010"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; set link action bundle B1&lt;span style="color:#960050;background-color:#1e0010"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; set auth authname isp_username@open.telekom.rs&lt;span style="color:#960050;background-color:#1e0010"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; set auth password isp_password&lt;span style="color:#960050;background-color:#1e0010"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; set link max-redial 0&lt;span style="color:#960050;background-color:#1e0010"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; set link keep-alive 10 60&lt;span style="color:#960050;background-color:#1e0010"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; set pppoe iface re0&lt;span style="color:#960050;background-color:#1e0010"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; set pppoe service &amp;#34;&amp;#34;&lt;span style="color:#960050;background-color:#1e0010"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; open&lt;span style="color:#960050;background-color:#1e0010"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;/etc/pf.conf&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-md" data-lang="md"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;# Macros and tables&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ext_if = &amp;#34;ng0&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;modem_if = &amp;#34;re0&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;modem = 192.168.100.1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;# Options&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;set block-policy drop&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;set skip on lo0&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;# Normalization&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;scrub in all&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;# NAT&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;nat on $ext_if inet from lan:network to any -&amp;gt; ($ext_if)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;nat on $modem_if inet from lan:network to any -&amp;gt; ($modem_if)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;# Quick rules&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;antispoof quick for ($ext_if)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;anchor &amp;#34;blacklistd/*&amp;#34; in on $ext_if&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;# Rules&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;block in log on $ext_if&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;pass out&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;pass proto tcp to any port ssh&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;pass proto { icmp, igmp, icmp6 }&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The default prefix is 64, so the configuration is short. Note that you can use&#10;two forms to assign value to an attribute: attribute#value which is the same as&#10;attribute=&amp;ldquo;value&amp;rdquo;.&lt;/p&gt;&#10;&lt;p&gt;/etc/rtadvd.conf&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-md" data-lang="md"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;lan:addr=&amp;#34;2001:aaaa:bbbb:cccc::&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;In jail DHCP for IPv4 is running with the following configuration in&#10;/usr/local/etc/dhcpd.conf:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-md" data-lang="md"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;server-identifier my.domain.tld;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;authoritative;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;log-facility local7;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;omapi-port 7911;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;subnet 172.16.0.0 netmask 255.255.255.0 {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; option domain-name &amp;#34;my.domain.tld&amp;#34;;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; option domain-name-servers 172.16.0.254;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; range 172.16.0.1 172.16.0.200;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; option routers 172.16.0.254;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; option broadcast-address 172.16.0.255;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; default-lease-time 3600;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; max-lease-time 7200;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; on commit {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; set clientIP = binary-to-ascii(10, 8, &amp;#34;.&amp;#34;, leased-address);&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; set clientHost = pick-first-value(option fqdn.hostname, option host-name, &amp;#34;&amp;#34;);&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; execute(&amp;#34;/usr/local/bin/dhcpd-hook.sh&amp;#34;, &amp;#34;add&amp;#34;, clientIP, clientHost, &amp;#34;my.domain.tld&amp;#34;);&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; }&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; on release {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; set clientIP = binary-to-ascii(10, 8, &amp;#34;.&amp;#34;, leased-address);&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; set clientHost = pick-first-value(option fqdn.hostname, option host-name, &amp;#34;&amp;#34;);&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; execute(&amp;#34;/usr/local/bin/dhcpd-hook.sh&amp;#34;, &amp;#34;delete&amp;#34;, clientIP, clientHost, &amp;#34;my.domain.tld&amp;#34;);&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; }&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; on expiry {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; set clientIP = binary-to-ascii(10, 8, &amp;#34;.&amp;#34;, leased-address);&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; set clientHost = pick-first-value(option fqdn.hostname, option host-name, &amp;#34;&amp;#34;);&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; execute(&amp;#34;/usr/local/bin/dhcpd-hook.sh&amp;#34;, &amp;#34;delete&amp;#34;, clientIP, clientHost, &amp;#34;my.domain.tld&amp;#34;);&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; }&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The configuration could be much smaller without hooks, but this way you have&#10;enough information how I register jails in DNS. This part will be detailed on&#10;&lt;a href="cbsd.io"&gt;cbsd.io&lt;/a&gt;.&lt;/p&gt;&#10;&lt;h2 id="laptop"&gt;&#10; Laptop&#10;&lt;/h2&gt;&#10;&lt;p&gt;It&amp;rsquo;s important to set wlan0 MAC address to be the same as your ethernet. In my&#10;case it is em0. For some reason, rtsold which comes with the FreeBSD base&#10;doesn&amp;rsquo;t work stable and my current workaround is to add &lt;code&gt;ipv6_defaultrouter&lt;/code&gt;.&#10;It does kinda defeat the purpose of software called &amp;ldquo;router advertisement&amp;rdquo;, but&#10;until &lt;a href="https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=261129"&gt;this bug&lt;/a&gt; is&#10;resolved, it is good enough for me, as I have small number of machines. You&#10;might think I could use dhcpcd for IPv4 and IPv6, but there&amp;rsquo;s a problem with&#10;that: no matter how I configure jails, they just can&amp;rsquo;t get IPv6 when I&amp;rsquo;m using&#10;dhcpcd on the host. More on that in a later post.&lt;/p&gt;&#10;&lt;p&gt;/etc/rc.conf:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-ini" data-lang="ini"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Network&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;cloned_interfaces&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;lagg0&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;wlans_iwn0&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;wlan0&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ifconfig_wlan0&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;ether f0:de:bb:aa:c2:2a WPA up&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ifconfig_em0&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;up&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;create_args_wlan0&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;country US regdomain FCC&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ifconfig_lagg0&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;laggproto failover laggport em0 laggport wlan0 DHCP&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ifconfig_lagg0_ipv6&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;inet6 -ifdisabled accept_rtadv auto_linklocal&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;gateway_enable&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;YES&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ipv6_gateway_enable&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;YES&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ipv6_defaultrouter&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;2001:aaaa:bbbb:cccc::3&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h1 id="server"&gt;&#10; Server&#10;&lt;/h1&gt;&#10;&lt;p&gt;On server I like to set static IPv4 and IPv6 addresses.&lt;/p&gt;&#10;&lt;p&gt;/etc/rc.conf:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-ini" data-lang="ini"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ifconfig_igb0&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;inet 192.168.111.201 netmask 255.255.255.0&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ifconfig_igb0_ipv6&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;inet6 2001:aaaa:bbbb:cccc::4 -ifdisabled auto_linklocal&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ipv6_defaultrouter&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;fe80::5a9c:fcff:fe10:6c2c%igb0&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;defaultrouter&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;192.168.111.254&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Not that &amp;ldquo;%igb0&amp;rdquo; means something like &amp;ldquo;search for this link-local address on&#10;igb0 interface&amp;rdquo;.&lt;/p&gt;&#10;&lt;p&gt;&lt;a href="https://meka.rs/blog/2022/01/22/freebsd-dual-stack-jails/"&gt;Next&lt;/a&gt;&lt;/p&gt;&#10;</description></item><item><title>FreeBSD and IPv6 Tunnel</title><link>https://meka.rs/blog/2021/12/19/freebsd-and-ipv6-tunnel/</link><pubDate>Sun, 19 Dec 2021 21:48:00 +0000</pubDate><guid>https://meka.rs/blog/2021/12/19/freebsd-and-ipv6-tunnel/</guid><description>&lt;p&gt;Huricane Electric is one of IPv6 tunnel providers and this post is specifically&#10;about setting up FreeBSD router with a tunnel and the configuration for IPv6&#10;autoconfig caller Router Advertisment (RS, on the router) and Router Solisticion&#10;(RS, on desktop or laptop). If you know how DHCP for IPv4 works, you will find&#10;it a bit weird how IPv6 works. First, in IPv6 world what is called DHCPv6 is&#10;closer to what DHCPv4 does than RA/RS. Here, RA/RS setup will be described. The&#10;end result is that router and clients have access to IPv4 and IPv6 at the same&#10;time, or in how it&amp;rsquo;s called &amp;ldquo;Dual Stack&amp;rdquo;.&lt;/p&gt;&#10;&lt;h3 id="router"&gt;&#10; Router&#10;&lt;/h3&gt;&#10;&lt;p&gt;Although Huricane Electric will give you exact commands/config for operating&#10;system of your choice, I&amp;rsquo;m showing here whole configuration for completeness.&#10;The address range &lt;code&gt;fd12:c09a:85be:4851::&lt;/code&gt; is just a dummy one, you should use&#10;the one HE provides.&lt;/p&gt;&#10;&lt;p&gt;In /etc/rc.conf:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ifconfig_re1&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;up&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ifconfig_re2&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;up&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ifconfig_bridge1_name&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;lan&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ifconfig_lan&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;addm re1 addm re2 addm wlan0 stp re1 stp re2 stp wlan0&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ifconfig_lan_alias0&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;inet 192.168.0.1 netmask 255.255.255.0&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ifconfig_lan_ipv6&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;inet6 fd12:c09a:85be:4851::3 auto_linklocal -ifdisabled&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# HE IPv6 tunnel&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;gif_interfaces&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;gif0&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;gifconfig_gif0&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;&amp;lt;MyIPv4&amp;gt; &amp;lt;HEIPv4&amp;gt;&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ifconfig_gif0_ipv6&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;inet6 fd12:c09a:85be:4851::2 fd12:c09a:85be:4851::1 prefixlen 128&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ipv6_defaultrouter&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;fd12:c09a:85be:4851::1&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;In /etc/rtadvd.conf:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;lan:&lt;span style="color:#ae81ff"&gt;\&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; :addrs#1&lt;span style="color:#ae81ff"&gt;\&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; :addr&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;fd12:c09a:85be:4851::&amp;#34;&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;\&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; :prefixlen#64&lt;span style="color:#ae81ff"&gt;\&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; :tc&lt;span style="color:#f92672"&gt;=&lt;/span&gt;ether&lt;span style="color:#ae81ff"&gt;\&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; :rltime#0&lt;span style="color:#ae81ff"&gt;\&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; :rdnss&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;fd12:c09a:85be:4851::3&amp;#34;&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;\&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; :dnssl&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;meka.rs&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;In /etc/rc.conf.d/rtadvd:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;rtadvd_enable&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;YES&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;rtadvd_interfaces&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;lan&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="desktoplaptop"&gt;&#10; Desktop/Laptop&#10;&lt;/h3&gt;&#10;&lt;p&gt;In /etc/rc.conf:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cloned_interfaces&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;lagg0&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;wlans_iwn0&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;wlan0&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ifconfig_wlan0&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;ether f0:de:f1:64:2c:3b WPA up&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ifconfig_em0&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;up&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;create_args_wlan0&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;country US regdomain FCC&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ifconfig_lagg0&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;laggproto failover laggport em0 laggport wlan0 DHCP&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ifconfig_lagg0_ipv6&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;inet6 accept_rtadv -ifdisabled&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ipv6_defaultrouter&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;fd12:c09a:85be:4851::3&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;rtsold_enable&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;YES&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Configuration is based on&#10;&lt;a href="https://meka.rs/blog/2016/12/24/freebsd-wifi-and-ethernet-bridging-and-aggregation/"&gt;Router and Laptop on FreeBSD&lt;/a&gt;.&#10;It can be simplified if you use only wlan, which probably means you don&amp;rsquo;t need&#10;bridge at all hence you should configure wlan0, for example.&lt;/p&gt;&#10;</description></item><item><title>FreeBSD Audio</title><link>https://meka.rs/blog/2021/10/12/freebsd-audio/</link><pubDate>Tue, 12 Oct 2021 10:00:00 +0000</pubDate><guid>https://meka.rs/blog/2021/10/12/freebsd-audio/</guid><description>&lt;p&gt;I started using FreeBSD in 2016 as a dual-boot with Linux. The reason was that&#10;at the time Linux provided no support for real-time threads and preemptive&#10;scheduling but did provide a wider choice of audio applications. Today, as the&#10;FreeBSD audio ecosystem improved a lot, I am a happy single-OS user.&lt;/p&gt;&#10;&lt;p&gt;You may ask yourself &amp;ldquo;why is being fast so important to audio&amp;rdquo; and the answer&#10;is &amp;ldquo;it isn&amp;rsquo;t most of the time&amp;rdquo;. To be more precise, from a listener&amp;rsquo;s&#10;perspective, it is the same if sound is late 5 seconds or 1 second, as long as&#10;the period of &amp;ldquo;being late&amp;rdquo; is the same for every sample up to a few&#10;microseconds. If samples have variable latencies, the original sound will be&#10;distorted by samples swinging around their precise time. So for playback, it&amp;rsquo;s&#10;not important to be fast, it&amp;rsquo;s important to be right on time for every sample&#10;to avoid distortions caused by samples being too early or too late, which is&#10;commonly called &amp;ldquo;jitter&amp;rdquo;.&lt;/p&gt;&#10;&lt;p&gt;On the other hand, a musician playing through a FreeBSD machine is interested&#10;in both: speed of processing and precision. We need to have in mind that all&#10;samples first have to be processed by hardware, then comes the driver and in&#10;the end user space programs. When every device&amp;rsquo;s output is late compared to&#10;input, that is called latency. If latency is 5ms and lower, it is impossible&#10;for most people to tell there&amp;rsquo;s any latency at all. Latency is important to&#10;musicians because of the feedback: hearing a sound that has 50ms latency can&#10;confuse the musician to a point where they can not play any more.&lt;/p&gt;&#10;&lt;p&gt;FreeBSD at the time had really nice real-time support but not so nice audio&#10;ecosystem and almost non-existing MIDI one. You must be wondering why I&#10;switched to something half-baked when Linux at the same time had awesome&#10;audio/MIDI support. It&amp;rsquo;s those jitters.&lt;/p&gt;&#10;&lt;p&gt;Although I had every program I could wish for on Linux, FreeBSD simply didn&amp;rsquo;t&#10;have jitters, and it matters a lot! Sometimes jitters would cause sudden and&#10;loud pops and that made studio recording more challenging. So having FreeBSD&#10;working perfectly, but unfortunately with not so much app support, was better&#10;for me than having all the apps I want and no way of being sure the sound will&#10;be recorded properly.&lt;/p&gt;&#10;&lt;p&gt;Today we have a different situation thanks to Hans Peter Selasky who wrote&#10;cuse, virtual_oss, USB stack and snd_uaudio and Yuri who ported around 1500&#10;applications to FreeBSD, among which is a huge number of audio/MIDI apps. To be&#10;honest, virtual_oss existed in 2016, but it wasn&amp;rsquo;t as versatile and stable as&#10;today. The reason why anyone would want virtual_oss is to make audio routing&#10;easy by having a virtual sound card which knows how to route the signal while&#10;user space applications are unaware of it and they just use FreeBSD sound(4)&#10;API. There are numerous other features of virtual_oss that can come handy like&#10;mixing, compressing and EQ in user space, but audio routing and&#10;splitting/merging one card to many virtual ones or combining input and output&#10;from different devices is the most common use case, like having bluetooth&#10;headphones and USB microphone, so virtual_oss is required more and more outside&#10;of recording studio and high-end sound setups.&lt;/p&gt;&#10;&lt;p&gt;One sound system must contain an API to work with audio, MIDI and mixer. Open&#10;Sound System (or OSS for short) on FreeBSD is no exception to this rule, so&#10;there are 3 most common devices for every API: /dev/dsp, /dev/midi and&#10;/dev/mixer. The most basic usage for /dev/dsp is to open(2) it, use ioctl(2) to&#10;configure sample rate and format and then use read(2) and write(2) for&#10;recording and playback. It is somewhat similar for /dev/midi, but /dev/mixer is&#10;all about control and no samples, so it mostly uses ioctl(2) to operate. As&#10;every system needs metadata, /dev/sndstat is used for OSS. If you &lt;code&gt;cat /dev/sndstat&lt;/code&gt;, you can find some information about your DSP and PCM devices.&#10;You can use &lt;code&gt;sysctl hw.snd.verbose=2&lt;/code&gt; to get even more information out of&#10;/dev/sndstat. Parsing this file as text is the only way to get the list of your&#10;sound devices that works across multiple FreeBSD versions. Ka Ho Ng used this&#10;technique in patch for cubeb, which is a sound library used by Mozilla, hence&#10;adding OSS and virtual_oss support to Firefox and other products by Mozilla.&#10;Today Ka Ho Ng is FreeBSD developer who implemented nvlist(9) based API to&#10;enumerate devices, or in simple terms: list hardware and virtual sound devices&#10;using nice API.&lt;/p&gt;&#10;&lt;p&gt;User space applications and libraries are growing and apps that I would like to&#10;mention that have been ported to FreeBSD are Ardour, Muse Sequencer, Zrythm,&#10;Drumgizmo, EQ10Q, Calf and Invada plugins. I use most of those in my studio on&#10;a regular basis and I have to admit I&amp;rsquo;m impressed how stable they work given&#10;that most developers did not develop with FreeBSD in mind.&lt;/p&gt;&#10;&lt;p&gt;Today in a studio, snd_uaudio and ports/packages will cover 99% of everyone&amp;rsquo;s&#10;needs. Few years back I talked to Benedict Reuschiling and he said &amp;ldquo;we never&#10;advocated FreeBSD for audio before&amp;rdquo;, so I&amp;rsquo;m sure everyone in the community is&#10;happy with advancements made in just a few years. I keep mentioning studio&#10;setups as they are more complex and demanding, but what about laptops and&#10;desktops whose sole purpose is not audio? That&amp;rsquo;s the beauty of FreeBSD audio&#10;and virtual_oss: if it works for complex setup, it works even better for simple&#10;one. All sample rate and format is taken care of per application while&#10;virtual_oss itself knows how to use real-time threads. Ideally, all that is&#10;needed is OSS support in applications.&lt;/p&gt;&#10;&lt;p&gt;For FreeBSD audio and DSP developers the situation is becoming increasingly&#10;better through newer APIs and more convenient development environments. For&#10;example, it is already possible to do all your development in jail if that jail&#10;has access to proper /dev/dspN. To achieve that following /etc/devfs.rules can&#10;be used:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;[&lt;/span&gt;audio&lt;span style="color:#f92672"&gt;=&lt;/span&gt;6&lt;span style="color:#f92672"&gt;]&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;add include $devfsrules_hide_all&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;add include $devfsrules_unhide_basic&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;add include $devfsrules_unhide_login&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;add path &lt;span style="color:#e6db74"&gt;&amp;#39;dsp*&amp;#39;&lt;/span&gt; unhide mode &lt;span style="color:#ae81ff"&gt;0666&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;add path &lt;span style="color:#e6db74"&gt;&amp;#39;vdsp*&amp;#39;&lt;/span&gt; unhide mode &lt;span style="color:#ae81ff"&gt;0666&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;add path &lt;span style="color:#e6db74"&gt;&amp;#39;*midi*&amp;#39;&lt;/span&gt; unhide mode &lt;span style="color:#ae81ff"&gt;0666&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;add path &lt;span style="color:#e6db74"&gt;&amp;#39;mixer*&amp;#39;&lt;/span&gt; unhide mode &lt;span style="color:#ae81ff"&gt;0666&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;add path &lt;span style="color:#e6db74"&gt;&amp;#39;sndstat&amp;#39;&lt;/span&gt; unhide mode &lt;span style="color:#ae81ff"&gt;0666&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;That is not new for FreeBSD, but it does bring one interesting use case:&#10;running tests inside jail. To do just that maybe it means you would hear weird&#10;sounds on your speakers when all you wanted is an end-to-end test of your audio&#10;application. Virtual_oss has different backends where hardware DSP is just one&#10;of them. Another example of backend is dummy, which allows virtual_oss to run&#10;without connection to any real hardware. To do that you can configure&#10;/etc/rc.conf in the following way:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;virtual_oss_enable&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;YES&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;virtual_oss_configs&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;dsp dummy&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;virtual_oss_dsp&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;-T /dev/sndstat -S -i 8 -C 18 -c 18 -r 48000 -b 32 -s 768 -f /dev/dsp0 -c 2 -w dsp.wav -d dsp -t dsp.ctl&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;virtual_oss_dummy&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;-T /dev/sndstat -S -i 8 -C 2 -c 2 -r 48000 -b 32 -s 768 -f /dev/null -c 2 -w vdsp.wav -d vdsp -t vdsp.ctl&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;There are two configs that are fairly similar. For dsp, one device with 18&#10;in/out channels is configured as /dev/dsp which have 2 channels. Also, the 2&#10;channel device is set as /dev/dsp which is the default OSS device, so&#10;applications which do not handle non-stereo cards will have no problems.&lt;/p&gt;&#10;&lt;p&gt;For those apps that know how to list sound devices and use channels properly&#10;/dev/vdsp is at their disposal. One unusual device is /dev/dsp.wav which you&#10;can use for recording just by using &lt;code&gt;cat /dev/dsp.wav &amp;gt;recording.wav&lt;/code&gt;. To&#10;control virtual_oss at runtime you can use &lt;code&gt;virtual_oss_ctl -f /dev/vdsp.ctl&lt;/code&gt;.&#10;The previous example creates one .ctl device file per virtual_oss&#10;configuration. Second configuration is a dummy and it uses /dev/null as a&#10;hardware device to achieve most of what dsp config is doing, only simpler. It&#10;creates only one device and that is /dev/vdsp.dummy which is stereo only. It&#10;uses the same resampling (-S), real-time priority (-i 8), sample rate (-r&#10;48000), bit rate (-b 32) and buffer size (-s 768) as dsp config while creating&#10;similar .wav and .ctl devices.&lt;/p&gt;&#10;&lt;p&gt;Now you can use /dev/dsp and /dev/vdsp inside or outside of jail to have either&#10;a real hardware device or purely virtual one. All of those flags can be changed&#10;at runtime with &lt;code&gt;virtual_oss_cmd&lt;/code&gt;. You can switch to &amp;ldquo;studio mode&amp;rdquo; as I call it&#10;(smaller buffer size), do your recording/production and then switch to &amp;ldquo;desktop&#10;mode&amp;rdquo; with larger buffer. Do note that virtual_oss can change buffer size on&#10;start as most applications using OSS API will read desired buffer size once, on&#10;initialization. Almost all flags supported by virtual_oss are also changeable&#10;during runtime via virtual_oss_cmd. Developer or not, all people sometimes need&#10;to switch their default input/output device so it is really handy in everyday&#10;use, too. Now if you need ALSA or SNDIO development inside that same jail, it&amp;rsquo;s&#10;just a matter of installing ports/packages and altering configuration to your&#10;liking (default sound device, for example).&lt;/p&gt;&#10;&lt;p&gt;Let&amp;rsquo;s see what studio means in technical terms. Core of every studio is a mixer&#10;and today&amp;rsquo;s mixers are usually also USB audio interfaces. For live performance&#10;and monitoring, mixer is where it all happens. For recording and&#10;(post)processing, the computer is doing it all. The description of the mixer&#10;and operating one is dependent on the model so I won&amp;rsquo;t cover it here, but the&#10;recording part is where FreeBSD shines.&lt;/p&gt;&#10;&lt;p&gt;Besides having architecture that allows for real time threads and less jitters&#10;(to be honest, using it for years I never saw any jitters at all!), it is&#10;really nice having storage feature like ZFS to make sure your recordings are&#10;safe. As with a big number of channels user space mixing and resampling is more&#10;efficient then the one in the kernel so virtual_oss and OSS provide an ideal&#10;combination. The core of every recording system is Digital Audio Workstation,&#10;or DAW for short. In my studio, the DAW of choice is Ardour. It is mature and&#10;stable and has great integration with JACK. For the set of effects I use Calf,&#10;Invada and EQ10Q plugins as they provide good implementations of reverbs,&#10;choruses, equalizers and flangers. My choice of drum sampler is Drumgizmo, but&#10;it&amp;rsquo;s no wonder being a contributor to the project and port maintainer. Drumgizmo&#10;is unique in a way that it records and plays samples (drum hits). The idea is to&#10;replicate a studio recording as close as possible, so its principle is to have,&#10;for example, a snare drum recorded with all 16 microphones. Although the&#10;microphone in the kick drum will record the snare hit very faintly, having all&#10;16 microphones record every hit makes the recording sound like a live studio.&#10;Recording with a non-main microphone is called bleeding and is controllable in&#10;Drumgizmo. Bleed and humanizer (randomizing hit strength, timing and position&#10;on the pad/cymbal) make recording sound very natural. I personally use hardware&#10;guitar/bass/vocal processor and synth, so I&amp;rsquo;m not experienced with software&#10;alternatives, but I do know some of my friends really like Geon Kick and&#10;Yoshimi for electronic music and Guitarix for guitar based music.&lt;/p&gt;&#10;&lt;p&gt;For me the hardware mixer is doing most of the audio routing and monitoring,&#10;but for USB audio interfaces that are not stand-alone, software has to do it.&#10;Usually, one would do routing based on JACK and it is a valid option, but with&#10;virtual_oss there&amp;rsquo;s another one. Let me give you an example. In the past I used&#10;USB audio interfaces that are not stand-alone and what I constantly have as a&#10;requirement that the first input (my guitar) is routed to outputs 9 and 10 (my&#10;guitar processor). To achieve this, you can add &amp;ldquo;-M i,0,8,0,0,0 -M i,0,9,0,0,0&amp;rdquo;&#10;to virtual_oss options. Note that channel numbers start with zero. There are&#10;also interfaces that have separate main output for speakers and headphones. For&#10;monitoring it is not so great so if you&amp;rsquo;d like to mirror everything that goes&#10;to speakers (output 1 and 2) to headphones (outputs 7 and 8), you can use &amp;ldquo;-M&#10;o,0,6,0,0,0 -M o,1,7,0,0,0&amp;rdquo;. The options virtual_oss alone supports give you&#10;the ability to have EQ, compressor, loop back, HTTP streaming and more, but it&#10;would be too much for this article to describe it all. Man page contains all&#10;options and examples of how you can achieve different setups.&lt;/p&gt;&#10;&lt;p&gt;If you think there&amp;rsquo;s not much that FreeBSD brings to the table in the audio&#10;world, you&amp;rsquo;re right and wrong at the same time. What the operating system can&#10;do in terms of audio is provide real time support, efficient resampling and&#10;good choice of open source DAWs and plugins. But that is true only if you use&#10;that computer exclusively for music.&lt;/p&gt;&#10;&lt;p&gt;I believe that general purpose operating systems must be general enough to be&#10;the choice for any task and that is where FreeBSD shines: with jails,&#10;firewalls, virtual switches, ZFS, packages that are up to date, security&#10;updates and all the person would expect from an operating system. FreeBSD&#10;provides it all while being great for music, so with it power is literally&#10;under your fingertips.&lt;/p&gt;&#10;&lt;p&gt;If you think about it, MacOS and Windows are mostly desktop operating systems,&#10;Linux lacking proper ZFS support/integration hardly makes it good for storage,&#10;Solaris is too huge for a router and other BSDs probably don&amp;rsquo;t have the number&#10;of audio ports that FreeBSD has. So to put it short, FreeBSD shines at not&#10;needing anything particular: no special care needed wherever you run it and&#10;whatever combination of apps you choose.&lt;/p&gt;&#10;&lt;p&gt;Call me stubborn, but having one operating system on a router, server, desktop,&#10;laptop and RPi is a big deal for me, especially if it solves all my problems on&#10;any hardware I put it on. For reference, my desktop machine in the studio is a&#10;12 year old i5 PC with 8GB of RAM which I also use for Python/React/C/C++&#10;development and most of that development is in jails.&lt;/p&gt;&#10;&lt;p&gt;What I&amp;rsquo;m trying to say is that FreeBSD gives you means to run literally&#10;everything on one machine while not sacrificing any efficiency.&lt;/p&gt;&#10;&lt;p&gt;So to put it really short, FreeBSD is great for audio studio not because it&#10;brings some unseen features, but because it does not collide with anything on&#10;the system while providing real time support, so the feeling is &amp;ldquo;this is just a&#10;normal desktop with audio apps&amp;rdquo;. Maybe it doesn&amp;rsquo;t sound too good, but just&#10;having &amp;ldquo;normal desktop&amp;rdquo; and &amp;ldquo;real time support&amp;rdquo; in one operating system is far&#10;from usual, and FreeBSD might be the only operating system not explicitly built&#10;for real time but able to provide that.&lt;/p&gt;&#10;&lt;p&gt;I have to say, the best quality of FreeBSD is our community. It is so easy to&#10;get to the right answer with the mailing list like multimedia@ and #freebsd&#10;channel on libera.chat. My personal experience is that the FreeBSD community is&#10;open and approachable. There are no distro-specific questions, the handbook is&#10;for FreeBSD and not just one of the FreeBSD forks/distributions. Developers are&#10;approachable by people who often are not sure what they need to ask in the&#10;first place. In one word, getting the proper information feels really easy and&#10;proper audio setup in a studio is a breeze using this operating system.&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;Note: when using jack configure it to use the real hardware. That means /dev/dsp1&#10;that is OSS device (in my case with 18 channels) instead of /dev/dsp which is&#10;virtual_oss device (in my case with 2 channels).&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;The work from Ka Ho Ng is in base and jack2 port is available&#10;(&lt;a href="https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=251125"&gt;bugzilla 251125&lt;/a&gt;)&#10;mostly thanks to Florian Walpen. My review (&lt;a href="https://reviews.freebsd.org/D30149"&gt;D30149&lt;/a&gt;)&#10;added a simple example of OSS development and is just the first of OSS examples&#10;to follow. One oftenly requested improvement to the handbook is the section&#10;of sound and audio. Alfonso Siciliano has great experience with mixer API&#10;and has contributed mixertui port and has offered help in understanding that&#10;code for future documentation purposes. Maolan is DAW (digital audio workstation)&#10;which is FreeBSD specific for now that I&amp;rsquo;m writing as an attempt to learn DSP&#10;and MIDI development and is the code where most of my experience/documentation&#10;comes from. While I do appreciate software like jack, I strongly believe that&#10;FreeBSD should have a DAW with native API supported out of the box, so I&amp;rsquo;m hoping&#10;that Maolan will improve FreeBSD based studios once it&amp;rsquo;s at least beta. Also,&#10;making APIs nicer to work with and documentation/examples better is what we as&#10;FreeBSD community must do if we want developers on other operating systems to be&#10;more portable and FreeBSD friendly. Over the past few years the community showed&#10;more interest in that area than I could ever imagine, so I am really grateful&#10;for being able to use a 12 year old desktop for everything including studio&#10;recording, web conferencing and development with nothing but FreeBSD and&#10;ports/packages it provides and no extra repositories.&lt;/p&gt;&#10;</description></item><item><title>Ne mogu vise da ćutim</title><link>https://meka.rs/blog/2021/05/02/ne-mogu-vise-da-%C4%87utim/</link><pubDate>Sun, 02 May 2021 16:30:00 +0000</pubDate><guid>https://meka.rs/blog/2021/05/02/ne-mogu-vise-da-%C4%87utim/</guid><description>&lt;p&gt;Ne pišem na srpskom iz prostog razloga: želim da me što više ljudi razume.&#10;Međutim, ono što me tišti su neki ljudi odavde i ako ikada nabasaju na ovaj&#10;post želim da ga dobro razumeju. Pošto nemam plan pisanja, možda će biti o&#10;jednoj, možda o više osoba, ali svakako želim da budem iskren sa sobom i sa&#10;drugima šta ja o tim osobama mislim i zašto to mislim. Razlog zašto pišem tek&#10;sada posle godina problema sa tim osobama je što sam mislio da je OK oprostiti,&#10;ali psiha me je dovela do grčenja mišića (da budem precizan, grče mi se listovi)&#10;te ne vidim drugi izlaz nego da to pustim iz sebe. Pa da počnem &amp;hellip;&lt;/p&gt;&#10;&lt;p&gt;Skoro sve osobe o kojima bih ovde želeo da pišem su profesori. To je tužno.&#10;Samo kad pomislim koga mi kao društvo puštamo da se šeta među decom/omladinom&#10;je bolesno, u najmanju ruku. Ali sada ne želim da pričam o društvu, želim da&#10;pričam o jednoj specifičnoj osobi. Ta osoba je&#10;&lt;a href="https://perun.pmf.uns.ac.rs/wiki/mirjana-ivanovic"&gt;Mirjana Ivanović&lt;/a&gt;. Ukratko,&#10;žena je glupa i bezobrazna i izdržati fakultet sa njom je bilo katastrofalno.&#10;Ako obratite pažnju na temu njenog magistarskog (što je ujedno i predmet koji&#10;je predavala i to očajno) je konstrukcija kompajlera. Postoje 2 razloga zašto&#10;mi nije ogadila taj predmet: skripta iz koje smo učili nije njena i ja sam bio&#10;očaran time kako kompajler radi. Za one koji nisu toliko sreće imali da ih&#10;kompajleri toliko privlače, Mira je bez sumnje ubila makar i tračak nade u tim&#10;ljudima da ona priča nešto pametno. Iz tog predmeta mi je dala 9 jer &amp;ldquo;nije to&#10;to&amp;rdquo;. Zapravo, pre nego što mi je ponudila 9 bilo je par sranja koje je&#10;napravila. Prvo mi je postavila pitanje koje ne postoji u skripti (iz koje ona&#10;predaje i podsećam, na predmetu koji je magistrirala). Drugo, dok sam pričao&#10;na tabli šta znam, u jednom momentu sam stao jer je pričala sa kolegom koji je&#10;bio na tabli pre mene. Kako sam pomislio da me ne čuje i ne prati, odlučio sam&#10;da sačekam, na šta je ona rekla &amp;ldquo;žene mogu da rade 3 stvari u isto vreme, a ja&#10;evo slušam vas, slušam kolegu i upisujem mu ocenu&amp;rdquo;. Koje proseravanje, nisam&#10;mogao da poverujem, jer ako neko priča nešto na pola metra od vas, a neko drugi&#10;na 5 metara, vi onog drugog ne čujete zbog decibela ne zbog intelekta. Ne znam&#10;šta mi je bilo, ali ja sam u tom momentu počeo da se smejem ko budala, jer taj&#10;komentar drugo ništa nije ni zaslužio. Kad me je pitala šta je smešno rekao sam&#10;da njen muž kad nam predaje neku baš tešku lekciju kaže &amp;ldquo;ova je baš muška&amp;rdquo;.&#10;Možda ćete pomisliti da nisam baš morao tako da reagujem, ali em sam rekao&#10;apslutnu istinu, em je ta moja izjava usledila nakon jedno 6 godina njenog&#10;izdrkavanja. Te naredi asistentu da poobara studente tako da nema više od 5oro&#10;na ispitu, te moram da se raspravljam sa njom da &amp;ldquo;jne&amp;rdquo; u asembleru znači &amp;ldquo;jump&#10;if not equal&amp;rdquo; jer kako je ona objasnila, &amp;ldquo;jne&amp;rdquo; je suprotno od onoga što jeste,&#10;te imamo ceo semestar predavanje o Modula-2 (jebem ti kompajler i koji izabraše,&#10;tuljani glupi) na kome saznamo da ništa od toga neće biti na ispitu, nego da&#10;ćemo odrađivati neke časove (odrađivanje na fakultetu, eeeee bre!) na kojima će&#10;biti zadaci za ispit. Tih časova je bilo 2. Slovima: dva!!! Onda nam je&#10;objašnjavala kako treba čovek da se požrtvuje za firmu i ako je tvom detetu&#10;rođendan da treba da ga iskuliraš ako firmi treba prekovremeno. Ne samo to,&#10;nego je godinu dana pre toga pričala kako sa profesorom koji piše raspored su&#10;se ona i muž dogovorili da je raspored takav da uvek jedan od roditelja može&#10;biti sa decom. Ljudi su pisali radove koje je ona kao zadnja kučka predavala&#10;kao svoje ne potpisavši nikog od tih ljudi. To je jedna glupa, licemerna,&#10;nadasve bezobrazna i plitka osoba. Sada kada mi ne predaješ više ništa, Miro&#10;majku i oca krvave ti jebem za ona obaranja &amp;ldquo;fali ti zarez&amp;rdquo;. Želim ti da ti&#10;zafali deci na svakom koraku uz nečije debilno objašnjenje &amp;ldquo;zato što ja tako&#10;kažem&amp;rdquo;.&lt;/p&gt;&#10;&lt;p&gt;Drugi po redu je &lt;a href="https://people.dmi.uns.ac.rs/~djura/"&gt;Đura Paunić&lt;/a&gt;. Kako je&#10;premator, valjda je odjebao više sa fakulteta pa ga nešto i nema po sajtu&#10;previše. Zapravo ima&#10;&lt;a href="https://www.pmf.uns.ac.rs/wp-content/uploads/2017/03/MDS31-1.pdf"&gt;nekih pomena&lt;/a&gt;&#10;njegovih govana, kao što je knjiga prepuna grešaka koju nikad u svojoj karijeri&#10;nije ispravio ne bi li ljudi bili primorani da dolaze na predavanja da bi čuli&#10;ispravke njegovih brljotina. A predavanje go kurac: prepisuje iz knjige na&#10;tablu. Ispit koji se zove &amp;ldquo;Strukture podataka i algoritmi&amp;rdquo; iliti &amp;ldquo;najbitnije&#10;što jedan programer može znati&amp;rdquo; sam pisao na papiru i čak i kad sam ga položio&#10;nisam stigao da napišem sve što znam. Razlog za to je što su zadaci iz doba&#10;Tjuringa i ništa iz te knjige se ne koristi više na taj način a student treba u&#10;svakom momentu da drži u glavi 9 pokazivača i da zna gde pokazuju. Ako ste ikad&#10;išta programirali, znate da je to nemoguće. Naravno, kao i smrdljiva Mira, Đura&#10;je imao praksu &amp;ldquo;nemoj da mi je previše studenata prošlo&amp;rdquo;. Eksplicitno sam pitao&#10;njegove asistente da li je on ikada programirao i svi do jednog su rekli&#10;&amp;ldquo;apsolutno ne&amp;rdquo;. To znači da je matora izdrkotina pričala neke budalaštine koje&#10;smo mi trebali da naučimo napamet. Pride, još me je njegov asistent, Pešović,&#10;čiji link isto ne mogu da nađem, oborio na &amp;ldquo;nije kao u knjizi&amp;rdquo;. Upljuvah se ja&#10;da objasnim kako je moj algoritam i brži i manje memorije zauzima i daje tačan&#10;rezultat. Na kraju sam ga oterao u pičku materinu i kad me je pitao šta sam&#10;rekao &amp;ldquo;to što si čuo&amp;rdquo;. Kontao sam u tom trenutku a evo i 20 godina kasnije kako&#10;ja kod tog debilka ionako nikad neću položiti, pa što da mu se ne najebem majke.&#10;Kada sam pao i drugi put taj ispit koji jebeno znam, rekao sam sebi da ako ne&#10;položim treći put, idem sa nožem na fakultet, stavljam ga Đuri pod grkljan i&#10;ako ne napiše ceo ispit za 3 sata, svinja će da bude preklana! Kako nisam u&#10;zatvoru, očigledno je da sam iz treće položio taj ispit. Đura je govno koje ni&#10;jednom studentu informatike neće nedostajati. Ako pak nađete takvog studenta,&#10;znate da ste našli isto govno kao i on sam što je, jer ko još može imati dobro&#10;mišljenje o profesoru koji ne zna da programira i predaje najbitniji&#10;programerski predmet osim jebeni licemer i dupelizac.&lt;/p&gt;&#10;&lt;p&gt;Ovo su samo neki od profesora koji su mi zadavali noćne more godinama i da&#10;želim da se zna kakvi su. Danas da im ide auto u sustret da ih pogazi, skoro pa&#10;sam siguran da bih ćutao! Nikada ne bih ubio nekog, ali ne mogu da vidim&#10;situaciju u kojoj bih ovima nešto pomogao ikada.&lt;/p&gt;&#10;</description></item><item><title>FreeBSD Upgrade Bootloader</title><link>https://meka.rs/blog/2021/04/16/freebsd-upgrade-bootloader/</link><pubDate>Fri, 16 Apr 2021 14:23:00 +0000</pubDate><guid>https://meka.rs/blog/2021/04/16/freebsd-upgrade-bootloader/</guid><description>&lt;p&gt;&lt;strong&gt;WARNING: Not tested on dual boot machines and probably doesn&amp;rsquo;t work&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;The recommended partitioning layout is to support BIOS and UEFI. The following&#10;is GPT partitioning (could be MBR in this simple example). Notice that the&#10;first two partitions are EFI and BIOS boot partitions. The EFI partition is&#10;nothing more than a FAT partition in most cases.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;gpart show&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&amp;gt; &lt;span style="color:#ae81ff"&gt;40&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;500118112&lt;/span&gt; ada0 GPT &lt;span style="color:#f92672"&gt;(&lt;/span&gt;238G&lt;span style="color:#f92672"&gt;)&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#ae81ff"&gt;40&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;532480&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt; efi &lt;span style="color:#f92672"&gt;(&lt;/span&gt;260M&lt;span style="color:#f92672"&gt;)&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#ae81ff"&gt;532520&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;1024&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;2&lt;/span&gt; freebsd-boot &lt;span style="color:#f92672"&gt;(&lt;/span&gt;512K&lt;span style="color:#f92672"&gt;)&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#ae81ff"&gt;533544&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;984&lt;/span&gt; - free - &lt;span style="color:#f92672"&gt;(&lt;/span&gt;492K&lt;span style="color:#f92672"&gt;)&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#ae81ff"&gt;534528&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;4194304&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;3&lt;/span&gt; freebsd-swap &lt;span style="color:#f92672"&gt;(&lt;/span&gt;2.0G&lt;span style="color:#f92672"&gt;)&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#ae81ff"&gt;4728832&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;495388672&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;4&lt;/span&gt; freebsd-zfs &lt;span style="color:#f92672"&gt;(&lt;/span&gt;236G&lt;span style="color:#f92672"&gt;)&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#ae81ff"&gt;500117504&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;648&lt;/span&gt; - free - &lt;span style="color:#f92672"&gt;(&lt;/span&gt;324K&lt;span style="color:#f92672"&gt;)&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To see current UEFI settings like which disk/partition/file is configured for&#10;booting, run the following:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;efibootmgr -v&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;BootCurrent: &lt;span style="color:#ae81ff"&gt;0019&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Timeout : &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt; seconds&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;BootOrder : 0019, 000A, 000C, 0006, 0007, 0008, 0009, 000B, 000D, 000E, 000F, 0010, 0011, 0012, &lt;span style="color:#ae81ff"&gt;0013&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;+Boot0019* FreeBSD HD&lt;span style="color:#f92672"&gt;(&lt;/span&gt;1,GPT,0a7e1ccc-8826-11eb-b711-f0def164c22a,0x28,0x82000&lt;span style="color:#f92672"&gt;)&lt;/span&gt;/File&lt;span style="color:#f92672"&gt;(&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;\e&lt;/span&gt;fi&lt;span style="color:#ae81ff"&gt;\f&lt;/span&gt;reebsd&lt;span style="color:#ae81ff"&gt;\l&lt;/span&gt;oader.efi&lt;span style="color:#f92672"&gt;)&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; ada0p1:/efi/freebsd/loader.efi &lt;span style="color:#f92672"&gt;(&lt;/span&gt;null&lt;span style="color:#f92672"&gt;)&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# A LOT OF LINES REMOVED&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Write disk (pmbr) and second partition (gptzfsboot) boot codes. If you&amp;rsquo;re using&#10;UFS instead of ZFS, change gptzfsboot to gptboot.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i &lt;span style="color:#ae81ff"&gt;2&lt;/span&gt; ada0&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# if not mounted, mount efi partition under /boot/efi&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# in my case, that&amp;#39;s adaop1, as efibootmgr reported&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cp /boot/loader.efi /boot/efi/efi/freebsd/loader.efi&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description></item><item><title>Serbia vs Internet</title><link>https://meka.rs/blog/2020/12/09/serbia-vs-internet/</link><pubDate>Wed, 09 Dec 2020 12:20:00 +0000</pubDate><guid>https://meka.rs/blog/2020/12/09/serbia-vs-internet/</guid><description>&lt;p&gt;Dear reader,&lt;/p&gt;&#10;&lt;p&gt;I really wish that you&amp;rsquo;re somewhere nice and you read this story with &amp;ldquo;in a&#10;land far away&amp;rdquo; at the beginning, wondering how strange we are. I really wish&#10;that place exists, because if we&amp;rsquo;re all and I mean ALL dealing with this, we&#10;screwed up as a global IT community.&lt;/p&gt;&#10;&lt;p&gt;This story starts 2.5 weeks ago when we decided to switch the Internet package we&#10;use. New one has 2 times download and 4 times upload compared to the old one, and&#10;why not. Also, we decided to take static IP so I don&amp;rsquo;t have to juggle dynamic&#10;DNS. It&amp;rsquo;s Monday, and we have to go to their office. It&amp;rsquo;s corona time, and we&#10;have to GO TO THE OFFICE!!! It&amp;rsquo;s even worse. We had to wait outside, it&amp;rsquo;s&#10;almost December at that time and I&amp;rsquo;m on northern hemisphere, so it&amp;rsquo;s fucking&#10;cold! We knew that it takes forever for any Serbian ISP to do anything, so my&#10;wife called, first, explaining what we want to do, so they wrote it down and&#10;said &amp;ldquo;just go to our office, show them your ID and it&amp;rsquo;s all done once you&#10;sign&amp;rdquo;. Ha! We fell for that again!? But yeah, it was shorter than without the&#10;preparation. The system didn&amp;rsquo;t work well, so it took eons to finish those&#10;papers. At the end the clerk said &amp;ldquo;I&amp;rsquo;ll send you an SMS once it&amp;rsquo;s done, so you&#10;don&amp;rsquo;t have to wait&amp;rdquo;. OK, so it took half eternity to do that and a few hours&#10;later we had a faster Internet. The fact is that with &lt;a href="https://mts.rs/"&gt;MTS&lt;/a&gt; you&#10;never know the speed of the Internet you&amp;rsquo;re signing for, because there is one&#10;speed declared on their site, one on their pamphlet and one printed out in&#10;their office. Of course, I&amp;rsquo;m talking about the same package! But OK, after&#10;speedtest you know what you have, and it&amp;rsquo;s 400/150MBit/s.&lt;/p&gt;&#10;&lt;p&gt;Now that was the easy part. Yeah, freezing my ass off was the easy part! Until&#10;tomorrow morning we didn&amp;rsquo;t get static IP no matter what I reset or reboot. I&#10;wrote them on the chat on their site and 30 minutes later, I have no Internet&#10;connection. The IP can not get more static than this, that&amp;rsquo;s for sure! I have&#10;no idea how many times we called, wrote to them, cried on twitter and whatnot.&#10;First support call came on Friday! I mean, by Friday you can have a heart&#10;operation, and it&amp;rsquo;s 4 days that it takes for MTS to even call (and ask for the&#10;imposibilionth time &amp;ldquo;what are the symptoms?&amp;rdquo;). Naturally, I didn&amp;rsquo;t wait for&#10;them to do something, I had better things to do. First, I noticed that when I&#10;restart their modem with factory settings, I can ping an IP for a short period&#10;after it boots. OK, so it means it connects, I have some connection, it fetches&#10;config from ISP server or wherever, loads it and all connections die. Now I know&#10;it&amp;rsquo;s not something physically broken, which would take a hell to freeze over&#10;before some ISP&amp;rsquo;s operator decided to go outside. Now all I need is admin&#10;user/pass to fix the modem config. Luckily, most providers here don&amp;rsquo;t practice&#10;security, so admin pass is&#10;&lt;a href="https://www.google.com/search?hl=en&amp;amp;q=mts%20password%20HG8245H"&gt;all over the Internet&lt;/a&gt;.&#10;As a security expert I should be advocating for this to change, but HELL NO! How&#10;am I going to fix their screw ups if they change all the passwords?&lt;/p&gt;&#10;&lt;p&gt;The Internet is back, and I notice their device can be configured in bridged mode.&#10;In the same WEB interface you have user/pass fields pre-filled, and you can see&#10;it&amp;rsquo;s PPPoE connection. Fine! Inspecting the pass element in the browser gave me what I&#10;thought is the password. Better looking at it, it had only numbers and letters&#10;A to F. Damn! I hoped it&amp;rsquo;s not hash, but here we are. One thousand calls later&#10;I&amp;rsquo;m talking to a guy who can actually give me a user/pass for PPPoE. In the meantime,&#10;waiting for them to find somebody who knows what I&amp;rsquo;m talking about I&#10;configured ppp.conf in FreeBSD. I know it&amp;rsquo;s a good config because the error I&#10;get is &amp;ldquo;wrong password&amp;rdquo;. Here is the part of that conversation:&lt;/p&gt;&#10;&lt;pre&gt;&#10;me: I need a PPPoE username and password&#10;him: Username is &amp;lt;username&amp;gt;&#10;me: ... and?&#10;him: That's it.&#10;me: If I give you a username for Facebook, can you login?&#10;me: There has to be more!&#10;him: Well, write this down (and he dictates my static IP)&#10;me: I already have that data, I need the password.&#10;him: telekom/telekom on 192.168.1.1&#10;me: That's your router and user/pass for it. I need a PPPoE password.&#10;me: P-P-P-O-E!!!&#10;him: I'll have to call you back.&#10;&#10;him: Your password is &amp;lt;curse in Serbian&amp;gt;&#10;me: I'm sure somebody was listening to my talks!&#10;&lt;/pre&gt;&#10;&lt;p&gt;By the way, he didn&amp;rsquo;t provide the whole username, because it&amp;rsquo;s in the form of&#10;&amp;lt;user&amp;gt;@open.telekom.rs (or something similar), but I didn&amp;rsquo;t care, it&amp;rsquo;s&#10;written in the WEB interface of an ISP device. Bridge mode, here I come! But damn, my&#10;speed is 40/40MBit/s. Looking around I found net/mpd5 and it got me to 200/150.&#10;OK, that&amp;rsquo;s nice! I read somewhere that igb has problems with PPPoE (something&#10;about not using all card&amp;rsquo;s queues). Luckily I have APU1 to replace that APU2.&#10;With APU1 now I have full speed. Hell yeah! But it&amp;rsquo;s not perfect, as AES-NI&#10;support in hardware came with APU2, so all VPNs will be slow. As a remedy for&#10;that, I can forward port to a home server and have a VPN concentrator there, but&#10;it&amp;rsquo;s not perfect.&lt;/p&gt;&#10;&lt;p&gt;Now we come to the fun part. One more reason why we need static IP is because&#10;IPv6 is a myth: everybody&amp;rsquo;s talking about it, but it can not be spotted in the&#10;wild. You know how your ISP is all nice and sweet when they need to push new&#10;technology or they just started giving some service? That&amp;rsquo;s when you need to&#10;strike! That&amp;rsquo;s a rare chance to get to somebody technical really fast and then&#10;ask real questions. Needles to say, when MTS started offering fibre optics,&#10;they started sending sales personnel to persuade people to switch their ISP. I&#10;asked them for IPv6 and the sales guy didn&amp;rsquo;t know, of course. So in a few days he&#10;came with a technical guy, we sat down and I asked a lot of questions, but once&#10;I got to IPv6, he said he has no idea what that is, but he has a number of the&#10;guy who probably knows about it. He called and gave me the phone. Needles to&#10;say, the third guy in a row has no idea what I&amp;rsquo;m talking about, so the answer&#10;is probably &amp;ldquo;no IPv6 address for you&amp;rdquo;. There was literally nobody else to call&#10;and ask for IPv6.&lt;/p&gt;&#10;&lt;p&gt;No IPv6 means I can use &lt;a href="https://tunnelbroker.net/"&gt;HE tunnel&lt;/a&gt; to get IPv6 over&#10;IPv4, and at least start learning about the technology and stack and whatnot.&#10;Once we had static IP, I realized DMZ is not going to work for that tunnel, so&#10;I needed to set the ISP device as a bridge, hence the above hassle. The tunnel broker&#10;is really nice as it gives you exact commands to type in your terminal as root&#10;for every operating system there is, so it&amp;rsquo;s the next best thing to having an&#10;actual IPv6.&lt;/p&gt;&#10;&lt;p&gt;I have APU1 currently working, APU2 that gave me headache and APU4 laying on my&#10;table waiting for me to configure it and try if it gives me full Internet speed&#10;while being able to utilize hardware AES-NI. One of these days, I&amp;rsquo;ll be on the&#10;Internet like it&amp;rsquo;s a normal thing in the 21st century.&lt;/p&gt;&#10;</description></item><item><title>Freenit Framework</title><link>https://meka.rs/blog/2020/10/04/freenit-framework/</link><pubDate>Sun, 04 Oct 2020 00:36:00 +0000</pubDate><guid>https://meka.rs/blog/2020/10/04/freenit-framework/</guid><description>&lt;p&gt;For few years I worked on a startkit to get me faster results, then I started&#10;teaching using it, and now it&amp;rsquo;s a framework. So let me tell you a story.&lt;/p&gt;&#10;&lt;p&gt;Backend is written in Python and uses Flask and SmoREST, while frontend is&#10;composed of React, Material-UI and Axios. What I tried to achieve is&#10;&amp;ldquo;deployment easy / development portable&amp;rdquo; rule. Yeah, it&amp;rsquo;s quite some rule, and I&#10;have to tell you, it was not always easy. The nice thing that came out of it is&#10;that devops repo for Freenit has support for &amp;ldquo;plain old&amp;rdquo; POSIX compliant&#10;scripts to initialize a project and start development. Those scripts are also&#10;used in Docker, CBSD/Reggae jail and Vagrant, which are all preconfigured. As I&#10;use FreeBSD, I made Freenit port/package available, and as I use it in&#10;production I always keep the version updated. I also have a config of uWSGI&#10;that is automatically disabled in development, enabled in production.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="https://meka.rs/images/freenit-demo.gif" alt="Designer"&gt;&#10;This year we streamed course on development using Freenit, and to make&#10;introduction to development easier, I created &lt;a href="designer.meka.rs"&gt;designer&lt;/a&gt; and&#10;I started working on &lt;a href="frontend.meka.rs"&gt;frontend documentation&lt;/a&gt;. Backend is&#10;kinda self-documented through Swagger and nice patterns that&#10;SmoREST/Marshmallow/Webargs enable. The &amp;ldquo;big thing&amp;rdquo; about designer is that it&amp;rsquo;s&#10;a drag n drop web design solution which uses JSON to save the work, but gives&#10;developer an opportunity to export it to React code with theme, styles and&#10;HTML/Material-UI components. The motive for this software is that I hate the&#10;fact that WEB designer and developer have to create the look from scratch, just&#10;using different tools/languages. This way, code is generated from design, and&#10;while it is not perfect, it is intentionally done so. What I mean is that the&#10;goal was to have saved and export file contain everything while being just&#10;json or js file. Naturally, I expect frontend developer to tidy up the code,&#10;split it into multiple files and so on. Other than that, generated code is&#10;decent, looked from developer&amp;rsquo;s perspective.&lt;/p&gt;&#10;&lt;p&gt;The course we streamed was about:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=S7ZaCP1j5Qk&amp;amp;list=PLpeJ1COhO5alSO2NsZtvJz0bXUwiziIe0"&gt;Freenit backend&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=uv11vOKHkMI&amp;amp;list=PLpeJ1COhO5alT0K6n0P95wZmHT9vYtvzc"&gt;Freenit frontend&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=ulJE9SWCGII&amp;amp;list=PLpeJ1COhO5ans6FiAN6WjJsMZFG8ChZj9"&gt;FreeBSD DevOps&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=4yGq1b6xoJE&amp;amp;list=PLpeJ1COhO5alXSy6Ecskh6d7ddvaBdg_g"&gt;Kotlin&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=gByyga_5mPw&amp;amp;list=PLpeJ1COhO5aneha988XS5ny6hMQ105g4a"&gt;C++&lt;/a&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;As this was the first year we streamed the course, we decided to do it in our&#10;native, Serbian, but next batch of courses will be in English, as we already&#10;have plans to record more.&lt;/p&gt;&#10;&lt;p&gt;One of my plans was to have everything upgradable with &amp;ldquo;pkg upgrade&amp;rdquo; if&#10;possible. As I&amp;rsquo;m developer of Freenit and maintainer of it&amp;rsquo;s port in FreeBSD, I&#10;know those are in sync. As a matter of fact, I know quite a lot of Python&#10;packages I use are in sync with FreeBSD ports. Most of that is due to&#10;responsive maintainers of those ports. I did some of that porting and the&#10;following picture is a tree of ports (represented by their bug ID) I had to&#10;port to have Freenit in ports.&lt;/p&gt;&#10;&lt;a href="https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=242817" target="_blank"&gt;&#10; &lt;img src="https://meka.rs/images/freenit.png" /&gt;&#10;&lt;/a&gt;&#10;&lt;p&gt;For development of the Freenit backend I use pip, but for development of any&#10;product/service based on it I use FreeBSD&amp;rsquo;s pkg. The reason is that I want to&#10;fail fast and discover changes in libraries ideally the day they are published&#10;to pip, but use more stable packages for production. To get there, I had great&#10;help from the FreeBSD community creating that port, especially from Koobs.&#10;Although he does not agree on using FreeBSD&amp;rsquo;s pkg for Python packages in&#10;production, we both understand why the other guy does things the way he does. I&#10;really like the freedom the combination of this OS and language provides as you&#10;can really find what &amp;ldquo;best way to hosting&amp;rdquo; is for you and your needs.&lt;/p&gt;&#10;&lt;p&gt;Primarily, I&amp;rsquo;m system administrator. I do know C/C++/Python/JavaScript to a good&#10;degree, but I most enjoy doing sys admin stuff. What I really like about it is&#10;automation, and you might notice it in my coding as well. For example, I created&#10;&lt;a href="https://github.com/mekanix/dotfiles/tree/master/UltiSnips"&gt;UltiSnips snippets&lt;/a&gt;&#10;for most commonly used Freenit (and other) constructs, so I can have a page done&#10;with designer, exported to React, added backend integration through snippet,&#10;write backend model/endpoint/migration with snippets or tools and developed&#10;inside CBSD/Reggae, which is also used to publish the code. One feature I&amp;rsquo;m&#10;currently working on is a uniform setup for Python jails so that deployment&#10;based on Freenit can be unified, too. What you need is just &lt;code&gt;USE_FREENIT=YES&lt;/code&gt; in&#10;your project/backend and you magically get build and publish functionalities.&lt;/p&gt;&#10;&lt;p&gt;Security is a long topic to add to already lengthy post. Also, it deserves a&#10;post on it&amp;rsquo;s own as it&amp;rsquo;s one of the really tricky topics in development of any&#10;kind. Needles to say, I have an opinion how it should be done in Freenit, so&#10;stay tuned for a new one!&lt;/p&gt;&#10;</description></item><item><title>OpenLDAP Multimaster</title><link>https://meka.rs/blog/2020/03/25/openldap-multimaster/</link><pubDate>Wed, 25 Mar 2020 23:41:00 +0000</pubDate><guid>https://meka.rs/blog/2020/03/25/openldap-multimaster/</guid><description>&lt;p&gt;One thing I can tell you about email servers is that I&amp;rsquo;m really dumb to set it&#10;up properly. I&amp;rsquo;m mail admin since 2006 and 14 years later I still don&amp;rsquo;t know&#10;how to do it. I mean, yeah, I do run a mail server and it does work, but it&amp;rsquo;s&#10;far from satisfying, but that&amp;rsquo;s not what I want to talk about in this post. I&#10;want to talk about one part of email server: OpenLDAP.&lt;/p&gt;&#10;&lt;p&gt;You can think of OpenLDAP, or just ldap for short, as a lightweight database&#10;for users and groups. The reason I chose ldap over SQL is that it&amp;rsquo;s less&#10;resource hungry while being really flexible. One drawback is that it&amp;rsquo;s&#10;complicated as hell. Not the software or configuration itself, but errors are&#10;usually misleading (at least to me). On top of that, although I knew OpenLDAP&#10;supports N-way multimaster, I never found any decent documentation on how to&#10;actually configure a cluster. So in short, this is the configuration that works&#10;on my server:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ServerID &lt;span style="color:#ae81ff"&gt;3&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;ldap://ldap3.domain.tld&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;moduleload syncprov&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;overlay syncprov&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;syncprov-checkpoint &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;syncprov-sessionlog &lt;span style="color:#ae81ff"&gt;100&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;syncrepl rid&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;31&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; provider&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;ldap://ldap1.domain.tld&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; type&lt;span style="color:#f92672"&gt;=&lt;/span&gt;refreshAndPersist&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; schemachecking&lt;span style="color:#f92672"&gt;=&lt;/span&gt;on&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; retry&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;5 10 30 +&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; searchbase&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;dc=ldap&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; bindmethod&lt;span style="color:#f92672"&gt;=&lt;/span&gt;simple&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; binddn&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;cn=root,dc=ldap&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; credentials&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;verysecret&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; starttls&lt;span style="color:#f92672"&gt;=&lt;/span&gt;yes&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; tls_cacert&lt;span style="color:#f92672"&gt;=&lt;/span&gt;/etc/ssl/cert.pem&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; tls_cert&lt;span style="color:#f92672"&gt;=&lt;/span&gt;/usr/local/etc/openldap/certs/fullchain.pem&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; tls_key&lt;span style="color:#f92672"&gt;=&lt;/span&gt;/usr/local/etc/openldap/certs/privkey.pem&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;syncrepl rid&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;32&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; provider&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;ldap://ldap2.domain.tld&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; type&lt;span style="color:#f92672"&gt;=&lt;/span&gt;refreshAndPersist&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; schemachecking&lt;span style="color:#f92672"&gt;=&lt;/span&gt;on&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; retry&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;5 10 30 +&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; searchbase&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;dc=ldap&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; bindmethod&lt;span style="color:#f92672"&gt;=&lt;/span&gt;simple&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; binddn&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;cn=root,dc=ldap&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; credentials&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;verysecret&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; starttls&lt;span style="color:#f92672"&gt;=&lt;/span&gt;yes&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; tls_cacert&lt;span style="color:#f92672"&gt;=&lt;/span&gt;/etc/ssl/cert.pem&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; tls_cert&lt;span style="color:#f92672"&gt;=&lt;/span&gt;/usr/local/etc/openldap/certs/fullchain.pem&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; tls_key&lt;span style="color:#f92672"&gt;=&lt;/span&gt;/usr/local/etc/openldap/certs/privkey.pem&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;MirrorMode on&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Of course, it is in FreeBSD jail and it uses letsencrypt certificates. There&#10;are few things you should note about above config. First, there are 3 ldap&#10;servers which are all masters. Second, ServerID, ldap URL and rid are somewhat&#10;connected: they all contain number 3 in them. That&amp;rsquo;s a convention I find&#10;easiest to follow and understand, and makes some errors somewhat easy to catch.&#10;For example, &lt;code&gt;rid&lt;/code&gt; should never contain two same digits, like 33. Although ldap&#10;server itself won&amp;rsquo;t stop you, it&amp;rsquo;s easier this way as &lt;code&gt;rid=33&lt;/code&gt; means that server&#10;3 should connect to itself, which is not good. You can have as much servers as&#10;you want and number of &lt;code&gt;syncrepl&lt;/code&gt; sections in your configuration should be one&#10;less than the number of servers. FreeBSD slapd servie should be configured like&#10;this:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;slapd_enable&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;YES&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;slapd_flags&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;-u ldap -g ldap -h ldap://ldap3.domain.tld&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;One thing you should be careful about is that &lt;code&gt;ldap3.domain.tld&lt;/code&gt; must be&#10;resolvable. On top of that, it should resolve to the IP of the jail it&amp;rsquo;s&#10;running in. This is usually not the case as you probably point domain names to&#10;server IP, not jail IP. The way I solved it is with the little help of Unbound.&#10;As CBSD/Reggae already uses unbound, I created a fake auth zone for&#10;ldap3.domain.tld:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ldap3.domain.tld. SOA ldap3.domain.tld. hostmaster.ldap3.domain.tld. &lt;span style="color:#f92672"&gt;(&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#ae81ff"&gt;1998092901&lt;/span&gt; ; Serial number&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#ae81ff"&gt;60&lt;/span&gt; ; Refresh&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#ae81ff"&gt;1800&lt;/span&gt; ; Retry&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#ae81ff"&gt;3600&lt;/span&gt; ; Expire&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#ae81ff"&gt;1728&lt;/span&gt; &lt;span style="color:#f92672"&gt;)&lt;/span&gt; ; Minimum TTL&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ldap3.domain.tld. NS ldap3.domain.tld.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ORIGIN ldap3.domain.tld&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;@ A 1.1.1.1&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Of course, you should replace &lt;code&gt;1.1.1.1&lt;/code&gt; with the actual IP address of jail&#10;where ldap is running. This is not ideal, but if I ever find better solution&#10;I will certainly write about it. There is just one more thing you should worry&#10;about and that&amp;rsquo;s renewing certificates. As uid/gid of cert files is probably&#10;not the same as those running slapd service, there&amp;rsquo;s a little script I wrote&#10;that is executed every time I run letsencrypt client (dehydrated, in my case,&#10;ran once a week):&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#!/bin/sh&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;DOMAIN&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;$1&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; &lt;span style="color:#f92672"&gt;[&lt;/span&gt; -z &lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;&lt;span style="color:#e6db74"&gt;${&lt;/span&gt;DOMAIN&lt;span style="color:#e6db74"&gt;}&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt; &lt;span style="color:#f92672"&gt;]&lt;/span&gt;; &lt;span style="color:#66d9ef"&gt;then&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; echo &lt;span style="color:#e6db74"&gt;&amp;#34;Usage &lt;/span&gt;$0&lt;span style="color:#e6db74"&gt; &amp;lt;domain&amp;gt;&amp;#34;&lt;/span&gt; &amp;gt;&amp;amp;&lt;span style="color:#ae81ff"&gt;2&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; exit &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;fi&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;PRIVKEY&lt;span style="color:#f92672"&gt;=&lt;/span&gt;/usr/local/etc/openldap/certs/privkey.pem&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;CERT_DIFF&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;dummy&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; &lt;span style="color:#f92672"&gt;[&lt;/span&gt; -e &lt;span style="color:#e6db74"&gt;${&lt;/span&gt;PRIVKEY&lt;span style="color:#e6db74"&gt;}&lt;/span&gt; &lt;span style="color:#f92672"&gt;]&lt;/span&gt;; &lt;span style="color:#66d9ef"&gt;then&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; CERT_DIFF&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;`&lt;/span&gt;diff /etc/certs/&lt;span style="color:#e6db74"&gt;${&lt;/span&gt;DOMAIN&lt;span style="color:#e6db74"&gt;}&lt;/span&gt;/privkey.pem &lt;span style="color:#e6db74"&gt;${&lt;/span&gt;PRIVKEY&lt;span style="color:#e6db74"&gt;}&lt;/span&gt;&lt;span style="color:#e6db74"&gt;`&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;fi&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; &lt;span style="color:#f92672"&gt;[&lt;/span&gt; ! -z &lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;&lt;span style="color:#e6db74"&gt;${&lt;/span&gt;CERT_DIFF&lt;span style="color:#e6db74"&gt;}&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt; &lt;span style="color:#f92672"&gt;]&lt;/span&gt;; &lt;span style="color:#66d9ef"&gt;then&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; cat /etc/certs/&lt;span style="color:#e6db74"&gt;${&lt;/span&gt;DOMAIN&lt;span style="color:#e6db74"&gt;}&lt;/span&gt;/privkey.pem &amp;gt;/usr/local/etc/openldap/certs/privkey.pem&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; cat /etc/certs/&lt;span style="color:#e6db74"&gt;${&lt;/span&gt;DOMAIN&lt;span style="color:#e6db74"&gt;}&lt;/span&gt;/fullchain.pem &amp;gt;/usr/local/etc/openldap/certs/fullchain.pem&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; chown ldap:ldap /usr/local/etc/openldap/certs/*.pem&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; chmod &lt;span style="color:#ae81ff"&gt;600&lt;/span&gt; /usr/local/etc/openldap/certs/*.pem&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; service slapd restart&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;fi&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;exit &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;It should be ran as &lt;code&gt;update_certs.sh domain.tld&lt;/code&gt;. You might not have&#10;letsencrypt certs in /etc/certs, so edit that script to conform to your paths&#10;and configuration.&lt;/p&gt;&#10;&lt;p&gt;NOTE: There are some blog posts that state you should use &lt;code&gt;chain.pem&lt;/code&gt; for&#10;&lt;code&gt;tls_cacert&lt;/code&gt;. That does not work. If you have trouble with your service, try&#10;running it as this:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;/usr/local/libexec/slapd -u ldap -g ldap -h ldap://ldap3.domain.tld -d &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;It will run slapd in the foreground and spew a lot of messages to your terminal.&#10;Some of them might be helpful. Also, you might want to use other number than 1&#10;for -d argument, but I found it&amp;rsquo;s the best verbosity level for me.&lt;/p&gt;&#10;&lt;p&gt;OpenLDAP has alternate configuration syntax usually called &lt;code&gt;cn=config&lt;/code&gt; for&#10;short. It allows you to keep configuration in ldap itself and changing those&#10;values makes them active right away. To be honest, I perfectly understand why&#10;some data centers would want not to restart the service when they change&#10;configuration, but for my little server, that&amp;rsquo;s an overkill. Also, cn=config&#10;variables for multimaster are somewhat similar to those I showed here, so it&#10;should be almost easy to convert them. Also, official documentation for&#10;multimaster uses cn=config, so&#10;&lt;a href="https://openldap.org/doc/admin24/replication.html"&gt;give it a try&lt;/a&gt; if you&amp;rsquo;re&#10;using cn=config.&lt;/p&gt;&#10;</description></item><item><title>FreeBSD Crossbow</title><link>https://meka.rs/blog/2020/02/18/freebsd-crossbow/</link><pubDate>Tue, 18 Feb 2020 17:48:00 +0000</pubDate><guid>https://meka.rs/blog/2020/02/18/freebsd-crossbow/</guid><description>&lt;p&gt;Once I started learning about containers and surrounding technologies, I heard&#10;about Solaris Zones and Crossbow. In short, zones are containers, like jails,&#10;and crossbow is something like a vnet. They say it&amp;rsquo;s way more flexible and&#10;powerful. One of the things it can do is prevent you from setting up static IP.&#10;I thought that&amp;rsquo;s pretty important thing and I wanted to have that. With&#10;CBSD/Reggae I&amp;rsquo;m a little closer to saying &amp;ldquo;we have it&amp;rdquo;. Reggae sets up a jail&#10;named &lt;code&gt;cbsd&lt;/code&gt; and inside it &lt;code&gt;/dev/pf&lt;/code&gt; and DHCP server are configured in a very&#10;special way. Because DHCP process is running as dhcp user, and that user can&#10;not run &lt;code&gt;pfctl&lt;/code&gt;, unless &lt;code&gt;/dev/pf&lt;/code&gt; owning group is the same as DHCP process&#10;group. Luckily, devfs.rules allows one set of rules for host and other set for&#10;the jail. That means &lt;code&gt;/dev/pf&lt;/code&gt; on host is owned by &lt;code&gt;root:root&lt;/code&gt; while it&amp;rsquo;s owned&#10;by &lt;code&gt;root:unbound&lt;/code&gt; inside the jail and mode is 660. Of course, DHCP runs under&#10;group unbound. The reason is that unbound files from host are nullfs mounted&#10;inside the jail. That way DHCP can edit unbound zones and add leased addresses&#10;to PF table. On host, that PF table is used to configure NAT, so basically&#10;allowing jails to reach Internet.&lt;/p&gt;&#10;&lt;p&gt;Let&amp;rsquo;s face it. What I just described is nowhere near to Solaris crossbow, but&#10;it&amp;rsquo;s the closest I can get.&lt;/p&gt;&#10;</description></item><item><title>CBSD Base Upgrade</title><link>https://meka.rs/blog/2019/11/18/cbsd-base-upgrade/</link><pubDate>Mon, 18 Nov 2019 19:36:00 +0000</pubDate><guid>https://meka.rs/blog/2019/11/18/cbsd-base-upgrade/</guid><description>&lt;p&gt;Upgrade in CBSD means the same as in FreeBSD: increse only in patch version.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cbsd baseupdate&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;service cbsd restart&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;For upgrade you need to stop the jail, set it to new base and start the jail.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cbsd jstop nginx&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cbsd jset jname&lt;span style="color:#f92672"&gt;=&lt;/span&gt;nginx ver&lt;span style="color:#f92672"&gt;=&lt;/span&gt;12.1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cbsd jstart nginx&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cbsd etcupdate jname&lt;span style="color:#f92672"&gt;=&lt;/span&gt;cbsd mode&lt;span style="color:#f92672"&gt;=&lt;/span&gt;update from&lt;span style="color:#f92672"&gt;=&lt;/span&gt;12.0 to&lt;span style="color:#f92672"&gt;=&lt;/span&gt;12.1 mode&lt;span style="color:#f92672"&gt;=&lt;/span&gt;diff&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;CBSD will ask you how do you want new base files to be fetched, and default is&#10;to download them. Other options include compiling from code and using host&#10;system files as new base. If you upgrade more then one jail, the first&#10;&lt;code&gt;jstart&lt;/code&gt; will create base jail for the rest to use.&lt;/p&gt;&#10;&lt;p&gt;Once you&amp;rsquo;ve upgraded all your jails, it&amp;rsquo;s time to cleanup&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cbsd removebase ver&lt;span style="color:#f92672"&gt;=&lt;/span&gt;12.0&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description></item><item><title>FreeBSD Upgrade</title><link>https://meka.rs/blog/2019/11/18/freebsd-upgrade/</link><pubDate>Mon, 18 Nov 2019 19:12:00 +0000</pubDate><guid>https://meka.rs/blog/2019/11/18/freebsd-upgrade/</guid><description>&lt;p&gt;Upgrade in FreeBSD world means having a host on version 12.0 and doing similar&#10;procedure like in &lt;a href="https://meka.rs/blog/2019/06/25/freebsd-update"&gt;FreeBSD update&lt;/a&gt;, but ending up with a&#10;major or minor version number incresed, not patch version number.&lt;/p&gt;&#10;&lt;p&gt;TL;DR&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;env PAGER&lt;span style="color:#f92672"&gt;=&lt;/span&gt;/bin/cat freebsd-update upgrade -r 12.1-RELEASE&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;freebsd-version -ku&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bectl create 12.0.11&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;freebsd-update install&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;reboot&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;freebsd-update install&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;reboot&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;pkg upgrade&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;freebsd-update install&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;reboot&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;code&gt;freebsd-update&lt;/code&gt; utility will tell you if there is anything to be fetched. If&#10;there isn&amp;rsquo;t, just ignore the rest of the commands.&lt;/p&gt;&#10;&lt;p&gt;First, using &lt;code&gt;freebsd-version&lt;/code&gt; and &lt;code&gt;bectl&lt;/code&gt; you create a boot environment for&#10;the current version of FreeBSD. Then, first install will update only kernel.&#10;As FreeBSD kernels are backward compatible, your system can boot with newer&#10;kernel then the rest of the operating system. Second install will take care of&#10;FreeBSD base. If everything is OK, after another &lt;code&gt;reboot&lt;/code&gt;, you should upgrade&#10;packages for the new OS version and run finall install which will take care of&#10;known package problems. The last &lt;code&gt;reboot&lt;/code&gt; is there to ensure everything is&#10;working OK, as you might have some kernel modules, like drm-kmod, which are&#10;changed during the upgrade.&lt;/p&gt;&#10;</description></item><item><title>FreeBSD Update</title><link>https://meka.rs/blog/2019/06/25/freebsd-update/</link><pubDate>Tue, 25 Jun 2019 13:03:00 +0000</pubDate><guid>https://meka.rs/blog/2019/06/25/freebsd-update/</guid><description>&lt;p&gt;As you might be comming from Linux background, like I am, you might not be&#10;familiar with the FreeBSD update procedure. The main difference is that FreeBSD&#10;has base system as one big component which is updated as a whole, plus it has&#10;packages like any other Unix.&lt;/p&gt;&#10;&lt;p&gt;TL;DR&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;env PAGER&lt;span style="color:#f92672"&gt;=&lt;/span&gt;/bin/cat freebsd-update fetch&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;freebsd-version -ku&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bectl create 12.0.3&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;freebsd-update install&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;reboot&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Check if &lt;a href="https://svnweb.freebsd.org/ports/head/UPDATING?view=markup"&gt;there&amp;rsquo;s a known migration problem&lt;/a&gt;.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;pkg upgrade&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;reboot&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;If you have jails, update them before last reboot&lt;/strong&gt;.&lt;/p&gt;&#10;&lt;p&gt;&lt;code&gt;freebsd-update&lt;/code&gt; utility will tell you if there is anything to be fetched. If&#10;there isn&amp;rsquo;t, just ignore the rest of the commands, but if there is, you&#10;probably want to know what is the current version using &lt;code&gt;freebsd-version&lt;/code&gt;. The&#10;-k and -u options stand for kernel and userland, respectively. Those version&#10;can be different (only the patch level), so pick the higher one. In the example&#10;above, that&amp;rsquo;s 12.0-p3. If you&amp;rsquo;re running on ZFS, you can use &lt;code&gt;bectl&lt;/code&gt; to create&#10;new boot environment out of the current one, so if update goes wrong, you can&#10;still boot system with the previous version. The boot environment is ZFS-only&#10;feature which allows for multiple root datasets which loader(8) knows how to&#10;boot into. In a sense, it&amp;rsquo;s like installing update and all the packages to new&#10;root partition, every time. If you&amp;rsquo;re not running your FreeBSD on ZFS, just skip&#10;this step. Finally, we install the actual update and reboot, so the new kernel&#10;and base system are loaded. As the final part, packages are updated.&lt;/p&gt;&#10;&lt;p&gt;If you have a machine you can not reboot for any reason and have access through&#10;VNC, serial console or other non-network channels, you can run this:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;env PAGER&lt;span style="color:#f92672"&gt;=&lt;/span&gt;/bin/cat freebsd-update fetch&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;freebsd-version -ku&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bectl create 12.0.3&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;shutdown now&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;freebsd-update install&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;exit&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;pkg upgrade&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The &lt;code&gt;shutdown&lt;/code&gt; command will not power your machine off. It will bring it into&#10;single user mode. In this mode, most processes are not running, only those to&#10;enable basic terminal functionallity (and a bit more, but let&amp;rsquo;s say nothing is&#10;running). It will ask for root password and once the actuall update is finished,&#10;&lt;code&gt;exit&lt;/code&gt; will start the services like on fresh boot. The drawback is that kernel&#10;updates are not activated, but you still profit from the updates to the&#10;userland. As FreeBSD tries relly hard to maintain ABI compatibility on the patch&#10;level, this is safe enough to do, but it is advisable to reboot once after the&#10;update to load the new kernel.&lt;/p&gt;&#10;</description></item><item><title>Videos</title><link>https://meka.rs/videos/</link><pubDate>Mon, 24 Jun 2019 18:31:00 +0000</pubDate><guid>https://meka.rs/videos/</guid><description>&lt;h3 id="dafed-61---kako-automatizacija-procesa-pomaže-u-razvoju-sigurnijih-aplikacija"&gt;&#10; DaFED #61 - Kako automatizacija procesa pomaže u razvoju sigurnijih aplikacija&#10;&lt;/h3&gt;&#10;&lt;iframe height="350px" width="100%" src="https://www.youtube.com/embed/XnJjMqa5fDw" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen&gt;&lt;/iframe&gt;&#10;&lt;h3 id="fosdem-2023---reggae-cool-way-of-managing-jailsvms-on-freebsd"&gt;&#10; FOSDEM 2023 - Reggae: cool way of managing jails/VMs on FreeBSD&#10;&lt;/h3&gt;&#10;&lt;video controls width="100%"&gt;&#10; &lt;source src="https://video.fosdem.org/2023/AW1.120/reggae_jails_vms_on_freebsd.mp4" /&gt;&#10;&lt;/video&gt;&#10;&lt;h3 id="eurobsd-2022---freebsd-audio-in-amateur-and-professional-setups"&gt;&#10; EuroBSD 2022 - FreeBSD audio in amateur and professional setups&#10;&lt;/h3&gt;&#10;&lt;iframe height="350px" width="100%" src="https://www.youtube.com/embed/9xIGfs6Bqpo" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen&gt;&lt;/iframe&gt;&#10;&lt;h3 id="fosdem-2021---managing-virtual-resources-with-cbsd-and-beyond"&gt;&#10; FOSDEM 2021 - Managing virtual resources with CBSD, and beyond&#10;&lt;/h3&gt;&#10;&lt;video controls width="100%"&gt;&#10; &lt;source src="https://video.fosdem.org/2021/D.bsd/cbsd_ecosystem.mp4" /&gt;&#10;&lt;/video&gt;&#10;&lt;h3 id="bsidesljubljana-2019---how-did-we-teach-ourselves-security"&gt;&#10; BSidesLjubljana 2019 - How Did We Teach (Ourselves) Security&#10;&lt;/h3&gt;&#10;&lt;video controls width="100%"&gt;&#10; &lt;source src="https://archive.org/download/BSidesLjubljana2019/t1_08_How_Did_We_Teach_%28Ourselves%29_Security-Goran_Meki%C4%87.mp4" /&gt;&#10;&lt;/video&gt;&#10;&lt;h3 id="fosdem-2019---freebsd-in-audio-studio"&gt;&#10; FOSDEM 2019 - FreeBSD in Audio Studio&#10;&lt;/h3&gt;&#10;&lt;video controls width="100%"&gt;&#10; &lt;source src="https://video.fosdem.org/2019/K.3.401/freebsd_in_audio_studio.mp4" /&gt;&#10;&lt;/video&gt;&#10;&lt;h3 id="bsidesljubljana-2018---modern-and-secure-devops-on-freebsd"&gt;&#10; BSidesLjubljana 2018 - Modern And Secure Devops on FreeBSD&#10;&lt;/h3&gt;&#10;&lt;video controls width="100%"&gt;&#10; &lt;source src="https://archive.org/download/BSidesLjubljana2018/18ModernAndSecureDevopsOnFreebsdByGoranMeki.mp4" /&gt;&#10;&lt;/video&gt;&#10;&lt;h3 id="fosdem-2018---cbsd-isolation-manager"&gt;&#10; FOSDEM 2018 - CBSD Isolation Manager&#10;&lt;/h3&gt;&#10;&lt;video controls width="100%"&gt;&#10; &lt;source src="https://video.fosdem.org/2018/K.3.401/cbsd_isolation_manager.mp4" /&gt;&#10;&lt;/video&gt;&#10;&lt;h3 id="balccon-2016---floss-way-of-funding-a-hackerspace"&gt;&#10; BalCCon 2016 - FLOSS Way of Funding a Hackerspace&#10;&lt;/h3&gt;&#10;&lt;iframe height="350px" width="100%" src="https://www.youtube.com/embed/DHNnCXgD4RU" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen&gt;&lt;/iframe&gt;&#10;&lt;h3 id="balccon-2015---what-is-hackerspace"&gt;&#10; BalCCon 2015 - What is Hackerspace&#10;&lt;/h3&gt;&#10;&lt;iframe height="350px" width="100%" src="https://www.youtube.com/embed/KpzQpAAwBvA" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen&gt;&lt;/iframe&gt;&#10;</description></item><item><title>IT Feels Like Constant Failure</title><link>https://meka.rs/blog/2019/04/08/it-feels-like-constant-failure/</link><pubDate>Mon, 08 Apr 2019 20:10:00 +0000</pubDate><guid>https://meka.rs/blog/2019/04/08/it-feels-like-constant-failure/</guid><description>&lt;p&gt;Do you remember when any operating system just worked? Me neither, and I hate&#10;it. I mean, Windows was always just a joke. Just think about it, Microsoft said&#10;their git repository is 300GB in size. How do you compile, let alone read? One&#10;will probably think of Linux, but what about systemd and Richard Stallman?&#10;Honestly, I&amp;rsquo;m not sure what is more revolting: shitty system software, or the&#10;most annoying guy ever. One might think about BSDs, but what about the support?&#10;FreeBSD being most popular and getting most attraction still lacks support for&#10;a lot of hardware. And the hardware? I don&amp;rsquo;t remember when I bought a piece of&#10;hardware that didn&amp;rsquo;t totally suck. As a matter of fact, how do you even do&#10;proper programming when the underlaying hardware is fucked up? And where are we&#10;as IT going? We&amp;rsquo;re creating bunch of sites and software for what? I can&amp;rsquo;t&#10;remember how many times I&amp;rsquo;ve heard &amp;ldquo;we&amp;rsquo;re creating something revolutionary&amp;rdquo;.&#10;It&amp;rsquo;s like nobody can create just a regular software solving small problems.&#10;Why? I hate the current state, and the worst is the hardware industry. Just&#10;look at the spectra and meltdown. I&amp;rsquo;m ashamed and sorry for contributing to&#10;this whole circus, where it&amp;rsquo;s only important to sell, get revenue and bail out.&#10;I may never stop doing IT stuff, but I do hate it from the bottom of my soul.&#10;Also, recent years showed me that my colleagues are mostly not interested in the&#10;IT at all, but to get their salary and go home. I can&amp;rsquo;t blame them, but I can&amp;rsquo;t&#10;like them either. As a matter of fact, there are more and more programmers that&#10;have no education. I don&amp;rsquo;t mean formal, as I know some exceptional developers&#10;without a single day at the university, but wish to know more is rare. Like&#10;we&amp;rsquo;re playing this dumb game to put money into someone&amp;rsquo;s pocket, and that&#10;pocket ain&amp;rsquo;t ours. It&amp;rsquo;s like we&amp;rsquo;re doing everything we can to screw this&#10;industry that once was so beautiful. That&amp;rsquo;s why IT feels like a constant&#10;failure, because it is!&lt;/p&gt;&#10;</description></item><item><title>HardenedBSD Install Over Serial</title><link>https://meka.rs/blog/2018/08/13/hardenedbsd-install-over-serial/</link><pubDate>Mon, 13 Aug 2018 00:45:00 +0000</pubDate><guid>https://meka.rs/blog/2018/08/13/hardenedbsd-install-over-serial/</guid><description>&lt;p&gt;If you have APU or similar router, it&amp;rsquo;s a big chance you&amp;rsquo;ll need serial console&#10;install procedure. You&amp;rsquo;ll have to mount install image before booting and change&#10;/boot/loader.conf so it includes the lines to use serial console:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;boot_multicons&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;YES&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;boot_serial&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;YES&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;comconsole_speed&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;115200&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;console&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;comconsole,vidconsole&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;When the machine boots, it will ask you for prefered console type. Default&#10;(vt100) is just fine. The rest of the installation is just like on the normal&#10;machine, but you&amp;rsquo;ll have to modify /boot/loader.conf on the newely installed.&#10;Reboot, and boot off of USB key once again with the same procedure, but go into&#10;shell, instead of install.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mkdir /tmp/install&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;zpool import -R /tmp/install -f zroot&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;zfs mount zroot/ROOT/default&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now write the same lines for serial console to /tmp/install/boot/loader.conf and&#10;you should be set.&lt;/p&gt;&#10;</description></item><item><title>CBSD Reggae</title><link>https://meka.rs/blog/2017/11/20/cbsd-reggae/</link><pubDate>Mon, 20 Nov 2017 03:00:00 +0000</pubDate><guid>https://meka.rs/blog/2017/11/20/cbsd-reggae/</guid><description>&lt;p&gt;If you didn&amp;rsquo;t get it by now, I&amp;rsquo;m huge CBSD fan. Actually, I&amp;rsquo;m CBSD developer&#10;now. :o) One of the things I play with is Reggae, and some people asked me to&#10;describe it and make a demo. So here goes the explanation why I created it, how&#10;to use it and what are my plans for it in the future.&lt;/p&gt;&#10;&lt;p&gt;As CBSD is used for almost everything in Reggae, I won&amp;rsquo;t discuss that part.&#10;So, besides jails, these are the topics I tried to cover with&#10;Reggae:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;network and pf being static&lt;/li&gt;&#10;&lt;li&gt;environment for bhyve VMs&lt;/li&gt;&#10;&lt;li&gt;ansible provisioning&lt;/li&gt;&#10;&lt;li&gt;development envrionemnt&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;Let me explain in a bit more detail. If you use CBSD as Oleg (lead developer)&#10;likes it, it will do all the magic for you: configure bridge interface for VMs,&#10;dynamically change PF rules when jails go up and so on. While this is&#10;absolutely great feature, I know bunch of admins that would like to try CBSD&#10;but don&amp;rsquo;t like other software to alter their firewall rules (me included).&#10;To automate the process of CBSD initialization with PF rules that don&amp;rsquo;t change&#10;and interfaces that are fixed (except tap and epair), I created command&#10;&lt;code&gt;reggae init&lt;/code&gt;. You can think of it as a test: it creates static config for&#10;CBSD network so you can test if everything is working as you would like it. As&#10;script grew, it became obvious to me that it can also be used to initialize&#10;the server, not just test weird CBSD config and such. Network interfaces are&#10;configured only because you have to NAT using interface names so those had to&#10;be static as much as possible. I like the setup where jails are on lo1 and&#10;virtual machines on bridge1. In /etc/pf.conf that&amp;rsquo;s&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;jail_if &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;lo1&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bridge_if &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;bridge1&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;nat on $ext_if from &lt;span style="color:#f92672"&gt;{&lt;/span&gt; &lt;span style="color:#f92672"&gt;(&lt;/span&gt;$jail_if:network&lt;span style="color:#f92672"&gt;)&lt;/span&gt;, &lt;span style="color:#f92672"&gt;(&lt;/span&gt;$bridge_if:network&lt;span style="color:#f92672"&gt;)&lt;/span&gt; &lt;span style="color:#f92672"&gt;}&lt;/span&gt; to any -&amp;gt; &lt;span style="color:#f92672"&gt;(&lt;/span&gt;$ext_if&lt;span style="color:#f92672"&gt;)&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;So that&amp;rsquo;s basically use case for the static network and how I tried to solve&#10;it. I&amp;rsquo;m sure there are better ways to do it, but I wanted to create proof of&#10;concept that we can discuss further.&lt;/p&gt;&#10;&lt;p&gt;As for VMs you need DHCP server to make it easier to work with, &lt;code&gt;reggae init&lt;/code&gt;&#10;will also setup two jails: dhcp and resolver. DHCP will lease IPs to VMs and&#10;register them in DNS (resolver). What you&amp;rsquo;ll notice is that only jail on&#10;bridge1 is DHCP, and that&amp;rsquo;s because it has to be on the same bridge as the VMs.&#10;Also, DHCP server is ISC&amp;rsquo;s Kea which has control socket file you can use to get&#10;statistics and to reconfigure/reload Kea. I still didn&amp;rsquo;t poke that socket, but&#10;I hope that in the future it will provide enough stats that CBSD can use it&#10;internally. Having resolver working, jails registration was straight forward:&#10;master_poststart.d / master_prestop.d hooks that use nsupdate and RNDC key to&#10;add/delete jail&amp;rsquo;s IP to/from the zone. So now Reggae has two zones, my.domain&#10;and vm.my.domain, as IPs assigned to jails and VMs are from different IP ranges&#10;and I want to be clear is it a jail or VM just from looking at the name.&lt;/p&gt;&#10;&lt;p&gt;For Ansible to provision jails you have to use jail connection instead ssh.&#10;Also, as Ansible expects python binary to be installed in /usr/bin, you have&#10;to tell Ansible where python is on FreeBSD machines. So this is how the&#10;inventory of one jail looks like:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;jail1 ansible_connection&lt;span style="color:#f92672"&gt;=&lt;/span&gt;jail ansible_python_interpreter&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#39;&amp;#34;/usr/bin/env python&amp;#34;&amp;#39;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To make it easier for me to run Ansible on a jail, I created some Makefiles to&#10;help me with common tasks. If you create hierarchy in your repo the way Reggae&#10;expects it, you can &amp;ldquo;just write Ansible playbook&amp;rdquo; and it will be applied to your&#10;jail with one &lt;code&gt;make&lt;/code&gt;. I could use a shell script for that, too, but I wanted to&#10;leave room for parallelism in the future.&lt;/p&gt;&#10;&lt;p&gt;To be able to reach your jail with Ansible once it&amp;rsquo;s on the server, Reggae will&#10;create &lt;code&gt;provision&lt;/code&gt; user, give it sudo priviledges and add public key to it&amp;rsquo;s&#10;ssh. What it does is&#10;&lt;code&gt;cp ~/.ssh/id_rsa.pub &amp;lt;jail-data&amp;gt;/home/provision/.ssh/authorized_keys&lt;/code&gt;. It is a&#10;bit hardcoded, but it will get better support in the future. The idea is to use&#10;SSH&amp;rsquo;s ProxyCommand to make your host jump box to jail. As Ansible knows how to&#10;use jump box, you can provision or update your jails on the server.&lt;/p&gt;&#10;&lt;p&gt;To make all this possible, I created extra files like jail profile, skel, etc,&#10;but there is also script which switches your DNS entry in /etc/resolv.conf from&#10;the one DHCP provided (or you entered, if you use static IP) to the resolver&#10;(jail where BIND9 is running), there are hooks for (de)registering jails, &amp;hellip;&#10;What I&amp;rsquo;m also trying to achieve is to have my dev environment be exactly the&#10;same (yeah, right, like that&amp;rsquo;s possible) as my production. Reggae also has&#10;development mode, in which it will mount your resository&amp;rsquo;s directory on host to&#10;/usr/src inside jail, create devel user with same UID:GID inside jail that user&#10;running make has on the host has and it adds one more target, so when you run&#10;&lt;code&gt;make &amp;amp;&amp;amp; make devel&lt;/code&gt; on yet uninitialized repository, it will provision it if&#10;needed, run &lt;code&gt;/usr/src/bin/init.sh&lt;/code&gt; and &lt;code&gt;/usr/src/bin/devel.sh&lt;/code&gt;, so by&#10;implementing those scripts you choose what happens on &lt;code&gt;make devel&lt;/code&gt;.&lt;/p&gt;&#10;&lt;p&gt;Here are some example repos using Reggae:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;a href="https://github.com/tilda-center/website"&gt;Tilda Center website&lt;/a&gt; (development&#10;mode example)&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://github.com/mekanix/jail-mail"&gt;EMail service&lt;/a&gt; (Ansible example)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;What I&amp;rsquo;d like to see in the future is much of this work merged into CBSD on&#10;one way or another. This is what makes my development experience nicer, and as&#10;such I&amp;rsquo;d like it to be less hackish at some parts. Sometimes, it&amp;rsquo;s hackish&#10;because of a CBSD bug, sometimes because I can&amp;rsquo;t think of a better solution at&#10;the time. As I use it for testing CBSD in &amp;ldquo;uncharted theritories&amp;rdquo;, I like being&#10;able to find bugs that wouldn&amp;rsquo;t pop up otherwise. Also, as I&amp;rsquo;d like to use CBSD&#10;in every situation I can think of, hence making dev env as close to production&#10;as possible, some extra tools or CBSD features are needed and Reggae is one of&#10;them, at least for me. The parts that proove to be useful to other people will&#10;probably go into CBSD or some more official CBSD repository.&lt;/p&gt;&#10;&lt;p&gt;This is how &lt;code&gt;reggae init&lt;/code&gt; feels like:&lt;/p&gt;&#10;&lt;script type="text/javascript" src="https://asciinema.org/a/NCYU9hyXtcwTq2aZhOlLMj9zk.js" id="asciicast-NCYU9hyXtcwTq2aZhOlLMj9zk" async&gt;&lt;/script&gt;&#10;&lt;p&gt;You can use it for development:&lt;/p&gt;&#10;&lt;script src="https://asciinema.org/a/QQ3iVvJtacJ3oy4eHM7z7fGHc.js" id="asciicast-QQ3iVvJtacJ3oy4eHM7z7fGHc" async&gt;&lt;/script&gt;&#10;&lt;p&gt;Or you can use it for project like service grouping:&lt;/p&gt;&#10;&lt;script src="https://asciinema.org/a/ep0fuYUY4cyMgRlhp0lgXvUZx.js" id="asciicast-ep0fuYUY4cyMgRlhp0lgXvUZx" async&gt;&lt;/script&gt;&#10;&lt;p&gt;Peek inside service:&lt;/p&gt;&#10;&lt;script src="https://asciinema.org/a/rHSbFdSWFUmsb22tTHVJyhy4U.js" id="asciicast-rHSbFdSWFUmsb22tTHVJyhy4U" async&gt;&lt;/script&gt;&#10;</description></item><item><title>Getting Started with Digital Audio</title><link>https://meka.rs/blog/2017/11/20/getting-started-with-digital-audio/</link><pubDate>Mon, 20 Nov 2017 03:00:00 +0000</pubDate><guid>https://meka.rs/blog/2017/11/20/getting-started-with-digital-audio/</guid><description>&lt;p&gt;It&amp;rsquo;s bad to start your post with an apology, but I must: this one won&amp;rsquo;t deal&#10;with FreeBSD as much as set some foundation for the posts to come.&lt;/p&gt;&#10;&lt;p&gt;The base for a good digital audio workstation, or DAW for short is audio&#10;interface. That is the piece of equipment that will do the most demanding task&#10;of converting from analog to digital and vice versa. As audio we hear is, after&#10;all, analog one must pick it&amp;rsquo;s audio interface a bit more carefully than the&#10;rest of the gear, so here are my tips on choosing a decent one:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;find as much as you can about it&amp;rsquo;s ADC (analog to digital converter) and DAC&#10;(digital to analog converter)&lt;/li&gt;&#10;&lt;li&gt;match impedance (more on that later)&lt;/li&gt;&#10;&lt;li&gt;as high sample/bit rate as possible with internal mixer using more bits than&#10;ADC/DAC so it has room to handle clipping (common these days is 24/32 bits)&lt;/li&gt;&#10;&lt;li&gt;ability to be world clock master and slave (more on that later)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;Impedance is a fancy word for electrical resistance. It has to do with the fact&#10;that resistance of a device is not the same in all circumstances. One of those&#10;situations where this really matters is equalizer: one band actually has lower&#10;resistance for a certain frequencies, and higher for others. All I&amp;rsquo;m trying to&#10;emphasize here is that when you here &amp;ldquo;impedance&amp;rdquo; you should think &amp;ldquo;resistance&amp;rdquo;&#10;and keep in mind that it&amp;rsquo;s dynamic.&lt;/p&gt;&#10;&lt;p&gt;One thing all electrical circuits like is when impedance of it&amp;rsquo;s output matches&#10;the one on the input of the next step. When I say &amp;ldquo;like&amp;rdquo;, I mean least amount&#10;of energy is wasted in transit from one circuit to another (read: you get more&#10;signal/noise ratio) and the least amount of distortion is introduced&#10;(unfortunately, every device adds some distortion). So, to have a perfect audio&#10;interface, choose the one that has mic, line and hi-z inputs. Mic input should&#10;have 48V option which is needed for condenser microphones (studio microphones).&#10;Line is what most devices use, like mp3 players, other sound cards and synths.&#10;Hi-z is just a fancy name for &amp;ldquo;guitar input&amp;rdquo;. What you should look for with hi-z&#10;is a active/passive switch. Active pickups have small amp inside them and need&#10;battery, so they are easy to recognize. Passive pickups are the ones without&#10;battery, and they have 3 to 9 times lower output than active ones (depending on&#10;the chosen pair of active/passive pickups).&lt;/p&gt;&#10;&lt;p&gt;As digital audio IO must operate at the precise same frequency across all&#10;devices, once you get guitar or vocal processor, you&amp;rsquo;ll need to sync your audio&#10;interface and processor. There are multiple ways for achieving that and it&#10;mostly depends on the way you&amp;rsquo;re going to connect the devices, but let me explain&#10;why it&amp;rsquo;s important. All digital devices use &amp;ldquo;the clock&amp;rdquo;. It&amp;rsquo;s what tells them&#10;&amp;ldquo;hey, it&amp;rsquo;s time for the next sample&amp;rdquo; among other things. That clock is usually&#10;quartz crystal which has a property of oscillating when electric current is&#10;introduced. When you have two devices with their own clocks, they have slight&#10;differences in frequencies which come from slight differences in crystals inside&#10;them. You might think &amp;ldquo;I don&amp;rsquo;t care about few milliseconds&amp;rdquo; of delay, but that&amp;rsquo;s&#10;not what&amp;rsquo;s in stake here. If digital device misses the clock beat, all audio&#10;can become gibberish and noise. This is solved by having devices that can use&#10;external clock as it&amp;rsquo;s own. Obviously, one of the devices must &amp;ldquo;export&amp;rdquo; it&amp;rsquo;s&#10;internal clock (acts as master) to other devices (slaves). S/PDIF and AES/EBU&#10;digital connections can also transmit the clock but you have to check your&#10;devices for such capabilities as not all can work this way. The safest option&#10;is to have World Clock on all of your devices, where your audio interface is&#10;the master. World Clock connector is BNC. It is especially important when you&#10;want to connect multiple devices to your computer (for example, via USB) as&#10;otherwise you&amp;rsquo;ll get a lot of small errors known as jitters.&lt;/p&gt;&#10;&lt;p&gt;For someone starting with audio, this must sound terribly boring, and maybe too&#10;technical, so please leave a comment if I didn&amp;rsquo;t cover something properly, or&#10;you have an idea how to make it more fun.&lt;/p&gt;&#10;</description></item><item><title>FreeBSD Cloud and DevOps 3</title><link>https://meka.rs/blog/2017/10/01/freebsd-cloud-and-devops-3/</link><pubDate>Sun, 01 Oct 2017 12:34:00 +0000</pubDate><guid>https://meka.rs/blog/2017/10/01/freebsd-cloud-and-devops-3/</guid><description>&lt;p&gt;By now you know &lt;a href="https://meka.rs/blog/2017/04/04/freebsd-cloud-and-devops-2/"&gt;how to manage jails with Makefile&lt;/a&gt;.&#10;It&amp;rsquo;s nice, but I took it a bit further this past few months. I realized that&#10;Makefile can effectively replace Vagrant, so I created program called&#10;&lt;a href="https://github.com/mekanix/reggae"&gt;Reggae&lt;/a&gt;: REGister Globaly Access Everywhere.&#10;In short it consists of few scripts that (de)register jail in/from&#10;&lt;a href="https://consul.io"&gt;Consul&lt;/a&gt;. As Consul acts as DNS, too, that means that when&#10;your jail is up, other jails using Consul as DNS will know about it. Also,&#10;Consul can be used for other things, but it&amp;rsquo;s a different topic.&lt;/p&gt;&#10;&lt;p&gt;From the last blog post in this series you know how to use Makefile for these&#10;tasks, but I&amp;rsquo;ll run through some of the Makefiles from my project. There are 3&#10;.mk files in Reggae:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;project.mk&lt;/li&gt;&#10;&lt;li&gt;service.mk&lt;/li&gt;&#10;&lt;li&gt;ansible.mk&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;So let me explain how it works on the example of the first project I used it&#10;with: mail server. If you look at the mail as a project, it consists of few&#10;services like ldap, webmail, mail (dovecot + postfix) and so on. I have&#10;mail/Makefile which looks like this:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-Makefile" data-lang="Makefile"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;REGGAE_PATH &lt;span style="color:#f92672"&gt;=&lt;/span&gt; /usr/local/share/reggae&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;SERVICES &lt;span style="color:#f92672"&gt;=&lt;/span&gt; letsencrypt https://github.com/mekanix/jail-letsencrypt &lt;span style="color:#ae81ff"&gt;\&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; ldap https://github.com/mekanix/jail-ldap &lt;span style="color:#ae81ff"&gt;\&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; mail https://github.com/mekanix/jail-mail &lt;span style="color:#ae81ff"&gt;\&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; jabber https://github.com/mekanix/jail-jabber &lt;span style="color:#ae81ff"&gt;\&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; webmail https://github.com/mekanix/jail-webmail &lt;span style="color:#ae81ff"&gt;\&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; web https://github.com/mekanix/jail-web &lt;span style="color:#ae81ff"&gt;\&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; webconsul https://github.com/mekanix/jail-webconsul&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;DOMAIN&lt;span style="color:#f92672"&gt;=&lt;/span&gt;lust4trust.com&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#960050;background-color:#1e0010"&gt;.include&lt;/span&gt; &lt;span style="color:#960050;background-color:#1e0010"&gt;&amp;lt;${REGGAE_PATH}/mk/project.mk&amp;gt;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Yes, that&amp;rsquo;s the whole file! The core of the Reggae is SERVICES in project.mk, so&#10;let&amp;rsquo;s see how it deals with it:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-Makefile" data-lang="Makefile"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;up&lt;/span&gt;&lt;span style="color:#f92672"&gt;:&lt;/span&gt; fetch setup&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#960050;background-color:#1e0010"&gt;.if&lt;/span&gt; &lt;span style="color:#960050;background-color:#1e0010"&gt;defined(service)&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#9;&lt;span style="color:#960050;background-color:#1e0010"&gt;@echo&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;=== ${service} ===&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#9;&lt;span style="color:#960050;background-color:#1e0010"&gt;@${MAKE}&lt;/span&gt; &lt;span style="color:#960050;background-color:#1e0010"&gt;${MAKEFLAGS}&lt;/span&gt; &lt;span style="color:#960050;background-color:#1e0010"&gt;-C&lt;/span&gt; &lt;span style="color:#960050;background-color:#1e0010"&gt;services/${service}&lt;/span&gt; &lt;span style="color:#960050;background-color:#1e0010"&gt;up&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#960050;background-color:#1e0010"&gt;.else&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#960050;background-color:#1e0010"&gt;.for&lt;/span&gt; &lt;span style="color:#960050;background-color:#1e0010"&gt;service&lt;/span&gt; &lt;span style="color:#960050;background-color:#1e0010"&gt;url&lt;/span&gt; &lt;span style="color:#960050;background-color:#1e0010"&gt;in&lt;/span&gt; &lt;span style="color:#960050;background-color:#1e0010"&gt;${SERVICES}&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#9;&lt;span style="color:#960050;background-color:#1e0010"&gt;@echo&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;=== ${service} ===&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#9;&lt;span style="color:#960050;background-color:#1e0010"&gt;@${MAKE}&lt;/span&gt; &lt;span style="color:#960050;background-color:#1e0010"&gt;${MAKEFLAGS}&lt;/span&gt; &lt;span style="color:#960050;background-color:#1e0010"&gt;-C&lt;/span&gt; &lt;span style="color:#960050;background-color:#1e0010"&gt;services/${service}&lt;/span&gt; &lt;span style="color:#960050;background-color:#1e0010"&gt;up&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#960050;background-color:#1e0010"&gt;.endfor&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#960050;background-color:#1e0010"&gt;.endif&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Lets break it down. First, &lt;code&gt;up&lt;/code&gt; target depends on &lt;code&gt;fetch&lt;/code&gt; and &lt;code&gt;setup&lt;/code&gt;. Once&#10;everything needed is downloaded and initialized, one of the two &lt;code&gt;if&lt;/code&gt; branches&#10;will be triggered. You can run it with &lt;code&gt;make up&lt;/code&gt; or &lt;code&gt;make service=ldap up&lt;/code&gt;.&#10;Former runs &lt;code&gt;up&lt;/code&gt; on all services (or jails in our case) and later get&amp;rsquo;s only&#10;ldap jail up. So the if is there to see if &lt;code&gt;service=&amp;lt;something&amp;gt;&lt;/code&gt; is present on the&#10;command line. If it&amp;rsquo;s not, biggest problem for Reggae starts. That for loop is&#10;where I lost most time figuring out how to have something I would call &amp;ldquo;list of&#10;tuples&amp;rdquo; in Python. After a lot of experimenting, I realized that if I use&#10;&lt;code&gt;service&lt;/code&gt; and &lt;code&gt;url&lt;/code&gt; as indexes in the same loop, it will do what I want. With&#10;&lt;code&gt;down&lt;/code&gt; target you have to do it in reverse, as some jails might depend on other&#10;jails (for nullfs mount, perheps?). As &lt;code&gt;SERVICES&lt;/code&gt; is array, not array of pairs,&#10;you have to reverse the indexes, too: &lt;code&gt;url&lt;/code&gt; and &lt;code&gt;service&lt;/code&gt; in for loop.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-Makefile" data-lang="Makefile"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;down&lt;/span&gt;&lt;span style="color:#f92672"&gt;:&lt;/span&gt; setup&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#960050;background-color:#1e0010"&gt;.if&lt;/span&gt; &lt;span style="color:#960050;background-color:#1e0010"&gt;defined(service)&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#9;&lt;span style="color:#960050;background-color:#1e0010"&gt;@${MAKE}&lt;/span&gt; &lt;span style="color:#960050;background-color:#1e0010"&gt;${MAKEFLAGS}&lt;/span&gt; &lt;span style="color:#960050;background-color:#1e0010"&gt;-C&lt;/span&gt; &lt;span style="color:#960050;background-color:#1e0010"&gt;services/${service}&lt;/span&gt; &lt;span style="color:#960050;background-color:#1e0010"&gt;down&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#960050;background-color:#1e0010"&gt;.else&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;.for url service in ${SERVICES&lt;/span&gt;&lt;span style="color:#f92672"&gt;:&lt;/span&gt;[-1..1]}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#9;@&lt;span style="color:#e6db74"&gt;${&lt;/span&gt;MAKE&lt;span style="color:#e6db74"&gt;}&lt;/span&gt; &lt;span style="color:#e6db74"&gt;${&lt;/span&gt;MAKEFLAGS&lt;span style="color:#e6db74"&gt;}&lt;/span&gt; -C services/&lt;span style="color:#e6db74"&gt;${&lt;/span&gt;service&lt;span style="color:#e6db74"&gt;}&lt;/span&gt; down&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#960050;background-color:#1e0010"&gt;.endfor&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#960050;background-color:#1e0010"&gt;.endif&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Service uses all the same Makefile tricks, so let me just show how I provision&#10;the jails. I implemented ansible.mk as an example, but Reggae is not Ansible&#10;centric. First thing is to mark the default target to run:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-Makefile" data-lang="Makefile"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;.MAIN&lt;/span&gt;&lt;span style="color:#f92672"&gt;:&lt;/span&gt; up&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This way it doesn&amp;rsquo;t matter which target is first, &lt;code&gt;up&lt;/code&gt; will be triggered if you&#10;just type &lt;code&gt;make&lt;/code&gt;. This also solves the problem of adding targets wherever you&#10;like thus extending what can be done with your project. So let&amp;rsquo;s look at how&#10;provisioning works.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-Makefile" data-lang="Makefile"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;provision&lt;/span&gt;&lt;span style="color:#f92672"&gt;:&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#9;@touch .provisioned&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#960050;background-color:#1e0010"&gt;.if&lt;/span&gt; &lt;span style="color:#960050;background-color:#1e0010"&gt;target(do_provision)&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#9;&lt;span style="color:#960050;background-color:#1e0010"&gt;@${MAKE}&lt;/span&gt; &lt;span style="color:#960050;background-color:#1e0010"&gt;${MAKEFLAGS}&lt;/span&gt; &lt;span style="color:#960050;background-color:#1e0010"&gt;do_provision&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#960050;background-color:#1e0010"&gt;.endif&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This is in &lt;code&gt;service.mk&lt;/code&gt; in Reggae. If you defined &lt;code&gt;do_provision&lt;/code&gt; or included&#10;ansible.mk from Reggae, provision will run it. As a matter of fact, this is how&#10;ldap service Makefile looks like:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-Makefile" data-lang="Makefile"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;SERVICE &lt;span style="color:#f92672"&gt;=&lt;/span&gt; ldap&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;REGGAE_PATH &lt;span style="color:#f92672"&gt;=&lt;/span&gt; /usr/local/share/reggae&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;CUSTOM_TEMPLATES &lt;span style="color:#f92672"&gt;=&lt;/span&gt; templates&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#960050;background-color:#1e0010"&gt;.include&lt;/span&gt; &lt;span style="color:#960050;background-color:#1e0010"&gt;&amp;lt;${REGGAE_PATH}/mk/ansible.mk&amp;gt;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#960050;background-color:#1e0010"&gt;.include&lt;/span&gt; &lt;span style="color:#960050;background-color:#1e0010"&gt;&amp;lt;${REGGAE_PATH}/mk/service.mk&amp;gt;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Including &lt;code&gt;ansible.mk&lt;/code&gt; before &lt;code&gt;service.mk&lt;/code&gt; ensures that &lt;code&gt;do_provision&lt;/code&gt; is&#10;defined when &lt;code&gt;provision&lt;/code&gt; target from service.mk is parsed. Also, &lt;code&gt;.MAIN&lt;/code&gt; will&#10;ensure that running just &lt;code&gt;make&lt;/code&gt; doesn&amp;rsquo;t run the first target from ansible.mk.&lt;/p&gt;&#10;&lt;p&gt;If you need to mount something extra in your jail, you can define &lt;code&gt;EXTRA_FSTAB&lt;/code&gt;&#10;with the value of path to fstab containing extra mounts. Also, in order for&#10;provision to work, some files had to be generated from templates, so this is the&#10;directory hierarchy you need in your service repo:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;templates/site.yml.tpl&lt;/li&gt;&#10;&lt;li&gt;playbook/group_vars&lt;/li&gt;&#10;&lt;li&gt;playbook/inventory&lt;/li&gt;&#10;&lt;li&gt;playbook/roles&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;You should know what those are if you ever used Ansible. Also, playbook&#10;directories are the ones where Reggae will either generate some files (that&#10;should be in .gitignore) or expect other files to be.&lt;/p&gt;&#10;&lt;p&gt;The last piece is registering with Consul. So, this is how I configured my&#10;/etc/rc.conf.d/consul:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;consul_enable&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;YES&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;consul_args&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;-bind=127.0.2.1 -client=127.0.2.1 -recursor=8.8.8.8 -ui -server -bootstrap&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You can run Consul in jail, too. As a matter of fact, I do and it&amp;rsquo;s IP is&#10;special: 127.0.2.1. If you do that, Reggae will just work with Consul. In some&#10;of the future posts I&amp;rsquo;ll explain how you can use Ansible with Consul to&#10;provision your jails. If you&amp;rsquo;re inpatient, you can check out my&#10;&lt;a href="https://github.com/mekanix/mail"&gt;mail project&lt;/a&gt;.&lt;/p&gt;&#10;</description></item><item><title>NuttX and Clang</title><link>https://meka.rs/blog/2017/07/03/nuttx-and-clang/</link><pubDate>Mon, 03 Jul 2017 15:23:00 +0000</pubDate><guid>https://meka.rs/blog/2017/07/03/nuttx-and-clang/</guid><description>&lt;p&gt;I am proud owner of a home audio studio, but it has a big flaw: hardware is not&#10;open source. You may think it&amp;rsquo;s not a big deal, but once you want to alter&#10;something, you realize you&amp;rsquo;re stuck. Let me explain. My mixer is digital and&#10;you control it over some other device (computer, or android based device). It&amp;rsquo;s&#10;a nice feature, and it has USB connection, so it can act as an audio interface.&#10;The problem with that is 48kHz sampling, which is OK for live gigs, but not so&#10;much for studio recordings. On the other hand, I have audio interface with 96kHz&#10;sampling, but it can not work as stand alone mixer. To be honest, I don&amp;rsquo;t know&#10;anything about DSP and embeded programming, but I said to myself &amp;ldquo;I know I can&#10;do better than this&amp;rdquo;. That&amp;rsquo;s how &amp;ldquo;the ride&amp;rdquo; began.&lt;/p&gt;&#10;&lt;p&gt;Since then I really wanted to make Arduino Due working, but for some reason GCC&#10;on FreeBSD gave a faulty binary. Back then I was desperate and I knew there is&#10;absolutely no way I can fix the issue with the compiler. Hell, I couldn&amp;rsquo;t even&#10;use it as developer, let alone debug it. So there came Clang/LLVM.&lt;/p&gt;&#10;&lt;p&gt;In &lt;a href="https://meka.rs/blog/2017/06/02/arduino-due-and-clang/"&gt;one of the previous posts&lt;/a&gt; I wrote&#10;about compiling blink LED test with Clang. That gave me hope that FreeBSD might&#10;be the perfect platform for me for embeded programming. As my end goal is to&#10;create a digital mixer with proper sampling rate, I knew from the begining I can&#10;not just write any code. It must be real time and optimized really good. I&amp;rsquo;ve&#10;got to be honest with you: there are two obstacles for me to write such a code.&#10;First one is that Arduino libraries are not optimal. I didn&amp;rsquo;t check, but I do&#10;have friends who are professional embeded programmers who told me that. Second&#10;one is that I&amp;rsquo;m system administrator. You can not imagine the desparation of a&#10;sys admin staring at the board which doesn&amp;rsquo;t blink.&lt;/p&gt;&#10;&lt;p&gt;Now for the good part. I discovered &lt;a href="http://www.nuttx.org/"&gt;NuttX&lt;/a&gt;. A friend in&#10;Tilda hackerspace asked me how do I search for such cool things, and the only&#10;answer I had was &amp;ldquo;gut feeling&amp;rdquo;. Later I discovered that even&#10;&lt;a href="https://www.youtube.com/watch?v=T8fLjWyI5nI"&gt;Sony is using it&lt;/a&gt; for audio in&#10;some of their products. Even better, they use C++11, which is like a scripting&#10;language compared to &amp;ldquo;plain&amp;rdquo; C++ I used back in 2008. When I say &amp;ldquo;used&amp;rdquo; it&amp;rsquo;s an&#10;overstatement. I think more apropriate phrase would be &amp;ldquo;I played with it&amp;rdquo;. So, I&#10;made my goal to make NuttX compile with Clang, and I made it. You can check out&#10;&lt;a href="https://github.com/mekanix/nuttx/tree/feature/clang"&gt;my fork&lt;/a&gt; for now, until&#10;the patch makes it into the official repository. Although I used FreeBSD for&#10;development, I hope it&amp;rsquo;s generic enough to be used on other OSes which Clang/LLVM&#10;supports. It still lacks LLVM libc++ support, and that&amp;rsquo;s what we&amp;rsquo;ll be working on&#10;in the hackerspace today (Tuesday it&amp;rsquo;s embeded programming day) and in the&#10;future.&lt;/p&gt;&#10;&lt;p&gt;So, the final product will be digital mixer which can be controlled over network&#10;based on NuttX, Clang,&#10;&lt;a href="http://www.st.com/content/st_com/en/products/evaluation-tools/product-evaluation-tools/mcu-eval-tools/stm32-mcu-eval-tools/stm32-mcu-nucleo/nucleo-f401re.html"&gt;Nucleo F401RE&lt;/a&gt;,&#10;and Cirus Logic &lt;a href="http://www.mouser.com/ds/2/76/CS4384_F1-39004.pdf"&gt;DAC&lt;/a&gt; /&#10;&lt;a href="http://www.mouser.com/ds/2/76/CirrusLogic_CS5368_F5-356402.pdf"&gt;ADC&lt;/a&gt;. The DAC/ADC choice was made by a new found friend from France I will&#10;talk about in some of the next posts (tramendesly interesting guy) who also&#10;wrote audio and midi server for NuttX.&lt;/p&gt;&#10;</description></item><item><title>FreeBSD and USB MIDI</title><link>https://meka.rs/blog/2017/06/17/freebsd-and-usb-midi/</link><pubDate>Sat, 17 Jun 2017 23:37:00 +0000</pubDate><guid>https://meka.rs/blog/2017/06/17/freebsd-and-usb-midi/</guid><description>&lt;p&gt;The problem I was having was that I could record MIDI, but not send it to&#10;hardware output. For impatient, just run &lt;code&gt;chmod o+rw /dev/umidi*&lt;/code&gt;. Yes, it was&#10;that stupid and it took me few days to realize what&amp;rsquo;s the problem, so let&amp;rsquo;s go&#10;through my setup and debug process. It will be fun, I promice.&lt;/p&gt;&#10;&lt;p&gt;I never used hardware MIDI before, although I used software MIDI for various&#10;things for years, so I have a rough feeling how things should work. Anyway, I&#10;have a footswitch (Behringer FCB1010) MIDI out into USB audio interface&#10;(Presonus AudioBox 1818VLS) in. Then &lt;code&gt;jack_umidi -d /dev/umidi0.0&lt;/code&gt; exposes&#10;hardware MIDI ports as jack MIDI ports. You can use &lt;code&gt;jack_lsp&lt;/code&gt; to display all&#10;jack ports and &lt;code&gt;jack_connect &amp;lt;out&amp;gt; &amp;lt;in&amp;gt;&lt;/code&gt; to connect whatever is coming from&#10;input to output and make your audio interface act as MIDI thru. That way I use&#10;Presonus as a &amp;ldquo;proxy&amp;rdquo; between FCB1010 and my guitar processor (Line 6 POD X3 Pro)&#10;in order to be able to record controls at the same time as I record dry guitar.&#10;I noticed that if I remove Presonus as proxy, controls work, but with it I&#10;couldn&amp;rsquo;t get it to work. I tested to make sure jack is emitting MIDI messages&#10;all, and it did. I tested hardware using my wife&amp;rsquo;s laptop and Linux, and that&#10;worked. At that point I realized it can be too many things, as I have too much&#10;apps in my setup, so I decided to make it as simple as possible: write a MIDI&#10;program in C based on &lt;a href="http://manuals.opensound.com/developer/softsynth.c.html"&gt;synth example&lt;/a&gt;.&#10;To be precise, I wanted to use the &lt;code&gt;open_midi_device&lt;/code&gt; and then whatever I read&#10;from it, I write to it back. The dumbest MIDI thru ever! Given example uses MIDI&#10;device in read only mode, but I needed read/write. Once I tried to alter it, I&#10;got &lt;code&gt;Permission denied&lt;/code&gt;. Looking at /dev/umidi0.0 permissions, no wonder, because&#10;it&amp;rsquo;s owner is root, group is operator and it&amp;rsquo;s mod is 644. To make this right,&#10;add this rules to &lt;code&gt;/etc/devfs.rules&lt;/code&gt; (create if it doesn&amp;rsquo;t exist):&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;[&lt;/span&gt;localrules&lt;span style="color:#f92672"&gt;=&lt;/span&gt;5&lt;span style="color:#f92672"&gt;]&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;add path &lt;span style="color:#e6db74"&gt;&amp;#39;umidi*&amp;#39;&lt;/span&gt; mode &lt;span style="color:#ae81ff"&gt;0666&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To make those rules active, add &lt;code&gt;devfs_system_ruleset=&amp;quot;localrules&amp;quot;&lt;/code&gt; to&#10;&lt;code&gt;/etc/rc.conf&lt;/code&gt;. On next reboot everything will be just fine.&lt;/p&gt;&#10;&lt;p&gt;Have fun with the MIDI!&lt;/p&gt;&#10;</description></item><item><title>Arduino Due and Clang</title><link>https://meka.rs/blog/2017/06/02/arduino-due-and-clang/</link><pubDate>Fri, 02 Jun 2017 04:00:00 +0000</pubDate><guid>https://meka.rs/blog/2017/06/02/arduino-due-and-clang/</guid><description>&lt;p&gt;Since October last year I&amp;rsquo;ve been trying to get my FreeBSD box compile working&#10;binary for Arduino Due. For some reason, GCC produced binary is missing a&#10;section which I observed through readelf. I tried to debug this, but I&amp;rsquo;m not&#10;even novice kernel developer, let alone bare metal embeded programmer. All that&#10;changed tonight (or should I say in the 4am today) when I stumbled upon&#10;&lt;a href="http://hannobraun.de/embedded/2015-04-30-building-with-llvm/"&gt;just the right post&lt;/a&gt;.&#10;I want to be clear, Hanno Braun did all the work, I just want to point out how&#10;to get it working on your FreeBSD box.&lt;/p&gt;&#10;&lt;p&gt;I use -STABLE branch currently so system compiler is Clang 4.0. Beside that&#10;you&amp;rsquo;ll need few extra packages.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;pkg install bossa arm-none-eabi-gcc&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Bossa is used to upload the binary to Arduno and GNU linker for ARM is used as&#10;LLDB is not ready, yet (or I didn&amp;rsquo;t find example how to use it with Arduino).&#10;Also, you&amp;rsquo;ll need to add your user into dialer group.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;pw group mod dialer -m &amp;lt;user&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Let&amp;rsquo;s say we have &lt;code&gt;blink.c&lt;/code&gt; file with the code which blinks the onboard LED and&#10;&lt;code&gt;linker-script.ld&lt;/code&gt; mentioned in the Hanno&amp;rsquo;s post. Just for reference, this is&#10;how he compiles the binary:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cc -nostdlib -ffreestanding -target arm-none-eabi -march&lt;span style="color:#f92672"&gt;=&lt;/span&gt;armv7-m -Tlinker-script.ld -Wl,--entry&lt;span style="color:#f92672"&gt;=&lt;/span&gt;start blink.c -o blink.elf&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;arm-none-eabi-objcopy -O binary blink.elf blink.bin&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;On my box, resulting &lt;code&gt;blink.bin&lt;/code&gt; is 332 bytes! Not bad!&lt;/p&gt;&#10;&lt;p&gt;The flashing part is a bit different on FreeBSD. First, you have to issue soft&#10;erase by connecting to serial port provided by Arduino using 1200 baud. You just&#10;have to connect, so nothing extra is needed.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cu -l /dev/cuaU0 -s &lt;span style="color:#ae81ff"&gt;1200&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Also, you&amp;rsquo;ll have to tell Bossa utility which device file to use.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bossac --write --verify -p /dev/cuaU0 --boot -R blink.bin&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Your Arduino Due should be blinking, now. Just for the sake of completeness, I&amp;rsquo;ll&#10;show what Hanno wrote in .c and .ld file.&lt;/p&gt;&#10;&lt;p&gt;blink.c:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-C" data-lang="C"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;// This is the top of the stack, as provided to us by the linker.&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;extern&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;unsigned&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;int&lt;/span&gt; _estack;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;// This is a partial definition of the vector table. It only defines the&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;// first two entries which, as far as I can tell, are the minimum needed&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;// for a program to work at all.&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;// Space for the other interrupt handlers is reserved. I&amp;#39;m not sure if this&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;// is necessary, but I can imagine that the vector table not having the&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;// right length could cause all kinds of problems (imagine if it was too&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;// short, and the linker would place something else directly after it).&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;typedef&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;struct&lt;/span&gt; {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#9;&lt;span style="color:#66d9ef"&gt;void&lt;/span&gt; &lt;span style="color:#f92672"&gt;*&lt;/span&gt;initial_stack_pointer_value;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#9;&lt;span style="color:#66d9ef"&gt;void&lt;/span&gt; &lt;span style="color:#f92672"&gt;*&lt;/span&gt;reset_handler;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#9;&lt;span style="color:#66d9ef"&gt;char&lt;/span&gt; other_interrupt_vectors[&lt;span style="color:#ae81ff"&gt;44&lt;/span&gt; &lt;span style="color:#f92672"&gt;*&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;4&lt;/span&gt;]; &lt;span style="color:#75715e"&gt;// space for 44 32-bit pointers&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;} VectorTable;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;void&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;start&lt;/span&gt;();&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;// The vector table. We&amp;#39;re using GCC-specific functionality to place this&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;// into the .vectors section, not where it would normally go (I suppose&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;// .rodata). The linker script makes sure that the .vectors section is at&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;// the right place.&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;__attribute__&lt;/span&gt; ((&lt;span style="color:#a6e22e"&gt;section&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#34;.vectors&amp;#34;&lt;/span&gt;)))&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;const&lt;/span&gt; VectorTable vector_table &lt;span style="color:#f92672"&gt;=&lt;/span&gt; {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#9;(&lt;span style="color:#66d9ef"&gt;void&lt;/span&gt; &lt;span style="color:#f92672"&gt;*&lt;/span&gt;)(&lt;span style="color:#f92672"&gt;&amp;amp;&lt;/span&gt;_estack),&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#9;(&lt;span style="color:#66d9ef"&gt;void&lt;/span&gt; &lt;span style="color:#f92672"&gt;*&lt;/span&gt;)start,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;};&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;// Addresses of several registers used to control parallel I/O.&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;static&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;volatile&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;int&lt;/span&gt; &lt;span style="color:#f92672"&gt;*&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;const&lt;/span&gt; pb_pio_enable &lt;span style="color:#f92672"&gt;=&lt;/span&gt; (&lt;span style="color:#66d9ef"&gt;int&lt;/span&gt; &lt;span style="color:#f92672"&gt;*&lt;/span&gt;)&lt;span style="color:#ae81ff"&gt;0x400E1000&lt;/span&gt;;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;static&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;volatile&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;int&lt;/span&gt; &lt;span style="color:#f92672"&gt;*&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;const&lt;/span&gt; pb_output_enable &lt;span style="color:#f92672"&gt;=&lt;/span&gt; (&lt;span style="color:#66d9ef"&gt;int&lt;/span&gt; &lt;span style="color:#f92672"&gt;*&lt;/span&gt;)&lt;span style="color:#ae81ff"&gt;0x400E1010&lt;/span&gt;;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;static&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;volatile&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;int&lt;/span&gt; &lt;span style="color:#f92672"&gt;*&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;const&lt;/span&gt; pb_set_output_data &lt;span style="color:#f92672"&gt;=&lt;/span&gt; (&lt;span style="color:#66d9ef"&gt;int&lt;/span&gt; &lt;span style="color:#f92672"&gt;*&lt;/span&gt;)&lt;span style="color:#ae81ff"&gt;0x400E1030&lt;/span&gt;;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;static&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;volatile&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;int&lt;/span&gt; &lt;span style="color:#f92672"&gt;*&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;const&lt;/span&gt; pb_clear_output_data &lt;span style="color:#f92672"&gt;=&lt;/span&gt; (&lt;span style="color:#66d9ef"&gt;int&lt;/span&gt; &lt;span style="color:#f92672"&gt;*&lt;/span&gt;)&lt;span style="color:#ae81ff"&gt;0x400E1034&lt;/span&gt;;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;// Bit mask for PB27. This is pin 13 (the built-in LED) on the Arduino Due.&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;static&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;const&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;int&lt;/span&gt; pb27_mask &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;0x08000000&lt;/span&gt;;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;// Addresses of several registers used to control the real-time timer.&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;static&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;volatile&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;int&lt;/span&gt; &lt;span style="color:#f92672"&gt;*&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;const&lt;/span&gt; timer_mode_register &lt;span style="color:#f92672"&gt;=&lt;/span&gt; (&lt;span style="color:#66d9ef"&gt;int&lt;/span&gt; &lt;span style="color:#f92672"&gt;*&lt;/span&gt;)&lt;span style="color:#ae81ff"&gt;0x400E1A30&lt;/span&gt;;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;static&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;volatile&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;int&lt;/span&gt; &lt;span style="color:#f92672"&gt;*&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;const&lt;/span&gt; timer_value_register &lt;span style="color:#f92672"&gt;=&lt;/span&gt; (&lt;span style="color:#66d9ef"&gt;int&lt;/span&gt; &lt;span style="color:#f92672"&gt;*&lt;/span&gt;)&lt;span style="color:#ae81ff"&gt;0x400E1A38&lt;/span&gt;;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;// As the name suggests, this function sleeps for a given number of&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;// milliseconds. Our replacement for Arduino&amp;#39;s delay function.&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;void&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;sleep_ms&lt;/span&gt;(&lt;span style="color:#66d9ef"&gt;int&lt;/span&gt; milliseconds) {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#9;&lt;span style="color:#66d9ef"&gt;int&lt;/span&gt; sleep_until &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#f92672"&gt;*&lt;/span&gt;timer_value_register &lt;span style="color:#f92672"&gt;+&lt;/span&gt; milliseconds;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#9;&lt;span style="color:#66d9ef"&gt;while&lt;/span&gt; (&lt;span style="color:#f92672"&gt;*&lt;/span&gt;timer_value_register &lt;span style="color:#f92672"&gt;&amp;lt;&lt;/span&gt; sleep_until) {}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;// This function is the entry point for our application and the handler&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;// function for the reset interrupt.&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;void&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;start&lt;/span&gt;() {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#9;&lt;span style="color:#75715e"&gt;// Enable PB27 (pin 13) and configure it for output.&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#9;&lt;span style="color:#f92672"&gt;*&lt;/span&gt;pb_pio_enable &lt;span style="color:#f92672"&gt;=&lt;/span&gt; pb27_mask;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#9;&lt;span style="color:#f92672"&gt;*&lt;/span&gt;pb_output_enable &lt;span style="color:#f92672"&gt;=&lt;/span&gt; pb27_mask;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#9;&lt;span style="color:#75715e"&gt;// Set the timer to a resolution of a millisecond.&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#9;&lt;span style="color:#f92672"&gt;*&lt;/span&gt;timer_mode_register &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;0x00000020&lt;/span&gt;;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#9;&lt;span style="color:#75715e"&gt;// Continuously set and clear output on PB27 (pin 13). This blinks&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#9;&lt;span style="color:#75715e"&gt;// the Due&amp;#39;s built-in LED, which is the single purpose of this&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#9;&lt;span style="color:#75715e"&gt;// program.&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#9;&lt;span style="color:#66d9ef"&gt;while&lt;/span&gt; (&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;) {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#9;&#9;&lt;span style="color:#f92672"&gt;*&lt;/span&gt;pb_set_output_data &lt;span style="color:#f92672"&gt;=&lt;/span&gt; pb27_mask;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#9;&#9;&lt;span style="color:#a6e22e"&gt;sleep_ms&lt;/span&gt;(&lt;span style="color:#ae81ff"&gt;200&lt;/span&gt;);&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#9;&#9;&lt;span style="color:#f92672"&gt;*&lt;/span&gt;pb_clear_output_data &lt;span style="color:#f92672"&gt;=&lt;/span&gt; pb27_mask;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#9;&#9;&lt;span style="color:#a6e22e"&gt;sleep_ms&lt;/span&gt;(&lt;span style="color:#ae81ff"&gt;200&lt;/span&gt;);&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#9;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;linker-script.ld:&lt;/p&gt;&#10;&lt;pre tabindex="0"&gt;&lt;code&gt;/* ----------------------------------------------------------------------------&#10; * SAM Software Package License&#10; * ----------------------------------------------------------------------------&#10; * Copyright (c) 2012, Atmel Corporation&#10; *&#10; * All rights reserved.&#10; *&#10; * Redistribution and use in source and binary forms, with or without&#10; * modification, are permitted provided that the following condition is met:&#10; *&#10; * - Redistributions of source code must retain the above copyright notice,&#10; * this list of conditions and the disclaimer below.&#10; *&#10; * Atmel&amp;#39;s name may not be used to endorse or promote products derived from&#10; * this software without specific prior written permission.&#10; *&#10; * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL &amp;#34;AS IS&amp;#34; AND ANY EXPRESS OR&#10; * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF&#10; * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE&#10; * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,&#10; * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT&#10; * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,&#10; * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF&#10; * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING&#10; * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,&#10; * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.&#10; * ----------------------------------------------------------------------------&#10; */&#10;&#10;OUTPUT_FORMAT(&amp;#34;elf32-littlearm&amp;#34;, &amp;#34;elf32-littlearm&amp;#34;, &amp;#34;elf32-littlearm&amp;#34;)&#10;OUTPUT_ARCH(arm)&#10;SEARCH_DIR(.)&#10;&#10;/* Memory Spaces Definitions */&#10;MEMORY&#10;{&#10;&#9;rom (rx) : ORIGIN = 0x00080000, LENGTH = 0x00080000 /* Flash, 512K */&#10;&#9;sram0 (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00010000 /* sram0, 64K */&#10;&#9;sram1 (rwx) : ORIGIN = 0x20080000, LENGTH = 0x00008000 /* sram1, 32K */&#10;&#9;ram (rwx) : ORIGIN = 0x20070000, LENGTH = 0x00018000 /* sram, 96K */&#10;}&#10;&#10;/* Section Definitions */&#10;SECTIONS&#10;{&#10; .text :&#10; {&#10; . = ALIGN(4);&#10; _sfixed = .;&#10; KEEP(*(.vectors .vectors.*))&#10; *(.text .text.* .gnu.linkonce.t.*)&#10; *(.glue_7t) *(.glue_7)&#10; *(.rodata .rodata* .gnu.linkonce.r.*)&#10; *(.ARM.extab* .gnu.linkonce.armextab.*)&#10;&#10; /* Support C constructors, and C destructors in both user code&#10; and the C library. This also provides support for C++ code. */&#10; . = ALIGN(4);&#10; KEEP(*(.init))&#10; . = ALIGN(4);&#10; __preinit_array_start = .;&#10; KEEP (*(.preinit_array))&#10; __preinit_array_end = .;&#10;&#10; . = ALIGN(4);&#10; __init_array_start = .;&#10; KEEP (*(SORT(.init_array.*)))&#10; KEEP (*(.init_array))&#10; __init_array_end = .;&#10;&#10; . = ALIGN(0x4);&#10; KEEP (*crtbegin.o(.ctors))&#10; KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))&#10; KEEP (*(SORT(.ctors.*)))&#10; KEEP (*crtend.o(.ctors))&#10;&#10; . = ALIGN(4);&#10; KEEP(*(.fini))&#10;&#10; . = ALIGN(4);&#10; __fini_array_start = .;&#10; KEEP (*(.fini_array))&#10; KEEP (*(SORT(.fini_array.*)))&#10; __fini_array_end = .;&#10;&#10; KEEP (*crtbegin.o(.dtors))&#10; KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))&#10; KEEP (*(SORT(.dtors.*)))&#10; KEEP (*crtend.o(.dtors))&#10;&#10; . = ALIGN(4);&#10; _efixed = .; /* End of text section */&#10; } &amp;gt; rom&#10;&#10; /* .ARM.exidx is sorted, so has to go in its own output section. */&#10; PROVIDE_HIDDEN (__exidx_start = .);&#10; .ARM.exidx :&#10; {&#10; *(.ARM.exidx* .gnu.linkonce.armexidx.*)&#10; } &amp;gt; rom&#10; PROVIDE_HIDDEN (__exidx_end = .);&#10;&#10; . = ALIGN(4);&#10; _etext = .;&#10;&#10; .relocate : AT (_etext)&#10; {&#10; . = ALIGN(4);&#10; _srelocate = .;&#10; *(.ramfunc .ramfunc.*);&#10; *(.data .data.*);&#10; . = ALIGN(4);&#10; _erelocate = .;&#10; } &amp;gt; ram&#10;&#10; /* .bss section which is used for uninitialized data */&#10; .bss ALIGN(4) (NOLOAD) :&#10; {&#10; . = ALIGN(4);&#10; _sbss = . ;&#10; _szero = .;&#10; *(.bss .bss.*)&#10; *(COMMON)&#10; . = ALIGN(4);&#10; _ebss = . ;&#10; _ezero = .;&#10; } &amp;gt; ram&#10;&#10; . = ALIGN(4);&#10; _end = . ;&#10;&#10; /* .stack_dummy section doesn&amp;#39;t contains any symbols. It is only&#10; used for linker to calculate size of stack sections, and assign&#10; values to stack symbols later */&#10; .stack_dummy :&#10; {&#10; *(.stack*)&#10; } &amp;gt; ram&#10;&#10; /* Set stack top to end of ram, and stack limit move down by&#10; * size of stack_dummy section */&#10; __StackTop = ORIGIN(ram) + LENGTH(ram);&#10; __StackLimit = __StackTop - SIZEOF(.stack_dummy);&#10; PROVIDE(_sstack = __StackLimit);&#10; PROVIDE(_estack = __StackTop);&#10;}&#10;&lt;/code&gt;&lt;/pre&gt;</description></item><item><title>FreeBSD Cloud and DevOps 2</title><link>https://meka.rs/blog/2017/04/04/freebsd-cloud-and-devops-2/</link><pubDate>Tue, 04 Apr 2017 12:17:00 +0000</pubDate><guid>https://meka.rs/blog/2017/04/04/freebsd-cloud-and-devops-2/</guid><description>&lt;p&gt;So you have all the pieces installed and configured. Let&amp;rsquo;s do something on top&#10;of that. I don&amp;rsquo;t like Vagrant, now that CBSD and Jails are around, but it&amp;rsquo;s&#10;perfect for DevOps jobs. I remember a friend of mine using Makefile for DevOps,&#10;even if under it is Docker or Vagrant. It&amp;rsquo;s small, portable and available on&#10;every OS worth mentioning. Nice way to keep everything low on resource usage.&lt;/p&gt;&#10;&lt;p&gt;So, let&amp;rsquo;s say we want to have at least 2 targets: up and setup. Setup would set&#10;up config files, where up would do the actual job. For example:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-Makefile" data-lang="Makefile"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;PROJECT&lt;span style="color:#f92672"&gt;=&lt;/span&gt;myproj&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;up&lt;/span&gt;&lt;span style="color:#f92672"&gt;:&lt;/span&gt; setup&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#9;@sudo cbsd jstart &lt;span style="color:#e6db74"&gt;${&lt;/span&gt;PROJECT&lt;span style="color:#e6db74"&gt;}&lt;/span&gt; &lt;span style="color:#f92672"&gt;||&lt;/span&gt; true&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;setup&lt;/span&gt;&lt;span style="color:#f92672"&gt;:&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#9;@sed -e &lt;span style="color:#e6db74"&gt;&amp;#34;s:PROJECT:&lt;/span&gt;&lt;span style="color:#e6db74"&gt;${&lt;/span&gt;PROJECT&lt;span style="color:#e6db74"&gt;}&lt;/span&gt;&lt;span style="color:#e6db74"&gt;:g&amp;#34;&lt;/span&gt; provision/inventory.tpl &amp;gt;provision/inventory&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#9;@sed -e &lt;span style="color:#e6db74"&gt;&amp;#34;s:PROJECT:&lt;/span&gt;&lt;span style="color:#e6db74"&gt;${&lt;/span&gt;PROJECT&lt;span style="color:#e6db74"&gt;}&lt;/span&gt;&lt;span style="color:#e6db74"&gt;:g&amp;#34;&lt;/span&gt; provision/group_vars/all.tpl &amp;gt;provision/group_vars/all&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#9;@sed -e &lt;span style="color:#e6db74"&gt;&amp;#34;s:PROJECT:&lt;/span&gt;&lt;span style="color:#e6db74"&gt;${&lt;/span&gt;PROJECT&lt;span style="color:#e6db74"&gt;}&lt;/span&gt;&lt;span style="color:#e6db74"&gt;:g&amp;#34;&lt;/span&gt; provision/localhost.yml.tpl &amp;gt;provision/localhost.yml&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#9;@sed -e &lt;span style="color:#e6db74"&gt;&amp;#34;s:PROJECT:&lt;/span&gt;&lt;span style="color:#e6db74"&gt;${&lt;/span&gt;PROJECT&lt;span style="color:#e6db74"&gt;}&lt;/span&gt;&lt;span style="color:#e6db74"&gt;:g&amp;#34;&lt;/span&gt; provision/site.yml.tpl &amp;gt;provision/site.yml&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#9;@sudo cbsd jcreate jconf&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;${&lt;/span&gt;PWD&lt;span style="color:#e6db74"&gt;}&lt;/span&gt;/cbsd.conf &lt;span style="color:#f92672"&gt;||&lt;/span&gt; true&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#9;@sudo sh -c &lt;span style="color:#e6db74"&gt;&amp;#39;sed -e &amp;#34;s:PWD:${PWD}:g&amp;#34; -e &amp;#34;s:PROJECT:${PROJECT}:g&amp;#34; fstab.conf &amp;gt;/cbsd/jails-fstab/fstab.${PROJECT}&amp;#39;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You can see that &lt;code&gt;up&lt;/code&gt; target is using cbsd.conf and fstab.conf. You can generate&#10;cbsd.conf with &lt;code&gt;cbsd jconstruct-tui&lt;/code&gt;, like usual, just choose not to start it&#10;once you configure it and CBSD will save the config in temporary file you can&#10;use as a template. The fstab.conf is simple:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;/cbsd/jails-data/PROJECT-data/etc /etc nullfs rw &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;/cbsd/jails-data/PROJECT-data/root /root nullfs rw &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;/cbsd/jails-data/PROJECT-data/tmp /tmp nullfs rw &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;/cbsd/jails-data/PROJECT-data/usr/home /usr/home nullfs rw &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;/cbsd/jails-data/PROJECT-data/usr/local /usr/local nullfs rw &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;/cbsd/jails-data/PROJECT-data/usr/compat /usr/compat nullfs rw &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;/cbsd/jails-data/PROJECT-data/var /var nullfs rw &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;PWD /usr/home/devel/workdir nullfs rw &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;One nice thing Vagrant has is it will provision your VM if it has provisioner&#10;configured if it&amp;rsquo;s the first time you&amp;rsquo;re starting that VM. Let&amp;rsquo;s add that:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-Makefile" data-lang="Makefile"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;up&lt;/span&gt;&lt;span style="color:#f92672"&gt;:&lt;/span&gt; setup&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#9;@sudo cbsd jcreate jconf&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;${&lt;/span&gt;PWD&lt;span style="color:#e6db74"&gt;}&lt;/span&gt;/cbsd.conf &lt;span style="color:#f92672"&gt;||&lt;/span&gt; true&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#960050;background-color:#1e0010"&gt;.if&lt;/span&gt; &lt;span style="color:#960050;background-color:#1e0010"&gt;!exists(.provisioned)&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#9;&lt;span style="color:#960050;background-color:#1e0010"&gt;@${MAKE}&lt;/span&gt; &lt;span style="color:#960050;background-color:#1e0010"&gt;${MAKEFLAGS}&lt;/span&gt; &lt;span style="color:#960050;background-color:#1e0010"&gt;provision&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#960050;background-color:#1e0010"&gt;.endif&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;provision&lt;/span&gt;&lt;span style="color:#f92672"&gt;:&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#9;@sudo ansible-playbook -i provision/inventory provision/site.yml&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#9;@touch .provisioned&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Instead of &lt;code&gt;vagrant ssh&lt;/code&gt; I added &lt;code&gt;make login&lt;/code&gt;:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-Makefile" data-lang="Makefile"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;login&lt;/span&gt;&lt;span style="color:#f92672"&gt;:&lt;/span&gt; up&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#9;@sudo cbsd jlogin &lt;span style="color:#e6db74"&gt;${&lt;/span&gt;PROJECT&lt;span style="color:#e6db74"&gt;}&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Finally, there are tear down targets, as well:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-Makefile" data-lang="Makefile"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;down&lt;/span&gt;&lt;span style="color:#f92672"&gt;:&lt;/span&gt; setup&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#9;@sudo cbsd jstop &lt;span style="color:#e6db74"&gt;${&lt;/span&gt;PROJECT&lt;span style="color:#e6db74"&gt;}&lt;/span&gt; &lt;span style="color:#f92672"&gt;||&lt;/span&gt; true&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#9;@sudo ansible-playbook -i provision/inventory provision/teardown.yml&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;destroy&lt;/span&gt;&lt;span style="color:#f92672"&gt;:&lt;/span&gt; down&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#9;@rm -f provision/inventory provision/site.yml provision/group_vars/all .provisioned&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#9;@sudo cbsd jremove &lt;span style="color:#e6db74"&gt;${&lt;/span&gt;PROJECT&lt;span style="color:#e6db74"&gt;}&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;All that&amp;rsquo;s left now is to write Ansible playbook, but I&amp;rsquo;ll leave that for some&#10;other post.&lt;/p&gt;&#10;</description></item><item><title>Sing, beastie, sing!</title><link>https://meka.rs/blog/2017/01/25/sing-beastie-sing/</link><pubDate>Wed, 25 Jan 2017 19:00:00 +0000</pubDate><guid>https://meka.rs/blog/2017/01/25/sing-beastie-sing/</guid><description>&lt;p&gt;FreeBSD digital audio workstation, or DAW for short, is now possible. At this&#10;very moment it&amp;rsquo;s not user friendly that much, but you&amp;rsquo;ll manage. What I want to&#10;say is that I worked on porting some of the audio apps to FreeBSD, met some&#10;other people interested in porting audio stuff and became heavily involved with&#10;DrumGizmo - drum sampling engine. Let me start with the basic setup.&lt;/p&gt;&#10;&lt;p&gt;FreeBSD doesn&amp;rsquo;t have hard real-time support, but it&amp;rsquo;s pretty close. For the&#10;needs of audio, FreeBSD&amp;rsquo;s implementation of real-time is sufficient and, in my&#10;opinion, superior to the one you can get on Linux with RT path (which is ugly,&#10;not supported by distributions and breaks apps like VirtualBox). As default&#10;install of FreeBSD is concerned with real-time too much, we have to tweak sysctl&#10;a bit, so append this to your /etc/sysctl.conf:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;kern.timecounter.alloweddeviation&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;hw.usb.uaudio.buffer_ms&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;2&lt;/span&gt; &lt;span style="color:#75715e"&gt;# only on -STABLE for now&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;hw.snd.latency&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;kern.coredump&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;So let me go through the list. First item tells FreeBSD how many events it can&#10;aggregate (or wait for) before emitting them. The reason this is the default is&#10;because aggregating events saves power a bit, and currently more laptops are&#10;running FreeBSD than DAWs. Second one is the lowest possible buffer for USB&#10;audio driver. If you&amp;rsquo;re not using USB audio, this won&amp;rsquo;t change a thing. Third&#10;option is for defining default latency if program doesn&amp;rsquo;t set one. Every program&#10;can change this value for it self, but most of them don&amp;rsquo;t deal with this. Fourth&#10;one has nothing to do with real-time, but dealing with programs that consume&#10;~3GB of RAM, dumping cores around made a problem on my machine. Besides, core&#10;dumps are only useful if you know how to debug the problem, or someone is&#10;willing to do that for you. I like to not generate those files by default, but&#10;if some app is constantly crashing, I enable dumps, run the app, crash it, and&#10;disable dumps again. I lost 30GB in under a minute by examining 10 different&#10;drumkits of DrumGizmo and all of them gave me 3GB of core file.&lt;/p&gt;&#10;&lt;p&gt;If you have audio interface with more than 8 channels, you&amp;rsquo;ll need virtual_oss&#10;and virtual_oss_ctl. The decision was made that more than 8 channels of audio&#10;are more suitable to be mixed, resampled and generally processed in user space.&#10;&lt;a href="https://github.com/mekanix/virtual_oss_rc"&gt;My rc script&lt;/a&gt; for virtual_oss is&#10;still pending, as I just can&amp;rsquo;t find the time to work on it. Copy virtual_oss&#10;from that repo to /usr/local/etc/rc.d and it will start virtual_oss assuming&#10;your audio interface has 18 channels. You have to add &lt;code&gt;virtual_oss_enable=&amp;quot;YES&amp;quot;&lt;/code&gt;&#10;to your /etc/rc.conf and you can alter the arguments by adding your own&#10;&lt;code&gt;virtual_oss_flags=&amp;quot;...&amp;quot;&lt;/code&gt;. For example, take a look at the rc script, as it has&#10;default value of virtual_oss_flags.&lt;/p&gt;&#10;&lt;p&gt;Next is my jack setup, which is oneliner:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# jackd -r -d oss -r 88200 -C /dev/vdsp.jack -P /dev/vdsp.jack -i 18 -o 18&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;I&amp;rsquo;m not using real-time for jack, as it&amp;rsquo;s not supported for a non-root process&#10;to raise it&amp;rsquo;s priority to real-time. You can do that by&#10;&lt;code&gt;sudo rtprio 10 -(pgrep jackd)&lt;/code&gt;.&lt;/p&gt;&#10;&lt;p&gt;Currently, Ardour 5.5 and DrumGizmo are in conflict.&#10;&lt;a href="https://github.com/tilda-center/freebsd-ports"&gt;Our hackerspace forked FreeBSD ports&lt;/a&gt;&#10;and added a quick patch for Ardour which removes the conflict. I talked to the&#10;maintainer of the port about it and he&amp;rsquo;s working on a proper patch and will try&#10;to push it upstream, to Ardour developers.&lt;/p&gt;&#10;&lt;p&gt;As there are some resampling problems with virtual_oss, you&amp;rsquo;re advised to use&#10;PulseAudio (not my favorite solution) by telling it to use virtual_oss. You&amp;rsquo;ll&#10;have to add the following to the /usr/local/etc/pulse/default.pa:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;load-module module-oss device&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;/dev/vdsp.jack&amp;#34;&lt;/span&gt; sink_name&lt;span style="color:#f92672"&gt;=&lt;/span&gt;output source_name&lt;span style="color:#f92672"&gt;=&lt;/span&gt;input&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And just for the reference, this is my virtual_oss config:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;virtual_oss_enable&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;YES&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;virtual_oss_flags&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;-S -i 8 -C 18 -c 18 -r 88200 -b 32 -s 384 -f /dev/dsp0 -c 2 -d dsp -c 18 -d vdsp.jack -t vdsp.ctl -M i,0,8,0,0,0 -M i,0,9,0,0,0&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ul&gt;&#10;&lt;li&gt;-S: enable resampling&lt;/li&gt;&#10;&lt;li&gt;-i: enable real time&lt;/li&gt;&#10;&lt;li&gt;-c/-C: 18ch in/out&lt;/li&gt;&#10;&lt;li&gt;-r: sampling rate&lt;/li&gt;&#10;&lt;li&gt;-b: bits&lt;/li&gt;&#10;&lt;li&gt;-s: size of buffer&lt;/li&gt;&#10;&lt;li&gt;-d: virtual oss device to create&lt;/li&gt;&#10;&lt;li&gt;-t: virtual oss control device to create&lt;/li&gt;&#10;&lt;li&gt;-M: mirror first input to outputs 8/9&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;The reason I mirror first input (input zero) to 8/9 is because I use my first&#10;input for guitar, and outputs 8/9 are towards guitar processor. With this setup&#10;I can play OSS, JACK and PulseAudio sound all at the same time, which I was not&#10;able to do on Linux.&lt;/p&gt;&#10;&lt;p&gt;Now sing, beastie!&lt;/p&gt;&#10;</description></item><item><title>FreeBSD Cloud and DevOps 1</title><link>https://meka.rs/blog/2017/01/08/freebsd-cloud-and-devops-1/</link><pubDate>Sun, 08 Jan 2017 16:00:00 +0000</pubDate><guid>https://meka.rs/blog/2017/01/08/freebsd-cloud-and-devops-1/</guid><description>&lt;p&gt;The reason I tried FreeBSD in August, after 11 years of being happy with Gentoo&#10;then Debian was the article about Docker on FreeBSD. I knew about PF, ZFS and&#10;DTrace from the past, but ability to run Linux images was just too good to be&#10;true. To the extent, it is too good, and the reason is that ABI Linux support is&#10;not complete. If you happen to need that missing bit in ABI, it&amp;rsquo;s a show stopper&#10;for anybody.&lt;/p&gt;&#10;&lt;p&gt;Poor was the result, I&amp;rsquo;m afraid, but there&amp;rsquo;s a positive side: Docker is not why&#10;I&amp;rsquo;m stuck with FreeBSD now. :o) There are so much better implementations of&#10;container technologies, I abandoned Docker completely. That and&#10;&lt;a href="https://thehftguy.com/2016/11/01/docker-in-production-an-history-of-failure/"&gt;Docker&amp;rsquo;s continuous failure&lt;/a&gt;&#10;make you think of changing the tech stack completely. In this serie, I&amp;rsquo;ll walk&#10;you through my current stack for production and devops.&lt;/p&gt;&#10;&lt;p&gt;For start, let me give you some of the vocabulary:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;ZFS - File system and volume manager.&lt;/li&gt;&#10;&lt;li&gt;Jail - Container technology, most similar to Linux LXC or Solaris Zones. Some&#10;think of it as chroot on steroids.&lt;/li&gt;&#10;&lt;li&gt;PF - Packet Filter - firewall.&lt;/li&gt;&#10;&lt;li&gt;BHyve - Type 2 hypervizor, or what provides VMs - virtual machines.&lt;/li&gt;&#10;&lt;li&gt;DNSMasq - DHCP and DNS server - keeps track of which virtual machine is where.&lt;/li&gt;&#10;&lt;li&gt;CBSD - Manages jails and virtual machines - create, up, down, destroy.&lt;/li&gt;&#10;&lt;li&gt;Sudo - Execute stuff as root when needed - devops side, mostly.&lt;/li&gt;&#10;&lt;li&gt;Make{,file} - Make is similar to GNU make with all it&amp;rsquo;s rules in Makefile.&lt;/li&gt;&#10;&lt;li&gt;Resolvconf - Software which configures /etc/resolv.conf&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;For this post I want you to get a working CBSD env. I&amp;rsquo;ll just assume you have&#10;machine which you&amp;rsquo;ll dedicate to FreeBSD only. Tips for install: use &amp;ldquo;Guided ZFS&#10;partitioning&amp;rdquo; and create user when asked. You&amp;rsquo;ll get to know the ZFS over time,&#10;but for now think of it as a requirement for easier jail and VM management. So,&#10;the only thing you have after install is FreeBSD base system on ZFS pool (by&#10;default, it&amp;rsquo;s name is zroot), root user and a regular user. As root prepare the&#10;CBSD:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# zfs create -o mountpoint=/cbsd zroot/cbsd&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# pkg install cbsd dnsmasq bind-tools tightvnc&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# env workdir=&amp;#34;/cbsd&amp;#34; /usr/local/cbsd/sudoexec/initenv&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# mkdir /usr/local/etc/dnsmasq.d&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;What this does is creates ZFS dataset which will be mounted on /cbsd as soon as&#10;&lt;code&gt;zfs create&lt;/code&gt; finishes. For now you can think of a dataset as of a partition&#10;which can be created and destroyed while ZFS pool is mounted. Don&amp;rsquo;t worry if you&#10;don&amp;rsquo;t undestand ZFS features, it&amp;rsquo;s really complex piece of software.&lt;/p&gt;&#10;&lt;p&gt;After ZFS dataset creation, &lt;code&gt;pkg&lt;/code&gt; installs CBSD and CBSD is initialized. I have&#10;few tips for the initialization, as it&amp;rsquo;s interactive: don&amp;rsquo;t enable NAT, use&#10;172.16.0.1 for DNS and &amp;ldquo;10.0.0.0/16 10.0.0.1/32&amp;rdquo; for IP range. Although CBSD&#10;does great job at figuring out what PF rules it should insert/remove, I like all&#10;the rules in one place, /etc/pf.conf:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ext_if &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;re0&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;jail_if &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;lo1&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bridge_if &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;bridge1&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;set skip on &lt;span style="color:#f92672"&gt;{&lt;/span&gt; lo0, $jail_if, $bridge_if &lt;span style="color:#f92672"&gt;}&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;scrub in all&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;nat on $ext_if from &lt;span style="color:#f92672"&gt;{&lt;/span&gt; &lt;span style="color:#f92672"&gt;(&lt;/span&gt;$jail_if:network&lt;span style="color:#f92672"&gt;)&lt;/span&gt;, &lt;span style="color:#f92672"&gt;(&lt;/span&gt;$bridge_if:network&lt;span style="color:#f92672"&gt;)&lt;/span&gt; &lt;span style="color:#f92672"&gt;}&lt;/span&gt; to any -&amp;gt; &lt;span style="color:#f92672"&gt;(&lt;/span&gt;$ext_if&lt;span style="color:#f92672"&gt;)&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;block in log all&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;pass out all keep state&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;pass proto tcp to any port ssh&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;pass inet proto &lt;span style="color:#f92672"&gt;{&lt;/span&gt; icmp, igmp &lt;span style="color:#f92672"&gt;}&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You can see lo1 and bridge1 interfaces, so they have to be configured. That&amp;rsquo;s&#10;done in /etc/rc.conf:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cloned_interfaces&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;bridge1 lo1&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ifconfig_bridge1&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;description re0 172.16.0.1&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ifconfig_lo1&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;up&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;A bit of an explanation is needed. First, lo1 will be used for jails, bridge1&#10;for VMs. As CBSD does great job of automating VM management, it also creates&#10;bridge and tap interface(s). As I wanted the network part to be as static as&#10;possible, I&amp;rsquo;m creating bridge1 the way CBSD would and give it the IP which VMs&#10;will use as DNS server and gateway. My only network card on desktop is re0,&#10;hence the description. Disclaimer: all this CBSD network mangling is more&#10;appropriately done by patching /cbsd/vnet.subr and /cbsd/vnet-tui.subr.&lt;/p&gt;&#10;&lt;p&gt;You have to enable PF, of course. I like to do it in /etc/rc.conf.d directory for&#10;DevOps purposes I&amp;rsquo;ll talk about later. There are two files for PF: pf and pflog.&lt;/p&gt;&#10;&lt;p&gt;/etc/rc.conf.d/pf:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;pf_enable&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;YES&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;/etc/rc.conf.d/pflog:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;pflog_enable&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;YES&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;As CBSD doesn&amp;rsquo;t provide DHCP or DNS for VMs, we&amp;rsquo;ll use DNSMasq. For devops on&#10;your desktop/laptop it&amp;rsquo;s enough and even for small to mid size cloud setups it&#10;would work. On large scale deployments you probably have BIND, already. To enable&#10;DNSMasq, first make it start on boot.&lt;/p&gt;&#10;&lt;p&gt;/etc/rc.conf.d/dnsmasq:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;dnsmasq_enable&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;YES&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You need to edit the config in /usr/local/etc/dnsmasq.conf. These are the&#10;options I changed:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;domain&lt;span style="color:#f92672"&gt;=&lt;/span&gt;vm&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;dhcp-range&lt;span style="color:#f92672"&gt;=&lt;/span&gt;172.16.0.50,172.16.0.250,12h&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;interface&lt;span style="color:#f92672"&gt;=&lt;/span&gt;lo0&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;interface&lt;span style="color:#f92672"&gt;=&lt;/span&gt;bridge1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bind-interfaces&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;resolv-file&lt;span style="color:#f92672"&gt;=&lt;/span&gt;/usr/local/etc/dnsmasq.d/resolvconf&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;conf-dir&lt;span style="color:#f92672"&gt;=&lt;/span&gt;/usr/local/etc/dnsmasq.d/,*.conf&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;All options are present in the file initially, but commented out. In short, this&#10;config provides DHCP and DNS service only on bridge1 which is dedicated for VMs&#10;while allowing for on-the-fly VM info changing by including everything from&#10;/usr/local/etc/dnsmaq.d directory which ends with .conf.&lt;/p&gt;&#10;&lt;p&gt;For easier URLs, you can use DNSMasq as your DNS server through 127.0.0.1. To do&#10;that this is what you need to have in /etc/resolvconf.conf:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;name_servers&lt;span style="color:#f92672"&gt;=&lt;/span&gt;127.0.0.1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;dnsmasq_resolv&lt;span style="color:#f92672"&gt;=&lt;/span&gt;/usr/local/etc/dnsmasq.d/resolvconf&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Whenever your DNS settings change, resolvconf will write the info into the file&#10;which will make DNSMasq re-read it.&lt;/p&gt;&#10;&lt;p&gt;The last thing to do is configure BHyve. You&amp;rsquo;ll need to load the modules and let&#10;CBSD take care of the rest, so add these lines to /boot/loader.conf:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;zfs_load&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;YES&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;vmm_load&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;YES&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;if_tap_load&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;YES&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;if_bridge_load&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;YES&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;nmdm_load&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;YES&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;ZFS and VMM are self explainatory module names, while TAP and Bridge are two&#10;kinds of interfaces used to emulate network stack inside VM. Null Modem or nmdm&#10;is used to get the terminal output through a serial line and tmux.&lt;/p&gt;&#10;&lt;p&gt;Reboot and you should be able to create new jails and virtual machines:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# cbsd jconstruct-tui&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# cbsd jstart &amp;lt;jail&amp;gt;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# cbsd jlogin &amp;lt;jail&amp;gt;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# cbsd jstop &amp;lt;jail&amp;gt;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# cbsd jremove &amp;lt;jail&amp;gt;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;With &lt;code&gt;cbsd jconstruct-tui&lt;/code&gt; you have to choose lo1 for the interface, once you&amp;rsquo;re&#10;greeted with the dialog based form. Commands for VMs are the same, just prepend&#10;them with &lt;code&gt;b&lt;/code&gt; instead of &lt;code&gt;j&lt;/code&gt;, e.g. &lt;code&gt;cbsd bconstruct-tui&lt;/code&gt;. The lo1 interface is&#10;only for jails, so for VMs you don&amp;rsquo;t have to do anything special.&lt;/p&gt;&#10;&lt;p&gt;Nice thing about bstart is that it will start bhyve process in tmux so &lt;code&gt;tmux a&lt;/code&gt;&#10;will open it. Another nice thing is that if booting from CD-ROM image, BHyve&#10;will wait for the VNC connection to start the boot process. That means that&#10;booting will not start the second you issued &lt;code&gt;cbsd bstart&lt;/code&gt;, but once you start&#10;&lt;code&gt;vncviewer localhost&lt;/code&gt;, so you can see all the messages.&lt;/p&gt;&#10;&lt;p&gt;Now, go and play with it a bit. Don&amp;rsquo;t worry, you don&amp;rsquo;t need any images or&#10;anything, CBSD will download them for you when you select appropriate template.&lt;/p&gt;&#10;</description></item><item><title>Lost Passport</title><link>https://meka.rs/blog/2017/01/02/lost-passport/</link><pubDate>Mon, 02 Jan 2017 03:00:00 +0000</pubDate><guid>https://meka.rs/blog/2017/01/02/lost-passport/</guid><description>&lt;p&gt;My wife and I went from Hamburg to Belgrade on 31st December. We had connected&#10;flights and from Hamburg we went to Zurich. In Zurich we realized my wife lost&#10;her passport. The situation is hilarious looking back, but totally not fun while&#10;it&amp;rsquo;s happening. So, her passport fell from her pocket in the plane and we&#10;noticed that on our way to the customs. What happens next is hell breaking loose,&#10;which we kindda expected for several reasons, but let me go back to the begining.&lt;/p&gt;&#10;&lt;p&gt;The reason why we were in Hamburg so late in the year was CCC, of course. That&#10;means we&amp;rsquo;re with our friends in Hamburg on the night of 30th, and flying home on&#10;the morning of the 31th December. One thing was sure: we won&amp;rsquo;t get enough sleep.&#10;Laying down in 4am and getting up at 6am makes you slugish. We asked a German&#10;friend about the S-Bahn to airport, and although it helped, seing everything in&#10;German in 7am throws you off the balance. Moreover, S1, which we were waiting,&#10;has (at least) 2 platforms which are not next to each other. After some reading&#10;we found out which is the right one and which dirrection we need. Now comes the&#10;first big problem: first 3 cars don&amp;rsquo;t end up on the same place as last 3 cars,&#10;so in order to get to the airport, you have to enter the right one. Description&#10;is, of course, in German. Finding someone awake at 7am on 31th December is hard.&#10;Finding someone who speaks German and English at that exact same time is &amp;hellip;&#10;frustrating, but we made it. Second problem: although the customs work 24/7, the&#10;one you need to get you EU tax money back works 9-17!!! There&amp;rsquo;s no country in&#10;the world that doesn&amp;rsquo;t hide behind bureaucracy when they need to give you (back)&#10;money. That was really, really close to our first departure, that I got my money&#10;back, got mu bag and entered the plane with ~5 minutes breaks between the&#10;actions. Third problem: got in Zurich, no passport. For fuck sake, how big that&#10;airport is! It&amp;rsquo;s even bigger when you have a forth problem: you didn&amp;rsquo;t go to&#10;toilet for 5 days, and your somach decides to do something about it that very&#10;minute. Fift problem: wife had an operation last year and running is not what&#10;she can do for long. Sixt problem: it&amp;rsquo;s fucking New Year, no one is working &amp;hellip;&#10;almost. Luckily, the clerk we saw about lost passport is one very capable woman&#10;who managed to find it by having 1000 phone calls. One thing was going on our&#10;hand: our plane was comming from Amsterdam where the fog made all flights late&#10;around ~40 minutes.&lt;/p&gt;&#10;&lt;p&gt;So, after around 40 minutes of running with a feeling of a knife in my stomach,&#10;we got into the line for departure. At that moment I&amp;rsquo;m all swetting like crazy,&#10;pushing all my things into my wife&amp;rsquo;s hands with only 4 words: &amp;ldquo;I can&amp;rsquo;t, no&#10;longer!&amp;rdquo;. How do you hurry in that situation? Relax so you mussle doesn&amp;rsquo;t cramp,&#10;or hurry like crazy? I&amp;rsquo;ll tell you this much: that was the fastest toilet&#10;business in my life. OK, everything is fine, I&amp;rsquo;m in line again, than in plane,&#10;we&amp;rsquo;re in Belgrade &amp;hellip; fuck!!! Did that clerk say she called the gate to take our&#10;bags off the plane because they can not travel without us? I remember she did&#10;that, but did she call back? After ~15 minutes at staring at other people&#10;luggage, we saw our bags. Of course they were the last.&lt;/p&gt;&#10;&lt;p&gt;Everything is fine now, really. We only need to get home, which has little&#10;detour to get a drivers dog so she doesn&amp;rsquo;t freak out when all the cracks start&#10;banging. After that we finally got home! Ah, rest, finally.&lt;/p&gt;&#10;&lt;p&gt;Rest my ass! In 4 hours friends are comming, we&amp;rsquo;re celebrating New Year at our&#10;flat. Shower, eat, sleep 2 hours, drink, eat, drink, drink &amp;hellip; in 3am pass out.&#10;Please, no more exciting and tiresome events untill summer, please!&lt;/p&gt;&#10;</description></item><item><title>FreeBSD WiFi and Ethernet Bridging and Aggregation</title><link>https://meka.rs/blog/2016/12/24/freebsd-wifi-and-ethernet-bridging-and-aggregation/</link><pubDate>Sat, 24 Dec 2016 22:27:00 +0000</pubDate><guid>https://meka.rs/blog/2016/12/24/freebsd-wifi-and-ethernet-bridging-and-aggregation/</guid><description>&lt;p&gt;The title is cumbersome but the topic is quite ordinary life, to be honest. Idea&#10;is to have WiFi and Ethernet cards unified. On the router that means that&#10;whether you&amp;rsquo;re getting your address over Wifi or Ethernet, you get the same&#10;range. On the client (usually laptop) we want to not be able to distinguish if&#10;we&amp;rsquo;re on Wifi or Ethernet connection, but we do prefer Ethernet.&lt;/p&gt;&#10;&lt;h2 id="router-configuration"&gt;&#10; Router Configuration&#10;&lt;/h2&gt;&#10;&lt;p&gt;When you think about it, what we need is described in lame terms as &amp;ldquo;I want wifi&#10;and ethernet interface to have same IPv4 address&amp;rdquo;. As that&amp;rsquo;s kindda imposible,&#10;you can have a bridge with Spanning Tree Protocol (or STP for short), which is&#10;the next best thing. Bridge is just one virtual interface which binds, or&#10;bridges, two or more interfaces. In my case, ethernet interface is re1 and wifi&#10;interface is wlan0. To create a bridge with STP (to be totally honest, FreeBSD&#10;defaults to RSTP or Rapid STP which is STP compatible) you&amp;rsquo;ll add the following&#10;to /etc/rc.conf:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# WiFi config&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;wlans_ath0&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;wlan0&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;create_args_wlan0&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;wlanmode hostap mode 11gn&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ifconfig_wlan0&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;ssid mywifi channel 8&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;hostapd_enable&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;YES&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Bridge config&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ifconfig_re1&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;up&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cloned_interfaces&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;bridge0&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ifconfig_bridge0&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;addm re1 addm wlan0 stp re1 stp wlan0&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ifconfig_bridge0_alias0&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;inet 192.168.5.1 netmask 255.255.255.0&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;That&amp;rsquo;s it. You&amp;rsquo;ll notice that we enabled hostapd, too. It is what provides WPA2&#10;on WiFi. It&amp;rsquo;s config is:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;interface&lt;span style="color:#f92672"&gt;=&lt;/span&gt;wlan0&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;debug&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ctrl_interface&lt;span style="color:#f92672"&gt;=&lt;/span&gt;/var/run/hostapd&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ctrl_interface_group&lt;span style="color:#f92672"&gt;=&lt;/span&gt;wheel&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ssid&lt;span style="color:#f92672"&gt;=&lt;/span&gt;mywifi&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;wpa&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;2&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;wpa_passphrase&lt;span style="color:#f92672"&gt;=&lt;/span&gt;password&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;wpa_key_mgmt&lt;span style="color:#f92672"&gt;=&lt;/span&gt;WPA-PSK&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;wpa_pairwise&lt;span style="color:#f92672"&gt;=&lt;/span&gt;CCMP&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;I found tutorials which set MAC address of all three interfaces: wifi, ethernet&#10;and bridge to the same value. I tried it and it doesn&amp;rsquo;t work. As a matter of&#10;fact, the config show here will produce that you see the same MAC of your router&#10;no matter how you connect to it: Wifi or Ethernet.&lt;/p&gt;&#10;&lt;p&gt;What you probably want is NAT enabled router. My prefered tool is PF. To enable&#10;PF and logger, add the following to /etc/rc.conf:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;pf_enable&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;YES&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;pflog_enable&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;YES&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;gateway_enable&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;YES&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The simplest rules for this use case are:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ext_if &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;re0&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;int_if &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;bridge0&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;set skip on lo0&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;scrub in all&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;nat on $ext_if from $int_if:network to any -&amp;gt; &lt;span style="color:#f92672"&gt;(&lt;/span&gt;$ext_if&lt;span style="color:#f92672"&gt;)&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;block in all&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;pass out all keep state&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;pass proto tcp to any port ssh&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;pass inet proto &lt;span style="color:#f92672"&gt;{&lt;/span&gt; icmp, igmp &lt;span style="color:#f92672"&gt;}&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="laptop-configuration"&gt;&#10; Laptop Configuration&#10;&lt;/h2&gt;&#10;&lt;p&gt;What we want on laptop is quite the opposite of the router: instead all bridged&#10;interfaces to work at the same time, we want only one to be active. The rule for&#10;activation is: if there&amp;rsquo;s no signal (or carier) on the Ethernet interface, use&#10;WiFi. That kind of virtual interface is called lagg or Link Aggregation. One&#10;lagg has master interface (in our case Ethernet one) and slaves. Master&#10;interface is the one that is added to the lagg the first. To aggregate WiFi and&#10;Ethernet on em0 interface, add the following to /etc/rc.conf:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cloned_interfaces&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;lagg0&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;wlans_iwn0&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;wlan0&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;create_args_wlan0&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;country US regdomain FCC&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ifconfig_lagg0&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;laggproto failover laggport em0 laggport wlan0 DHCP&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ifconfig_wlan0&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;ether f0:de:f1:64:2c:3b WPA&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ifconfig_em0&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;up&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;There are 3 important parts. First, wlan0 MAC is set to be the same as the one&#10;found on em0. This minifies the time it takes to switch between the two&#10;interfaces. Second, don&amp;rsquo;t put DHCP anywhere except on the lagg0. Third, you have&#10;to bring all the interfaces you use up (hence the last line).&lt;/p&gt;&#10;&lt;p&gt;With the router that leases the addresses only from one pool, and interfaces&#10;that are effectively on the same IP range, aggregating interfaces on laptop with&#10;the same MAC address will give you the same IP no matter how you&amp;rsquo;re connecting.&#10;Also, as FreeBSD PF doesn&amp;rsquo;t have egress, having all outbound traffic on one&#10;interface, be it virtual or hardware, makes things easier to filter and route.&lt;/p&gt;&#10;</description></item><item><title>FreeBSD Network Optimization and CCC Tickets</title><link>https://meka.rs/blog/2016/11/07/freebsd-network-optimization-and-ccc-tickets/</link><pubDate>Mon, 07 Nov 2016 23:45:00 +0000</pubDate><guid>https://meka.rs/blog/2016/11/07/freebsd-network-optimization-and-ccc-tickets/</guid><description>&lt;p&gt;Today was the first day of presale tickets for people without voucher. Let me be&#10;precise, today at 20:00 started the DDoS on&#10;&lt;a href="http://tickets.events.ccc.de"&gt;ticket servers&lt;/a&gt;. So, let me put things into&#10;perspective. Because CCC is more and more popular, they had to do something to&#10;limit the number of tickets. They decided to give vouchers to hackerspaces and&#10;alikes. As we heard of that too late (or were too lazy, pick your favorite),&#10;the reply we got was &amp;ldquo;we ended requests for vouchers earlier today&amp;rdquo;. Bummer!&lt;/p&gt;&#10;&lt;p&gt;Next you can do is buy a normal ticket, but that&amp;rsquo;s limited, too. You have 3&#10;chances to do so: 07, 19 and 25 November. So, let&amp;rsquo;s see. Last year there were&#10;about 13k people. Let&amp;rsquo;s say only 5k are buying tickets. Guess what, they all&#10;tried to do it today at exactly 20:00. If you dig/nslookup tickets.events.ccc.de,&#10;you&amp;rsquo;ll see that it&amp;rsquo;s the only one IP. There might be multiple app servers behind&#10;nginx (yeah, we saw nginx 500 error messages), but still, that&amp;rsquo;s HUGE amount of&#10;traffic for one IP. And then games began.&lt;/p&gt;&#10;&lt;p&gt;My wife and I loaded the page 30 minutes before, so the CSS, JS and whatnot is&#10;cached. We knew there&amp;rsquo;s going to be problems, so we were prepared. We both have&#10;Linux with dual boot: Windows in her case, FreeBSD in mine. I saw it in her eyes&#10;&amp;ldquo;I already booted Windows &amp;hellip;&amp;rdquo; and got reply to silent question &amp;ldquo;Yeah, and&#10;you&amp;rsquo;re going to race with all the people on better OSes?&amp;rdquo;. So there we are,&#10;Linux on her machine, and FreeBSD on mine. I was thinking two things: she&amp;rsquo;s&#10;already on Linux, if the site doesn&amp;rsquo;t work on FreeBSD for some reason, there&amp;rsquo;s&#10;her machine to refresh the page while I reboot, and let&amp;rsquo;s add diversity, who&#10;knows maybe Linux has some problems that FreeBSD doesn&amp;rsquo;t. I was going to go with&#10;BSD because they practically implemented TCP/IP sockets (hence the name &amp;ldquo;BSD&#10;sockets&amp;rdquo;). I know that network stack implementation is better on FreeBSD than&#10;Linux, and I don&amp;rsquo;t even want to discuss Windows. Did it work? Oh yeah! My wife&amp;rsquo;s&#10;Linux didn&amp;rsquo;t load the first page while I bought us tickets. So let&amp;rsquo;s see how I&#10;did it.&lt;/p&gt;&#10;&lt;p&gt;Does network stack and BSD vs. Linux really work? Absolutely NO! The difference&#10;is that my wife&amp;rsquo;s on laptop over WiFi, and I&amp;rsquo;m on desktop over ethernet. WPA2,&#10;I&amp;rsquo;m sure, is much more overhead than Linux implementation of TCP/IP stack. I&amp;rsquo;m&#10;sorry if you feel fooled by the title, but I really thought about optimal&#10;implementation of TCP/IP when I considered which OS to boot, and it&amp;rsquo;s more fun&#10;to have a title like this then &amp;ldquo;How I bought CCC tickets&amp;rdquo;.&lt;/p&gt;&#10;&lt;p&gt;So, here we are, the page is loaded, I choose to buy 2 tickets (yeah, my wife is&#10;a huge fan of hacking) and &amp;hellip; error 500. I feel I used all the force in the&#10;Universe pressing F5 frantically. Then I got to the page to choose payment method&#10;and then one page to enter email, than the final one, which didn&amp;rsquo;t work. I&#10;decided I&amp;rsquo;m gonna get the tickets no matter what! On the third page, you&amp;rsquo;re&#10;informed the ticket is reserved for you for 30 minutes. If for any reason you&#10;don&amp;rsquo;t want it, you just close the browser and the ticket is returned to the pool&#10;of tickets. That&amp;rsquo;s nasty, as I have to do something with the server which is&#10;under heavy DDoS . Of course it was about to timeout when I tried a little hack&#10;(it&amp;rsquo;s not even a hack, to be honest): return to the previous page, click the&#10;same button, and after using the F5 force again, you get another 30 minutes. So,&#10;I figured how to not be time limited. That&amp;rsquo;s cool! Then comes the hard part. On&#10;the last page where you confirm everything, submit button didn&amp;rsquo;t work and gave&#10;some errors about django in the browser console. WHAT THE FUCKING FUCK!!! Pissed&#10;off I looked at #33c3 hashtag on twitter and saw that most people who bought&#10;tickets are speaking German. Right! Switch to German on the last page, and F5&#10;force again. IT WORKED!!! Do I speak German? Nein! The button looks the same and&#10;I really didn&amp;rsquo;t care about the letters.&lt;/p&gt;&#10;&lt;p&gt;The moral of the story: you better be system and network administrator and&#10;backend and frontend developer if you want to buy CCC ticket without the voucher.&lt;/p&gt;&#10;&lt;h2 id="update-1"&gt;&#10; Update 1&#10;&lt;/h2&gt;&#10;&lt;p&gt;No matter how you intend to pay for the ticket, select Bank transfer&#10;as selecting credit card will give you one more form to fill in. You&amp;rsquo;ll get the&#10;email which, among other details, contains link to tiketing server&amp;rsquo;s page with&#10;details about your ticket. Tomorrow, when all the DDoS is over, go to that link&#10;and choose &amp;ldquo;switch payment method&amp;rdquo; if you want to pay with credit card. This way&#10;you have one page less to display, which is infinity for a server under DDoS.&lt;/p&gt;&#10;</description></item><item><title>FreeBSD In Two Months</title><link>https://meka.rs/blog/2016/10/28/freebsd-in-two-months/</link><pubDate>Fri, 28 Oct 2016 00:15:00 +0000</pubDate><guid>https://meka.rs/blog/2016/10/28/freebsd-in-two-months/</guid><description>&lt;p&gt;My last post was about CCC and it&amp;rsquo;s almost the time for a new one. I was so&#10;bussy hacking things that I forgot I have a blog. Huge amount of new things&#10;happened to me, but I&amp;rsquo;ll focus on the FreeBSD. I installed BETA1 of 11.0 as soon&#10;as it came out as I really wanted to see how good is the Docker support. Now I&#10;don&amp;rsquo;t even use Docker, and FreeBSD is my main OS on laptop and desktop, although&#10;I still have Debian on desktop for the sake of recording my band. So let me give&#10;you some context and my history with this operating system.&lt;/p&gt;&#10;&lt;p&gt;I remember I was using 5.0 for a while and 4.9 before it for quite a while. The&#10;first thing I noticed is the size of the system and the speed at which world is&#10;compiled. It was so much faster to compile FreeBSD libc than glibc that I&#10;suspected that there&amp;rsquo;s something missing in the BSD libc. For me, that was all I&#10;needed to switch from using SuSE 7.2 at the time (I think). It was 2003-2005&#10;that I used FreeBSD with some pauses. As my university was under heavy influence&#10;by M$, I had trouble adjusting Linux to do what was needed. Doing the same on&#10;FreeBSD wasn&amp;rsquo;t even poissible. Soon, I switch to Gentoo, as it was the next best&#10;thing.&lt;/p&gt;&#10;&lt;p&gt;To be honest, I never looked back to FreeBSD until two months ago. What I read&#10;was that version 11 is comming with the Docker support, which I used heavily on&#10;my servers. From past experience I knew about the beauty of FreeBSD build system&#10;and PF as firewall and ZFS and DTrace and &amp;hellip; I was lucky enough that about a&#10;month after I installed FreeBSD on my laptop, there was a EuroBSD conference in&#10;my country. Of course I rushed there! But something happened since then.&lt;/p&gt;&#10;&lt;p&gt;Talking to some of the clients and friends gave me impression that GPLv3 is&#10;scaring people and companies. As a huge fan of GNU, I just thought they are not&#10;using open source, so they don&amp;rsquo;t know what they are talking about, but then I&#10;read about GPLv3 more. As a tool for binding people to write more open source&#10;code, it became monopolistic licence in a way that if anything is GPL,&#10;everything is GPL. This resonated in my head for some time and that was what&#10;made me realize why are BSD people so licence pure - you can&amp;rsquo;t ignore business&#10;just because you have this vision in your head that says &amp;ldquo;everyone should write&#10;open source code&amp;rdquo;. BSD community seamed (and it is) more permissive and open to&#10;the real world.&lt;/p&gt;&#10;&lt;p&gt;But licences are not my strong point, so I&amp;rsquo;ll stick to the tech part. Let me&#10;just briefly describe some of the technologies in the BSD world. First in my&#10;book is ZFS. It is so much more than a file system. It has RAID included, if&#10;needed, it has copy-on-write, it&amp;rsquo;s got 128bit system, it has volume manager and&#10;on top of it all, RAID is not just RAID, it&amp;rsquo;s RAIDZ, meaning ZFS keeps extra&#10;checksum for every block, which make it super consistent.&lt;/p&gt;&#10;&lt;p&gt;Second on my list of favorite technologies is PF. It&amp;rsquo;s so readable that&#10;sometimes I wonder if they screwed up implementation just to make it more&#10;readable (of course they didn&amp;rsquo;t). Even so, it&amp;rsquo;s strongest point is not syntax,&#10;it&amp;rsquo;s statefulness of the firewall. PF deserves a post on it&amp;rsquo;s on but to put the&#10;statefull firewall into context: it gives you more logical connections between&#10;the packets.&lt;/p&gt;&#10;&lt;p&gt;Third one is DTrace which stands for &amp;ldquo;dynamic tracer&amp;rdquo;. It&amp;rsquo;s an interesting idea&#10;that every OS is full of probes in different places, and when turned on, they&#10;give you information about &amp;hellip; well, depends what probs you enable. When no&#10;probe is enabled, it has no overhead at all, which makes it great for debugging&#10;production servers. It can trace kernel and user space and has a AWKish syntax.&lt;/p&gt;&#10;&lt;p&gt;Fourth, and last for this post is Jail. Although it&amp;rsquo;s technology introduced in&#10;FreeBSD world in 2000, somehow it didn&amp;rsquo;t get much publicity. Together with ZFS&#10;it makes one hell of a system for hosting stuff. Also, that&amp;rsquo;s the core of&#10;FreeBSD implementation of Docker.&lt;/p&gt;&#10;&lt;p&gt;Almost none of that is what I&amp;rsquo;m working on, right now. Although I made a switch&#10;because of the above mentioned technologies, the main reason for me to hack it&#10;more is it&amp;rsquo;s fully preemptive kernel, which is the core of any real time system.&#10;Real time makes sound better and delay from plucking a guitar string to hearing&#10;it on the speakers is lower. Most of the work on supporting audio interfaces&#10;with more than 8 channes is done by Hans Petter Selasky, so I&amp;rsquo;d like to&#10;publicly thank him for all the trouble he when through. Although my FreeBSD DAW&#10;is not perfect due to smaller number of audio apps then the number found in&#10;Linux world, it shows huge potential.&lt;/p&gt;&#10;&lt;p&gt;What happened in 2 months exactly? As I&amp;rsquo;m Python and JavaScript developer,&#10;musician, video editor and in one word hacker, I didn&amp;rsquo;t expect FreeBSD to&#10;fullfill all my needs (no other OS did). Today only Drumgizmo is what&amp;rsquo;s missing&#10;on my FreeBSD box to make it a perfect DAW. To be honest, after two months of&#10;using it I expect that I would be learning kernel development in order to make&#10;any sound. Instead, it almost gives me all the power I would ever need (yeah,&#10;I know there&amp;rsquo;s new power to be found).&lt;/p&gt;&#10;&lt;p&gt;So to put it all together, what FreeBSD gives me is the power to have one&#10;machine for everything: security, firewalling, FS consistency, real time audio&#10;and development environment for any language I choose to work with. I really&#10;enjoy my new OS, but I have one concern. As I&amp;rsquo;m talking to people how great&#10;FreeBSD is, I&amp;rsquo;m affraid I&amp;rsquo;ll become one of those preachers who can&amp;rsquo;t stop&#10;talking. It&amp;rsquo;s not my vocal cords I&amp;rsquo;m concerned about, as after all I am a singer&#10;in a metal band. It&amp;rsquo;s the damage I might do to the FreeBSD as a project if I&amp;rsquo;m&#10;preaching about it too much.&lt;/p&gt;&#10;&lt;p&gt;Thank you, FreeBSD project!&lt;/p&gt;&#10;</description></item><item><title>32C3</title><link>https://meka.rs/blog/2016/04/20/32c3/</link><pubDate>Wed, 20 Apr 2016 15:00:00 +0000</pubDate><guid>https://meka.rs/blog/2016/04/20/32c3/</guid><description>&lt;p&gt;We got in Hamburg few days before Christmas so we had enough time to see the&#10;city, this time. I had a feeling that people in Hamburg are depressed which was&#10;a drag as I got there not too happy about the recent development of my life. To&#10;be honest, first few days I thought I would be better at home, or anywhere else.&#10;But then the congress started and it got a bit better, but the feeling of&#10;something missing didn&amp;rsquo;t go away. Even worse, I wasn&amp;rsquo;t the only one who had that&#10;feeling. As every normal guy would do, I fixed it with rakija, of course.&lt;/p&gt;&#10;&lt;p&gt;Although it&amp;rsquo;s important for me to tell you the whole state of mind I was in,&#10;that&amp;rsquo;s not the reason I&amp;rsquo;m writing this post. We (LUGoNS) were lucky enough to&#10;have a table beside MetaLab guys. Amount of happiness coming from them was&#10;amazing. As always, CCC was full of wonderfully talented hackers and I had great&#10;time at the Python Booth, for example. Great time passes fast, and the closing&#10;ceremony was getting close.&lt;/p&gt;&#10;&lt;p&gt;For me, the whole point of going to 32C3 was closing ceremony. It was really&#10;emotional for me. Emotional enough to find a shoulder to weep on it. Tears just&#10;broke out of me and all bad feelings started to pour out of me. What really&#10;happened on that ceremony was that the guy who was talking said something I&#10;didn&amp;rsquo;t know it will be such a trigger = &amp;ldquo;Look around you, remember small things&#10;and take it home&amp;rdquo;. And I did. That&amp;rsquo;s when I realized what is going on.&lt;/p&gt;&#10;&lt;p&gt;The background story first. Back in 1999. my country was bombed by NATO. Few&#10;days of that period I spent in a moist, old basement with my parents, PC&#10;motherboard and a magazine with audio synthesizers. That basement had no&#10;electricity, toilet or anything, so when something was needed we went to the&#10;house. What&amp;rsquo;s important is that it was full of equipment. At that point I made&#10;a promise to myself that I will have huge pile of electronics one day.&#10;Meaningful electronics! That &amp;ldquo;remember the small things&amp;rdquo; somehow reminded me of&#10;that day 16 years ago. After coming to my senses my girlfriend asked me &amp;ldquo;what&#10;the hell was that?&amp;rdquo;. The only thing I kept repeating was &amp;ldquo;I made it&amp;rdquo;. I was&#10;repeating it like hypnotized.&lt;/p&gt;&#10;&lt;p&gt;I&amp;rsquo;m a co-founder of a hackerspace and we&amp;rsquo;re piling wonderful electronics. I&#10;barely hold my self together while writing this and remembering = &amp;ldquo;from the&#10;shitty basement to a hackerspace&amp;rdquo;.&lt;/p&gt;&#10;&lt;p&gt;Thank you CCC, I will remember it all!&lt;/p&gt;&#10;</description></item><item><title>I am a hacker</title><link>https://meka.rs/blog/2015/11/30/i-am-a-hacker/</link><pubDate>Mon, 30 Nov 2015 22:00:00 +0000</pubDate><guid>https://meka.rs/blog/2015/11/30/i-am-a-hacker/</guid><description>&lt;p&gt;What is a hacker? Who the hell knows? On top of that, I&amp;rsquo;m clamming I&amp;rsquo;m one of&#10;them. What gives me the right? I&amp;rsquo;m not sure, but in short, I know one thing:&#10;hackers are smart and they never give up. Once I heard the smartest man I&amp;rsquo;ve&#10;ever met saying to a developer: &amp;ldquo;OK, make something, then Meka will do the&#10;magic&amp;rdquo;. That&amp;rsquo;s the best compliment I&amp;rsquo;ve ever got. I guess that makes me smart,&#10;too. And never giving up &amp;hellip; I know I&amp;rsquo;m that kind of guy. If anyone wants me to&#10;do anything I&amp;rsquo;m remotely interested in, it&amp;rsquo;s enough I hear &amp;ldquo;that it&amp;rsquo;s&#10;impossible&amp;rdquo;. I guess it&amp;rsquo;s enough proof I&amp;rsquo;m persistent.&lt;/p&gt;&#10;&lt;p&gt;Let&amp;rsquo;s go from the start. I knew I&amp;rsquo;m good at math since 3rd grade elementary&#10;school. I&amp;rsquo;ve been the best physics student in elementary, too. I&amp;rsquo;ve never been&#10;the best student, that&amp;rsquo;s for sure. I was more interested in asking &amp;ldquo;why&amp;rdquo; and&#10;&amp;ldquo;how&amp;rdquo; than having a good grade. I always asked myself &amp;ldquo;what if we do this&#10;differently&amp;rdquo; and it always gave me bad grades, but somehow, when things go&#10;south, I get to answer the tough questions. High school was even worse. I was a&#10;bit above the average. University? Totally below average. Of course, if grades&#10;mean anything to you. The mean shit to me. And let me take this opportunity to&#10;say that except 3 professors, all of them are total crap. One of the proofs is&#10;that I&amp;rsquo;ve got this answer to &amp;ldquo;Why am I failing programming?&amp;rdquo;: &amp;ldquo;Your algorithms&#10;are too advanced for professors to get them&amp;rdquo;. Let me repeat: I was below&#10;average.&lt;/p&gt;&#10;&lt;p&gt;Today, I&amp;rsquo;m co-founder of a &lt;a href="http://tilda.center/"&gt;Tilda Center&lt;/a&gt;, Novi Sad&amp;rsquo;s&#10;hackerspace. So, I&amp;rsquo;m discussing funding and finances with my friend and he told&#10;me &amp;ldquo;Don&amp;rsquo;t make the same mistake I made with &lt;a href="https://lugons.org/"&gt;LUGoNS&lt;/a&gt;&amp;rdquo;. What&#10;he told me is &amp;ldquo;don&amp;rsquo;t invest too much of your own money into it&amp;rdquo;. How can I not&#10;to? I believe in Tilda with my whole heart. So, after a while, I&amp;rsquo;m telling him&#10;something like &amp;ldquo;Well, yeah, I know what you mean, but I can make it work, trust&#10;me. Besides, I know math, physics, electronics, backend and frontend&#10;programming, system and network administration, devops, guitar playing, singing,&#10;audio and video production and post production, cooking and I&amp;rsquo;m starting with&#10;capoeira trainings this Tuesday. With all this knowledge, I will make it work&#10;on Mars, if needed&amp;rdquo;. I&amp;rsquo;m not good at all those things equaly, obviously, but&#10;I&amp;rsquo;m refusing to accept I&amp;rsquo;m not above average at any of those except capoeira.&lt;/p&gt;&#10;&lt;p&gt;For the end, let me just tell you I&amp;rsquo;m not trying to brag around how good I am at&#10;anything. This post is to remind me I&amp;rsquo;m not as stupid as I have tendency to tell&#10;people I am, and to remind me of the most important achievement in my life: I&#10;AM A HACKER!!! I have to repeat that in order to understand why I&amp;rsquo;m so&#10;different and unaccepted. Thank you for reading!&lt;/p&gt;&#10;</description></item><item><title>OpenBSD WiFi</title><link>https://meka.rs/blog/2015/08/18/openbsd-wifi/</link><pubDate>Tue, 18 Aug 2015 22:00:00 +0000</pubDate><guid>https://meka.rs/blog/2015/08/18/openbsd-wifi/</guid><description>&lt;p&gt;I&amp;rsquo;m a proud owner of &lt;a href="http://pcengines.ch/apu.htm"&gt;APU&lt;/a&gt;. I&amp;rsquo;m currently running&#10;OpenBSD on it. It&amp;rsquo;s pretty &lt;a href="https://github.com/mekanix/openbsd-config"&gt;simple config&lt;/a&gt;.&#10;Everything was &amp;ldquo;working&amp;rdquo; until I decided to tighten the screws on the device, as&#10;I purchased a new screwdriver. Since then, WiFi is terribly slow. I had ~2s&#10;delay between pressing a key and seeing character when logged in over ssh from&#10;laptop to desktop. So, I&amp;rsquo;ve disassembled the device and assembled it all over&#10;again, but no luck. Then I realized that I&amp;rsquo;m using 11b mode. Switching to&#10;&lt;a href="https://github.com/mekanix/openbsd-config/commit/08cb7e40cb1f67e446d6255327661af9aeb87f4b"&gt;11g and priority 0&lt;/a&gt;&#10;made it all working well. SSH is more responsive and&#10;&lt;a href="http://speedtest.net"&gt;speed test&lt;/a&gt; shows 10Mbit/s instead of ~5Mbit/s it showed&#10;previously. I&amp;rsquo;ve learned my lesson.&lt;/p&gt;&#10;</description></item><item><title>Guitar Pickups</title><link>https://meka.rs/blog/2015/07/25/guitar-pickups/</link><pubDate>Sat, 25 Jul 2015 22:00:00 +0000</pubDate><guid>https://meka.rs/blog/2015/07/25/guitar-pickups/</guid><description>&lt;p&gt;When I was searching for my guitar, I read a lot of articles about pickups, too.&#10;In &lt;a href="http://tilda.center"&gt;Tilda Center&lt;/a&gt; we have at least two guys who play guitar&#10;beside me, and once we had discussion about this exact topic, which made me&#10;believe that there are not enough articles about pickups, types, usages,&#10;electronics behind them etc. Or, maybe, the articles are not clear enough. I&amp;rsquo;ll&#10;try to explain.&lt;/p&gt;&#10;&lt;p&gt;First, there are few types of different types of pickups. The most famous are&#10;single coil and humbucker. Let&amp;rsquo;s start with single coil.&lt;/p&gt;&#10;&lt;p&gt;From &lt;a href="http://media.musiciansfriend.com/is/image/MMGS7/S1-Hot-Passive-Single-Coil-Pickup/308017000000000-00-750x750.jpg"&gt;this picture&lt;/a&gt;&#10;you can see that single coil have single line of magnets. If you&amp;rsquo;ve ever played&#10;a guitar with this kind of pickups, you&amp;rsquo;ve noticed that they have a lot of&#10;noise, especially if you have CRT monitor. Single coil have &amp;ldquo;flat&amp;rdquo; sound and a&#10;bit thin.&lt;/p&gt;&#10;&lt;p&gt;&lt;a href="http://www.musik-produktiv.it/pic-003750176xl/dimarzio-humbucker-the-breed.jpg"&gt;Humbuckers&lt;/a&gt;,&#10;on the other hand, have two lines of magnets. If you&amp;rsquo;ve ever heard of balanced&#10;cable, you know the basic principle: one line of magnets have their polarity&#10;N-S, while the other line is S-N. That means that one line of magnets&#10;generate sound, while the other line generates inverse sound. In perfect&#10;conditions, if you mix those two signals, generated sound will cancel each other&#10;out, and the only signal that you&amp;rsquo;ll end up is the noise generated in magnet&#10;coils. As a matter of fact, noise will be doubled, because generated noise is&#10;not inversed like the sound. I hope this is clear enough. Now imagine that you&#10;invert one of the sounds before mixing. What you&amp;rsquo;d have is opposite: double the&#10;sound, noise canceled out.&lt;/p&gt;&#10;&lt;p&gt;The difference in sound is obvious. There&amp;rsquo;s less noise (or hum) in humbuckers&#10;than single coils. As magnets and wires are not perfect, humbucker will cancel&#10;out some of the high frequencies. To me, that&amp;rsquo;s a good thing, as I find single&#10;coil sound too piercing.&lt;/p&gt;&#10;&lt;p&gt;There are other types of pickups, but they are either single coil or humbucker&#10;in it&amp;rsquo;s essence. For example, EMG and Seymor Duncan have active pickups: the&#10;ones which have small integrated amp in them so the signal they output is much&#10;higher (think high gain distortion). In order to power up that amp, 9V battery&#10;is needed, and is usually placed with the rest of the electronics on the back of&#10;the guitar.&lt;/p&gt;&#10;&lt;p&gt;To put it into perspective, let me tell you what bands I associate with what&#10;types of guitars/pickups. When I think about single coil, it&amp;rsquo;s either Strat or&#10;Tele. Bends that come to my mind playing those guitars are Dire Straights, Eric&#10;Clapton. Iron Maiden, for example, uses single coil, but I always felt they are&#10;somewhere in the middle: between singles and hums. When I think about&#10;humbuckers, Gerry Moore, Clutch and Corrosion of Conformity come to mind, while&#10;I think best example of active pickups are Zakk Wylde, Kerry King and Metallica&#10;(sorry for all of those being EMG based, I don&amp;rsquo;t know anyone playing Seymour&#10;Duncan&amp;rsquo;s Blackouts except a friend of mine, and I&amp;rsquo;m probably putting them in my&#10;next guitar)&lt;/p&gt;&#10;</description></item><item><title>Tilda Center Summer</title><link>https://meka.rs/blog/2015/06/28/tilda-center-summer/</link><pubDate>Sun, 28 Jun 2015 22:00:00 +0000</pubDate><guid>https://meka.rs/blog/2015/06/28/tilda-center-summer/</guid><description>&lt;p&gt;As my plans for summer festivals and beaches are ruined, my activity in&#10;&lt;a href="http://tilda.center"&gt;Tilda Center&lt;/a&gt; increased. Pure action-reaction physics at&#10;work. :o) We got two new tables and weekly meetings on Mondays and Thursdays.&#10;On Mondays is a general discussion or gathering to just hang out. On Thursdays,&#10;theme of the meeting is &lt;a href="https://github.com/one-love"&gt;One Love&lt;/a&gt;, project a few&#10;of us are contributing to. In future, we&amp;rsquo;re hoping to fund our hackerspace with&#10;it. I can tell you it&amp;rsquo;s interesting. Amount of ideas worth trying out is&#10;astonishing. One of the members even brought guitar for slight adjustments.&#10;Knowledge is flowing, and it&amp;rsquo;s great. We even have time for Danube beach, when&#10;the weather is kind enough. :o) Soon, I hope we&amp;rsquo;ll have &amp;ldquo;conference&amp;rdquo; room in&#10;Tilda ready. We already have a white board on the wall. Ah, I love drawings on&#10;the meetings. So much easier to comprehend someone else&amp;rsquo;s idea if it&amp;rsquo;s drawn. I&#10;tend to teach our young members that everything can be represented as a&#10;drawing, and if it can&amp;rsquo;t, you can make analogy to something from common life.&#10;It&amp;rsquo;s great how much errors are stressed out like this, during planing stage.&#10;Reminds me of &lt;a href="https://www.youtube.com/watch?v=PUv66718DII"&gt;Brad Victor&lt;/a&gt;. We&#10;opened back in April and we caused so much joy, but there is so much to explore&#10;and so much to learn. What a great ride up to now!&lt;/p&gt;&#10;</description></item><item><title>Dockerize Everything</title><link>https://meka.rs/blog/2015/06/18/dockerize-everything/</link><pubDate>Thu, 18 Jun 2015 22:00:00 +0000</pubDate><guid>https://meka.rs/blog/2015/06/18/dockerize-everything/</guid><description>&lt;p&gt;Often I hear the &amp;ldquo;Dockerize Everything&amp;rdquo; phrase. To be honest, when ever there&amp;rsquo;s&#10;a new technology, people praise it as &amp;ldquo;it fixes everything&amp;rdquo;. I don&amp;rsquo;t believe&#10;that&amp;rsquo;s the truth about any technology, not even docker. It&amp;rsquo;s not that I think&#10;docker is a bad thing. Hell, I wrote&#10;&lt;a href="https://meka.rs/tag/cloud-basics.html"&gt;series of blog posts about docker&lt;/a&gt;. I just think docker is&#10;used where it&amp;rsquo;s not suited too often. One such example is data container. As it&#10;might be great for huge number of servers, it&amp;rsquo;s not that great for small fleets&#10;of servers. For example, if you have nginx and data container such that data&#10;container is used as a volume for nginx, every time you change data container&#10;because you have new files, nginx has to be restarted. That means you have&#10;downtime even if you want to upload just a new css file. That&amp;rsquo;s not so great.&#10;But why would you ignore &amp;ldquo;normal&amp;rdquo; directories just because docker exists? Docker&#10;can use directory as a volume, so if you upload the same css file to a server&amp;rsquo;s&#10;directory, no downtime is needed. That&amp;rsquo;s what I did for my blog: have the static&#10;files in directory and use nginx docker container.&lt;/p&gt;&#10;&lt;p&gt;Just to conclude, it&amp;rsquo;s important to research new technologies, but it&amp;rsquo;s equally&#10;important to draw the line what should new technology do, and what should old&#10;one be used.&lt;/p&gt;&#10;</description></item><item><title>pfSense Community</title><link>https://meka.rs/blog/2015/06/17/pfsense-community/</link><pubDate>Wed, 17 Jun 2015 22:00:00 +0000</pubDate><guid>https://meka.rs/blog/2015/06/17/pfsense-community/</guid><description>&lt;p&gt;Few days ago I wrote about&#10;&lt;a href="https://meka.rs/blog/2015/06/07/pfsense-vs-openbsd"&gt;pfsense vs openbsd&lt;/a&gt; and&#10;&lt;a href="https://twitter.com/meka_floss/status/607327909431361536"&gt;twitted about it&lt;/a&gt;. As&#10;you can see, it triggered a flamewar, which was never my intention. The reason I&#10;continued that flamewar (and one more with the same person on other thread) was&#10;the I had nothing better to do, to be honest. I was away from home with my&#10;laptop, and I was tired of programming and administration projects. I&amp;rsquo;ve noticed&#10;that OpenBSD community hardly said anything. I don&amp;rsquo;t understand why anyone would&#10;be intimidated with the fact that one person twitted about not using some piece&#10;of software. Having that attitude could never attract people. Linux user group&#10;I&amp;rsquo;m member of had few men like that, and we ended up pushing away people who&#10;wanted to be part of our group and contribute. Even if people are wrong, they&#10;should be let to make mistake, if they decided to try something out.&lt;/p&gt;&#10;&lt;p&gt;On the other hand, the arguments presented were funny. For example, one of the&#10;arguments was that PF on FreeBSD 11 is faster than the one on OpenBSD 5.6. While&#10;this may or may not be true, the fact is that FreeBSD 11 is not released, making&#10;it bleeding edge version. At the same time, OpenBSD 5.7 is the current stable&#10;version, not 5.6. And who said that the speed of firewall was even important,&#10;compared to ease of use and integration with the rest of the system. As a matter&#10;of fact, firewall is just one small part of the system, and it&amp;rsquo;s not even the&#10;reason why I made the switch.&lt;/p&gt;&#10;&lt;p&gt;All in all, pfSense community, or at least two gentlemen that were the loudest,&#10;are one more reason why I will not use their product. It&amp;rsquo;s not my anger or any&#10;other emotion. If I learned anything from open source projects is that community&#10;is everything. Sad for pfSense!&lt;/p&gt;&#10;</description></item><item><title>pfSense vs OpenBSD</title><link>https://meka.rs/blog/2015/06/07/pfsense-vs-openbsd/</link><pubDate>Sun, 07 Jun 2015 22:00:00 +0000</pubDate><guid>https://meka.rs/blog/2015/06/07/pfsense-vs-openbsd/</guid><description>&lt;p&gt;I&amp;rsquo;ve had pfSense on my router for some time now. To be honest, about a year. The&#10;reason I decided to switch to OpenBSD should be obvious, but I&amp;rsquo;ll write about it&#10;anyway. Let me introduce you to the background of the two choices.&lt;/p&gt;&#10;&lt;p&gt;PfSense is based on FreeBSD. To be more precise, version 2.1 which was latest&#10;stable release up to few months ago, is based on FreeBSD 8, while 2.2 is based&#10;on FreeBSD 10. To be honest, FreeBSD is one of the most exciting projects ever.&#10;In my opinion mostly because of the technologies it ported from other operating&#10;systems like ZFS and DTrace from OpenSolaris and PF from OpenBSD, to name the&#10;few. With such diversity of ported projects, it has my deep respect if for&#10;nothing else, than for being able to incorporate and maintain them in a secure&#10;and stable way. If you ever tried to continuously port and maintain a software&#10;from other platform, you know what it takes. For me, firewall is the most&#10;important part of routing OS, and FreeBSD having incorporated the best one,&#10;makes it great.&lt;/p&gt;&#10;&lt;p&gt;But, it&amp;rsquo;s not all that great. For example, PF in FreeBSD is based on OpenBSD&amp;rsquo;s&#10;implementation (which is original) from 4 years ago. Although FreeBSD and&#10;OpenBSD have different plans and courses for their implementation of PF, I like&#10;OpenBSD&amp;rsquo;s syntax better. Another thing that made me switch to OpenBSD is DHCP+DNS&#10;on pfSense. I don&amp;rsquo;t know if it&amp;rsquo;s up to FreeBSD or pfSense, but once a machine&#10;gets IP, it takes too long (as in 15 minutes) for it to be registered in DNS.&#10;All of this was enough for me to at least try OpenBSD. Hmmmm &amp;hellip; try. Let me&#10;tell you I&amp;rsquo;m not going back to pfSense, but I might give FreeBSD a chance. I like&#10;to experiment, so we&amp;rsquo;ll see.&lt;/p&gt;&#10;&lt;p&gt;I&amp;rsquo;ve also ditched ubound and dhcpd in favor of DNSMasq which serves great as a&#10;DHCP+DNS server. WiFi hostap works like a charm, and almost every system config&#10;file is in /etc. The way to make console redirect to serial port is to enter 2&#10;lines in /etc/boot.conf (you have to use proper pfSense image to do that). All&#10;that and the fact that Cisco and Apple is PF makes me feel warm. :o) No,&#10;seriously, what makes me have this feeling of security is what I&amp;rsquo;ve heard from&#10;a friend few years back: &amp;ldquo;OpenBSD policy that the mistake in the documentation&#10;is the mistake in the code&amp;rdquo;.&lt;/p&gt;&#10;&lt;p&gt;One of these days I&amp;rsquo;ll be writing a script to automate the provisioning of my&#10;router which will portrait the ease of using OpenBSD more than this post.&lt;/p&gt;&#10;</description></item><item><title>Tube vs Transistor</title><link>https://meka.rs/blog/2015/06/07/tube-vs-transistor/</link><pubDate>Sun, 07 Jun 2015 22:00:00 +0000</pubDate><guid>https://meka.rs/blog/2015/06/07/tube-vs-transistor/</guid><description>&lt;p&gt;For so long I&amp;rsquo;ve listened about debate how tubes have &amp;ldquo;warmer&amp;rdquo; sound. All&#10;audiophiles will tell you that you can not compare amps which are tube based to&#10;those that have transistors in them. I don&amp;rsquo;t say they&amp;rsquo;re wrong, but I&amp;rsquo;m never&#10;satisfied with &amp;ldquo;It&amp;rsquo;s just the way it is&amp;rdquo; explanation, so I searched for more&#10;info. First, I don&amp;rsquo;t believe that just because you use tubes you get better&#10;sound. There has to be more to it. As they&amp;rsquo;ve explained me, tubes have a feature&#10;which makes even harmonics stand out, while the transistor does the same for odd&#10;ones. This makes tube harmonics get along better. For simplicity, think of&#10;overtones which are octaves. Octaves are 2x, 4x, 8x &amp;hellip; the original sound which&#10;are even harmonics.&lt;/p&gt;&#10;&lt;p&gt;Now the fun part. I didn&amp;rsquo;t know, but more than once I&amp;rsquo;ve heard from really&#10;educated people that you can make an amp with transistors which makes even&#10;harmonics stand out. You&amp;rsquo;ll probably ask yourself, just like I did, why don&amp;rsquo;t&#10;we have these amps around. I don&amp;rsquo;t know, but I&amp;rsquo;m almost sure it has something&#10;to do with economy.&lt;/p&gt;&#10;&lt;p&gt;There is some area of audio amps where tubes are superb and transistors can&amp;rsquo;t&#10;ever come close to them: distortion in guitar amps. The reason for this is that&#10;tubes and transistors act totally different when they are saturated, hence the&#10;difference in sound of distortion.&lt;/p&gt;&#10;&lt;p&gt;I&amp;rsquo;m a guitar player, among other things, and the best think I can think of, in&#10;theory, is tube preamp with transistor power amp which makes even harmonics&#10;stand out. I don&amp;rsquo;t know if it&amp;rsquo;s possible, but I would sure would like to try to&#10;create one.&lt;/p&gt;&#10;</description></item><item><title/><link>https://meka.rs/resume/</link><pubDate>Sat, 06 Jun 2015 22:00:00 +0000</pubDate><guid>https://meka.rs/resume/</guid><description>&lt;p&gt;&lt;a class="nopdf" href="../resume.pdf"&gt;PDF&lt;/a&gt;&lt;/p&gt;&#10;&lt;h1 id="goran-mekić"&gt;&#10; Goran Mekić&#10;&lt;/h1&gt;&#10;&lt;h3 id="senior-backend-systems-engineer--devops-senior-engineer--low-latency--distributed-systems--rust-c-python"&gt;&#10; Senior Backend Systems Engineer | DevOps Senior Engineer | Low-Latency &amp;amp; Distributed Systems | Rust, C++, Python&#10;&lt;/h3&gt;&#10;&lt;div class="pdfonly"&gt;&#10;&lt;p&gt;&lt;a href="https://meka.rs/"&gt;meka.rs&lt;/a&gt; · &lt;a href="mailto:meka@sys.it.com"&gt;meka@sys.it.com&lt;/a&gt;&lt;/p&gt;&#10;&lt;/div&gt;&#10;&lt;a href="#personal-statement" aria-label="Personal statement"&gt;&#10; &lt;h2 id="personal-statement"&gt;Personal Statement&lt;/h2&gt;&#10;&lt;/a&gt;&#10;&lt;p&gt;Senior backend systems engineer with 15+ years designing, optimizing, and operating&#10;high-performance distributed systems in production environments. Most recently owned&#10;performance and reliability for infrastructure managing &lt;strong&gt;250+ PB of data&lt;/strong&gt; at Axcient&#10;across multiple data centers.&lt;/p&gt;&#10;&lt;p&gt;Specializes in low-latency Rust and C++ systems, Linux production environments, and&#10;DevOps automation (Kubernetes, Terraform, AWS). Brings deep systems expertise -&#10;including kernel-level debugging, tracing, and storage internals - to bear on&#10;commercial backend and infrastructure challenges.&lt;/p&gt;&#10;&lt;p&gt;Particularly passionate about Rust as a language for building fast, reliable, and&#10;predictable systems, and about applying that systems thinking to audio AI - combining&#10;real-time signal processing, machine learning pipelines, and careful hardware/OS-level&#10;tuning to create expressive and performant audio tools. This passion drives ongoing work&#10;at the intersection of low-latency audio, DSP, intelligent signal processing, and artificial&#10;intelligence.&lt;/p&gt;&#10;&lt;p&gt;Strong believer in DevOps as a practice, not just a set of tools. Over the years I have&#10;automated provisioning, deployment, and operational workflows across bare-metal, virtualized,&#10;and cloud environments using Ansible, SaltStack, Terraform, Kubernetes, Docker, Jail, and CI/CD&#10;pipelines. I treat infrastructure as code, observability as a first-class concern, and&#10;reliable repeatable deployments as essential to keeping complex systems healthy at scale.&#10;Deeply versed in both FreeBSD and Linux as daily drivers for production infrastructure - from&#10;kernel-level debugging, tracing with DTrace, and jail/zone isolation to storage design with ZFS,&#10;network stack tuning, and building secure, stable server environments that stay maintainable over&#10;the long term.&lt;/p&gt;&#10;&lt;a href="#skills" aria-label="Skills"&gt;&#10; &lt;h2 id="skills"&gt;Skills&lt;/h2&gt;&#10;&lt;/a&gt;&#10;&lt;p&gt;&lt;strong&gt;Languages &amp;amp; Runtimes&lt;/strong&gt;&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Rust: &lt;code&gt;●●●●●&lt;/code&gt;&lt;/li&gt;&#10;&lt;li&gt;Python: &lt;code&gt;●●●●●&lt;/code&gt;&lt;/li&gt;&#10;&lt;li&gt;JavaScript / TypeScript: &lt;code&gt;●●●●●&lt;/code&gt;&lt;/li&gt;&#10;&lt;li&gt;FastAPI: &lt;code&gt;●●●●●&lt;/code&gt;&lt;/li&gt;&#10;&lt;li&gt;REST APIs: &lt;code&gt;●●●●●&lt;/code&gt;&lt;/li&gt;&#10;&lt;li&gt;Svelte: &lt;code&gt;●●●●●&lt;/code&gt;&lt;/li&gt;&#10;&lt;li&gt;Flask: &lt;code&gt;●●●●○&lt;/code&gt;&lt;/li&gt;&#10;&lt;li&gt;Django: &lt;code&gt;●●●●○&lt;/code&gt;&lt;/li&gt;&#10;&lt;li&gt;React: &lt;code&gt;●●●●○&lt;/code&gt;&lt;/li&gt;&#10;&lt;li&gt;C / C++: &lt;code&gt;●●●●○&lt;/code&gt;&lt;/li&gt;&#10;&lt;li&gt;Go: &lt;code&gt;●●○○○&lt;/code&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;&lt;strong&gt;Systems &amp;amp; Administration&lt;/strong&gt;&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Linux administration: &lt;code&gt;●●●●●&lt;/code&gt;&lt;/li&gt;&#10;&lt;li&gt;Ansible/SaltStack/Puppet: &lt;code&gt;●●●●●&lt;/code&gt;&lt;/li&gt;&#10;&lt;li&gt;FreeBSD / Unix internals: &lt;code&gt;●●●●●&lt;/code&gt;&lt;/li&gt;&#10;&lt;li&gt;Docker / Jails: &lt;code&gt;●●●●●&lt;/code&gt;&lt;/li&gt;&#10;&lt;li&gt;Kubernetes: &lt;code&gt;●●●●○&lt;/code&gt;&lt;/li&gt;&#10;&lt;li&gt;Terraform: &lt;code&gt;●●●●○&lt;/code&gt;&lt;/li&gt;&#10;&lt;li&gt;ZFS: &lt;code&gt;●●●●○&lt;/code&gt;&lt;/li&gt;&#10;&lt;li&gt;Virtualization: &lt;code&gt;●●●●○&lt;/code&gt;&lt;/li&gt;&#10;&lt;li&gt;AWS: &lt;code&gt;●●●●○&lt;/code&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;&lt;strong&gt;Low-Latency &amp;amp; Distributed Systems&lt;/strong&gt;&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Distributed storage: &lt;code&gt;●●●●●&lt;/code&gt;&lt;/li&gt;&#10;&lt;li&gt;Real-time processing: &lt;code&gt;●●●●●&lt;/code&gt;&lt;/li&gt;&#10;&lt;li&gt;Systems optimization: &lt;code&gt;●●●●●&lt;/code&gt;&lt;/li&gt;&#10;&lt;li&gt;High-throughput backends: &lt;code&gt;●●●●○&lt;/code&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;&lt;strong&gt;Observability &amp;amp; Debugging&lt;/strong&gt;&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Production incident response: &lt;code&gt;●●●●●&lt;/code&gt;&lt;/li&gt;&#10;&lt;li&gt;DTrace: &lt;code&gt;●●●●●&lt;/code&gt;&lt;/li&gt;&#10;&lt;li&gt;Prometheus: &lt;code&gt;●●●●○&lt;/code&gt;&lt;/li&gt;&#10;&lt;li&gt;Grafana: &lt;code&gt;●●●●○&lt;/code&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;hr class="nopdf"/&gt;&#10;&lt;a href="#work-experience" aria-label="Work experience"&gt;&#10; &lt;h2 id="work-experience"&gt;Work Experience&lt;/h2&gt;&#10;&lt;/a&gt;&#10;&lt;div id="sysit"&gt;&lt;/div&gt;&#10;&lt;h3 id="sysit--2026"&gt;&#10; &lt;a href="https://sys.it.com/"&gt;SysIT&lt;/a&gt; | 2026&#10;&lt;/h3&gt;&#10;&lt;p&gt;Business Development &amp;amp; Technical Consultant&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Advise organizations on aligning technology strategy with business objectives, with a focus on&#10;scalable and efficient systems&lt;/li&gt;&#10;&lt;li&gt;Design and implement AI-driven solutions using tools such as Claude, ChatGPT, and Gemini to&#10;automate workflows and improve decision-making&lt;/li&gt;&#10;&lt;li&gt;Architect, deploy, and manage containerized infrastructure using Kubernetes, ensuring&#10;reliability, scalability, and cost efficiency&lt;/li&gt;&#10;&lt;li&gt;Develop and maintain infrastructure as code using Terraform to enable repeatable, secure,&#10;and automated environments&lt;/li&gt;&#10;&lt;li&gt;Deliver high-performance systems development in Rust, including low-level and DSP-focused&#10;applications&lt;/li&gt;&#10;&lt;li&gt;Perform kernel-level debugging and patching in FreeBSD environments to resolve complex system&#10;issues&lt;/li&gt;&#10;&lt;li&gt;Analyze and optimize system and application performance using advanced tools such as DTrace&lt;/li&gt;&#10;&lt;li&gt;Support engineering teams in improving development processes, reducing technical debt, and&#10;accelerating delivery cycles&lt;/li&gt;&#10;&lt;li&gt;Partner with stakeholders to identify inefficiencies and implement technical solutions that&#10;streamline operations and improve product performance&lt;/li&gt;&#10;&lt;li&gt;Planning and implementation of C++/Rust libraries and systems&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div id="axcient"&gt;&lt;/div&gt;&#10;&lt;h3 id="axcient--2022--2025"&gt;&#10; &lt;a href="https://axcient.com"&gt;Axcient&lt;/a&gt; | 2022 – 2025&#10;&lt;/h3&gt;&#10;&lt;p&gt;&lt;strong&gt;Systems Architect / Backend Engineer&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;Owned performance, reliability, and scalability of large-scale distributed storage systems&#10;operating across multiple data centers.&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Drove system-level performance improvements across infrastructure managing 250+ PB of data&lt;/li&gt;&#10;&lt;li&gt;Investigated and resolved critical production issues involving distributed coordination,&#10;storage systems, and compute interactions&lt;/li&gt;&#10;&lt;li&gt;Performed deep analysis of system behavior using tracing tools (DTrace) and monitoring systems&lt;/li&gt;&#10;&lt;li&gt;Built automation for managing infrastructure across hundreds of machines using SaltStack&lt;/li&gt;&#10;&lt;li&gt;Improved observability using Prometheus and Grafana, enabling faster diagnosis of production issues&lt;/li&gt;&#10;&lt;li&gt;Partnered with engineering teams to improve system architecture and operational reliability&lt;/li&gt;&#10;&lt;li&gt;Maintained internal C/C++/Rust tools&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div id="bakson"&gt;&lt;/div&gt;&#10;&lt;h3 id="bakson-ltd--2025"&gt;&#10; &lt;a href="https://baksonltd.com/"&gt;Bakson LTD&lt;/a&gt; | 2025&#10;&lt;/h3&gt;&#10;&lt;p&gt;Led the modernization of OSS deployment pipelines and infrastructure management through Terraform,&#10;Kubernetes, and proactive technical guidance.&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Contributed to variety of OSS projects in different programming languages&lt;/li&gt;&#10;&lt;li&gt;Worked with a variety of teams to maintain high standards of quality across OSS projects&lt;/li&gt;&#10;&lt;li&gt;Collaborated with software developers, system administrators, and IT staff to streamline&#10;development and deployment workflows&lt;/li&gt;&#10;&lt;li&gt;Set up and maintenance cloud infrastructure required to run specific OSS projects&lt;/li&gt;&#10;&lt;li&gt;Designed, implemented, and managed CI/CD pipelines for efficient software delivery&lt;/li&gt;&#10;&lt;li&gt;Mentored junior team members and provide technical guidance&lt;/li&gt;&#10;&lt;li&gt;Administered kubernetes cluster&lt;/li&gt;&#10;&lt;li&gt;Maintained terraform code&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div id="fourity"&gt;&lt;/div&gt;&#10;&lt;h3 id="fourity--2021--2022"&gt;&#10; &lt;a href="https://fourity.com"&gt;Fourity&lt;/a&gt; | 2021 – 2022&#10;&lt;/h3&gt;&#10;&lt;p&gt;Led design and implementation of backend and distributed systems across multiple projects.&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Architected scalable backend systems with focus on performance, resilience, and maintainability&lt;/li&gt;&#10;&lt;li&gt;Designed distributed system components and infrastructure automation strategies&lt;/li&gt;&#10;&lt;li&gt;Delivered systems capable of handling high-load environments with minimal operational overhead&lt;/li&gt;&#10;&lt;li&gt;Provided technical leadership and guided engineering decisions across teams&lt;/li&gt;&#10;&lt;li&gt;Senior Backend Engineer&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div id="cala-health"&gt;&lt;/div&gt;&#10;&lt;h3 id="cala-health--2018"&gt;&#10; &lt;a href="https://www.calahealth.com"&gt;Cala Health&lt;/a&gt; | 2018&#10;&lt;/h3&gt;&#10;&lt;p&gt;Worked on a regulated medical platform requiring high reliability, performance, and secure data handling.&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Designed and developed backend services supporting real-time, data-intensive medical workflows&lt;/li&gt;&#10;&lt;li&gt;Built and maintained REST APIs used across internal systems and external integrations&lt;/li&gt;&#10;&lt;li&gt;Improved system performance through profiling and optimization of backend services&lt;/li&gt;&#10;&lt;li&gt;Contributed to architecture decisions around scalability, fault tolerance, and system reliability&lt;/li&gt;&#10;&lt;li&gt;Implemented secure data handling aligned with medical and privacy requirements&lt;/li&gt;&#10;&lt;li&gt;Collaborated with product, research, and clinical teams to deliver reliable system behavior&lt;/li&gt;&#10;&lt;li&gt;Debugged production issues with focus on stability and predictable performance under load&lt;/li&gt;&#10;&lt;li&gt;Integrated AWS services (S3, Cognito) for secure storage, authentication, and scalability&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div id="firebird-networks"&gt;&lt;/div&gt;&#10;&lt;h3 id="firebird-networks-pulsar--2018---2019"&gt;&#10; Firebird Networks Pulsar | 2018 - 2019&#10;&lt;/h3&gt;&#10;&lt;p&gt;Sole architect and developer of a network gear configuration automation tool.&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Designed and implemented a scalable Ansible-based automation solution for network gear&lt;/li&gt;&#10;&lt;li&gt;Built a React frontend with WebSockets/Socket.IO for real-time monitoring and control&lt;/li&gt;&#10;&lt;li&gt;Developed a robust Flask backend API for network management&lt;/li&gt;&#10;&lt;li&gt;Managed the full software development lifecycle from requirements to deployment&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div id="geosolutions"&gt;&lt;/div&gt;&#10;&lt;h3 id="geosolutions--2017"&gt;&#10; &lt;a href="https://www.geo-solutions.it"&gt;GeoSolutions&lt;/a&gt; | 2017&#10;&lt;/h3&gt;&#10;&lt;p&gt;Developed monitoring solution for GeoNode, an open-source geospatial data platform.&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Designed and implemented a Django/Python monitoring system for GeoNode performance and user engagement&lt;/li&gt;&#10;&lt;li&gt;Built interactive data visualizations with React and D3.js&lt;/li&gt;&#10;&lt;li&gt;Delivered actionable insights that improved client user experience&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div id="photoslurp"&gt;&lt;/div&gt;&#10;&lt;h3 id="photoslurp--2015---2016"&gt;&#10; &lt;a href="http://www.photoslurp.com/"&gt;Photoslurp&lt;/a&gt; | 2015 - 2016&#10;&lt;/h3&gt;&#10;&lt;p&gt;Full-stack developer on a platform for collecting, exchanging, and managing media rights.&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Built frontend features with Bootstrap, jQuery, Backbone.js, and Underscore&lt;/li&gt;&#10;&lt;li&gt;Developed Django/Python backend for media data, permissions, and rights workflows&lt;/li&gt;&#10;&lt;li&gt;Designed secure, scalable RESTful APIs for media rights requests&lt;/li&gt;&#10;&lt;li&gt;Implemented Celery, Redis, and RabbitMQ for asynchronous task processing&lt;/li&gt;&#10;&lt;li&gt;Automated deployment with Ansible and maintained PostgreSQL database&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div id="fsd"&gt;&lt;/div&gt;&#10;&lt;h3 id="fsd--2015"&gt;&#10; &lt;a href="https://fsd.rs"&gt;fSD&lt;/a&gt; | 2015&#10;&lt;/h3&gt;&#10;&lt;p&gt;Implemented DevOps practices for a PHP/EmberJS ERP system development team.&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Automated server provisioning, configuration, and deployment with Ansible&lt;/li&gt;&#10;&lt;li&gt;Managed consistent virtualized development environments using Vagrant&lt;/li&gt;&#10;&lt;li&gt;Built CI/CD pipelines with Jenkins for automated testing and deployment&lt;/li&gt;&#10;&lt;li&gt;Improved reliability and security across development, staging, and production&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div id="reciprocity-labs"&gt;&lt;/div&gt;&#10;&lt;h3 id="reciprocity-labs--2014---2015"&gt;&#10; &lt;a href="http://reciprocitylabs.com"&gt;Reciprocity Labs&lt;/a&gt; | 2014 - 2015&#10;&lt;/h3&gt;&#10;&lt;p&gt;Backend developer focused on SAML authentication, expanding to full-stack delivery.&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Led SAML-based SSO implementation integrated with multiple identity providers&lt;/li&gt;&#10;&lt;li&gt;Built secure RESTful APIs using Python/Flask for authentication and application logic&lt;/li&gt;&#10;&lt;li&gt;Advised on server hardening, encryption, ACLs, and security best practices&lt;/li&gt;&#10;&lt;li&gt;Automated provisioning and deployment with Vagrant and Ansible&lt;/li&gt;&#10;&lt;li&gt;Optimized MySQL schema and queries for scalability&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div id="lambda-solutions"&gt;&lt;/div&gt;&#10;&lt;h3 id="lambda-solutions--2014---2014"&gt;&#10; &lt;a href="http://www.lambdasolutions.net/"&gt;Lambda Solutions&lt;/a&gt; | 2014 - 2014&#10;&lt;/h3&gt;&#10;&lt;p&gt;System Administrator for Moodle and Totara LMS hosting solutions.&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Deployed and configured highly available, scalable Moodle and Totara environments&lt;/li&gt;&#10;&lt;li&gt;Automated server provisioning and configuration with Ansible&lt;/li&gt;&#10;&lt;li&gt;Managed AWS infrastructure (EC2, S3, RDS) for cost-effective scalability&lt;/li&gt;&#10;&lt;li&gt;Implemented monitoring with Nagios and Zabbix for proactive issue detection&lt;/li&gt;&#10;&lt;li&gt;Hardened servers, configured SSL/TLS, and designed backup/disaster recovery strategies&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div id="secent-llc"&gt;&lt;/div&gt;&#10;&lt;h3 id="secent-llc--2013---2014"&gt;&#10; &lt;a href="http://www.secent.com/"&gt;Secent LLC&lt;/a&gt; | 2013 - 2014&#10;&lt;/h3&gt;&#10;&lt;p&gt;Team Lead and Senior Developer for a reverse proxy and SSO solution.&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Led development of a configurable reverse proxy and SSO solution using Django/Python&lt;/li&gt;&#10;&lt;li&gt;Integrated SimpleSAMLphp and built custom RESTful APIs for secure, high-volume authentication&lt;/li&gt;&#10;&lt;li&gt;Enforced SSL/TLS, access controls, and conducted regular security audits&lt;/li&gt;&#10;&lt;li&gt;Automated server deployment with Ansible and managed PostgreSQL databases&lt;/li&gt;&#10;&lt;li&gt;Coordinated the development team and collaborated with DevOps and network security teams&lt;/li&gt;&#10;&lt;li&gt;Built automated build, test, and packaging pipelines for aerospace software using Jenkins, VMware, and Git&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div id="saturized"&gt;&lt;/div&gt;&#10;&lt;h3 id="saturized--2011---2013"&gt;&#10; &lt;a href="http://www.saturized.com/"&gt;Saturized&lt;/a&gt; | 2011 - 2013&#10;&lt;/h3&gt;&#10;&lt;p&gt;Infrastructure engineer responsible for reliability, performance, and security.&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Planned capacity, allocated storage, and designed backup and disaster recovery strategies&lt;/li&gt;&#10;&lt;li&gt;Monitored system health with Munin, Icinga, and Zabbix; tuned performance and resolved bottlenecks&lt;/li&gt;&#10;&lt;li&gt;Hardened systems, managed firewalls, and maintained compliance with security standards&lt;/li&gt;&#10;&lt;li&gt;Administered web, file, and firewall servers using Puppet for configuration management&lt;/li&gt;&#10;&lt;li&gt;Managed QEmu/Libvirt virtualization and Gerrit/Git source control&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div id="ddor"&gt;&lt;/div&gt;&#10;&lt;h3 id="ddor--2006---2011"&gt;&#10; &lt;a href="http://www.ddor.rs/"&gt;DDOR&lt;/a&gt; | 2006 - 2011&#10;&lt;/h3&gt;&#10;&lt;p&gt;Solaris/Linux system administrator for business-critical infrastructure.&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Administered Solaris and Linux servers across a wide range of applications&lt;/li&gt;&#10;&lt;li&gt;Managed enterprise storage (EMC Clariion, Fujitsu Eternus DX440) and VMware ESXi virtualization&lt;/li&gt;&#10;&lt;li&gt;Implemented backup, disaster recovery, performance tuning, and capacity planning&lt;/li&gt;&#10;&lt;li&gt;Configured firewalls, security patches, and monitoring with Monit and Munin&lt;/li&gt;&#10;&lt;li&gt;Automated server configuration with Puppet and supported Oracle APP and Tomcat&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div id="home-invest"&gt;&lt;/div&gt;&#10;&lt;h3 id="home-invest--2006---2006"&gt;&#10; &lt;a href="http://homeinvest.rs/"&gt;Home Invest&lt;/a&gt; | 2006 - 2006&#10;&lt;/h3&gt;&#10;&lt;p&gt;Implemented and maintained core network services for the organization.&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Installed and maintained Mail (Postfix/Dovecot), DHCP, DNS (Bind), and Samba Domain Controller&lt;/li&gt;&#10;&lt;li&gt;Administered Linux systems and applied timely security updates and patches&lt;/li&gt;&#10;&lt;li&gt;Configured IPTables firewall rules to secure internal and external communications&lt;/li&gt;&#10;&lt;li&gt;Created system documentation and knowledge transfer materials&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;hr/&gt;&#10;&lt;a href="#projects" aria-label="Projects"&gt;&#10; &lt;h2 id="projects"&gt;Projects&lt;/h2&gt;&#10;&lt;/a&gt;&#10;&lt;div id="maolan"&gt;&lt;/div&gt;&#10;&lt;h3 id="maolan---real-time-audio-processing-platform-rust--c--2018"&gt;&#10; &lt;a href="https://maolan.rs"&gt;Maolan&lt;/a&gt; - Real-Time Audio Processing Platform (Rust / C++) | 2018&#10;&lt;/h3&gt;&#10;&lt;p&gt;Designed and built a high-performance audio processing system focused on low-latency workloads.&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Architected a modular audio processing engine in Rust with emphasis on performance and&#10;extensibility&lt;/li&gt;&#10;&lt;li&gt;Implemented real-time processing pipelines with strict latency constraints&lt;/li&gt;&#10;&lt;li&gt;Optimized system behavior across Linux environments through deep OS-level tuning&lt;/li&gt;&#10;&lt;li&gt;Integrated multiple audio backends and drivers for stable and efficient processing&lt;/li&gt;&#10;&lt;li&gt;Worked at OS and hardware interaction level to minimize processing overhead&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div id="freenit"&gt;&lt;/div&gt;&#10;&lt;h3 id="freenit---highly-automatable-web-framework--2017"&gt;&#10; &lt;a href="https://freenit-framework.github.io"&gt;Freenit&lt;/a&gt; - Highly automatable WEB framework | 2017&#10;&lt;/h3&gt;&#10;&lt;p&gt;Freenit is a framework for automating modern web application development. The goal is to&#10;automate the repetitive parts of product development so you can focus on implementation&#10;details that matter. A common workflow is to build UI in the designer, save it as .json,&#10;version that file in git, and export the result as Svelte code. The exported code is intended&#10;to be pixel-accurate and easy to reshape for your application.&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;A visual designer to speed up UI and design work&lt;/li&gt;&#10;&lt;li&gt;Frontend tooling based on Svelte&lt;/li&gt;&#10;&lt;li&gt;Backend tooling based on FastAPI&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div id="tilda-center"&gt;&lt;/div&gt;&#10;&lt;h3 id="tilda-center--2015"&gt;&#10; &lt;a href="https://tilda.center"&gt;Tilda Center&lt;/a&gt; | 2015&#10;&lt;/h3&gt;&#10;&lt;p&gt;Tilda Center is a hackerspace and educational hub focused on modern&#10;technologies and open-source tools. I co-founded the center to bridge the gap&#10;between affordable, high-quality education and cutting-edge technology. I am&#10;responsible for leading technical research, teaching, and system administration.&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Developed and delivered training in Python/Flask/FastAPI, React/Redux/Svelte,&#10;HTML/CSS, electronics, and audio production.&lt;/li&gt;&#10;&lt;li&gt;Managed IT infrastructure, including Linux/FreeBSD systems, ZFS, PF, and&#10;automation using Ansible.&lt;/li&gt;&#10;&lt;li&gt;Led research initiatives on FreeBSD kernel development, DSP/RT Rust/C++&#10;environments, and audio/music systems.&lt;/li&gt;&#10;&lt;li&gt;Designed and implemented internal systems for virtualized environments and&#10;efficient resource management using CBSD/Reggae.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div id="comms"&gt;&lt;/div&gt;&#10;&lt;h3 id="communications-server--2018"&gt;&#10; &lt;a href="https://github.com/mekanix/comms"&gt;Communications Server&lt;/a&gt; | 2018&#10;&lt;/h3&gt;&#10;&lt;p&gt;Designed and automated deployment of production-grade communication systems.&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Built distributed systems for mail, DNS, chat, and directory services&lt;/li&gt;&#10;&lt;li&gt;Designed high-availability configurations with redundancy and failover mechanisms&lt;/li&gt;&#10;&lt;li&gt;Automated infrastructure using Ansible and container-like isolation&lt;/li&gt;&#10;&lt;li&gt;Improved reliability and operational efficiency through automation and system design&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div id="cbsd"&gt;&lt;/div&gt;&#10;&lt;h3 id="cbsdreggaeclonos---virtualization--orchestration--2017"&gt;&#10; &lt;a href="https://github.com/cbsd"&gt;CBSD/Reggae/ClonOS&lt;/a&gt; - Virtualization &amp;amp; Orchestration | 2017&#10;&lt;/h3&gt;&#10;&lt;p&gt;Worked on tooling for managing large-scale virtualized environments.&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Developed orchestration tools for multi-node infrastructure&lt;/li&gt;&#10;&lt;li&gt;Implemented parallel build and deployment systems for jails and virtual machines&lt;/li&gt;&#10;&lt;li&gt;Optimized resource utilization and system performance in multi-tenant environments&lt;/li&gt;&#10;&lt;li&gt;Improved scalability and operational efficiency of virtualization workflows&lt;/li&gt;&#10;&lt;li&gt;Storage &amp;amp; System Optimization Work&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div id="drumgizmo"&gt;&lt;/div&gt;&#10;&lt;h3 id="drumgizmo--2017"&gt;&#10; &lt;a href="http://drumgizmo.org"&gt;Drumgizmo&lt;/a&gt; | 2017&#10;&lt;/h3&gt;&#10;&lt;p&gt;DrumGizmo is an open-source, multichannel drum plugin and stand-alone&#10;application for music production.&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Contributed to the FreeBSD OSS audio driver backend and ported the software&#10;to FreeBSD.&lt;/li&gt;&#10;&lt;li&gt;Maintained FreeBSD ports for seamless integration with the system.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div id="one-love"&gt;&lt;/div&gt;&#10;&lt;h3 id="one-love--2014"&gt;&#10; &lt;a href="https://github.com/one-love"&gt;One Love&lt;/a&gt; | 2014&#10;&lt;/h3&gt;&#10;&lt;p&gt;One Love is a decentralized management platform for data centers using Docker&#10;and cloud technologies. As a full-stack developer, I’ve contributed to both&#10;frontend and backend development.&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Designed and developed the frontend using React, Redux, and Webpack to ensure&#10;seamless user experience.&lt;/li&gt;&#10;&lt;li&gt;Developed backend services using Flask, ZeroMQ, and REST APIs for&#10;high-performance, scalable communication.&lt;/li&gt;&#10;&lt;li&gt;Managed deployment pipelines on AWS, DigitalOcean, and other cloud platforms,&#10;with a focus on automation and efficiency.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;hr/&gt;&#10;&lt;a href="#high-impact-contributions" aria-label="High-impact contributions"&gt;&#10; &lt;h2 id="high-impact-contributions"&gt;High-Impact Contributions&lt;/h2&gt;&#10;&lt;/a&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Owned performance and reliability for distributed systems managing &lt;strong&gt;250+ PB&lt;/strong&gt; across&#10;multiple data centers&lt;/li&gt;&#10;&lt;li&gt;Diagnosed and resolved complex production issues including deadlocks, race conditions, and&#10;cross-layer performance degradation&lt;/li&gt;&#10;&lt;li&gt;Built and optimized low-latency processing systems in Rust and C++ for real-time environments&lt;/li&gt;&#10;&lt;li&gt;Designed backend and infrastructure systems that scale across hundreds of nodes with high&#10;availability&lt;/li&gt;&#10;&lt;li&gt;Improved observability and debugging capabilities using DTrace, Prometheus, and Grafana&lt;/li&gt;&#10;&lt;li&gt;Consistently trusted with production-critical systems where failure has significant operational&#10;impact&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;a href="#social-engagement" aria-label="Social engagement"&gt;&#10; &lt;h2 id="social-engagement"&gt;Social Engagement&lt;/h2&gt;&#10;&lt;/a&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=gByyga_5mPw&amp;amp;list=PLpeJ1COhO5aneha988XS5ny6hMQ105g4a"&gt;C++ lectures in Serbian&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=XnJjMqa5fDw"&gt;DaFED #61 – Kako automatizacija procesa pomaže u razvoju sigurnijih aplikacija&lt;/a&gt; → Presented how process automation improves application security and reduces human error in development workflows&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://archive.fosdem.org/2023/schedule/event/reggae_jails_vms_on_freebsd/"&gt;FOSDEM 2023 – Reggae: cool way of managing jails/VMs on FreeBSD&lt;/a&gt; → Introduced Reggae as a tool for managing FreeBSD jails and virtual machines, focusing on scalable development environments&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=9xIGfs6Bqpo"&gt;EuroBSD 2022 – FreeBSD audio in amateur and professional setups&lt;/a&gt; → Explored FreeBSD-based audio workflows across hobbyist and professional use cases, including system configuration and performance&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://archive.fosdem.org/2021/schedule/event/cbsd_ecosystem/"&gt;FOSDEM 2021 – Managing virtual resources with CBSD, and beyond&lt;/a&gt; → Demonstrated advanced resource management and orchestration using CBSD for virtualization on FreeBSD&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://archive.org/download/BSidesLjubljana2019/t1_08_How_Did_We_Teach_%28Ourselves%29_Security-Goran_Meki%C4%87.mp4"&gt;BSides Ljubljana 2019 – How Did We Teach (Ourselves) Security&lt;/a&gt; → Shared practical approaches to self-learning and teaching cybersecurity within community-driven environments&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://archive.fosdem.org/2019/schedule/event/freebsd_in_audio_studio/"&gt;FOSDEM 2019 – FreeBSD in Audio Studio&lt;/a&gt; → Presented real-world usage of FreeBSD in audio production environments, covering stability and performance considerations&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://archive.org/download/BSidesLjubljana2018/18ModernAndSecureDevopsOnFreebsdByGoranMeki.mp4"&gt;BSides Ljubljana 2018 – Modern and Secure DevOps on FreeBSD&lt;/a&gt; → Covered secure DevOps practices using FreeBSD, including isolation, automation, and system hardening&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://archive.fosdem.org/2018/schedule/event/cbsd_isolation_manager/"&gt;FOSDEM 2018 – CBSD Isolation Manager&lt;/a&gt; → Introduced CBSD as a solution for lightweight virtualization and system isolation on FreeBSD&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=DHNnCXgD4RU"&gt;BalCCon 2016 – FLOSS Way of Funding a Hackerspace&lt;/a&gt; → Discussed sustainable funding models for open-source communities and hackerspaces&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=KpzQpAAwBvA"&gt;BalCCon 2015 – What is Hackerspace&lt;/a&gt; → Introduced the concept, structure, and community impact of hackerspaces&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;hr/&gt;&#10;&lt;a href="#education" aria-label="Education"&gt;&#10; &lt;h2 id="education"&gt;Education&lt;/h2&gt;&#10;&lt;/a&gt;&#10;&lt;div id="university"&gt;&lt;/div&gt;&#10;&lt;h3 id="master-of-science-in-business-information-technology"&gt;&#10; Master of Science in Business Information Technology&#10;&lt;/h3&gt;&#10;&lt;h4 id="faculty-of-sciences-university-of-novi-sad"&gt;&#10; Faculty of Sciences, University Of Novi Sad&#10;&lt;/h4&gt;&#10;&lt;p&gt;Studying all aspect of IT including Computer Networks, Software Engineering,&#10;Data Structures and Algorithms, E-business and Artificial Intelligence&lt;/p&gt;&#10;&lt;div id="high-scool"&gt;&lt;/div&gt;&#10;&lt;h3 id="electronics-technician"&gt;&#10; Electronics Technician&#10;&lt;/h3&gt;&#10;&lt;h4 id="the-electricity--electronics-middle-school-mihajlo-pupin-novi-sad"&gt;&#10; The electricity &amp;amp; electronics middle school &amp;ldquo;Mihajlo Pupin&amp;rdquo; Novi Sad&#10;&lt;/h4&gt;&#10;&lt;p&gt;Mihajlo Pupin Novi Sad Eletronics Middle School Designing and building of&#10;electrical circuits, including simple digital boards and fixing all non-SMP low&#10;voltage devices, scheme and PCB design, primarily for audio devices.&lt;/p&gt;&#10;</description></item><item><title>All Strings Attached</title><link>https://meka.rs/blog/2015/06/06/all-strings-attached/</link><pubDate>Sat, 06 Jun 2015 22:00:00 +0000</pubDate><guid>https://meka.rs/blog/2015/06/06/all-strings-attached/</guid><description>&lt;p&gt;First of all, I&amp;rsquo;m no physicist. Everything written here is what I&amp;rsquo;ve gathered&#10;from other sources, like books and Wikipedia. As I never had a chance to check&#10;my thoughts with someone with proper and formal physics education, I might be&#10;(terribly) wrong, so don&amp;rsquo;t quote me as a scientist or a proven theorist.&lt;/p&gt;&#10;&lt;p&gt;Most of my thoughts come from Brian Greene&amp;rsquo;s&#10;&lt;a href="http://www.briangreene.org/?page_id=24"&gt;Fabric of the Cosmos&lt;/a&gt;. I like how&#10;the book is easy to understand so much that I recommend it to everyone. I&amp;rsquo;ll&#10;admit it, I was hardly waiting to get to the strings. Don&amp;rsquo;t get me wrong, the&#10;whole book is golden, but I was mostly interested in strings. Just imagine&#10;(if you can, but up to now, nobody was able to) that vibrating string manifests&#10;itself as a particle. I mean, different vibrational patterns make up different&#10;things in our Universe: particles, time, energy, radiation, &amp;hellip; Once more,&#10;strings create time. Wow! What a concept. But I want to talk about something&#10;more scientific, if I may call it that. Throughout the research which is mostly&#10;mathematical, scientists came to conclude that the string theory gave birth to&#10;5 different frameworks of string theory. It&amp;rsquo;s like you say there are 5 different&#10;variations of the same theory. A bit awkward situation for science, but the 6th&#10;variation solved it all, or at least is trying to do that. It&amp;rsquo;s not the 6th&#10;variation, it&amp;rsquo;s &amp;ldquo;one ring to rule them all&amp;rdquo;, to be a bit more precise. It&amp;rsquo;s&#10;called the M-theory and nobody knows what M stands for. The craziest proposal&#10;I&amp;rsquo;ve heard of what M is: 180 degrees of W which stands for Witten, the person&#10;who came up with the idea of M-theory.&#10;&lt;a href="http://en.wikipedia.org/wiki/Edward_Witten"&gt;Edward Witten&lt;/a&gt; is such a crazy guy&#10;that you have to love him. Although he&amp;rsquo;s physicist, he&amp;rsquo;s the first man who got&#10;the Fields Medal award, which is award in math. Unbelievable guy!&lt;/p&gt;&#10;&lt;p&gt;Anyway, back to the topic. In short, there are strings which are loops, and&#10;strings which are like a rope with two ends. Researchers found that &amp;ldquo;rope like&amp;rdquo;&#10;strings are attached to 2 dimensional branes. I won&amp;rsquo;t go into what branes are&#10;for two reasons: I don&amp;rsquo;t know and it&amp;rsquo;s not that important at this time. The&#10;funny thing is that all forces are rope alike, except gravity. Even more, all&#10;forces except gravity are strings with two ends on the same brane. Now, this is&#10;astonishing, at least to me. This makes gravity special, which researchers knew&#10;before string theory, but it&amp;rsquo;s even more special now. In theory, strings are&#10;1-dimensional objects living in a 11-dimensional environment (10 spacial and 1&#10;time dimension). All vibrational patterns of all known forces and matter are&#10;bound to the same brane, except gravity. This makes gravity able to traverse our&#10;3 spacial dimensions and span on other branes. How? Gravity is made of loop&#10;strings, hence not being tied to any brane. Isn&amp;rsquo;t that remarkable? I&amp;rsquo;m thrilled&#10;that we can (at least in theory) communicate with other dimensions through&#10;gravity. How? First thought is&#10;&lt;a href="https://en.wikipedia.org/wiki/Gravitational_wave"&gt;gravitational wave&lt;/a&gt;. Imagine&#10;that you can use gravitational waves to create bits, just like computers use&#10;electromagnetic field. I don&amp;rsquo;t even know if it&amp;rsquo;s theoretically possible, but&#10;dreaming about other dimensions is becoming less of a dream and more of a&#10;research. That makes me happy!&lt;/p&gt;&#10;</description></item><item><title>Goran Mekić</title><link>https://meka.rs/pages/home/</link><pubDate>Sat, 06 Jun 2015 22:00:00 +0000</pubDate><guid>https://meka.rs/pages/home/</guid><description>&lt;ul&gt;&#10;&lt;li&gt;Co-founder of &lt;a href="http://tilda.center"&gt;Tilda Center&lt;/a&gt; - Hackerspace in Novi Sad&lt;/li&gt;&#10;&lt;li&gt;Guitar player in &lt;a href="https://lust4thrust.com"&gt;Lust 4 Thrust&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;Co-organizer of &lt;a href="https://pyser.org"&gt;Python Serbia Conference&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;Co-organizer of &lt;a href="https://bsidesns.org"&gt;BSidesNoviSad&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;Author of &lt;a href="https://github.com/freenit-framework"&gt;Freenit Framework&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;Author of &lt;a href="https://github.com/maolan"&gt;Maolan&lt;/a&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;</description></item><item><title>Presonus Troubles</title><link>https://meka.rs/blog/2015/05/23/presonus-troubles/</link><pubDate>Sat, 23 May 2015 22:00:00 +0000</pubDate><guid>https://meka.rs/blog/2015/05/23/presonus-troubles/</guid><description>&lt;p&gt;For some time now, I have problems with Presonus AudioBox 1818VSL. The problem&#10;is the SPDIF input is muted. I tried this and that, I submitted an issue on&#10;Presonus ticketing system and nothing helped. First, Presonus, you&amp;rsquo;re morons.&#10;Every new driver needs to update firmware on the device, too, and there is no&#10;way you can update/downgrade driver without firmware or vice versa. Second,&#10;Presonus, you&amp;rsquo;re idiots. You&amp;rsquo;ve made USB compliant audio interface, only to&#10;change the mode to non-complaint in the newest firmware, rendering the device&#10;useless on GNU/Linux. Third, Presonus, you&amp;rsquo;re imbeciles. The controls you get&#10;with &lt;code&gt;alsamixer&lt;/code&gt; is a joke. You can not mute/unmute digital inputs, for example.&#10;This is not true, and this was my problem for months now. Once Debian is going&#10;for reboot/shutdown, it saves the current state of audio interface to&#10;&lt;code&gt;/var/lib/alsa/asound.state&lt;/code&gt; file. Every time Debian loads this file, digital&#10;inputs just stop working. And they so stop working, they don&amp;rsquo;t even work on&#10;Windows. What I had to do is uninstall driver on Windows, install new driver,&#10;reboot, launch Presonus&amp;rsquo; mixer which says it has to update the firmware, fail,&#10;update firmware again, uninstall driver, install old driver (version 1.1, which&#10;has a firmware which is USB compliant) reboot, launch mixer, fail firmware&#10;upgrade (which is actually downgrade), update firmware and than it works.&lt;/p&gt;&#10;&lt;p&gt;At first, I said &amp;ldquo;OK, I&amp;rsquo;ll turn off Presonus before shutting down the PC&amp;rdquo;, but&#10;that&amp;rsquo;s not good. I have to think too much for one simple shutdown. Later on, I&#10;made &lt;code&gt;/var/lib/alsa/asound.state&lt;/code&gt; link to &lt;code&gt;/dev/null&lt;/code&gt;. That loaded garbage into&#10;the audio interface (so, go through Windows procedure from hell once again).&#10;Then I made &lt;code&gt;/var/lib/alsa&lt;/code&gt; link to &lt;code&gt;/dev/null&lt;/code&gt;. That solved the problem, but&#10;I didn&amp;rsquo;t like the solution. After countless days of poking, I realized that&#10;amixer returns interesting result for one of the controls:&lt;/p&gt;&#10;&lt;pre&gt;&lt;code&gt;amixer -c 1 get 'AudioBox 1818 VSL Clock Selector Capture Sw'&#10; Simple mixer control 'AudioBox 1818 VSL Clock Selector Capture Sw',0&#10; Capabilities: pswitch&#10; Playback channels: Front Left - Front Right - Rear Left - Rear Right - Front Center - Woofer - Side Left - Side Right - Rear Center - ? - ? - ? - ? - ? - ? - ?&#10; Mono:&#10; Front Left: Playback [on]&#10; Front Right: Playback [on]&#10; Rear Left: Playback [on]&#10; Rear Right: Playback [on]&#10; Front Center: Playback [on]&#10; Woofer: Playback [on]&#10; Side Left: Playback [on]&#10; Side Right: Playback [on]&#10; Rear Center: Playback [off]&#10; ?: Playback [off]&#10; ?: Playback [off]&#10; ?: Playback [off]&#10; ?: Playback [off]&#10; ?: Playback [off]&#10; ?: Playback [off]&#10; ?: Playback [off]&#10;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;p&gt;Wait a fucking minute!!! Something is off? Let&amp;rsquo;s make it on:&lt;/p&gt;&#10;&lt;pre&gt;&lt;code&gt;amixer -c 1 set 'AudioBox 1818 VSL Clock Selector Capture Sw' 'on,on,on,on,on,on,on,on,on,on,on,on,on,on,on,on'&#10;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;p&gt;Guess what? Every reboot works like a charm now. I have no idea why Presonus&#10;reports these to be off on the first run, but that&amp;rsquo;s the fix. If you have&#10;similar problems, I hope this is the solution. Next, record album, finally!&lt;/p&gt;&#10;</description></item><item><title>The Hell</title><link>https://meka.rs/blog/2015/05/14/the-hell/</link><pubDate>Thu, 14 May 2015 22:00:00 +0000</pubDate><guid>https://meka.rs/blog/2015/05/14/the-hell/</guid><description>&lt;p&gt;Everyone hates the hospitals, I&amp;rsquo;m sure, but recent events made me wonder if I&#10;ever noticed how bad health care in my country is. It made me so sad to see the&#10;great clinic of Belgrade, the clinic where all worst cases are sent to, is in&#10;such a bad shape. Sad and eager to do something. I still don&amp;rsquo;t know what, but a&#10;hacker in me can&amp;rsquo;t sit still. The hard part is that my beloved one is in it&#10;right now. I can&amp;rsquo;t make up my mind if that&amp;rsquo;s a good or bad thing. We know she&#10;needs an operation for some time now, and that clinic is the best place in the&#10;country to do it, but I&amp;rsquo;ve seen how it looks. One of the terms that hits my&#10;mind a lot is really not nice. It&amp;rsquo;s 4:30 in the morning, and I can&amp;rsquo;t sleep. I&#10;will be hitting the road in today, and I can&amp;rsquo;t make myself sleep. I&amp;rsquo;ll be tired&#10;like hell, nervous, angry and all in all fucked up. Sometimes I wish I&amp;rsquo;m blind.&lt;/p&gt;&#10;</description></item><item><title>Hackerspace</title><link>https://meka.rs/blog/2015/04/01/hackerspace/</link><pubDate>Wed, 01 Apr 2015 22:00:00 +0000</pubDate><guid>https://meka.rs/blog/2015/04/01/hackerspace/</guid><description>&lt;p&gt;I think it&amp;rsquo;s about 15 years now that I want a hackerspace in my town, and today&#10;that dream become reality. The hackerspace or makerspace (I never could tell&#10;the difference) is and will be alternate place for acquiring knowledge.&#10;Let&amp;rsquo;s go to the beginnings and see how it all unfolded.&lt;/p&gt;&#10;&lt;h1 id="inspiration"&gt;&#10; Inspiration&#10;&lt;/h1&gt;&#10;&lt;p&gt;I started dreaming about hackerspace more seriously about 2 years ago. What was&#10;the real trigger is the last year&amp;rsquo;s &lt;a href="https://2k14.balccon.org"&gt;BalCCon&lt;/a&gt;. One of&#10;our guests was Mitch Altman. If you never heard of the guy, I recommend his &lt;a href="https://www.youtube.com/watch?v=WkiX7R1-kaY"&gt;TED&#10;talk in Brussels&lt;/a&gt;. The man is one&#10;of those smiley faces that radiates out &amp;ldquo;it&amp;rsquo;s easy if you really want it&amp;rdquo;&#10;message. One night we were sitting in the basement of the museum where the&#10;BalCCon was held and talked about starting a hackerspace in Novi Sad. He had a&#10;lot to say, but only one thing he said stuck in my head: &amp;ldquo;Out of 60k&#10;hackerspaces round the globe, not single one ever failed because of lack of&#10;funding&amp;rdquo;. It took me two weeks to process that. To be more precise, I live in a&#10;place and time where people are happy if they have any job. Let me repeat that,&#10;it&amp;rsquo;s important: &amp;ldquo;ANY JOB&amp;rdquo;. That&amp;rsquo;s the reason I couldn&amp;rsquo;t just accept the truth&#10;about hackerspace funding. Once I accepted that in my mind, I was ready for the&#10;the next step.&lt;/p&gt;&#10;&lt;p&gt;You might think that the next step would be opening the hackerspace, but no. I&#10;had to talk to a lot more people (on BalCCon, of course) who had experience with&#10;this matter. I&amp;rsquo;ve heard all kinds of squat stories, funding initiatives,&#10;creative ways of persuading landlords how to keep the rent low, and such, but&#10;one man was really standing out: Arnd from&#10;&lt;a href="http://techinc.nl/"&gt;Technologia Incognita&lt;/a&gt; (sorry, Arnd, I don&amp;rsquo;t know your&#10;online identity). Although Mitch is inspiring, Arnd gave me tons of stories from&#10;his hackerspace experience that really pushed me forward. With all of these&#10;educational stories, I&amp;rsquo;ve set my path.&lt;/p&gt;&#10;&lt;h1 id="diy"&gt;&#10; DIY&#10;&lt;/h1&gt;&#10;&lt;p&gt;As always, we tried asking for resources from other organizations and&#10;foundations with no luck. At one point I was pissed of by my incompetence to&#10;start a hackerspace. All other people are able to do it, but not me. I took it&#10;really personal, so I sit down and realized one simple fact: I have my own flat,&#10;but if I didn&amp;rsquo;t have it, I would be forced to rent one, like most of my friends&#10;do, and it&amp;rsquo;s the same with the hackerspace. So I decided to change the client,&#10;and the minimal salary I would be satisfied with, and I made it. Don&amp;rsquo;t get me&#10;wrong, there are friends of mine that give moral and financial support, I was&#10;just sick of planing projects to fund a hackerspace (in short, begging), and I&#10;was determined to be able to fund it on my own, if everything else fails.&lt;/p&gt;&#10;&lt;h1 id="result"&gt;&#10; Result&#10;&lt;/h1&gt;&#10;&lt;p&gt;In short, the result is &lt;a href="http://tilda.center"&gt;Tilda Center&lt;/a&gt;. I&amp;rsquo;m sitting in the&#10;hackerspace of my town while writing this post with Internet connection provided&#10;by the kind people of NS Wireless. We have our own 67 square meters of space to&#10;gather, hack, talk, exchange knowledge and welcome new people. Come, visit us!&lt;/p&gt;&#10;</description></item><item><title>Life Together</title><link>https://meka.rs/blog/2015/03/18/life-together/</link><pubDate>Wed, 18 Mar 2015 22:00:00 +0000</pubDate><guid>https://meka.rs/blog/2015/03/18/life-together/</guid><description>&lt;p&gt;I&amp;rsquo;m trying to keep my private life private, but this is just too weird and works&#10;too good to hide. For few years I&amp;rsquo;m living with my girlfriend and things are&#10;sometimes good, sometimes bad, as in any relationship (love or otherwise). To be&#10;honest, I got sick of bad times, because in most cases the reason for the&#10;situation to become bad is ridiculous: &amp;ldquo;you forgot to&amp;hellip;&amp;rdquo;, &amp;ldquo;you didn&amp;rsquo;t&amp;hellip;&amp;rdquo; and&#10;so on.&lt;/p&gt;&#10;&lt;p&gt;It&amp;rsquo;s not that I never lived with someone, it&amp;rsquo;s just that I&amp;rsquo;m the only child of&#10;the only child, so you might think of how much work I didn&amp;rsquo;t do. I don&amp;rsquo;t know&#10;how is it to live with someone, but I do know something else: Scrum! You might&#10;find it weird, but it works. My girlfriend and I are having daily scrum&#10;meetings, sync calendars and plan the day. My idea was, if I know how to lead&#10;the project, and don&amp;rsquo;t know how to have a life with someone, then pretend it&amp;rsquo;s a&#10;project. It can&amp;rsquo;t be worse than this. :o)&lt;/p&gt;&#10;</description></item><item><title>Responsive sites</title><link>https://meka.rs/blog/2015/03/10/responsive-sites/</link><pubDate>Tue, 10 Mar 2015 22:00:00 +0000</pubDate><guid>https://meka.rs/blog/2015/03/10/responsive-sites/</guid><description>&lt;p&gt;Probably this &lt;a href="http://motherfuckingwebsite.com/"&gt;mother fucking web site&lt;/a&gt; sums&#10;it all up. With colorful vocabulary and down to earth arguments, it makes a&#10;good point. What my experience showed me is that designers are so rarely&#10;starting with &amp;ldquo;function first, looks second&amp;rdquo;. When I say &amp;ldquo;function&amp;rdquo; I mean make&#10;it user friendly. I think the fancy term for it is &amp;ldquo;user experience&amp;rdquo;. Once I&#10;stumbled upon a page explaining what user experience really is. Unfortunately,&#10;I can not find the link to it now. One of the examples was &amp;ldquo;don&amp;rsquo;t ask for a&#10;type of credit card&amp;rdquo;. When you read about it, Visa cards start with digit 4,&#10;MasterCard start with 51 or 53. There were tons of suggestions like that, but&#10;basically every site should ask for as less interaction with the user as&#10;possible.&lt;/p&gt;&#10;&lt;p&gt;To conclude with the quote from the mother fucking web site: &amp;ldquo;Good design is as&#10;little design as possible&amp;rdquo;. Think about it!&lt;/p&gt;&#10;</description></item><item><title>Troubles with pull requests</title><link>https://meka.rs/blog/2015/02/27/troubles-with-pull-requests/</link><pubDate>Fri, 27 Feb 2015 22:00:00 +0000</pubDate><guid>https://meka.rs/blog/2015/02/27/troubles-with-pull-requests/</guid><description>&lt;p&gt;Imagine two repos with a pull request from one to another. What you&amp;rsquo;re actually&#10;doing when accepting pull request is equivalent of &lt;code&gt;git merge&lt;/code&gt;, so your &lt;code&gt;HEAD&lt;/code&gt;&#10;will point to the merge commit upon accepting the pull request. Nothing new&#10;there, right? But what if you have hundreds of commits and you find a bug?&#10;Well, that sure thought you to merge more often, for start. If not, leave the&#10;Internet!&lt;/p&gt;&#10;&lt;p&gt;One thing I don&amp;rsquo;t like about merges is that &lt;code&gt;git log&lt;/code&gt; is funky. We as humans can&#10;not think in jumps, which is the way computers and git commit parent work. We&amp;rsquo;re&#10;stranded in &lt;code&gt;git log&lt;/code&gt;, and that&amp;rsquo;s all that our brain can really comprehend. We&#10;have to draw the tree and curves representing merges and whatnot. Now just&#10;imagine you have thousands of commits. To be honest, yeah, there is information&#10;which commit is merge and which is &amp;ldquo;normal&amp;rdquo;, you can filter them out or show&#10;only merges and filter by different criteria, but what we all really want is&#10;&amp;ldquo;tell me what&amp;rsquo;s wrong&amp;rdquo; button/command. Listing all those thousands of commits&#10;one after the other really doesn&amp;rsquo;t tell you much.&lt;/p&gt;&#10;&lt;p&gt;But what if you rebase, or cherry-pick one commit at a time? Then the first&#10;commit that breaks the code will be spotted right away. Yes, it&amp;rsquo;s more painful&#10;because some conflicts you&amp;rsquo;re having with rebase don&amp;rsquo;t show up when doing merge.&#10;The reason to do it is that you really don&amp;rsquo;t want to think in jumps, which merge&#10;commits really are. Imagine continuous stream of commits (read: &lt;code&gt;git log&lt;/code&gt;) which&#10;you don&amp;rsquo;t have to imagine in your head as trees and branches. No double parent&#10;commits, only pure code, one commit after another. It would be much easier to&#10;read, but to be honest, I have no idea how would someone implement it. As it is,&#10;merge commits (which pull requests really are) are the least evil we have.&lt;/p&gt;&#10;</description></item><item><title>Modern WEB applications</title><link>https://meka.rs/blog/2015/02/22/modern-web-applications/</link><pubDate>Sun, 22 Feb 2015 22:00:00 +0000</pubDate><guid>https://meka.rs/blog/2015/02/22/modern-web-applications/</guid><description>&lt;p&gt;Who am I to tell you about WEB applications? Even worse, modern ones? I am&#10;system administrator, right? Well, not exactly. The reason I never liked WEB&#10;programming is that I could never see the point of trying to shoot HTML through&#10;the WEB server, load balancer and browser to tons of different devices with who&#10;knows what resolution and ratio. How can you even dream of supporting the jungle&#10;of devices capable of running a browser? Deep down I always felt that&amp;rsquo;s wrong.&#10;I never had an alternative, so I kept my mouth shut, but admit it, it&amp;rsquo;s a design&#10;level flaw.&lt;/p&gt;&#10;&lt;p&gt;That&amp;rsquo;s a few years old story of mine. Now I think different. With frameworks&#10;like &lt;a href="https://angularjs.org/"&gt;AngularJS&lt;/a&gt; and &lt;a href="http://canjs.com/"&gt;CanJS&lt;/a&gt;, to name&#10;the few, it all changed. First, frontend is finally in the front. I mean, what&#10;frontend is capable of doing now is calculate the height and width of the&#10;elements based on resolution, because the code is running where it&amp;rsquo;s most&#10;suitable for this kind of calculations: the browser. Yes, I know you could alter&#10;the page with javascript before single page application frameworks saw the light&#10;of the day, but it was hackish and ugly.&lt;/p&gt;&#10;&lt;p&gt;One more thing changed. Backend became &amp;ldquo;only&amp;rdquo; the REST API, or the fancy word&#10;&amp;ldquo;DB with some minimal code&amp;rdquo;. If your application is only changing the models in&#10;the backend, you might look at the whole backend as the DB with the REST&#10;interface. That means no more DB procedures, you&amp;rsquo;ve got a proper scripting&#10;language at your disposal with multiple supported DB types, portable code and&#10;properly decoupled code and the DB. Single page application frameworks didn&amp;rsquo;t&#10;bring this to the table, but modern WEB app design and REST did.&lt;/p&gt;&#10;&lt;p&gt;While we&amp;rsquo;re at it, REST brought some optimization, too. Well, JSON did it, but&#10;it&amp;rsquo;s almost the same thing, as almost all REST implementations use JSON as a&#10;format. As only data that is really necessary to fill the template is&#10;transmitted.&lt;/p&gt;&#10;&lt;p&gt;One thing I always hated about WEB applications is authentication. Session?&#10;Cookie? That&amp;rsquo;s just plain and simple wrong. In the age when every application is&#10;behind a load balancer, how do you balance authentication? One solution is&#10;saving the session in the DB. Just think about it for a second. You&amp;rsquo;ll be saving&#10;a temporary information in a DB, which saves the data forever. The modern way of&#10;dealing with this is forgetting the session and the cookies, and using&#10;&lt;a href="http://openid.net/specs/draft-jones-json-web-token-07.html"&gt;JSON WEB Tokens&lt;/a&gt;,&#10;or JWT for short. Simplified, you obtain the token by POSTing to a&#10;authentication endpoint, that token is transfered in a HTTP header on every&#10;request, thus allowing the backend to know who you are. The token itself is just&#10;a very long string. It does have the structure and rules how to generate one,&#10;but I&amp;rsquo;m not going into that now, as it&amp;rsquo;s too much detail for this post. If all&#10;your backend servers generate and use the token in the same way, there&amp;rsquo;s no&#10;difference which server actually generated the token, which enables you to have&#10;proper load balancing.&lt;/p&gt;&#10;&lt;p&gt;This is just my point of view. It will evolve over time, I&amp;rsquo;m sure. You may find&#10;I made mistakes in my judgment. I&amp;rsquo;ll admit it right away, I&amp;rsquo;m not experienced&#10;in this field as much as I&amp;rsquo;d like, but I still do know the principles.&lt;/p&gt;&#10;</description></item><item><title>CCC Summary</title><link>https://meka.rs/blog/2015/01/01/ccc-summary/</link><pubDate>Thu, 01 Jan 2015 22:00:00 +0000</pubDate><guid>https://meka.rs/blog/2015/01/01/ccc-summary/</guid><description>&lt;p&gt;To be honest, this CCC was mental healing for me. I went on a trip with a lot&#10;on my mind and I just couldn&amp;rsquo;t relax. I didn&amp;rsquo;t relax until the last day of the&#10;congress. Why? For 8.5 years of my professional carrier as a system&#10;administrator, I&amp;rsquo;ve never heard &amp;ldquo;good job, man&amp;rdquo; in as many words as &amp;ldquo;what did&#10;you fuck up?&amp;rdquo; kind of critics, so it finally got to me. On the other hand, CCC&#10;is all about sharing knowledge and telling interesting stories to other people.&#10;It relaxed me because I realized that, although I&amp;rsquo;m totally weird for people in&#10;my country, I&amp;rsquo;m nothing strange on the conference. I was accepted. FINALLY!!!&lt;/p&gt;&#10;&lt;p&gt;Let&amp;rsquo;s start from the beginning. My fiancé was so excited about CCC. I still&#10;can&amp;rsquo;t understand her, as she&amp;rsquo;s something like a child psychologist. There are&#10;topics covering e-learning and stuff like that, but she understands hacking,&#10;programming, administration, security, privacy, etc. So, for the first time in&#10;my life I&amp;rsquo;m with the girl I don&amp;rsquo;t have to explain what my job and hobbies are&#10;all about. What a relief! Second, she booked us tickets for hacker tour of&#10;&lt;a href="http://desy.de"&gt;DESY&lt;/a&gt;, particle accelerator. What? My girlfriend not only&#10;understands me, she&amp;rsquo;s pushing me in the right direction? I must be dreaming.&#10;Let me repeat. My fiancé was excited about seeing particle accelerator more&#10;then buying new camera (she&amp;rsquo;s also amateur photographer). How cool is that?&lt;/p&gt;&#10;&lt;p&gt;OK, we&amp;rsquo;re at the airport. As I&amp;rsquo;ve never flew in an airplane before, I had no&#10;idea what to expect. It was fun, of course. Seeing the clouds from above,&#10;seeing the Sun, as it&amp;rsquo;s winter and it&amp;rsquo;s cloudy every day. The G force when&#10;taking off was something I should have anticipated, but I was so surprised. And&#10;most of all, the size of Munich and Hamburg airports was astonishing. Let me&#10;explain. I was born and I still live in a town of 300k people. We don&amp;rsquo;t even&#10;have an airport, so seeing something that huge was great. Oh, and seeing that&#10;even Germans get some things too late was so precious to me.&lt;/p&gt;&#10;&lt;p&gt;We&amp;rsquo;re in Hamburg. As my fiancé and I can&amp;rsquo;t speak German, it&amp;rsquo;s fun. It&amp;rsquo;s so well&#10;organized that we can not comprehend it. It took me 4 days to figure out how to&#10;properly read S bahn maps. Germans are looking at us like Martians when we ask&#10;something like &amp;ldquo;in which direction is Dammtor station?&amp;rdquo;, because it&amp;rsquo;s so&#10;obvious to them. Let me tell you, I don&amp;rsquo;t mind. I come from a different&#10;culture, if you can call it a culture at all, and having diversity in almost&#10;everything is something I find useful. Of course, you feel like a jerk at&#10;first, but it&amp;rsquo;s an adventure.&lt;/p&gt;&#10;&lt;p&gt;We&amp;rsquo;re at the Congress Centrum Hamburg, finally. It&amp;rsquo;s so huge I didn&amp;rsquo;t get to&#10;know my way around it in 4 days. I still couldn&amp;rsquo;t find my way around, and we&#10;heard from an older W Holand member that they maybe return CCC to Berlin, but&#10;to a proper congress center big enough for 50k people. I was like &amp;ldquo;What? That&amp;rsquo;s&#10;1/6 of the population of my town! Do you rent a bike to go around it?&amp;rdquo;. Anyway,&#10;they have few solutions in mind when CCH becomes too crowded (it&amp;rsquo;s already a&#10;bit crowded). You can download all lectures from &lt;a href="https://ftp.ccc.de/congress/31C3/"&gt;CCC&#10;FTP&lt;/a&gt;. To be honest, I can point at only&#10;one lecturer, a friend of ours from Varaždin, Croatia:&#10;&lt;a href="https://ftp.ccc.de/congress/31C3/h264-hd/31c3-5966-en-de-UNHash_-_Methods_for_better_password_cracking_hd.mp4"&gt;UNHash - Methods for better password&#10;cracking&lt;/a&gt;.&lt;/p&gt;&#10;&lt;p&gt;After congress, we had new year eve celebration at our friends house from&#10;Hamburg who speaks really good Serbian, so we finally could forget English. He&#10;was super nice and prepared beer and dinner I will never forget. Even if it was&#10;the worst night ever I would still have to say it was the best ever, because of&#10;his kick boxing black belt. No kidding with this guy. :o)&lt;/p&gt;&#10;&lt;p&gt;For the end, I have few things anyone traveling to Germany and not knowing&#10;German language should know. First, Turkish food is THE BEST! Sorry folks from&#10;other countries, but Turks prepare insanely large and delicious dishes. You&#10;can&amp;rsquo;t compete with that. Second is, if you want to ask a random dude on the&#10;street for directions or help in English, ask the black guy, as Germans and&#10;English are not really tight. It&amp;rsquo;s not about racism, it&amp;rsquo;s just that there&amp;rsquo;s a&#10;huge chance that black guy is actually from USA and can understand you. Of&#10;course, we decided to take German classes once we get home. Ideally, knowing&#10;English, German, Spanish and Chinese, you&amp;rsquo;re prepared for the world. We&amp;rsquo;ll see&#10;how good we&amp;rsquo;ll become at learning new languages, but hey, I learn new&#10;programming languages once a year. What&amp;rsquo;s a new spoken language compared to&#10;that. :o) We&amp;rsquo;re preparing for the flight home, as tomorrow morning we&amp;rsquo;re&#10;departing. It was nice, useful, helpful and fun. Thank you for all the fish!&lt;/p&gt;&#10;</description></item><item><title>CCC</title><link>https://meka.rs/blog/2014/12/29/ccc/</link><pubDate>Mon, 29 Dec 2014 22:00:00 +0000</pubDate><guid>https://meka.rs/blog/2014/12/29/ccc/</guid><description>&lt;p&gt;Of course, I&amp;rsquo;m talking about &lt;a href="http://ccc.de"&gt;CCC&lt;/a&gt;. As there&amp;rsquo;s a lot of talk&#10;about hacking this and that on a technical level, I will try to avoid that.&lt;/p&gt;&#10;&lt;p&gt;It&amp;rsquo;s the third day of the congress, and, as expected, I&amp;rsquo;ve seen all kinds of&#10;crazy lectures. The variety of topics is astonishing. For example, I&amp;rsquo;m&#10;currently sitting next to the ring making workshop with people hammering metal&#10;for hours. We&amp;rsquo;ve seen food hacking base, where you can learn how to cook like a&#10;hacker: using arduino to control temperature of kefir and such. You can see&#10;lectures like &amp;ldquo;copy wrong&amp;rdquo; dealing with weirdness of copyright laws and&#10;licensing (hint: you can take panorama pictures of Eiffel tower by day, but not&#10;by night because lights on it are made by architect that is not &amp;ldquo;dead + 100&#10;years&amp;rdquo;). You can also leave your kid in the area with rubber balls and toys, so&#10;parents can watch their favorite lecturer. You can learn how to solder and work&#10;with arduino for TV B Gone. You can hear what&amp;rsquo;s the real problem with quantum&#10;computers where camera man asked some really technical questions, and the girl&#10;from the crowd knows so much more then I do! Don&amp;rsquo;t get me wrong, I don&amp;rsquo;t think&#10;it&amp;rsquo;s bad that girls know such things, but with my background of growing up in&#10;and old fashioned society, that&amp;rsquo;s weird, and I like it! And my favorite,&#10;creating your own audio devices and programming firmware and software for it&#10;(hint: software like &lt;a href="http://puredata.info/"&gt;pure data&lt;/a&gt;)&lt;/p&gt;&#10;&lt;p&gt;Let me also tell you that all the people are super nice. Everybody is&#10;collecting trash, either someone else&amp;rsquo;s or their own. Everybody is environment&#10;friendly, helping the neighbor or spreading awareness of all kinds of crazy&#10;cultural topics (hint: there&amp;rsquo;s a &amp;ldquo;medical advice: please wash your hands!&amp;rdquo;).&#10;For the end, do I need to tell you I didn&amp;rsquo;t expect this?&lt;/p&gt;&#10;</description></item><item><title>Presonus Audiobox 1818VLS 2</title><link>https://meka.rs/blog/2014/12/15/presonus-audiobox-1818vls-2/</link><pubDate>Mon, 15 Dec 2014 22:00:00 +0000</pubDate><guid>https://meka.rs/blog/2014/12/15/presonus-audiobox-1818vls-2/</guid><description>&lt;p&gt;And it finally arrived. First, right channel on the headphones didn&amp;rsquo;t work. I&#10;made a peace with myself that I have to spend some more money for sending it to&#10;Thomman to replace it with a working one. I tried everything that came to my&#10;head and couldn&amp;rsquo;t figure out what&amp;rsquo;s wrong. As my friend brought it for me, we&#10;were not at my home, so on the way home I figured out that I didn&amp;rsquo;t check the&#10;pan. While unpacking it, there was a trillion of &amp;ldquo;please be the pan&amp;rdquo; prayers.&#10;I&amp;rsquo;ve connected it, fired it up, and everything was just working. I still have&#10;no idea how or why. And now for the technical details.&lt;/p&gt;&#10;&lt;p&gt;The reason I wanted this card is because it&amp;rsquo;s the only USB 2.0 audio interface&#10;that is seamlessly supported under GNU/Linux that I know of. You just plug it&#10;in, start JACK, and you have 18 inputs and 18 outputs. Just so you know, 1+2&#10;outputs are the main, 7+8 are headphones and 9+10 are S/PDIF. As for inputs,&#10;9+10 are S/PDIF and the rest is as it&amp;rsquo;s numerated. My setup is that in first&#10;input I have my guitar (1st and 2nd are mic/instrument combo, others are&#10;mic/line). The guitar is always routed to S/PDIF output, and that output goes&#10;to my guitar processor&amp;rsquo;s (Line 6 POD X3 Pro) input. S/PDIF output of POD is&#10;returned into S/PDIF input on the card. This setup enables me to record dry and&#10;wet guitar at the same time, as POD always gets it&amp;rsquo;s input from Presonus, I&#10;never have to change inputs or outputs with it, and I can reamp dry tracks. One&#10;of the problems I had with a previous setup was that audio card didn&amp;rsquo;t have&#10;guitar input, so I had to use POD for everything. This means, that while&#10;recording dry guitar, I would listen to analog output of POD with full&#10;simulation of amp for monitoring, and send dry signal through S/PDIF. Once I&#10;record it, I had to switch input to S/PDIF, which is the last item on the menu&#10;where you choose your input. Guess what&amp;rsquo;s the first option: guitar input, of&#10;course. So I spent a lot of time going back and forth through the menu which&#10;doesn&amp;rsquo;t go to first item once you&amp;rsquo;ve passed the last one. What a hassle! And&#10;that&amp;rsquo;s not enough. Because previous card, M-Audio Delta 1010LT can not be&#10;worldclock master, I had to switch the master every time I wanted to switch to&#10;&amp;ldquo;studio mode&amp;rdquo; or back to normal mode. Switching to studio means POD is the&#10;master, I switch to S/PDIF sync on Delta and everything works. The trouble is&#10;going back, because you can&amp;rsquo;t just switch the sync source. You have to stop&#10;JACK, switch the sync source, start JACK and start all programs that don&amp;rsquo;t&#10;handle JACK stopping well. If I just power off POD while it&amp;rsquo;s sync master,&#10;Delta just dies. One reboot later you&amp;rsquo;re good to go. That was a pain! Now I can&#10;even bring my studio anywhere and record. That means that I can finally have&#10;the same setup and latency no matter where I record (we used my guitar player&amp;rsquo;s&#10;laptop and audio interface for vocals).&lt;/p&gt;&#10;&lt;p&gt;Now for some fine tuning. First, every USB interface should have 3 as number of&#10;periods, compared to all other interfaces which have 2. You really want&#10;linux-image-lowlatency. My stable setup with a xrun now and then dropped from&#10;10.5ms to 2.7ms. On 10.5ms you can notice the latency if you play something&#10;fast, and we do. Of course, I use maximum sampling frequency of 96k. I&#10;recommend using KXStudio repository, Cadence for JACK management, Ardour3 for&#10;recording and SoundCloud for sharing tunes. Hear ya soon!&lt;/p&gt;&#10;</description></item><item><title>Life is a Dream</title><link>https://meka.rs/blog/2014/12/09/life-is-a-dream/</link><pubDate>Tue, 09 Dec 2014 22:00:00 +0000</pubDate><guid>https://meka.rs/blog/2014/12/09/life-is-a-dream/</guid><description>&lt;p&gt;Ever heard of it? Life is a dream? Did you ever think about it? I did. A lot!&#10;And I can tell you it is. Just look at what we do, create, transform and&#10;whatnot. Just by wishing something it comes true. Just by work you get results.&#10;When you think about it, you could do everything differently in your life. You&#10;could shape yourself, your life, your surrounding. Any of us could. I mean,&#10;even quantum physics says that anything is possible. What do we do with that?&#10;Dress up and go to boring work. Are we insane? Are we media oriented? Are we&#10;blind? In a word, fuck you, life. I publicly express my regret for existing in&#10;this world. I regret I&amp;rsquo;m incompetent to change the world (not really, but it&#10;involves starting from scratch). I&amp;rsquo;m sorry, but the mediocrity of the world got&#10;to me. Where do I sign up for a &lt;a href="http://www.mars-one.com"&gt;mission to Mars&lt;/a&gt; or&#10;exploration of black holes?&lt;/p&gt;&#10;</description></item><item><title>Presonus Audiobox 1818VLS</title><link>https://meka.rs/blog/2014/12/07/presonus-audiobox-1818vls/</link><pubDate>Sun, 07 Dec 2014 22:00:00 +0000</pubDate><guid>https://meka.rs/blog/2014/12/07/presonus-audiobox-1818vls/</guid><description>&lt;p&gt;For years I have &lt;a href="http://www.m-audio.com/products/view/delta-1010lt#.VIS-oN_0_RY"&gt;M-Audio Delta&#10;1010LT&lt;/a&gt;. It&amp;rsquo;s&#10;great, but it lacks some things I need now. One of the things is being&#10;worldclock master. Second is Hi-Z input. All of that is covered with &lt;a href="http://www.presonus.com/products/AudioBox-1818VSL"&gt;Presonus&#10;Audiobox 1818VLS&lt;/a&gt;. As a&#10;consequence, I can use my &lt;a href="http://line6.com/legacy/podx3pro"&gt;Line 6 POD X3 Pro&lt;/a&gt;&#10;without switching who&amp;rsquo;s the master on a card (it kills all audio programs, too)&#10;and without ever changing the routing or setup. What it basically means is that&#10;POD can run in stereo mode in which it expects two guitars on the inputs, and&#10;each guitar has only one channel (left or right). The reason I want this is so&#10;I can route from &lt;a href="https://ardour.org/"&gt;Ardour&amp;rsquo;s&lt;/a&gt; outputs of clean guitars to&#10;POD when doing playback, and route one Audiobox&amp;rsquo;s input to two inputs of POD,&#10;emulating two guitars. Why am I telling you this? I&amp;rsquo;ve ordered Presonus, and I&#10;can&amp;rsquo;t wait to hear how it works with my Ubuntu. It&amp;rsquo;s almost Christmas :o) Once&#10;it&amp;rsquo;s in my posession, I&amp;rsquo;ll tell you all about routing audio signals via&#10;&lt;a href="http://jackaudio.org/"&gt;JACK&lt;/a&gt;.&lt;/p&gt;&#10;</description></item><item><title>PCEngines APU</title><link>https://meka.rs/blog/2014/12/02/pcengines-apu/</link><pubDate>Tue, 02 Dec 2014 22:00:00 +0000</pubDate><guid>https://meka.rs/blog/2014/12/02/pcengines-apu/</guid><description>&lt;p&gt;I had TP-Link provided by ISP for years, and I never bothered to replace it. It&#10;does work, but sometimes it&amp;rsquo;s just a pain in the ass. For example, the closer&#10;my laptop is to the router, more packet drops I have. I finally decided to grab&#10;a new router, and, of course, I got an &amp;ldquo;underground one&amp;rdquo;. I mean, who ever&#10;heard of PCEngines? Their model APU has variant with 4GB of RAM. Impressive,&#10;right? :o) There is no particular reason I decided for 4GB. It was there and I&#10;didn&amp;rsquo;t want to think what I can and can&amp;rsquo;t do. It&amp;rsquo;s loaded with 16GB SSD hard&#10;drive and Atheros WiFi card with 2 antennas. It has 3 gigabit ports and serial&#10;console. ALIX, former model had VGA, also, which made things much easier,&#10;because finding null terminated USB to RS232 cable is near to impossible (thank&#10;you &lt;a href="http://www.ktehnika.co.rs/"&gt;KT&lt;/a&gt;). So, I grabbed pfSense USB image with&#10;serial console, dd&amp;rsquo;ed it to USB stick and install is pretty straight forward.&lt;/p&gt;&#10;&lt;p&gt;Let&amp;rsquo;s take a step back. You get all the pieces and it&amp;rsquo;s not tricky to assemble&#10;it if you follow &lt;a href="http://www.pcengines.ch/apucool.htm"&gt;instructions&lt;/a&gt;. Trust me,&#10;it&amp;rsquo;s not hard even the first time (I&amp;rsquo;ve never had anything similar before). For&#10;pfSense installation, follow [Gooze&#10;instructions](&lt;a href="http://www.gooze.eu/howto/pfsense-installation-on-alix-apu-board-h"&gt;http://www.gooze.eu/howto/pfsense-installation-on-alix-apu-board-h&lt;/a&gt;&#10;owto) and you&amp;rsquo;re set. Next few tips are just to get you there easier.&lt;/p&gt;&#10;&lt;p&gt;First, APU&amp;rsquo;s serial port is on baud of 115200, and pfSense installation is on&#10;baud of 9600, so you boot on one baud, configure device, switch to lower baud,&#10;do the installation of pfSense and switch back to higher baud. Once you install&#10;the device, you don&amp;rsquo;t have to change baud ever again. Second &amp;ldquo;trick&amp;rdquo; is that in&#10;order to use WiFi card as AP, you have to assign ath0 interface as optional&#10;interface, then rename OPT1 to WIFI in order to find it easier in the future,&#10;and configure the same filter rules like those for LAN. That should be enough&#10;for you to start using WIFI. On software side, you only need minicom configured&#10;with /dev/ttyUSB0 on your laptop, and pfSense installation. Hardware: USB&#10;stick, APU, USB to RS232 converter and F2F (meaning &amp;ldquo;female to female&amp;rdquo;) serial&#10;cable. Have fun! :o)&lt;/p&gt;&#10;</description></item><item><title>Freelancing and USA company</title><link>https://meka.rs/blog/2014/11/27/freelancing-and-usa-company/</link><pubDate>Thu, 27 Nov 2014 22:00:00 +0000</pubDate><guid>https://meka.rs/blog/2014/11/27/freelancing-and-usa-company/</guid><description>&lt;p&gt;Sorry, folks, but I&amp;rsquo;ve got nothing nice for this post. Last night I got an&#10;email that made me laugh and angry, at the same time. I tried to negotiate some&#10;freelance job, and after a week of talk I get &amp;ldquo;send me a Word copy of your&#10;resume and a copy of your drivers license or passport&amp;rdquo;. Right. Word? For Linux&#10;administrator? First big fail by the company. OK, I copy/paste my&#10;&lt;a href="https://meka.rs/resume"&gt;resume&lt;/a&gt; into LibreOffice, do some minor editing and send it with &amp;ldquo;My&#10;Word copy of a resume is attached &amp;hellip; I can&amp;rsquo;t send one (copy of a passport,&#10;that is) to random people on the Internet just because they ask me to. Sorry&amp;rdquo;.&#10;Am I being I jerk? I don&amp;rsquo;t think so. Think about it. You can reset almost&#10;anything with a copy of a passport and email address. Almost anything, for&#10;example, was my password for a credit card site. I might be crazy, but I&amp;rsquo;m not&#10;dumb. What&amp;rsquo;s their excuse? &amp;ldquo;We&amp;rsquo;re going to give you root login, and we&amp;rsquo;re&#10;serious US company&amp;rdquo; (in much more words, so I&amp;rsquo;m paraphrasing). So that should&#10;give you credibility to ask people for passport? Right! Naturally, they&#10;canceled the job. To be honest, they just got to a job post first, otherwise I&#10;would do it.&lt;/p&gt;&#10;&lt;p&gt;Let&amp;rsquo;s go back a little. Let&amp;rsquo;s say I want to hire you and I say &amp;ldquo;I&amp;rsquo;m a&#10;representative of a US company&amp;rdquo;. Would you give me your passport? How do you&#10;know I do have a company? Internet site? Or I&amp;rsquo;m really registered. It&amp;rsquo;s easy to&#10;do that even in my shit hole of a country where you usually need tons of&#10;papers, but not for a company, they want to get your tax money as soon as&#10;possible. Just think what all you can do with someone&amp;rsquo;s ID or passport. Now add&#10;to that the fact that I&amp;rsquo;m a hacker, meaning I spend my time thinking about&#10;intrusion, malware, viruses, social engineering and who knows what else. Why?&#10;Because I&amp;rsquo;m usually hired to think about that and come up with a protection. In&#10;a word, I&amp;rsquo;m dealing with all kinds of lies and deceiving people, but all of a&#10;sudden, if you happen to have a USA company, I should trust you? I mean, why&#10;even emphasize your in the USA? World terrorist number one country in the world&#10;should give me some fuzzy feeling and I fall into hypnotic state and trust you&#10;completely? Get the fuck out!&lt;/p&gt;&#10;&lt;p&gt;And let me tell you, I did think this through. I didn&amp;rsquo;t want to say who they&#10;are, but fuck you retards from [Epic Farts](http =//epicforce.net/). If you mark&#10;me as &amp;ldquo;not smart enough&amp;rdquo; when declining my application, I can be jerk, too, you&#10;dumb ass.&lt;/p&gt;&#10;</description></item><item><title>Cloud Computing Basics 7</title><link>https://meka.rs/blog/2014/11/21/cloud-computing-basics-7/</link><pubDate>Fri, 21 Nov 2014 22:00:00 +0000</pubDate><guid>https://meka.rs/blog/2014/11/21/cloud-computing-basics-7/</guid><description>&lt;p&gt;There&amp;rsquo;s been so much talk about Consul-template and I&amp;rsquo;ve never shown you any&#10;examples. Consul-template is what gives Docker container the knowledge when&#10;something is changed in Consul. It does it by having a template for&#10;configuration file filled with Consul data and command to run when template is&#10;generated. Let&amp;rsquo;s take a look at my Dockerfile for NginX:&lt;/p&gt;&#10;&lt;pre&gt;&lt;code&gt;FROM nginx:latest&#10;MAINTAINER Goran Mekić &amp;lt;meka@lugons.org&amp;gt;&#10;&#10;ENV DEBIAN_FRONTEND noninteractive&#10;ADD consul /app/consul&#10;ADD consul-template /usr/bin/consul-template&#10;ADD run.sh /run.sh&#10;&#10;CMD /run.sh&#10;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;p&gt;It&amp;rsquo;s a bit dirty as I get consul-template out of the sky, but kids, don&amp;rsquo;t be&#10;like me. :o) Yeah, always works!&lt;/p&gt;&#10;&lt;p&gt;I have my run.sh:&lt;/p&gt;&#10;&lt;pre&gt;&lt;code&gt;#!/bin/bash&#10;&#10;set -e&#10;&#10;rm /etc/nginx/conf.d/*&#10;consul-template -config /app/consul/nginx.conf&#10;sleep 1&#10;tail -f /var/log/nginx.log&#10;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;p&gt;Great. So Consul-template does all the work. Let&amp;rsquo;s see the config.&lt;/p&gt;&#10;&lt;pre&gt;&lt;code&gt;consul = &amp;quot;172.17.42.1:8500&amp;quot;&#10;&#10;template {&#10; source = &amp;quot;/app/consul/nginx.tmpl&amp;quot;&#10; destination = &amp;quot;/etc/nginx/conf.d/onelove.conf&amp;quot;&#10; command = &amp;quot;service nginx restart&amp;quot;&#10;}&#10;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;p&gt;Remember I&amp;rsquo;ve told you that Consul is available on 172.17.42.1 on all hosts?&#10;This is where it comes handy. It is achieved through docker0 interface. Ensure&#10;you have the same IP on all hosts and that Consul is bind to it, and that&amp;rsquo;s it.&lt;/p&gt;&#10;&lt;p&gt;Second part is the template. What, where and how are the questions it answers.&#10;What source template I should use? Where to put the output? How to notify the&#10;service. Yeah, I&amp;rsquo;m aggressive, I restart instead of reload because of simplicity.&#10;The problem I had was with the run.sh. If you look closely, only thing I really&#10;call is &lt;code&gt;consul-template&lt;/code&gt;. I never start nginx by hand or automatically inside&#10;the container, so if I have used &lt;code&gt;reload&lt;/code&gt;, there would be nothing to reload&#10;initially (read: container doesn&amp;rsquo;t boot).&lt;/p&gt;&#10;&lt;p&gt;There are two thing you can do to ensure that your load balancers don&amp;rsquo;t reboot&#10;all at the same time. First one is to explore&#10;(wait parameter)[https://github.com/hashicorp/consul-template#usage] and restart&#10;with random delay. Second one is to initialize the config, start services, and&#10;watch for changes. When there is a change, reinitialize config and reload&#10;service. Example of it is&#10;&lt;a href="https://github.com/one-love/api/blob/master/bin/run.sh"&gt;One Love API&lt;/a&gt;.&lt;/p&gt;&#10;&lt;pre&gt;&lt;code&gt;#!/bin/bash&#10;&#10;set -e&#10;&#10;export COMMAND=&amp;quot;consul-template -config /app/consul/api.conf&amp;quot;&#10;&#10;echo -n &amp;quot;Waiting for initial config &amp;quot;&#10;until $COMMAND -once; do&#10; echo -n &amp;quot;.&amp;quot;&#10; sleep 3&#10;done&#10;echo &amp;quot; done&amp;quot;&#10;&#10;uwsgi --ini /app/uwsgi.ini&#10;python /app/manage.py migrate --noinput&#10;python /app/manage.py collectstatic --noinput&#10;&#10;$COMMAND &amp;amp;&#10;sleep 1&#10;tail -f /var/log/uwsgi.log&#10;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;p&gt;Now you know everything I know about the cloud computing. This is my way of&#10;doing things, and my view. You don&amp;rsquo;t have to agree on everything. I&amp;rsquo;m not going&#10;to agree with these posts in a year! What I didn&amp;rsquo;t describe is Docker HUB, but&#10;go to site, register, and add your repository. Play with it, it&amp;rsquo;s dead simple. I&#10;gave my best to give you posts that have no bull shit talk, because I was mad on&#10;todays media representing the cloud. I hope I did it. Happy dockering!&lt;/p&gt;&#10;&lt;p&gt;&lt;a href="https://meka.rs/blog/2014/11/20/cloud-computing-basics-6/"&gt;previous&lt;/a&gt;&lt;/p&gt;&#10;</description></item><item><title>Real Time Feedback</title><link>https://meka.rs/blog/2014/11/21/real-time-feedback/</link><pubDate>Fri, 21 Nov 2014 22:00:00 +0000</pubDate><guid>https://meka.rs/blog/2014/11/21/real-time-feedback/</guid><description>&lt;p&gt;As I&amp;rsquo;m learning about WEB development, I&amp;rsquo;m learning how not to do it. Anyone can&#10;do it, but only few can find so many solutions that are bad and know why they&#10;are bad. That means that those few will nag big time about most of the solutions,&#10;but once they shut up, you know you&amp;rsquo;re doing it right. I&amp;rsquo;m lazy. I know it&amp;rsquo;s my&#10;strength and my weakness. That&amp;rsquo;s the reason I tend to automate everything. The&#10;trouble is that I also tend to optimize a lot. I hate inefficient procedures.&#10;That&amp;rsquo;s my reason for two monitors. Think about it. I&amp;rsquo;m writing every post in&#10;&lt;a href="http://www.vim.org/"&gt;vim&lt;/a&gt;. That means I have no idea how my post will look like.&#10;But if you take a look at&#10;&lt;a href="https://github.com/mekanix/meka.rs/tree/master/_posts"&gt;the code&lt;/a&gt;, you&amp;rsquo;ll notice&#10;it is folded on 80th character. We&amp;rsquo;re all crazy in our own way, I just accepted&#10;my weirdness. :o)&lt;/p&gt;&#10;&lt;p&gt;OK, now the important stuff. When you write in vim, you realize you can execute&#10;a script on every save. What if you&amp;rsquo;re editing a post, the script you&amp;rsquo;re&#10;running remembers the window which has the focus, focuses chromium window, sends&#10;it &amp;ldquo;CTRL+r&amp;rdquo;, and returns back? Basically, you&amp;rsquo;ll have your post rendered every&#10;time you change the post. And what if you have two monitors? You could see the&#10;change almost while you&amp;rsquo;re typing. That&amp;rsquo;s pretty close to real time feedback.&#10;And if you have real time feedback, you can see what you&amp;rsquo;re doing, which is&#10;great. Now tell me, isn&amp;rsquo;t this the best reason you&amp;rsquo;ve ever heard for a monitor&#10;purchase? :o)&lt;/p&gt;&#10;&lt;p&gt;All you need is vim config like&lt;/p&gt;&#10;&lt;pre&gt;&lt;code&gt;au BufWritePost * silent !/home/meka/bin/vim-reload-chromium.sh&#10;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;p&gt;and the script&lt;/p&gt;&#10;&lt;pre&gt;&lt;code&gt;#!/bin/bash&#10;&#10;exec 1&amp;gt;/dev/null&#10;exec 2&amp;gt;/dev/null&#10;&#10;ACTIVE_WINDOW=$(xdotool getactivewindow)&#10;CHROMIUM_WINDOW=$(xdotool search --name '^.* - Chromium$')&#10;&#10;sleep 2&#10;xdotool windowactivate ${CHROMIUM_WINDOW}&#10;xdotool key &amp;quot;CTRL+r&amp;quot;&#10;xdotool windowactivate ${ACTIVE_WINDOW}&#10;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;p&gt;Now go, prepare for Christmas! :o)&lt;/p&gt;&#10;</description></item><item><title>Cloud Computing Basics 6</title><link>https://meka.rs/blog/2014/11/20/cloud-computing-basics-6/</link><pubDate>Thu, 20 Nov 2014 22:00:00 +0000</pubDate><guid>https://meka.rs/blog/2014/11/20/cloud-computing-basics-6/</guid><description>&lt;p&gt;Docker here, Docker there, and no Docker build anywhere. That&amp;rsquo;s not fair. How&#10;about we create the first docker? Docker image is built from &lt;code&gt;Dockerfile&lt;/code&gt;.&#10;The syntax of &lt;code&gt;Dockerfile&lt;/code&gt; is almost the same as &lt;code&gt;Bash&lt;/code&gt;. This is an example of&#10;Dockerfile:&lt;/p&gt;&#10;&lt;pre&gt;&lt;code&gt;FROM debian:jessie&#10;MAINTAINER Goran Mekić &amp;lt;meka@lugons.org&amp;gt;&#10;RUN touch /some-file.txt&#10;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;p&gt;To build it run &lt;code&gt;docker build -t username/repo .&lt;/code&gt; in a directory containing&#10;Dockerfile. It&amp;rsquo;s advisable to have a &lt;a href="https://registry.hub.docker.com/"&gt;HUB&lt;/a&gt;&#10;username, as registration is free and has autobuild capabilities. We&amp;rsquo;ll deal&#10;with simple builds for now, and leave autobuild for some future post.&lt;/p&gt;&#10;&lt;p&gt;To upload your image issue this command:&lt;/p&gt;&#10;&lt;pre&gt;&lt;code&gt;docker push username/repo&#10;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;p&gt;Docker will ask you for username/password/email combination. Fill it up, wait&#10;for upload to finish and that&amp;rsquo;s it. You have your first Docker image. Let&amp;rsquo;s give&#10;it a spin.&lt;/p&gt;&#10;&lt;pre&gt;&lt;code&gt;docker run --rm -i -t username/repo /bin/bash&#10;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;p&gt;What it does is (simplified):&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;code&gt;--rm&lt;/code&gt;: remove container when it stops&lt;/li&gt;&#10;&lt;li&gt;&lt;code&gt;-i&lt;/code&gt;: this will be interactive container (read: someone will type commands in it)&lt;/li&gt;&#10;&lt;li&gt;&lt;code&gt;-t&lt;/code&gt;: give me a terminal emulation&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;Note that every command in Dockerfile will create additional layer. It means&#10;that Docker images are organized as multiple file system layers which have&#10;dependencies. Much like a git repo branch is pointer to commit which has its&#10;own dependencies, Docker image remembers which file system layer is on top. As&#10;every layer remembers which layer it depends on, you can have dependency line.&#10;In the example above, there will be at least 3 layers: FROM, MAINTAINER and RUN&#10;lines make them. This has consequences you have to be aware of. First, if the&#10;line in Dockerfile and dependent layers didn&amp;rsquo;t change from last build, Docker&#10;will use last build&amp;rsquo;s layer, not build it (read: cache). Second, EVERY line in&#10;Dockerfile creates layer. So, if you create 1GB file on one line, delete it on&#10;the other, you&amp;rsquo;ll have a small layer (from deleting 1GB) dependent on a big&#10;layer (where you created 1GB), although lower layer is unusable, because upper&#10;layer effectively masked it.&lt;/p&gt;&#10;&lt;p&gt;The &amp;ldquo;trick&amp;rdquo; I use is to have a build script which will cause 2 lines in&#10;Dockerfile: one for ADD and one for RUN. I start with debian:jessie, add all&#10;build tools, build my app, remove build tools and do the cleanup. The build&#10;does last much longer, but you end up with MUCH smaller images. I managed to&#10;shrink &lt;a href="https://github.com/one-love/api"&gt;One Love API&lt;/a&gt; image from 1GB to 298MB just using this. What I think would be&#10;the optimal solution are two images, one for building, one for using application.&#10;And guess what. There are. For example, you have&#10;&lt;a href="https://registry.hub.docker.com/_/python/"&gt;python:latest and python:onbuild&lt;/a&gt;&#10;images.&lt;/p&gt;&#10;&lt;p&gt;I leave it up to you how to build your applications, these are just some ideas.&#10;Idealy, you can base your application on busybox environment, and use images as&#10;small as 5MB. If not, lurk around for your perfect solution.&lt;/p&gt;&#10;&lt;p&gt;&lt;a href="https://meka.rs/blog/2014/11/17/cloud-computing-basics-5/"&gt;previous&lt;/a&gt;&#10;&lt;a href="https://meka.rs/blog/2014/11/21/cloud-computing-basics-7/"&gt;next&lt;/a&gt;&lt;/p&gt;&#10;</description></item><item><title>Cloud Computing Basics 5</title><link>https://meka.rs/blog/2014/11/17/cloud-computing-basics-5/</link><pubDate>Mon, 17 Nov 2014 22:00:00 +0000</pubDate><guid>https://meka.rs/blog/2014/11/17/cloud-computing-basics-5/</guid><description>&lt;p&gt;You hear me talk about thousands of servers and never about how to get to the&#10;point where you make 10,000 servers go up. The fancy word is &amp;ldquo;provisioning&amp;rdquo;. I&#10;don&amp;rsquo;t even know what&amp;rsquo;s it supposed to mean, but for me it means &amp;ldquo;make a recipe&#10;which will make machine configured for a purpose&amp;rdquo;. As we&amp;rsquo;re talking about cloud&#10;computing and Docker, what we need is a machine that is Consul and Registrator&#10;ready. Getting to that point on multiple servers is not such a short task, but&#10;it&amp;rsquo;s repetitive. And, along comes &lt;a href="http://www.ansible.com/home"&gt;Ansible&lt;/a&gt;. Over&#10;the years people realized that they want a language for specifying server&#10;configuration that is declarative, so Ansible uses &lt;a href="http://www.yaml.org/"&gt;YAML&lt;/a&gt;&#10;for that. We also need a language to describe the configuration of different&#10;services, and&lt;a href="http://jinja.pocoo.org/docs/dev/"&gt;Jinja2&lt;/a&gt; offers that. On top of&#10;that, it&amp;rsquo;s Python, so it has extra plus on my scale. As you can&amp;rsquo;t just apply&#10;something on your servers and hope for the best, you need some development&#10;environment. I think &lt;a href="https://www.vagrantup.com/"&gt;Vagrant&lt;/a&gt; has no competition&#10;in that field, yet. Let&amp;rsquo;s see on the example of this blog how to use it. Clone&#10;&lt;a href="https://github.com/mekanix/meka.rs"&gt;meka.rs&lt;/a&gt;, and execute &lt;code&gt;vagrant up&lt;/code&gt;. It&#10;should download CentOS 7 box, create new virtual machine in VirtualBox and&#10;provision it with Ansible. What it does is not that important right now. Let&amp;rsquo;s&#10;start with example Ansible task:&lt;/p&gt;&#10;&lt;pre&gt;&lt;code&gt;- name: install docker&#10; sudo: yes&#10; yum:&#10; pkg: docker&#10; state: latest&#10;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;p&gt;Yeah, it&amp;rsquo;s that simple and readable. That&amp;rsquo;s fine, but let&amp;rsquo;s dive into the&#10;details. First, there&amp;rsquo;s a&#10;&lt;a href="https://github.com/mekanix/meka.rs/blob/master/provision/site.yml"&gt;site.yml&lt;/a&gt;&#10;file. You can see the title of Ansible playbook, hosts on which it will be run&#10;on and roles it will apply. As I have &lt;a href="https://github.com/mekanix/meka.rs/tree/master/provision/roles"&gt;two roles&lt;/a&gt;&#10;but mention only one in site.yml, it means that role &lt;code&gt;common&lt;/code&gt; is a dependency&#10;of &lt;code&gt;meka&lt;/code&gt;. That dependency is noted in&#10;&lt;a href="https://github.com/mekanix/meka.rs/blob/master/provision/roles/meka/meta/main.yml"&gt;meta&lt;/a&gt;.&#10;There&amp;rsquo;s only one thing missing: list of servers that this playbook applies to.&#10;Vagrant will generate that list on the fly depending on the configuration inside&#10;Vagrantfile, like number of machines. Nice thing about Vagrant is that it will&#10;share directory of the repo as &lt;code&gt;/vagrant&lt;/code&gt; inside virtual machine. Basically this&#10;means that you can code on your laptop/desktop with your favorite editor and see&#10;those changes on the same distribution that is used in production, on the same&#10;docker that is used in production. Idea is to have almost identical environment&#10;in all stages, like development, testing, pre-production, production, &amp;hellip; It&#10;enables developers to make less bugs that are caused by differences in&#10;environments.&lt;/p&gt;&#10;&lt;p&gt;Ansible is such an important and easy to use tool, that I have no more words to&#10;describe it but &amp;ldquo;read all from the&#10;&lt;a href="https://github.com/mekanix/meka.rs/tree/master/provision"&gt;provision directory&lt;/a&gt;&amp;rdquo;.&#10;It&amp;rsquo;s simple and powerful.&lt;/p&gt;&#10;&lt;p&gt;&lt;a href="https://meka.rs/blog/2014/11/16/cloud-computing-basics-4/"&gt;previous&lt;/a&gt;&#10;&lt;a href="https://meka.rs/blog/2014/11/20/cloud-computing-basics-6/"&gt;next&lt;/a&gt;&lt;/p&gt;&#10;</description></item><item><title>Cloud Computing Basics 4</title><link>https://meka.rs/blog/2014/11/16/cloud-computing-basics-4/</link><pubDate>Sun, 16 Nov 2014 22:00:00 +0000</pubDate><guid>https://meka.rs/blog/2014/11/16/cloud-computing-basics-4/</guid><description>&lt;p&gt;So, you&amp;rsquo;ve seen how &lt;a href="https://consul.io/"&gt;Consul&lt;/a&gt; and&#10;&lt;a href="https://github.com/progrium/registrator"&gt;Registrator&lt;/a&gt; can be combined in&#10;&lt;a href="https://meka.rs/blog/2014/11/15/cloud-computing-basics-3/"&gt;previous post&lt;/a&gt;. How about we get&#10;down and dirty, finally? One way to start a docker container is to run it with&#10;&lt;a href="http://www.freedesktop.org/wiki/Software/systemd/"&gt;systemd&lt;/a&gt;. It&amp;rsquo;s my favorite&#10;way, so let&amp;rsquo;s take a look how does Consul service looks like:&lt;/p&gt;&#10;&lt;pre&gt;&lt;code&gt;[Unit]&#10;Description=Consul&#10;After=docker.service network.target&#10;Requires=docker.service&#10;Wants=network.target&#10;&#10;[Service]&#10;TimeoutStartSec=0&#10;ExecStartPre=/usr/bin/docker pull progrium/consul&#10;ExecStart=/usr/bin/docker run -h site -p 8500:8500 -p 53:53/udp --rm --name consul progrium/consul -server -bootstrap -advertise 192.168.33.33&#10;ExecStop=/usr/bin/docker stop consul&#10;&#10;[Install]&#10;WantedBy=multi-user.target&#10;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;p&gt;There are small, almost hidden but important pieces of this code. First, you&#10;see there are multiple ports published, and that is:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;8500: HTTP&lt;/li&gt;&#10;&lt;li&gt;53: DNS&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;There are at least 4 more ports exposed on consul Docker image, but this is&#10;more than enough. In previous posts you could read that Consul&amp;rsquo;s HTTP interface&#10;has REST API and UI. If you visit &lt;a href="http://192.168.33.33:8500"&gt;Vagrant IP&lt;/a&gt;,&#10;you&amp;rsquo;ll see all the services that are registered. That&amp;rsquo;s the port that&#10;Registrator uses to do it&amp;rsquo;s magic. But more interesting port is 53. First,&#10;notice it&amp;rsquo;s UDP, not TCP. Second, that port is DNS. In other words, if you run&#10;container which publishes port 80, Registrator will pick it up and register it&#10;in Consul. That means that you can ask Consul&amp;rsquo;s DNS where is your new created&#10;container like this&lt;/p&gt;&#10;&lt;pre&gt;&lt;code&gt;dig @172.17.42.1 web.service.consul&#10;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;p&gt;IP of 172.17.42.1 is interesting because it&amp;rsquo;s IP of docker0 interface which is&#10;available on every host. As Consul is distributed among all hosts, and that IP&#10;is available on every host, you can tell all containers to use 172.17.42.1 as&#10;DNS:&lt;/p&gt;&#10;&lt;pre&gt;&lt;code&gt;[Unit]&#10;Description=PostgreSQL&#10;After=registrator.service network.target&#10;Requires=registrator.service&#10;Wants=network.target&#10;&#10;[Service]&#10;TimeoutStartSec=0&#10;ExecStartPre=-/bin/mkdir -p /var/lib/docker/volumes/postgresql&#10;ExecStartPre=/usr/bin/docker pull paintedfox/postgresql:latest&#10;ExecStart=/usr/bin/docker run --dns 172.17.42.1 -P -e SERVICE_TAGS=master -e DB=onelove -e PASS=password -v /var/lib/docker/volumes/postgresql:/data --rm --name postgresql paintedfox/postgresql&#10;ExecStop=/usr/bin/docker stop postgresql&#10;&#10;[Install]&#10;WantedBy=multi-user.target&#10;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;p&gt;Notice &lt;code&gt;--dns&lt;/code&gt; option. Now, this is the flow of DNS data/queries. Every&#10;container will ask Consul for .consul domains. If FQDN container is asking for&#10;is not subdomain of .consul, Consul will ask external DNS, which is usually&#10;&lt;code&gt;8.8.8.8&lt;/code&gt;. In the previous example, I&amp;rsquo;ve set a service tag to master. Because it&#10;is a service for PostgreSQL, which might be part of DB cluster, you must have a&#10;master server. Although there&amp;rsquo;s only one DB server here, I still like to set&#10;master just in case I decide to scale later. On DNS side it means you&amp;rsquo;ll get&#10;&lt;code&gt;master.postgresql.service.consul&lt;/code&gt; records. As a matter of fact, you&amp;rsquo;ll get two&#10;records: A and SRV. First one will only return IP address, while second has&#10;richer structure which includes IP and port. So, if your application depends on&#10;DNS only, you can still dockerize it. Nice thing is that queries are super fast&#10;and are not cached.&lt;/p&gt;&#10;&lt;p&gt;For the last, one trick I use lately. My DB host is always &lt;code&gt;master.postgresql.service.consul&lt;/code&gt; and I don&amp;rsquo;t even generate it on change with Consul-template. Fact is&#10;that when DNS records change, as DNS is not cached, application server will hit&#10;new DB server the second it&amp;rsquo;s in DNS. For some other neat tricks, check out&#10;&lt;a href="http://www.consul.io/docs/index.html"&gt;Consul documentation&lt;/a&gt;.&lt;/p&gt;&#10;&lt;p&gt;&lt;a href="https://meka.rs/blog/2014/11/15/cloud-computing-basics-3/"&gt;previous&lt;/a&gt;&#10;&lt;a href="https://meka.rs/blog/2014/11/17/cloud-computing-basics-5/"&gt;next&lt;/a&gt;&lt;/p&gt;&#10;</description></item><item><title>Cloud Computing Basics 3</title><link>https://meka.rs/blog/2014/11/15/cloud-computing-basics-3/</link><pubDate>Sat, 15 Nov 2014 22:00:00 +0000</pubDate><guid>https://meka.rs/blog/2014/11/15/cloud-computing-basics-3/</guid><description>&lt;p&gt;So I&amp;rsquo;ve scratched the surface of a service discovery in a&#10;&lt;a href="https://meka.rs/blog/2014/11/14/cloud-computing-basics-2/"&gt;previous post&lt;/a&gt;. Let&amp;rsquo;s dream on. Up&#10;to now, I&amp;rsquo;ve only written about running a single container on a single host.&#10;But I&amp;rsquo;m poor, I want multiple things on the same hardware. Let&amp;rsquo;s go back a&#10;little. Docker containers are like tiny virtual machines. They have IP address,&#10;disk space, running processes, &amp;hellip; Strictly speaking, docker isn&amp;rsquo;t a virtual&#10;machine, but it almost is. There&amp;rsquo;s one quirk about containers: they can open&#10;PostgreSQL port on a random port. Here&amp;rsquo;s the reasoning. If you want to host&#10;multiple PostgreSQL instances, they can&amp;rsquo;t all be on the same port. &amp;ldquo;Not a&#10;problem&amp;rdquo;, one would say, &amp;ldquo;I&amp;rsquo;ll configure different PostgreSQL instances on&#10;different ports&amp;rdquo;. There&amp;rsquo;s only one problem: you&amp;rsquo;re running all PostgreSQL&#10;containers from the same image. Yes, you can put configuration at runtime, but&#10;remember, we have 10,000 hosts. You just can&amp;rsquo;t do it efficiently. OK, this is&#10;how Docker does it. PostgreSQL is, by default, listening on port 5432. If you&#10;just do &lt;code&gt;docker run postgres&lt;/code&gt;, you won&amp;rsquo;t even open a port. That&amp;rsquo;s Docker&amp;rsquo;s&#10;weirdness about ports. Docker images are built with predefined ports to be&#10;opened in a container. But that same port doesn&amp;rsquo;t get mapped unless you&#10;explicitly say so with -p or -P. Here&amp;rsquo;s an example&lt;/p&gt;&#10;&lt;pre&gt;&lt;code&gt;docker run -p 5432:5432 --rm postgres&#10;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;p&gt;What it does is tell Docker to bind container&amp;rsquo;s port 5432 to all interfaces on&#10;the host on the port 5432. In one word, you have your 5432 port open on the&#10;host. You can do something like &lt;code&gt;-p 127.0.0.1:5432:5432&lt;/code&gt; to listen on localhost&#10;only. You can, also, do things like &lt;code&gt;-p 127.0.0.1::5432&lt;/code&gt; and Docker will bind&#10;container&amp;rsquo;s 5432 port to a random port on localhost. But how do you know where&#10;to find it? You can use &lt;code&gt;docker port &amp;lt;container&amp;gt; 5432&lt;/code&gt; and it will tell you. I&#10;agree it&amp;rsquo;s not the most elegant way of figuring out a port, but it works. You&amp;rsquo;re&#10;able to put multiple docker images with the same open port, and they will be&#10;happy to run together. Also, you will probably want to use private network IP&#10;instead of 127.0.0.1 and have all your hosts on that network.&lt;/p&gt;&#10;&lt;p&gt;If your containers are secure enough, and they never are, you can expose all&#10;ports on all interfaces. This means that every port is accessible on any network&#10;interface of the host. To do that&lt;/p&gt;&#10;&lt;pre&gt;&lt;code&gt;docker run -P --rm postgres&#10;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;p&gt;The &lt;code&gt;docker port&lt;/code&gt; command will still work and everything else remains the same.&lt;/p&gt;&#10;&lt;p&gt;By now you probably wonder how Docker knows which ports are open on the&#10;container. No, it doesn&amp;rsquo;t seek all open ports. You must specify which ports will&#10;be opened (or exposed, in Docker terminology). That&amp;rsquo;s part of the build process&#10;which I will cover in some later post. For now, just remember that one line of&#10;Dockerfile for PostgreSQL is&lt;/p&gt;&#10;&lt;pre&gt;&lt;code&gt;EXPOSE 5432&#10;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;p&gt;Two old problems remain:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;how to run it in 10,000 servers environment&lt;/li&gt;&#10;&lt;li&gt;how to tell application container the DB info&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;No wonder, it has something to do with Consul. One really neat container is&#10;&lt;a href="https://github.com/progrium/registrator"&gt;Registrator&lt;/a&gt;. It listens for Docker&#10;events and every time new container runs, it registers container&amp;rsquo;s exposed ports&#10;to Consul. After that, let Consul-template do the rest.&lt;/p&gt;&#10;&lt;p&gt;I&amp;rsquo;m starting to go in &amp;ldquo;WTF&amp;rdquo; direction, again. I have a proof this is not an&#10;empty story. If you clone&#10;&lt;a href="https://github.com/one-love/vagrant-one-love"&gt;One Love&lt;/a&gt; and follow the&#10;instructions on that page, you&amp;rsquo;ll get my project (in early alpha at the time of&#10;writing this post) which utilizes all I was talking about. It takes a fair&#10;amount of time for it to download everything, but once it does, you have my&#10;application in virtual machine, but that&amp;rsquo;s not the reason I told you to do this.&#10;The reason is that you have Consul&amp;rsquo;s WEB interface available at&#10;&lt;a href="http://192.168.33.33:8500"&gt;Vagrant VM&lt;/a&gt;. Now go and play with it :o)&lt;/p&gt;&#10;&lt;p&gt;&lt;a href="https://meka.rs/blog/2014/11/14/cloud-computing-basics-2/"&gt;previous&lt;/a&gt;&#10;&lt;a href="https://meka.rs/blog/2014/11/16/cloud-computing-basics-4/"&gt;next&lt;/a&gt;&lt;/p&gt;&#10;</description></item><item><title>Cloud Computing Basics 1</title><link>https://meka.rs/blog/2014/11/13/cloud-computing-basics-1/</link><pubDate>Thu, 13 Nov 2014 22:00:00 +0000</pubDate><guid>https://meka.rs/blog/2014/11/13/cloud-computing-basics-1/</guid><description>&lt;p&gt;The first critic I&amp;rsquo;ve got for a blog was &amp;ldquo;Yeah, it&amp;rsquo;s all nice and shinny, but&#10;WTF? Where are examples, documentation, &amp;hellip; ? How do I do it?&amp;rdquo; Let&amp;rsquo;s go back a&#10;little. Cloud is extremely complicated network of hardware and virtual machines&#10;where one second your server is in New York, next second is in Amsterdam, if&#10;you happen to believe the media and PR &amp;ldquo;experts&amp;rdquo;. In reality, yes, sometimes&#10;it might happen that your machine gets migrated to another data center, but&#10;why would anyone do it if there&amp;rsquo;s no need? What cloud provides is easy migration&#10;of machines, it doesn&amp;rsquo;t enforce them! In other words, just because you can&#10;scratch your nose, doesn&amp;rsquo;t mean you have to scratch it all the time, but when&#10;you do, it&amp;rsquo;s better if you&amp;rsquo;re able to do it in seconds. That&amp;rsquo;s all there is&#10;about the cloud. The logic is simple. If you can have a number of machines that&#10;are basically junk, you can create highly redundant WEB site if all machines are&#10;on the fast network. You don&amp;rsquo;t mirror all the data between them, but download&#10;virtual machines or docker images fast when you need it and hope nobody noticed.&lt;/p&gt;&#10;&lt;p&gt;That&amp;rsquo;s where &lt;a href="https://docker.com/"&gt;Docker&lt;/a&gt; comes in. Docker images are made to&#10;be as small as possible. For example,&#10;&lt;a href="https://registry.hub.docker.com/u/progrium/consul/"&gt;Consul&lt;/a&gt; image is ~50MB,&#10;&lt;a href="https://registry.hub.docker.com/u/progrium/registrator/"&gt;Registrator&lt;/a&gt; image is&#10;~20MB. Of course, not all images can be that small, and I did mention two of the&#10;smallest images I know of, but maybe your application can sit on top of it&#10;(base image is called&#10;&lt;a href="https://registry.hub.docker.com/u/progrium/busybox/"&gt;busybox&lt;/a&gt;). Or you might&#10;need big image only to build your application, but not to run it? Docker&#10;optimization and security are separate and hot topics these days, and I&amp;rsquo;m&#10;trying to give you the basics here :o)&lt;/p&gt;&#10;&lt;p&gt;What marketing around cloud technologies will tell you is that &amp;ldquo;On hardware&#10;level we have multiple machines working as a unit to run your code on, so if&#10;one fails, some other takes over&amp;rdquo;. Right. Let&amp;rsquo;s say you have two machines with&#10;docker. One is your main site, and the other one is just a spare. Main one dies.&#10;And what then? How does the spare becomes the main? Let&amp;rsquo;s say it&amp;rsquo;s a simple&#10;modification of DNS record. OK, we got our new IP registered. But we had docker&#10;container running on the old main computer only. Docker Hub is a service which&#10;offers hosting docker images, so your spare machine can, in case of this blog,&#10;run this:&lt;/p&gt;&#10;&lt;pre&gt;&lt;code&gt;docker pull mekanix/blog&#10;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;p&gt;Docker will do the magic of downloading and updating the image, if you had an&#10;old one, for you. As a matter of fact, why don&amp;rsquo;t you try it? Clone the&#10;&lt;a href="https://github.com/mekanix/meka.rs"&gt;repository of this blog&lt;/a&gt;, install&#10;&lt;a href="https://www.vagrantup.com/"&gt;Vagrant&lt;/a&gt; and&#10;&lt;a href="https://www.virtualbox.org/"&gt;VirtualBox&lt;/a&gt;, and run:&lt;/p&gt;&#10;&lt;pre&gt;&lt;code&gt;git checkout no-ansible&#10;vagrant up&#10;vagrant ssh&#10;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;p&gt;First line is there just to make sure you don&amp;rsquo;t need Ansible, yet. I&amp;rsquo;ll cover&#10;Ansible, provisioning and deployment in some of the later posts. To setup a&#10;docker:&lt;/p&gt;&#10;&lt;pre&gt;&lt;code&gt;sudo yum install docker&#10;sudo gpasswd -a vagrant docker&#10;sudo systemctl enable docker&#10;sudo systemctl start docker&#10;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;p&gt;Your docker is now running, and you can control it. You control the cloud! To&#10;pick up the changes on vagrant account you have to logout and run the container:&lt;/p&gt;&#10;&lt;pre&gt;&lt;code&gt;vagrant ssh&#10;docker pull mekanix/blog&#10;docker run -p 80:80 --rm mekanix/blog&#10;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;p&gt;And that&amp;rsquo;s it. Go to &lt;a href="http://192.168.33.33/"&gt;Vagrant IP&lt;/a&gt; and you should see this&#10;blog. If you want to update the image, stop the container (CTRL+C) and&lt;/p&gt;&#10;&lt;p&gt;docker pull&#10;docker run&lt;/p&gt;&#10;&lt;p&gt;Happy docking :o)&lt;/p&gt;&#10;&lt;p&gt;&lt;a href="https://meka.rs/blog/2014/11/14/cloud-computing-basics-2/"&gt;next&lt;/a&gt;&lt;/p&gt;&#10;</description></item><item><title>Cloud Computing Basics 2</title><link>https://meka.rs/blog/2014/11/12/cloud-computing-basics-2/</link><pubDate>Wed, 12 Nov 2014 22:00:00 +0000</pubDate><guid>https://meka.rs/blog/2014/11/12/cloud-computing-basics-2/</guid><description>&lt;p&gt;So I&amp;rsquo;ve scratched the surface of a cloud in a&#10;&lt;a href="https://meka.rs/blog/2014/11/13/cloud-computing-basics-1/"&gt;previous post&lt;/a&gt;. Let&amp;rsquo;s dream on. Let&amp;rsquo;s&#10;say you&amp;rsquo;re hosting a &lt;a href="https://www.djangoproject.com/"&gt;Django&lt;/a&gt; site. For start,&#10;let&amp;rsquo;s assume that everything is inside one big container: Django, PostgreSQL,&#10;NginX, &amp;hellip;&lt;/p&gt;&#10;&lt;p&gt;After few months, your site grows and one machine is not enough. How do you&#10;add another, when your docker image has all included, and you should share the&#10;DB? So, you decide to have PostgreSQL in a separate docker, or someone is&#10;hosting it for you. The only thing you need from Django perspective are DB&#10;credentials. You end up with working Django cluster, but how do you register it&#10;in DNS? DNS is slow. If you kill one machine and start another, with different&#10;IP, DNS can take days to propagate.&lt;/p&gt;&#10;&lt;p&gt;So you decide to put a load balancer in&#10;front of those Django machines, because load balancer reconfiguration and&#10;restart can take 5 minutes or less if you know what to do. Much faster than DNS&#10;propagation. But now, you have a problem. If that load balancer fails, you don&amp;rsquo;t&#10;have a site. So you start yet another load balancer and have it proxy the&#10;requests for two Django machines, so if one load balancer fails, there&amp;rsquo;s another.&lt;/p&gt;&#10;&lt;p&gt;Over the following months your company and app grow, and you find your self in a&#10;position where you need 5 application servers, 3 DB servers and 2 load balancers.&#10;Imagine you have to change the password. You would do it on all 5 servers by&#10;hand, restating each when done. Or you&amp;rsquo;ve already discovered Ansible (or Puppet,&#10;or Chef, or SaltStack, or &amp;hellip;) and do it automatically. But imagine you have&#10;10,000 servers. It would take an hour, I suppose, to update all the machines.&#10;That means, when you change DB password, it will take you an hour to get to the&#10;last machine. That hour the last machine uses old DB password, which renders it&#10;non useful. It would be nice if machines could agree on a set of parameters that&#10;are needed and distributed. In our case, it would be nice if every machine could&#10;remember DB user/pass combination, so wherever you start you Django docker, it&#10;knows how to connect to DB. That&amp;rsquo;s exactly what &lt;a href="https://consul.io/"&gt;Consul&lt;/a&gt;&#10;does.&lt;/p&gt;&#10;&lt;p&gt;Consul is an application with integrated WEB UI, REST API, DNS, RPC and&#10;tons of other things, but interesting for us is it&amp;rsquo;s ability to cluster and&#10;remember settings. I start it as a docker container on every host of the fleet.&#10;If you have 6 machines with clustered Consul, changing variable on one host makes&#10;it mirror to all other machines. That&amp;rsquo;s great, but it doesn&amp;rsquo;t tackle with docker&#10;containers, so Consul alone is not enough for your 10,000 machines data center.&#10;&lt;a href="https://github.com/hashicorp/consul-template"&gt;Consul-template&lt;/a&gt; is small utility&#10;which sits in your Django container and connects to Consul. When Consul variable&#10;changes, consul-template will generate the configuration from a template you&#10;provide and Consul data, and restart your Django. To be technically correct, it&#10;will execute command you configured it with, but you want that command to do the&#10;restart of you application once the configuration is generated. Now DB user/pass&#10;changes can be effective in seconds instead of hours.&lt;/p&gt;&#10;&lt;p&gt;Why stop there? You can have your DB docker react on changing the DB user/pass&#10;combination in Consul. In other words, if you add DB user to Consul, DB&#10;container will create it (if you &amp;ldquo;restart&amp;rdquo; consul-template script is smart&#10;enough). You can go wild with Consul variables and cloud setup. It&amp;rsquo;s up to you&#10;and your team to find what should be shared through Consul, and what should be&#10;part of on-disk configuration.&lt;/p&gt;&#10;&lt;p&gt;&lt;a href="https://meka.rs/blog/2014/11/13/cloud-computing-basics-1/"&gt;previous&lt;/a&gt;&#10;&lt;a href="https://meka.rs/blog/2014/11/15/cloud-computing-basics-3/"&gt;next&lt;/a&gt;&lt;/p&gt;&#10;</description></item><item><title>Service Discovery</title><link>https://meka.rs/blog/2014/11/09/service-discovery/</link><pubDate>Sun, 09 Nov 2014 22:00:00 +0000</pubDate><guid>https://meka.rs/blog/2014/11/09/service-discovery/</guid><description>&lt;p&gt;Yes, docker is my new favorite toy, and it is big word on the Internet. So I&#10;have my hands in the gutter trying to figure out the optimal way to configure&#10;my cloud. What&amp;rsquo;s the big deal? For start, etcd is not my best friend, any more.&#10;I like Consul implementation and features much more. Hence, CoreOS is not the&#10;perfect distribution. I&amp;rsquo;m using Debian Jessie which is in beta2 stage in the&#10;time of writing this post. The reson for this switch is Registrator. Consul,&#10;Registrator and Consul-Template are 3 projects that make service discovery a&#10;piece of cake.&lt;/p&gt;&#10;&lt;p&gt;Consul is something like a distributed database. It stores key/value pairs. It&#10;sounds like &amp;ldquo;not much&amp;rdquo; but it&amp;rsquo;s built on top of Serf, so it&amp;rsquo;s built to be&#10;distributed. Consul, also, has built in DNS server, so key/value pairs can be&#10;A or SRV records. In one word &amp;ldquo;where is my postgresql docker container&amp;rdquo;.&lt;/p&gt;&#10;&lt;p&gt;Registrator is just crazy. You give it Docker&amp;rsquo;s socket file to listen for&#10;events, and every time new docker container is up, it automaticly registares&#10;them in Consul, and deregisters them when container is down. This means that&#10;every time new application container is up, you can query it via Consul&amp;rsquo;s DNS&#10;protocol. If you start your containers with -P, for example, Registrator will&#10;register the ports your container is bind to.&lt;/p&gt;&#10;&lt;p&gt;Consul-Template is golang program that listens for changes in Consul, generates&#10;configuration of a service (say, nginx), and runs a command (say, service nginx&#10;restart). Why is this cool? Just imagine you have your load balancer,&#10;application server and database server running. You have a peak, and you start&#10;one more application server, which needs to be added to load balancer, and&#10;configured with database connection. With consul-template, it&amp;rsquo;s as easy as&#10;starting new application container. Because Registrator will pick up on which&#10;IP and port it is awailable, consul-template on load balancer is able to&#10;regenerate configuration and restart nginx. If hosting provider has&#10;autoscaling support (I know AWS has it), you have your cloud dynamicly scaling.&#10;How cool is that?&lt;/p&gt;&#10;</description></item><item><title>Cloud Computing - intro</title><link>https://meka.rs/blog/2014/11/02/cloud-computing-intro/</link><pubDate>Sun, 02 Nov 2014 22:00:00 +0000</pubDate><guid>https://meka.rs/blog/2014/11/02/cloud-computing-intro/</guid><description>&lt;p&gt;As &lt;a href="http://www.youtube.com/watch?v=ecZL4Q2EVuY"&gt;nobody understands the cloud&lt;/a&gt;,&#10;it became obvious to me I will hack something out of it. And I did. A job. My&#10;latest toy is &lt;a href="https://coreos.com/"&gt;CoreOS&lt;/a&gt;. It features two nice things a man&#10;doesn&amp;rsquo;t need until he faces big amount of servers. First being collective&#10;consciousness, aka etcd, allowing storing information about the services,&#10;like which upstream servers for your load balancers are on which IP addresses.&#10;Second is fleetd, which uses etcd to store and read data. It starts docker&#10;containers on your CoreOS instances. Actually, it starts systemd services,&#10;which is even better! :o) Oh, did I mention cloud computing these days is all&#10;about running containers? &lt;a href="https://www.docker.com/"&gt;Docker&lt;/a&gt; containers in my&#10;case. Lastly, in dynamic environment of the cloud, you need dynamic&#10;configuration. But what application in the world has dynamic configuration?&#10;None that I know. Despite that fact, cloud computing and docker containers&#10;are thriving. There&amp;rsquo;s a secret ingredient:&#10;&lt;a href="https://github.com/kelseyhightower/confd"&gt;confd&lt;/a&gt;. What it does is poll etcd&#10;every 10 seconds or so, checking if there are changes on some of the keys in it&#10;and if there is, generates the configuration of your application and restarts&#10;it. Confd uses templates and etcd data to generate the configuration, so once&#10;you have your fleet running, changing master DB host is as easy as&lt;/p&gt;&#10;&lt;pre&gt;&lt;code&gt;etcdctl set /my/app/db/server 192.168.0.4&#10;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;p&gt;and all containers having confd will pick up the changes. Just imagine, one&#10;command and thousand services change their configuration accordingly. This is&#10;small step for cloud, but huge step for a man, because it&amp;rsquo;s hard to start&#10;thinking about &amp;ldquo;configuration is in the cloud&amp;rdquo;. Once you grasp that idea,&#10;you&amp;rsquo;re on a great way to cloud computing.&lt;/p&gt;&#10;</description></item></channel></rss>