From c9febbdd876888e2b16c1b6b57f7658c63bea91e Mon Sep 17 00:00:00 2001 From: neil Date: Wed, 19 Oct 2016 22:14:42 +0800 Subject: [PATCH] fix for centos ncat and debian default netcat (#330) --- acme.sh | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/acme.sh b/acme.sh index 09920730..0ea9584f 100755 --- a/acme.sh +++ b/acme.sh @@ -1231,14 +1231,29 @@ _startserver() { _debug "_NC" "$_NC" + #for centos ncat + if _contains "$nchelp" "nmap.org" ; then + _debug "Using ncat: nmap.org" + if [ "$DEBUG" ] ; then + if printf "HTTP/1.1 200 OK\r\n\r\n$content" | $_NC $Le_HTTPPort ; then + return + fi + else + if printf "HTTP/1.1 200 OK\r\n\r\n$content" | $_NC $Le_HTTPPort > /dev/null 2>&1; then + return + fi + fi + _err "ncat listen error." + fi + # while true ; do if [ "$DEBUG" ] ; then - if ! printf "HTTP/1.1 200 OK\r\n\r\n$content" | $_NC $Le_HTTPPort ; then - printf "HTTP/1.1 200 OK\r\n\r\n$content" | $_NC -p $Le_HTTPPort ; + if ! printf "HTTP/1.1 200 OK\r\n\r\n$content" | $_NC -p $Le_HTTPPort ; then + printf "HTTP/1.1 200 OK\r\n\r\n$content" | $_NC $Le_HTTPPort ; fi else - if ! printf "HTTP/1.1 200 OK\r\n\r\n$content" | $_NC $Le_HTTPPort > /dev/null 2>&1; then - printf "HTTP/1.1 200 OK\r\n\r\n$content" | $_NC -p $Le_HTTPPort > /dev/null 2>&1 + if ! printf "HTTP/1.1 200 OK\r\n\r\n$content" | $_NC -p $Le_HTTPPort > /dev/null 2>&1; then + printf "HTTP/1.1 200 OK\r\n\r\n$content" | $_NC $Le_HTTPPort > /dev/null 2>&1 fi fi if [ "$?" != "0" ] ; then