site-josuah

/usr/josuah
Log | Files | Refs

commit 8c570c64466353e3f6fd327622885b4996005e91
parent d08e890334e00dc1b580a20f58f8753dd2a90097
Author: Josuah Demangeon <me@josuah.net>
Date:   Sun,  4 Oct 2020 18:19:26 +0200

nicer syntax

Diffstat:
Mwiki/awk/index.md | 5+----
Mwiki/git-hooks/index.md | 12+++++-------
Mwiki/jj/index.md | 90+++++++++++++++++++++++++++++++++++++++++++++----------------------------------
Mwiki/jj/jj-tail | 12------------
Mwiki/qmail/destination-mx/index.md | 10+++++-----
Mwiki/tinydns/index.md | 4+---
6 files changed, 63 insertions(+), 70 deletions(-)

diff --git a/wiki/awk/index.md b/wiki/awk/index.md @@ -27,7 +27,6 @@ Instead of trying to remember the number of the column, using the name of the column is much easier, and permit to have new columns inserted in the .csv file without breaking the script. -``` $ cat input.txt domain_name,expiry_date,creation_date,owner,account_id nowhere.com,2020-03,2019-05,me,23535 @@ -165,9 +164,7 @@ awk 1 ``` -I learned this with the [jj] project. - -[jj]: https://github.com/aaronNGi/jj/ +I learned this with the [jj](https://github.com/aaronNGi/jj/) project. A sort() function ----------------- diff --git a/wiki/git-hooks/index.md b/wiki/git-hooks/index.md @@ -1,13 +1,11 @@ Git Hooks ========= -Git [[hooks]] permit to run commands on a range of git events, mainly: a git +Git [hooks](https://githooks.com/) permit to run commands on a range of git events, mainly: a git commit. I use 3 shell scripts of roughly 10 lines each to configure git hooks, calling scripts from within the repository itself: `.githooks/<hookname>` -[hooks]: https://githooks.com/ - git-hooks-run ------------- This is what runs on every event, to put on `/bare-repo.git/hook/<hookname>`. @@ -24,7 +22,7 @@ git cat-file blob "$ref:.git$hookname" | { } ``` -It checks if there is a file called `.githooks/<hookname>` (git ls-tree "$ref" +It checks if there is a file called `.githooks/<hookname>` (git ls-tree "$ref" ...), and if so, extract this file from git (git cat-file blob ...), read the shebang, and execute the rest with the command of the shebang ("| { ... }"). @@ -46,8 +44,8 @@ It replace selected hooks at repo.git/hooks/post-update with only this shebang: #!/usr/bin/env git-hooks-run ``` -This has the effect of calling the git-hooks-run from above with -hook/post-update as argument, along with the extra arguments providedd by git, +This has the effect of calling the git-hooks-run from above with +hook/post-update as argument, along with the extra arguments providedd by git, which is all we need for our hook. git-hooks-workdir @@ -72,7 +70,7 @@ exec echo "$workdir" ``` To use it from within the hook, to catch the workdir and make sure there is -no remaining file even in case of failure, thanks to the trap internal shell +no remaining file even in case of failure, thanks to the trap internal shell command: ``` diff --git a/wiki/jj/index.md b/wiki/jj/index.md @@ -1,6 +1,5 @@ The jj IRC client ================== - [jj](https://github.com/aaronNGi/jj/) is an [Internet Relay Chat (IRC)](https://invidio.us/watch?v=R8FOGlnYkgg) client based on the principles of [ii](https://tools.suckless.org/ii/), using FIFO (named pipe) files to read @@ -34,7 +33,6 @@ the right client. Another aspect of applicative routing is client-side. Much like ii or sic, and all the modular bots in the wild, the jj acts as a is a client-side IRC router through hooks and log files. - How jj works ------------ As opposed to ii, which is plain C, jj uses an awk script to do the heavy @@ -69,7 +67,6 @@ This permits to run it through [s6-networking][s6], [ucspi][u1], [ucspi-ssl][u2] [u2]: https://www.fehcom.de/ipnet/ucspi-ssl.html [cp]: https://curvecp.org/ - State of IRC client \<=\> server connexions ------------------------------------------- Because it is run by different people and projects, the connexion to IRC @@ -93,7 +90,6 @@ client with a good TLS implementation (lots of lines of code), and a socks proxy (more lines of code), with a configuration interface (many many lines of code). - How UCSPI helps --------------- I use jj under the [[s6]] and [[s6-rc]] supervision tree on a VPS (until I get @@ -122,7 +118,6 @@ and popularized through its set of programs. [chainloading]: https://en.wikipedia.org/wiki/Chain_loading [djb]: https://cr.yp.to/djb.html - How I use jj and s6/s6-rc and UCSPI together -------------------------------------------- The s6 and s6-rc package come with an execline shell-like language that makes @@ -134,26 +129,36 @@ startup scripts: Boilerplate I have everywhere (sorry sk., #!/usr/bin/env...): - #!/usr/bin/env execlineb - fdmove -c 2 1 +``` +#!/usr/bin/env execlineb +fdmove -c 2 1 +``` This command reads the content of each file in ./env/ and export environment variables to their content: env/IRC_HOST, env/IRC_USER, env/IRC_PASSWORD, ... - s6-envdir "env" +``` +s6-envdir "env" +``` I use the "irc" user and the /var/irc/ direcTory: - s6-setuidgid irc +``` +s6-setuidgid irc +``` This starts a TCP connexion to the local Tor daemon running: - s6-tcpclient 127.0.0.1 9050 +``` +s6-tcpclient 127.0.0.1 9050 +``` This starts a SOCK5 proxy session for communicating with the [hackint](https://hackint.org/) - sockc "5ogdsfyoqk47ompu.onion" "6667" +``` +sockc "5ogdsfyoqk47ompu.onion" "6667" +``` At that point, the program called by sockc will be able to communicate directly with IRC commands, as the TCP connexion is ready, the socks @@ -162,7 +167,9 @@ session is set, and the raw IRC protocol follows. It is now possible to call jjd directly, which will recognize the UCSPI environment through the $PROTO environment variable. - jjd +``` +jjd +``` In case there is another context, situation, other UCSPI commands can be inserted or moved, including the setup of client certifiates, that often goes @@ -170,14 +177,15 @@ through environment variables. This is the same script while run as #!/bin/sh. Yes, this is a single command! - #!/bin/sh - fdmove -c 2 1 \ - s6-envdir "env" \ - s6-setuidgid irc \ - s6-tcpclient 127.0.0.1 9050 \ - sockc "5ogdsfyoqk47ompu.onion" "6667" \ - jjd - +``` +#!/bin/sh +fdmove -c 2 1 \ + s6-envdir "env" \ + s6-setuidgid irc \ + s6-tcpclient 127.0.0.1 9050 \ + sockc "5ogdsfyoqk47ompu.onion" "6667" \ + jjd +``` Making jj useable interactively ------------------------------- @@ -217,30 +225,34 @@ Instead of going with one window per chatroom and switching between chatrooms, jj-tail gives a combined feed with the output of all channels in a same stream showing a headers for each channel. - == irc.freenode.net/##networking == - 00:12 ikityik: it's like having a bad fever dream with this ISP - == irc.freenode.net/#cat-v == - 00:12 cicl: when usb is enabled sounds like a vm? - 00:12 cicl: whats the context? - == irc.freenode.net/#openbsd == - 00:12 thrig: Logan Runners? - 00:12 knot: with blackjack and hookers +``` +== irc.freenode.net/##networking == +00:12 ikityik: it's like having a bad fever dream with this ISP +== irc.freenode.net/#cat-v == +00:12 cicl: when usb is enabled sounds like a vm? +00:12 cicl: whats the context? +== irc.freenode.net/#openbsd == +00:12 thrig: Logan Runners? +00:12 knot: with blackjack and hookers +``` To avoid being bothered with too many channels at once, it takes a list of find(1) -path $filters as argument that will match the name of the server/channels: - $ jj-tail - <log of all channels of all servers ...> - ^C - $ jj-tail freenode - <log of all channels of freenode/* ...> - ^C - $ jj-tail qmail smtp - <log of freenode/#qmail freenode/#opensmtpd ...> - ^C - $ jj-tail server - <server logs of all channels follows (wich hilights) ...> +``` +$ jj-tail +<log of all channels of all servers ...> +^C +$ jj-tail freenode +<log of all channels of freenode/* ...> +^C +$ jj-tail qmail smtp +<log of freenode/#qmail freenode/#opensmtpd ...> +^C +$ jj-tail server +<server logs of all channels follows (wich hilights) ...> +``` This way, you can reduce the scope of the conversation to one server, similar channels on multiple servers, just the selected channels... diff --git a/wiki/jj/jj-tail b/wiki/jj/jj-tail @@ -1,18 +1,6 @@ #!/bin/sh -e # tail all jj channels in /var/irc -case "$1" in (-[0-9]*) - export MIN="$(awk -v now="$(date +%s)" -v time="${1#-}" 'BEGIN { - while (match(time, /^[0-9]+[dhms]/)) { - t[substr(time, RLENGTH, 1)] = substr(time, 1, RLENGTH - 1) - time = substr(time, RLENGTH + 1) - } - print(now - t["d"]*86400 - t["h"]*3600 - t["m"]*60 - t["s"]) - }')" - shift - ;; -esac - # build a list of (-path "") to give to find(1) [ "$#" = 0 ] && set -- "" for x in "$@"; do diff --git a/wiki/qmail/destination-mx/index.md b/wiki/qmail/destination-mx/index.md @@ -140,11 +140,11 @@ qmail-remote! Why a high value for prefme in some cases? ------------------------------------------ ``` - qmail-remote.c - ... - 401 if (relayhost) prefme = 300000; - 402 if (flagallaliases) prefme = 500000; - ... +qmail-remote.c +... +401 if (relayhost) prefme = 300000; +402 if (flagallaliases) prefme = 500000; +... ``` When the mail server needs to relay everything to somewhere, or for these diff --git a/wiki/tinydns/index.md b/wiki/tinydns/index.md @@ -81,9 +81,7 @@ kuntur josuah.z0.is Uploading data.cdb to nameservers --------------------------------- "make push" update all necessary parts to build data.cdb as seen above, then -calls [[push.awk]]. - -[push.awk]: /wiki/tinydns/push.awk +calls [push.awk](/wiki/tinydns/push.awk). push.awk copies data.cdb to each nameserver in rr.ns, using the IP found in rr.host (so even if your DNS is down, you can still update it from remote).