diff --git a/inc/sites.inc b/inc/sites.inc index bebb93c2..bded1d38 100755 --- a/inc/sites.inc +++ b/inc/sites.inc @@ -610,77 +610,79 @@ SITEINFO(){ fi if [ "${1}" == "edit" ]; then - if [ "${2}" == "" ]; then - echo -en "\n${idsCL[LightCyan]}Enter the site number you want to edit: ${idsCL[Default]}" - read siteid - echo - else - siteid=${2} - fi - site=${SITELIST[${siteid}]} - sitefile=${gosite}/${site}.conf - certpath=$(grep ssl_certificate_key ${sitefile}) - if [ "${certpath}" != "" ]; then - ssl='Yes' - certpath=${certpath%/*}; certpath=${certpath#* } - SUBJECTNAMES=$(openssl x509 -in ${certpath}/cert.pem -noout -text|grep -oP '(?<=DNS:|IP Address:)[^,]+'|sort -uV) - CERTEXPIRE=$(date -d "$(: | openssl x509 -in ${certpath}/cert.pem -text | grep 'Not After' |awk '{print $4,$5,$7}')" '+%s'); - SUBJECTNAMES=${SUBJECTNAMES//$'\n'/, } - else - ssl='-' - fi - if [ "$(grep include/proxy.conf ${sitefile})" != "" ]; then - type='Proxy' - server=$(grep 'set $server' ${sitefile}) - server=${server#*\"}; server=${server%\"*} - scheme=$(grep 'set $forward_scheme' ${sitefile}) - scheme=${scheme##* }; scheme=${scheme%;*} - port=$(grep 'set $port' ${sitefile}) - port=${port##* }; port=${port%;*} - c=0; spc7=''; spct=$((${cw_spc7}-${#server})); until [ $c = ${spct} ]; do spc7="${spc7} "; c=`expr $c + 1`; done - proxyhost="${server}${spc7}:${port}" - else - type='HTTP' - proxyhost='' - fi - [ "$(grep include/hsts-support.conf ${sitefile})" != "" ] && hsts='Yes' || hsts='-' - [ "$(grep include/websocket-support.conf ${sitefile})" != "" ] && wbskt='Yes' || wbskt='-' - [ "$(grep include/block-exploits.conf ${sitefile})" != "" ] && explt='Yes' || explt='-' - [ "$(grep include/secure-access.conf ${sitefile})" != "" ] && lock='Yes' || lock='-' - f=0 - until [ "${edit}" = "c" ]; do - echo -e "\033[K${idsCL[White]}0) Site Address: ${idsCL[Cyan]}${idsST[Bold]}${site}${idsST[Reset]}" - echo -e "\033[K${idsCL[White]}1) Site Type: ${idsCL[Cyan]}${idsST[Bold]}${type}${idsST[Reset]}" - echo -e "\033[K${idsCL[White]}2) SSL Secure: ${idsCL[Cyan]}${idsST[Bold]}${ssl}${idsST[Reset]} - ${idsCL[LightCyan]}(${SUBJECTNAMES})" - echo -e "\033[K${idsCL[White]}3) HSTS Enabled ${idsCL[Cyan]}${idsST[Bold]}${hsts}${idsST[Reset]}" - echo -e "\033[K${idsCL[White]}4) Web Sockets: ${idsCL[Cyan]}${idsST[Bold]}${wbskt}${idsST[Reset]}" - echo -e "\033[K${idsCL[White]}5) Exploits Block: ${idsCL[Cyan]}${idsST[Bold]}${explt}${idsST[Reset]}" - echo -e "\033[K${idsCL[White]}6) Secured Access: ${idsCL[Cyan]}${idsST[Bold]}${lock}${idsST[Reset]}" - if [ "${type}" == "Proxy" ]; then - echo -e "\033[K${idsCL[White]}7) Proxy Address: ${idsCL[Cyan]}${idsST[Bold]}${server}${idsST[Reset]}" - echo -e "\033[K${idsCL[White]}8) Proxy Scheme: ${idsCL[Cyan]}${idsST[Bold]}${scheme}${idsST[Reset]}" - echo -e "\033[K${idsCL[White]}9) Proxy Port: ${idsCL[Cyan]}${idsST[Bold]}${port}${idsST[Reset]}" + while [ "${edit^}" != "E" ]; do + + if [ "${2}" == "" ]; then + echo -en "\n${idsCL[LightCyan]}Enter the site number you want to edit: ${idsCL[Default]}" + read siteid + echo else - echo -e "\033[K" - echo -e "\033[K" - echo -e "\033[K" + siteid=${2} fi - if [ "${edit}" != "s" ]; then - if [ $f -eq 0 ]; then - echo -e "\033[K" - echo -e "\033[K" - echo -e "\033[K (${idsCL[Green]}s${idsCL[Default]})ave, (${idsCL[Red]}c${idsCL[Default]})ancel, (${idsCL[Green]}e${idsCL[Default]})xit" + site=${SITELIST[${siteid}]} + sitefile=${gosite}/${site}.conf + certpath=$(grep ssl_certificate_key ${sitefile}) + if [ "${certpath}" != "" ]; then + ssl='Yes' + certpath=${certpath%/*}; certpath=${certpath#* } + SUBJECTNAMES=$(openssl x509 -in ${certpath}/cert.pem -noout -text|grep -oP '(?<=DNS:|IP Address:)[^,]+'|sort -uV) + CERTEXPIRE=$(date -d "$(: | openssl x509 -in ${certpath}/cert.pem -text | grep 'Not After' |awk '{print $4,$5,$7}')" '+%s'); + SUBJECTNAMES=${SUBJECTNAMES//$'\n'/, } + else + ssl='-' + fi + + if [ "$(grep include/proxy.conf ${sitefile})" != "" ]; then + type='Proxy' + server=$(grep 'set $server' ${sitefile}) + server=${server#*\"}; server=${server%\"*} + scheme=$(grep 'set $forward_scheme' ${sitefile}) + scheme=${scheme##* }; scheme=${scheme%;*} + port=$(grep 'set $port' ${sitefile}) + port=${port##* }; port=${port%;*} + c=0; spc7=''; spct=$((${cw_spc7}-${#server})); until [ $c = ${spct} ]; do spc7="${spc7} "; c=`expr $c + 1`; done + proxyhost="${server}${spc7}:${port}" + else + type='HTTP' + proxyhost='' + fi + [ "$(grep include/hsts-support.conf ${sitefile})" != "" ] && hsts='Yes' || hsts='-' + [ "$(grep include/websocket-support.conf ${sitefile})" != "" ] && wbskt='Yes' || wbskt='-' + [ "$(grep include/block-exploits.conf ${sitefile})" != "" ] && explt='Yes' || explt='-' + [ "$(grep include/secure-access.conf ${sitefile})" != "" ] && lock='Yes' || lock='-' + f=0 + until [ "${edit}" = "c" ]; do + echo -e "\033[K${idsCL[White]}0) Site Address: ${idsCL[Cyan]}${idsST[Bold]}${site}${idsST[Reset]}" + echo -e "\033[K${idsCL[White]}1) Site Type: ${idsCL[Cyan]}${idsST[Bold]}${type}${idsST[Reset]}" + echo -e "\033[K${idsCL[White]}2) SSL Secure: ${idsCL[Cyan]}${idsST[Bold]}${ssl}${idsST[Reset]} - ${idsCL[LightCyan]}(${SUBJECTNAMES})" + echo -e "\033[K${idsCL[White]}3) HSTS Enabled ${idsCL[Cyan]}${idsST[Bold]}${hsts}${idsST[Reset]}" + echo -e "\033[K${idsCL[White]}4) Web Sockets: ${idsCL[Cyan]}${idsST[Bold]}${wbskt}${idsST[Reset]}" + echo -e "\033[K${idsCL[White]}5) Exploits Block: ${idsCL[Cyan]}${idsST[Bold]}${explt}${idsST[Reset]}" + echo -e "\033[K${idsCL[White]}6) Secured Access: ${idsCL[Cyan]}${idsST[Bold]}${lock}${idsST[Reset]}" + if [ "${type}" == "Proxy" ]; then + echo -e "\033[K${idsCL[White]}7) Proxy Address: ${idsCL[Cyan]}${idsST[Bold]}${server}${idsST[Reset]}" + echo -e "\033[K${idsCL[White]}8) Proxy Scheme: ${idsCL[Cyan]}${idsST[Bold]}${scheme}${idsST[Reset]}" + echo -e "\033[K${idsCL[White]}9) Proxy Port: ${idsCL[Cyan]}${idsST[Bold]}${port}${idsST[Reset]}" + else echo -e "\033[K" echo -e "\033[K" echo -e "\033[K" - echo -e "\033[7A" fi - - while [ "${edit^}" != "E" ]; do + if [ "${edit}" != "s" ]; then + if [ $f -eq 0 ]; then + echo -e "\033[K" + echo -e "\033[K" + echo -e "\033[K (${idsCL[Green]}s${idsCL[Default]})ave, (${idsCL[Red]}c${idsCL[Default]})ancel, (${idsCL[Green]}e${idsCL[Default]})xit" + echo -e "\033[K" + echo -e "\033[K" + echo -e "\033[K" + echo -e "\033[7A" + fi + echo -en "\n\033[K${idsCL[LightCyan]}Enter the line number to edit: ${idsCL[Default]}" read -n 1 edit - + case "${edit}" in 0) ;; 1) [ "${type}" == "HTTP" ] && type='Proxy' || type='HTTP';; @@ -708,7 +710,7 @@ SITEINFO(){ read port echo -e "\033[5A"; echo -e "\033[K"; echo -e "\033[K"; echo -e "\033[K"; echo -e "\033[K"; echo -e "\033[K"; echo -e "\033[5A" ;; - + [Ee]) echo -e "\n\n\n" exit 0 @@ -717,39 +719,39 @@ SITEINFO(){ echo -e "\n\033[K\033[14A"; echo -e "\033[K\n\033[K\n\033[K\n\033[K\n\033[K\n\033[K\n\033[K\n\033[K\n\033[K\n\033[K\n\033[K\n\033[K\n\033[K\n\033[K"; echo -e "\033[14A" - + ;; esac - done - # [ "$edit" = "7" ] && echo -e "\033[5A"; echo -e "\033[K"; echo -e "\033[K"; echo -e "\033[K"; echo -e "\033[K"; echo -e "\033[K"; echo -e "\033[5A" - echo -e "\033[12A" - else - echo -en "\n\033[K${idsCL[LightCyan]}Confirm changes (Y/n): ${idsCL[Default]}" - read -n 1 confirm - case "${confirm}" in - [Nn]) - edit='' - echo -e "\033[12A" - ;; - *) - echo -e "\n\n\n" + # [ "$edit" = "7" ] && echo -e "\033[5A"; echo -e "\033[K"; echo -e "\033[K"; echo -e "\033[K"; echo -e "\033[K"; echo -e "\033[K"; echo -e "\033[5A" + echo -e "\033[12A" + else + echo -en "\n\033[K${idsCL[LightCyan]}Confirm changes (Y/n): ${idsCL[Default]}" + read -n 1 confirm + case "${confirm}" in + [Nn]) + edit='' + echo -e "\033[12A" + ;; + *) + echo -e "\n\n\n" - # NEWPROXYSITE_CREATE ${site} ${server} ${port} ${scheme} ${wbskt} ${hsts} ${explt} ${lock} - # SITENAME=${1} - # PROXYHOST=${2} - # PROXYPORT=${3} - # PROXYSCHEME=${4} - # WEBSOCKET=${5} - # HSTS=${6} - # EXPLOITS=${7} - # SECURE=${8} + # NEWPROXYSITE_CREATE ${site} ${server} ${port} ${scheme} ${wbskt} ${hsts} ${explt} ${lock} + # SITENAME=${1} + # PROXYHOST=${2} + # PROXYPORT=${3} + # PROXYSCHEME=${4} + # WEBSOCKET=${5} + # HSTS=${6} + # EXPLOITS=${7} + # SECURE=${8} - edit=c - ;; - esac + edit=c + ;; + esac - fi - f=1 + fi + f=1 + done done echo