Merge remote-tracking branch 'orange/master'

This commit is contained in:
tv 2023-05-16 19:32:49 +02:00
commit 56cff01ac4
9 changed files with 164 additions and 22 deletions

View File

@ -809,7 +809,14 @@ in {
blob64 = { blob64 = {
owner = config.krebs.users.mic92; owner = config.krebs.users.mic92;
nets = rec { nets = rec {
internet = {
# of2.dse.cit.tum.de.
ip4.addr = "131.159.38.25";
ip6.addr = "2a09:80c0:38::25";
aliases = [ "blob64.i" ];
};
retiolum = { retiolum = {
via = internet;
aliases = [ "blob64.r" ]; aliases = [ "blob64.r" ];
tinc.pubkey = '' tinc.pubkey = ''
-----BEGIN RSA PUBLIC KEY----- -----BEGIN RSA PUBLIC KEY-----

View File

@ -81,7 +81,8 @@ let
echo "$_from: $(report_error "$response")" echo "$_from: $(report_error "$response")"
exit 0 exit 0
fi fi
printf '%s' "$text" | echo "$_from: $(cat)" # value seems to be 512 - overhead
echo "$_from: $text" | fold -s -w 426
printf '%s' "$response" | printf '%s' "$response" |
jq -r '[.item.messages[1].sourceAttributions[].seeMoreUrl] | to_entries[] | "[\(.key + 1)]: \(.value)"' jq -r '[.item.messages[1].sourceAttributions[].seeMoreUrl] | to_entries[] | "[\(.key + 1)]: \(.value)"'
@ -90,6 +91,52 @@ let
}; };
}; };
bing-img = {
pattern = "!bing-img (.*)$";
activate = "match";
arguments = [1];
timeoutSec = 1337;
command = {
filename = pkgs.writeDash "bing-img" ''
set -efu
report_error() {
printf '%s' "$*" |
curl -Ss http://p.r --data-binary @- |
tail -1 |
echo "error $(cat)"
exit 0
}
export PATH=${makeBinPath [
pkgs.dash
pkgs.coreutils
pkgs.curl
pkgs.findutils
pkgs.jq
]}
response=$(printf '%s' "$*" |
curl -SsG http://bing-gpt.r/api/images --data-urlencode 'prompt@-'
)
if [ "$?" -ne 0 ]; then
report_error "$response"
else
if ! text=$(
printf '%s' "$response" |
jq -er '.[].url'
); then
echo "$_from: $(report_error "$response")"
exit 0
fi
echo "$text" |
xargs -I {} dash -c 'curl -Ss {} |
curl -Ss https://p.krebsco.de --data-binary @- |
tail -1' |
tr '\n' ' ' |
echo "$_from: $(cat)"
fi
'';
};
};
confuse = { confuse = {
pattern = "!confuse (.*)$"; pattern = "!confuse (.*)$";
activate = "match"; activate = "match";
@ -362,6 +409,7 @@ let
bedger-add bedger-add
bedger-balance bedger-balance
bing bing
bing-img
hooks.sed hooks.sed
interrogate interrogate
say say

View File

@ -0,0 +1,27 @@
{ pkgs, stockholm, stdenv }:
with stockholm.lib;
stdenv.mkDerivation rec {
pname = "htgen-paste";
version = "1.0.0";
src = ./src;
buildPhase = ''
(
exec > htgen-paste
echo PATH=${makeBinPath [
pkgs.nix
pkgs.file
pkgs.coreutils
pkgs.findutils
]}
echo STATEDIR=${shell.escape "\${STATEDIR-$HOME}"}
cat $src/htgen-paste
)
'';
installPhase = ''
install -D htgen-paste $out/bin/htgen-paste
'';
}

View File

@ -0,0 +1,68 @@
find_item() {
if test ${#1} -ge 7; then
set -- "$(find "$STATEDIR/items" -mindepth 1 -maxdepth 1 \
-regex "$STATEDIR/items/$1[0-9A-Za-z]*$")"
if test -n "$1" && test $(echo "$1" | wc -l) = 1; then
echo "$1"
return 0
fi
fi
return 1
}
abs_path=${Request_URI%%\?*}
case "$Method $abs_path" in
"GET /"[0-9a-z]*)
if item=$(find_item ${abs_path#/}); then
content_type=$(cat "$item".content_type 2>/dev/null || file -ib "$item")
printf 'HTTP/1.1 200 OK\r\n'
printf 'Content-Type: %s\r\n' "$content_type"
printf 'Server: %s\r\n' "$Server"
printf 'Connection: close\r\n'
printf 'Content-Length: %d\r\n' $(wc -c < $item)
printf '\r\n'
cat $item
exit
fi
;;
"POST /")
content=$(mktemp -t htgen.$$.content.XXXXXXXX)
trap "rm $content >&2" EXIT
case ${req_expect-} in 100-continue)
printf 'HTTP/1.1 100 Continue\r\n\r\n'
esac
head -c $req_content_length > $content
sha256=$(sha256sum -b $content | cut -d\ -f1)
base32=$(nix-hash --to-base32 --type sha256 $sha256)
item=$STATEDIR/items/$base32
ref=http://$req_host/$base32
if ! test -e $item; then
mkdir -v -p $STATEDIR/items >&2
cp -v $content $item >&2
fi
if test -n ${reg_content_type-}; then
echo -n "$req_content_type" > "$item".content_type
fi
base32short=$(echo $base32 | cut -b-7)
if item=$(find_item $base32short); then
ref=$(echo "$ref"; echo "http://$req_host/$base32short")
fi
printf 'HTTP/1.1 200 OK\r\n'
printf 'Content-Type: text/plain; charset=UTF-8\r\n'
printf 'Server: %s\r\n' "$Server"
printf 'Connection: close\r\n'
printf 'Content-Length: %d\r\n' $(expr ${#ref} + 1)
printf '\r\n'
printf '%s\n' "$ref"
exit
;;
esac

View File

@ -1,6 +1,7 @@
{ curl, gnused, writeDashBin }: { curl, gnused, writeDashBin }:
writeDashBin "kpaste" '' writeDashBin "kpaste" ''
${curl}/bin/curl -sS http://p.r --data-binary @"''${1:--}" | ${curl}/bin/curl -sS http://p.r --data-binary @"''${1:--}" \
-H "Content-Type-Override: ''${KPASTE_CONTENT_TYPE-}" |
${gnused}/bin/sed '$ {p;s|http://p.r|https://p.krebsco.de|}' ${gnused}/bin/sed '$ {p;s|http://p.r|https://p.krebsco.de|}'
'' ''

View File

@ -1,9 +1,9 @@
{ {
"url": "https://github.com/NixOS/nixpkgs", "url": "https://github.com/NixOS/nixpkgs",
"rev": "645bc49f34fa8eff95479f0345ff57e55b53437e", "rev": "897876e4c484f1e8f92009fd11b7d988a121a4e7",
"date": "2023-04-19T18:04:47+02:00", "date": "2023-05-06T22:28:42+01:00",
"path": "/nix/store/jh86824939585dinrs1zlkh6cvz8l8l7-nixpkgs", "path": "/nix/store/55lpvam2wgdmrbzx0j5gf51dqrqn8wqv-nixpkgs",
"sha256": "0kfndc7xdkm89yl0f27wdnwd6gdad3i49jx7gvaib1hz0ifpmxzv", "sha256": "0i9j45jwmqhiv7v8i4dmigaras3iw4hmrds2vvd5x8riln3hyizn",
"fetchLFS": false, "fetchLFS": false,
"fetchSubmodules": false, "fetchSubmodules": false,
"deepClone": false, "deepClone": false,

View File

@ -1,9 +1,9 @@
{ {
"url": "https://github.com/NixOS/nixpkgs", "url": "https://github.com/NixOS/nixpkgs",
"rev": "fd901ef4bf93499374c5af385b2943f5801c0833", "rev": "a08e061a4ee8329747d54ddf1566d34c55c895eb",
"date": "2023-04-22T11:27:49+08:00", "date": "2023-05-09T12:11:35+02:00",
"path": "/nix/store/gpfv5hbki6g1b63nqw7md5bjlcpzsz1w-nixpkgs", "path": "/nix/store/lwy9r49c92ml9mbvp2kx1m31p7bcpzxd-nixpkgs",
"sha256": "1fd7xyfna0klfbv37qq1ms2j4gzjpy14a8vbnw1i8ix6fijkywjf", "sha256": "1h0yd0xka6wj9sbbq34gw7a9qlp044b7dhg16bmn8bv96ix55vzj",
"fetchLFS": false, "fetchLFS": false,
"fetchSubmodules": false, "fetchSubmodules": false,
"deepClone": false, "deepClone": false,

View File

@ -65,8 +65,4 @@
]; ];
boot.cleanTmpDir = true; boot.cleanTmpDir = true;
# vbox
virtualisation.virtualbox.host.enable = true;
users.users.mainUser.extraGroups = [ "vboxusers" ];
} }

View File

@ -82,14 +82,9 @@ with import <stockholm/lib>;
krebs.htgen.paste = { krebs.htgen.paste = {
port = 9081; port = 9081;
script = toString [ script = /* sh */ ''
"PATH=${makeBinPath [ (. ${pkgs.htgen-paste}/bin/htgen-paste)
pkgs.nix '';
pkgs.file
]}:$PATH"
"STATEDIR=$HOME"
". ${pkgs.htgen}/examples/paste"
];
}; };
systemd.services.paste-gc = { systemd.services.paste-gc = {