Skip to content

Commit 5e670e0

Browse files
author
neil
committed
support haiku
1 parent bc646d1 commit 5e670e0

File tree

3 files changed

+205
-31
lines changed

3 files changed

+205
-31
lines changed

.github/workflows/DNS.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,4 +597,57 @@ jobs:
597597
598598
599599
600+
Haiku:
601+
runs-on: ubuntu-latest
602+
needs: OpenIndiana
603+
env:
604+
TEST_DNS : ${{ secrets.TEST_DNS }}
605+
TestingDomain: ${{ secrets.TestingDomain }}
606+
TEST_DNS_NO_WILDCARD: ${{ secrets.TEST_DNS_NO_WILDCARD }}
607+
TEST_DNS_NO_SUBDOMAIN: ${{ secrets.TEST_DNS_NO_SUBDOMAIN }}
608+
TEST_DNS_SLEEP: ${{ secrets.TEST_DNS_SLEEP }}
609+
CASE: le_test_dnsapi
610+
TEST_LOCAL: 1
611+
DEBUG: ${{ secrets.DEBUG }}
612+
http_proxy: ${{ secrets.http_proxy }}
613+
https_proxy: ${{ secrets.https_proxy }}
614+
HTTPS_INSECURE: 1 # always set to 1 to ignore https error, since OpenIndiana doesn't accept the expired ISRG X1 root
615+
TokenName1: ${{ secrets.TokenName1}}
616+
TokenName2: ${{ secrets.TokenName2}}
617+
TokenName3: ${{ secrets.TokenName3}}
618+
TokenName4: ${{ secrets.TokenName4}}
619+
TokenName5: ${{ secrets.TokenName5}}
620+
steps:
621+
- uses: actions/checkout@v4
622+
- name: Clone acmetest
623+
run: cd .. && git clone --depth=1 https://github.com/acmesh-official/acmetest.git && cp -r acme.sh acmetest/
624+
- uses: vmactions/haiku-vm@v1
625+
with:
626+
envs: 'TEST_DNS TestingDomain TEST_DNS_NO_WILDCARD TEST_DNS_NO_SUBDOMAIN TEST_DNS_SLEEP CASE TEST_LOCAL DEBUG http_proxy https_proxy HTTPS_INSECURE TokenName1 TokenName2 TokenName3 TokenName4 TokenName5 ${{ secrets.TokenName1}} ${{ secrets.TokenName2}} ${{ secrets.TokenName3}} ${{ secrets.TokenName4}} ${{ secrets.TokenName5}}'
627+
sync: rsync
628+
run: |
629+
if [ "${{ secrets.TokenName1}}" ] ; then
630+
export ${{ secrets.TokenName1}}="${{ secrets.TokenValue1}}"
631+
fi
632+
if [ "${{ secrets.TokenName2}}" ] ; then
633+
export ${{ secrets.TokenName2}}="${{ secrets.TokenValue2}}"
634+
fi
635+
if [ "${{ secrets.TokenName3}}" ] ; then
636+
export ${{ secrets.TokenName3}}="${{ secrets.TokenValue3}}"
637+
fi
638+
if [ "${{ secrets.TokenName4}}" ] ; then
639+
export ${{ secrets.TokenName4}}="${{ secrets.TokenValue4}}"
640+
fi
641+
if [ "${{ secrets.TokenName5}}" ] ; then
642+
export ${{ secrets.TokenName5}}="${{ secrets.TokenValue5}}"
643+
fi
644+
cd ../acmetest
645+
./letest.sh
646+
- name: onError
647+
if: ${{ failure() }}
648+
run: |
649+
echo "See how to debug in VM:"
650+
echo "https://github.com/acmesh-official/acme.sh/wiki/debug-in-VM"
651+
652+
600653

.github/workflows/Haiku.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Haiku
2+
on:
3+
push:
4+
branches:
5+
- '*'
6+
paths:
7+
- '*.sh'
8+
- '.github/workflows/Haiku.yml'
9+
10+
pull_request:
11+
branches:
12+
- dev
13+
paths:
14+
- '*.sh'
15+
- '.github/workflows/Haiku.yml'
16+
17+
concurrency:
18+
group: ${{ github.workflow }}-${{ github.ref }}
19+
cancel-in-progress: true
20+
21+
22+
23+
jobs:
24+
Haiku:
25+
strategy:
26+
matrix:
27+
include:
28+
- TEST_ACME_Server: "LetsEncrypt.org_test"
29+
CA_ECDSA: ""
30+
CA: ""
31+
CA_EMAIL: ""
32+
TEST_PREFERRED_CHAIN: (STAGING)
33+
- TEST_ACME_Server: "LetsEncrypt.org_test"
34+
CA_ECDSA: ""
35+
CA: ""
36+
CA_EMAIL: ""
37+
TEST_PREFERRED_CHAIN: (STAGING)
38+
ACME_USE_WGET: 1
39+
#- TEST_ACME_Server: "ZeroSSL.com"
40+
# CA_ECDSA: "ZeroSSL ECC Domain Secure Site CA"
41+
# CA: "ZeroSSL RSA Domain Secure Site CA"
42+
# CA_EMAIL: "githubtest@acme.sh"
43+
# TEST_PREFERRED_CHAIN: ""
44+
runs-on: ubuntu-latest
45+
env:
46+
TEST_LOCAL: 1
47+
TEST_ACME_Server: ${{ matrix.TEST_ACME_Server }}
48+
CA_ECDSA: ${{ matrix.CA_ECDSA }}
49+
CA: ${{ matrix.CA }}
50+
CA_EMAIL: ${{ matrix.CA_EMAIL }}
51+
TEST_PREFERRED_CHAIN: ${{ matrix.TEST_PREFERRED_CHAIN }}
52+
ACME_USE_WGET: ${{ matrix.ACME_USE_WGET }}
53+
steps:
54+
- uses: actions/checkout@v4
55+
- uses: vmactions/cf-tunnel@v0
56+
id: tunnel
57+
with:
58+
protocol: http
59+
port: 8080
60+
- name: Set envs
61+
run: echo "TestingDomain=${{steps.tunnel.outputs.server}}" >> $GITHUB_ENV
62+
- name: Clone acmetest
63+
run: cd .. && git clone --depth=1 https://github.com/acmesh-official/acmetest.git && cp -r acme.sh acmetest/
64+
- uses: vmactions/haiku-vm@v1
65+
with:
66+
envs: 'TEST_LOCAL TestingDomain TEST_ACME_Server CA_ECDSA CA CA_EMAIL TEST_PREFERRED_CHAIN ACME_USE_WGET'
67+
nat: |
68+
"8080": "80"
69+
prepare: pkg install socat curl
70+
sync: nfs
71+
run: |
72+
cd ../acmetest \
73+
&& ./letest.sh
74+
- name: onError
75+
if: ${{ failure() }}
76+
run: |
77+
echo "See how to debug in VM:"
78+
echo "https://github.com/acmesh-official/acme.sh/wiki/debug-in-VM"
79+

acme.sh

Lines changed: 73 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,13 @@ _dlg_versions() {
250250
socat -V 2>&1
251251
else
252252
_debug "socat doesn't exist."
253+
if _exists "python3"; then
254+
python3 -V 2>&1
255+
elif _exists "python2"; then
256+
python2 -V 2>&1
257+
elif _exists "python"; then
258+
python -V 2>&1
259+
fi
253260
fi
254261
}
255262

@@ -2559,41 +2566,76 @@ _startserver() {
25592566
_debug Le_Listen_V4 "$Le_Listen_V4"
25602567
_debug Le_Listen_V6 "$Le_Listen_V6"
25612568

2562-
_NC="socat"
2563-
if [ "$Le_Listen_V6" ]; then
2564-
_NC="$_NC -6"
2565-
SOCAT_OPTIONS=TCP6-LISTEN
2566-
elif [ "$Le_Listen_V4" ]; then
2567-
_NC="$_NC -4"
2568-
SOCAT_OPTIONS=TCP4-LISTEN
2569-
else
2570-
SOCAT_OPTIONS=TCP-LISTEN
2571-
fi
2569+
if _exists "socat"; then
2570+
_NC="socat"
2571+
if [ "$Le_Listen_V6" ]; then
2572+
_NC="$_NC -6"
2573+
SOCAT_OPTIONS=TCP6-LISTEN
2574+
elif [ "$Le_Listen_V4" ]; then
2575+
_NC="$_NC -4"
2576+
SOCAT_OPTIONS=TCP4-LISTEN
2577+
else
2578+
SOCAT_OPTIONS=TCP-LISTEN
2579+
fi
25722580

2573-
if [ "$DEBUG" ] && [ "$DEBUG" -gt "1" ]; then
2574-
_NC="$_NC -d -d -v"
2575-
fi
2581+
if [ "$DEBUG" ] && [ "$DEBUG" -gt "1" ]; then
2582+
_NC="$_NC -d -d -v"
2583+
fi
25762584

2577-
SOCAT_OPTIONS=$SOCAT_OPTIONS:$Le_HTTPPort,crlf,reuseaddr,fork
2585+
SOCAT_OPTIONS=$SOCAT_OPTIONS:$Le_HTTPPort,crlf,reuseaddr,fork
25782586

2579-
#Adding bind to local-address
2580-
if [ "$ncaddr" ]; then
2581-
SOCAT_OPTIONS="$SOCAT_OPTIONS,bind=${ncaddr}"
2582-
fi
2587+
#Adding bind to local-address
2588+
if [ "$ncaddr" ]; then
2589+
SOCAT_OPTIONS="$SOCAT_OPTIONS,bind=${ncaddr}"
2590+
fi
25832591

2584-
_content_len="$(printf "%s" "$content" | wc -c)"
2585-
_debug _content_len "$_content_len"
2586-
_debug "_NC" "$_NC $SOCAT_OPTIONS"
2587-
export _SOCAT_ERR="$(_mktemp)"
2588-
$_NC $SOCAT_OPTIONS SYSTEM:"sleep 1; \
2592+
_content_len="$(printf "%s" "$content" | wc -c)"
2593+
_debug _content_len "$_content_len"
2594+
_debug "_NC" "$_NC $SOCAT_OPTIONS"
2595+
export _SOCAT_ERR="$(_mktemp)"
2596+
$_NC $SOCAT_OPTIONS SYSTEM:"sleep 1; \
25892597
echo 'HTTP/1.0 200 OK'; \
25902598
echo 'Content-Length\: $_content_len'; \
25912599
echo ''; \
25922600
printf '%s' '$content';" 2>"$_SOCAT_ERR" &
2593-
serverproc="$!"
2601+
serverproc="$!"
2602+
else
2603+
_PYTHON=""
2604+
if _exists "python3"; then
2605+
_PYTHON="python3"
2606+
elif _exists "python2"; then
2607+
_PYTHON="python2"
2608+
elif _exists "python"; then
2609+
_PYTHON="python"
2610+
fi
2611+
if [ "$_PYTHON" ]; then
2612+
_debug "Using python: $_PYTHON"
2613+
_AF="socket.AF_INET"
2614+
_BIND_ADDR="0.0.0.0"
2615+
if [ "$Le_Listen_V6" ]; then
2616+
_AF="socket.AF_INET6"
2617+
_BIND_ADDR="::"
2618+
fi
2619+
if [ "$ncaddr" ]; then
2620+
_BIND_ADDR="$ncaddr"
2621+
fi
2622+
export _SOCAT_ERR="$(_mktemp)"
2623+
$_PYTHON -c "import socket,sys;s=socket.socket($_AF,socket.SOCK_STREAM);s.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1);s.bind((sys.argv[2],int(sys.argv[1])));s.listen(5);res='HTTP/1.0 200 OK\r\nContent-Length: '+str(len(sys.argv[3]))+'\r\n\r\n'+sys.argv[3];
2624+
while True:
2625+
c,a=s.accept()
2626+
c.sendall(res.encode() if hasattr(res, 'encode') else res)
2627+
c.close()" "$Le_HTTPPort" "$_BIND_ADDR" "$content" 2>"$_SOCAT_ERR" &
2628+
serverproc="$!"
2629+
_NC="$_PYTHON"
2630+
else
2631+
_err "Please install socat or python first for standalone mode."
2632+
return 1
2633+
fi
2634+
fi
2635+
25942636
if [ -f "$_SOCAT_ERR" ]; then
25952637
if grep "Permission denied" "$_SOCAT_ERR" >/dev/null; then
2596-
_err "socat: $(cat $_SOCAT_ERR)"
2638+
_err "$_NC: $(cat $_SOCAT_ERR)"
25972639
_err "Can not listen for user: $(whoami)"
25982640
_err "Maybe try with root again?"
25992641
rm -f "$_SOCAT_ERR"
@@ -3557,9 +3599,9 @@ _on_before_issue() {
35573599
fi
35583600
fi
35593601

3560-
if _hasfield "$_chk_web_roots" "$NO_VALUE"; then
3561-
if ! _exists "socat"; then
3562-
_err "Please install socat tools first."
3602+
if _hasfield "$_chk_web_roots" "$NO_VALUE" && [ "$_chk_web_roots" = "$NO_VALUE" ]; then
3603+
if ! _exists "socat" && ! _exists "python" && ! _exists "python2" && ! _exists "python3"; then
3604+
_err "Please install socat or python tools first."
35633605
return 1
35643606
fi
35653607
fi
@@ -6664,9 +6706,9 @@ _precheck() {
66646706
return 1
66656707
fi
66666708

6667-
if ! _exists "socat"; then
6668-
_err "It is recommended to install socat first."
6669-
_err "We use socat for the standalone server, which is used for standalone mode."
6709+
if ! _exists "socat" && ! _exists "python" && ! _exists "python2" && ! _exists "python3"; then
6710+
_err "It is recommended to install socat or python first."
6711+
_err "We use socat or python for the standalone server, which is used for standalone mode."
66706712
_err "If you don't want to use standalone mode, you may ignore this warning."
66716713
fi
66726714

0 commit comments

Comments
 (0)