#!/usr/local/bin/bash
export LD_LIBRARY_PATH=./
cd /usr/local/lib/legends

#check if URL is allowed.  prevents malicious URL abuse
isAllowed ()
{
  [ $# -eq 1 ] || return $FAILURE

  case $1 in
  *[!0-9\.\:]*|"") exit -1 ;;
               *) return;;
  esac
}

### handle protocol to connect translation, removes all other args
if [[ "$1" == "legends://"* ]]; then
	#chances are this cae from a web site, so validate the url.
	#url can only contain numbers, period and :
	
	isAllowed "${1:10}"
	exec ./LinLegends -connect IP:${1:10}
else
	exec ./LinLegends $*
fi


