Hurricane Electric's IPv6 Tunnel Broker Forums

Advanced search  

News:

Welcome to Hurricane Electric's Tunnelbroker.net forums!

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - adamel

Pages: [1]
1
I created a simple script that can create/update/delete records in HE DNS, which I'm now using with https://github.com/lukas2511/dehydrated

In the deploy_challenge hook I have:
Code: [Select]
hednsupdate _acme-challenge.${DOMAIN}. TXT "${TOKEN_VALUE}" 300
And in clean_challenge:
Code: [Select]
hednsupdate _acme-challenge.${DOMAIN}. DELETE
Code: [Select]
#!/bin/sh

url=https://dns.he.net/

# These should be set in .hedns-credentials
login=
password=
zoneid=
# Optionally override these.
ttl=300

if [ -e ${HOME}/.hedns-credentials ]; then
    . ${HOME}/.hedns-credentials
fi

function usage()
{
    prog=$(basename $0)
    cat <<EOF
Create/update:
 $prog NAME TYPE CONTENT [TTL]
Delete:
 $prog NAME "DELETE"
EOF
}

record=$1
type=$2
content=$3
usettl=${4-${ttl}}

if [ $# -lt 2 ] || [ $# -lt 3 -a "${type}" != DELETE ]; then
    usage
    exit 1
fi

cookies=${HOME}/.hedns-cookies.txt
touch ${cookies}
chmod 0600 ${cookies}

function get_id()
{
    curl -sS --cookie ${cookies} "${url}?hosted_dns_zoneid=${zoneid}&menu=edit_zone&hosted_dns_editzone" | grep -B5 ">${record}" | sed -nre 's/.*dns_tr.* id="([^"]*)".*/\1/p' | head -n 1
}

# Get any initial cookies.
curl -sS --cookie-jar ${cookies} ${url} -o /dev/null
# Login.
curl -sS --cookie ${cookies} --cookie-jar ${cookies} --data "email=${login}&pass=${password}&submit=Login%21" ${url} -o /dev/null

# Check if we should update or create new.
recordid=$(get_id)
if [ "${type}" == DELETE ]; then
    if [ ! "${recordid}" ]; then
echo "No such record"
exit 1
    fi
    curl -sS --cookie ${cookies} --data "menu=edit_zone&hosted_dns_zoneid=${zoneid}&hosted_dns_recordid=${recordid}&hosted_dns_editzone=1&hosted_dns_delrecord=1" "${url}index.cgi" | grep "^${record}"
    [ $? -ne 0 ]
    exit
fi
if [ "${recordid}" ]; then
    op=Update
else
    op=Submit
fi
curl -sS --cookie ${cookies} --data "account=&menu=edit_zone&Type=${type}&hosted_dns_zoneid=${zoneid}&hosted_dns_recordid=${recordid}&hosted_dns_editzone=1&Priority=&Name=${record}&Content=${content}&TTL=${usettl}&hosted_dns_editrecord=${op}" "${url}?hosted_dns_zoneid=${zoneid}&menu=edit_zone&hosted_dns_editzone" | grep "^${record}"

Pages: [1]