Browse Source

fix for centos ncat and debian default netcat (#330)

neil 8 years ago
parent
commit
c9febbdd87
1 changed files with 19 additions and 4 deletions
  1. 19 4
      acme.sh

+ 19 - 4
acme.sh

@@ -1231,14 +1231,29 @@ _startserver() {
 
 
   _debug "_NC" "$_NC"
   _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
 #  while true ; do
     if [ "$DEBUG" ] ; then
     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
       fi
     else
     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      
     fi
     fi
     if [ "$?" != "0" ] ; then
     if [ "$?" != "0" ] ; then