nix-configs/other/scripts/networkhooks/WIFI@DB.nu

41 lines
1,016 B
Text
Raw Normal View History

2023-10-28 22:25:06 +02:00
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;
}