This commit is contained in:
Schrottkatze 2023-10-28 22:25:06 +02:00
parent 224c80c420
commit 1cd19687be
21 changed files with 315 additions and 68 deletions

View file

@ -0,0 +1,40 @@
def main [
interface: string
type: string
] {
if not ($type == 'up') {
exit
};
mullvad disconnect;
let page = http get 'http://172.0.0.1/';
let hotspot_ip = $page | htmlq 'input[name=uamip]' -a 'value';
let hotspot_port = $page | htmlq 'input[name=uamport]' -a 'value';
let pl_data = $page
| htmlq input -a name -r input[name=button]
| lines
| wrap name
| merge (
$page
| htmlq input -a value
| lines
| wrap value
)
| drop 1;
let payload = $pl_data
| each {|kv| [
($kv.name | url encode --all)
($kv.value | url encode --all) ]
| str join '='
} | str join '&';
let res = curl --insecure --resolve $"www.hotsplots.de:($hotspot_port):($hotspot_ip)" -H 'Content-Type: application/x-www-form-urlencoded' "https://www.hotsplots.de/auth/login.php" --data-raw $"($payload)" ;
let url = $res | htmlq 'meta[http-equiv=refresh]' -a 'content' | parse '0;url={url}';
http get $url.url.0;
mullvad connect;
}

View file

@ -0,0 +1,22 @@
#! /usr/bin/env nix-shell
#! nix-shell -i bash -p curl htmlq
# echo "Fetching cookie and CSRF token..."
# form=$(curl --silent --location --junk-session-cookies --cookie-jar /tmp/wifionice "https://login.wifionice.de/en/" --resolve login.wifionice.de:443:10.101.64.10 -i | htmlq "input")
# keys=$(htmlq "input" --attribute "name" <<< "$form")
# values=$(htmlq "input" --attribute "value" <<< "$form")
# payload=$(paste --delimiters="=" <(echo "$keys") <(echo "$values") | tr "\n" "&")
# echo "Payload: \"$payload\""
# echo "POSTing payload..."
# curl --cookie /tmp/wifionice "https://login.wifionice.de/en/" --resolve login.wifionice.de:443:10.101.64.10 -d "$payload"
def main [
interface: string
type: string
] {
let form = curl --silent --location --junk-session-cookies --cookie-jar /tmp/wifionice 'https://login.wifionice.de/en/' --resolve 'login.wifionice.de:443:10.101.64.10' -i | htmlq 'input';
# TODO
}

View file

@ -0,0 +1,41 @@
const wave_timeout = 15min;
def main [
interface: string
type: string
] {
if not ('/var/lib/ccchh-winken/last' | path exists) {
mkdir '/var/lib/ccchh-winken';
0 | into datetime | save '/var/lib/ccchh-winken/last' -f;
}
let $last_waved = open '/var/lib/ccchh-winken/last' --raw | into datetime;
if ((date now) - $last_waved) > $wave_timeout {
if $type == "up" {
mullvad disconnect;
curl mqtt://mqtt.z9/winkekatze/katz9/eye/set -d (rand-color);
curl mqtt://mqtt.z9/winkekatze/Viktoria/eye/set -d (rand-color);
curl mqtt://mqtt.z9/winkekatze/allcats -d 'wink';
mullvad connect;
date now | save '/var/lib/ccchh-winken/last' -f;
}
}
}
def rand-color [] {
const colors = [
"blue"
"cyan"
"green"
"pink"
"red"
"white"
"yellow"
];
$colors | get (random integer 0..(($colors | length) - 1))
}