-
Notifications
You must be signed in to change notification settings - Fork 34
/
mldonkey
executable file
·33 lines (28 loc) · 902 Bytes
/
mldonkey
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash
# Resolve possible redirects (mldonkey doesn't seem to handle these well)
url="$(curl -sL4 --head --referer "$2" "$1" |
awk '/^Location:/ {loc=$2} END {sub("\r", "", loc); print loc}')"
[[ -z "$url" ]] && url="$1"
read host port login password\
< <( awk '{
for (i=1; i<NF+1; i++)
if (!k) k=$i; else {auth[k]=$i; k=""}
if (auth["service"]=="mld")
print auth["machine"], auth["port"],\
auth["login"], auth["password"]}'\
~/.netrc )
[[ -z "$host" || -z "$port" || -z "$login" || -z "$password" ]] && exit 1
umask 077
exec 3>/tmp/leech_mld.lock
flock -w 300 3
echo -e "auth $login $password\nhttp '$url' '$2'\nexit\n" |
ncat "$host" "$port" 2>&1 >/dev/null
err=$?
flock -u 3
if [[ $err -eq 0 ]]
then
msg="Link relayed successfully\nLink: ${1}"
msg+="\nResolved-to: ${url}"
else msg="Failed sending link, exit code: $err"
fi
notify-send -u critical "Leech: MLD" "$msg"