bug-wget
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-wget] Login to sonic.net using post-data over https not working


From: Eric Moret
Subject: Re: [Bug-wget] Login to sonic.net using post-data over https not working
Date: Sun, 6 Feb 2011 23:17:45 -0800

[...]
> Eric the short answer for you is the problem is at least the misspelling of
> endpoint:
[...]

So embarassing ...

Anyways, I got it working, thanks again for helping out. I am
publishing below the script that brings it all together for others to
use in case they need it.

$ cat sonic-endpoint-update
#!/bin/sh
# In order for this script to function you have to download and
configure a certificate bundle, if you don't have one already:
#
# $ wget --output-document=/etc/ca-bundle.crt http://curl.haxx.se/ca/cacert.pem
#
# Verify the sha256 of the ca-bundle.crt file with:A
#
# $ grep -v "^## Converted at: " /etc/ca-bundle.crt | sha256sum
# b9ae94e8cc91d9f8135f0d84dc3cf0d91456e99288fcb7b2ea3bb27d50378a68
#
# Configure your wget to point to that ca-bundle.crt file
# $ cat >> ~/.wgetrc
# ca_certificate = /etc/ca-bundle.crt
# ^D

# Testing IPv6 connectivity
testping () {
  echo -n "IPv6 ping:  "
  ping -n 1 ipv6.google.com > /dev/null
  if [ $? == 0 ]; then
    echo "Success"
    exit 0
  else
    echo "Failure"
  fi
}

usage () {
  echo "Usage: $0 -u username -p password" >&2
  exit 1
}

testping
echo "Updating sonic.net endpoint tunnel."

while getopts 'u:p:' OPTION; do
  case "$OPTION" in
    u)
      USER=$OPTARG
      ;;
    p)
      PASSWORD=$OPTARG
      ;;
  esac;
done;

if [ -z "$USER" -o -z "$PASSWORD" ]; then
  usage
fi

# Creating session cookie temp file
COOKIE=$(mktemp)
trap "rm -f $COOKIE" EXIT TERM INT QUIT
printf "members.sonic.net\tFALSE\t/\tTRUE\t0\tPHPSESSID\t" > $COOKIE

# Logging in to sonic.net
wget    --load-cookies=$COOKIE \
        --save-cookies=$COOKIE \
        --keep-session-cookies \
        --post-data="user=$USER&pw=$PASSWORD" \
        --output-document=- \
        --quiet https://members.sonic.net/ \
        | grep --quiet "logged in as <strong>$USER"
if [ $? == 0 ]; then
  echo "Logged in as $USER"
else
  echo "Loggin failure" >&2
  exit 1
fi

# Retrieving current external IP
MY_IP=$(wget --quiet \
        --output-document=- \
        http://www.whatismyip.com/automation/n09230945.asp)
echo "Current external IP: $MY_IP"

# Updating external IP to sonic.net
ENDPOINT=$(wget --load-cookies=$COOKIE \
        --post-data="endpoint=$MY_IP&rdns_server=none&change=1&action=step1" \
        --quiet \
        --output-document=- \
        https://members.sonic.net/connections/ipv6tunnel/ \
        | egrep -o '([[:digit:]]{1,3}\.){3}[[:digit:]]{1,3}')
echo "New endpoint IP at sonic.net: $ENDPOINT"

testping



reply via email to

[Prev in Thread] Current Thread [Next in Thread]