mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
Merge pull request #153 from mtatton/master
[ build ] added aarch64, testing https server
This commit is contained in:
commit
a45a892684
1
.gitignore
vendored
1
.gitignore
vendored
@ -20,3 +20,4 @@ elinks
|
|||||||
*.o
|
*.o
|
||||||
features.log
|
features.log
|
||||||
src/elinks.exe
|
src/elinks.exe
|
||||||
|
test/server/__pycache__
|
||||||
|
75
build.sh
75
build.sh
@ -1,8 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#
|
#
|
||||||
# shell script to build static elinks
|
# shell script menus for elinks binaries building
|
||||||
# for differenct architectures with
|
|
||||||
# the same configuration
|
|
||||||
#
|
#
|
||||||
|
|
||||||
clear
|
clear
|
||||||
@ -28,6 +26,9 @@ configure() {
|
|||||||
echo "--[ Host : " $2 "]--"
|
echo "--[ Host : " $2 "]--"
|
||||||
sleep 2
|
sleep 2
|
||||||
rm -f config.cache
|
rm -f config.cache
|
||||||
|
# Thanks rkd77 for discovery of jemmaloc needed
|
||||||
|
# to correct openssl functionality
|
||||||
|
# LIBS="-ljemalloc -lpthread -lm" \
|
||||||
time \
|
time \
|
||||||
CC=$1 \
|
CC=$1 \
|
||||||
LD=$2 \
|
LD=$2 \
|
||||||
@ -40,8 +41,8 @@ configure() {
|
|||||||
--prefix=/usr \
|
--prefix=/usr \
|
||||||
--enable-256-colors \
|
--enable-256-colors \
|
||||||
--enable-fastmem \
|
--enable-fastmem \
|
||||||
--with-static \
|
|
||||||
--enable-utf-8 \
|
--enable-utf-8 \
|
||||||
|
--with-static \
|
||||||
--without-openssl \
|
--without-openssl \
|
||||||
--without-quickjs \
|
--without-quickjs \
|
||||||
--disable-88-colors \
|
--disable-88-colors \
|
||||||
@ -73,9 +74,13 @@ configure() {
|
|||||||
# turn off warnings
|
# turn off warnings
|
||||||
sed -i 's/-Wall/-w/g' Makefile.config
|
sed -i 's/-Wall/-w/g' Makefile.config
|
||||||
#sed -i 's/-lpthread/-pthread/g' Makefile.config
|
#sed -i 's/-lpthread/-pthread/g' Makefile.config
|
||||||
build
|
#build
|
||||||
|
return 0
|
||||||
else
|
else
|
||||||
|
echo "--[ Listing errors in config.log ]--"
|
||||||
|
cat config.log | grep error
|
||||||
echo "--[ Configuration failed... ]--"
|
echo "--[ Configuration failed... ]--"
|
||||||
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,8 +94,10 @@ build() {
|
|||||||
echo "--[ Build Sucessfull ]--"
|
echo "--[ Build Sucessfull ]--"
|
||||||
echo "--[ All Done. ]--"
|
echo "--[ All Done. ]--"
|
||||||
echo "--[ ................ ]--"
|
echo "--[ ................ ]--"
|
||||||
|
return 0
|
||||||
else
|
else
|
||||||
echo "--[ Build failed... ]--"
|
echo "--[ Build failed... ]--"
|
||||||
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,6 +160,14 @@ set_arch() {
|
|||||||
BIN_SUFFIX=""
|
BIN_SUFFIX=""
|
||||||
LDFLAGS=""
|
LDFLAGS=""
|
||||||
LIBS="-L../../lib/$ARCHIT"
|
LIBS="-L../../lib/$ARCHIT"
|
||||||
|
elif [ "$1" = "arm64" ]; then
|
||||||
|
ARCHIT="$1"
|
||||||
|
CC="aarch64-linux-gnu-gcc"
|
||||||
|
LD="aarch64-linux-gnu-ld"
|
||||||
|
MAKE_HOST="aarch64-linux-gnu"
|
||||||
|
BIN_SUFFIX=""
|
||||||
|
LDFLAGS=""
|
||||||
|
LIBS="-L../../lib/$ARCHIT"
|
||||||
elif [ "$1" = "native" ]; then
|
elif [ "$1" = "native" ]; then
|
||||||
ARCHIT="$1"
|
ARCHIT="$1"
|
||||||
CC="gcc"
|
CC="gcc"
|
||||||
@ -164,11 +179,37 @@ set_arch() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# ARCH SELECTION MENU
|
||||||
|
arch_menu() {
|
||||||
|
MENU_ARCHS="$ARCHS return"
|
||||||
|
echo "[=] Build architecture selection menu"
|
||||||
|
select SEL in $MENU_ARCHS; do
|
||||||
|
echo "[=] Build architecture selection menu"
|
||||||
|
if [ "$SEL" = "lin64" ]; then
|
||||||
|
set_arch lin64
|
||||||
|
elif [ "$SEL" = "win64" ]; then
|
||||||
|
set_arch win64
|
||||||
|
elif [ "$SEL" = "arm32" ]; then
|
||||||
|
set_arch arm32
|
||||||
|
elif [ "$SEL" = "arm64" ]; then
|
||||||
|
set_arch arm64
|
||||||
|
elif [ "$SEL" = "native" ]; then
|
||||||
|
set_arch native
|
||||||
|
elif [ "$SEL" = "make" ]; then
|
||||||
|
build
|
||||||
|
elif [ "$SEL" = "return" ]; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
echo "--[ Compiler: " $CC " ]--"
|
||||||
|
echo "--[ Host : " $MAKE_HOST " ]--"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
# MAIN LOOP
|
# MAIN LOOP
|
||||||
ARCHIT=""
|
ARCHIT=""
|
||||||
BIN_SUFFIX=""
|
BIN_SUFFIX=""
|
||||||
ARCHS="lin64 win64 arm32"
|
ARCHS="lin64 win64 arm32 arm64 native"
|
||||||
CC_SEL="lin64 win64 arm32 native \
|
CC_SEL="arch null null null \
|
||||||
config make test \
|
config make test \
|
||||||
pub debug \
|
pub debug \
|
||||||
info \
|
info \
|
||||||
@ -176,14 +217,8 @@ build_all \
|
|||||||
exit"
|
exit"
|
||||||
set_arch native
|
set_arch native
|
||||||
select SEL in $CC_SEL; do
|
select SEL in $CC_SEL; do
|
||||||
if [ "$SEL" = "lin64" ]; then
|
if [ "$SEL" = "arch" ]; then
|
||||||
set_arch lin64
|
arch_menu
|
||||||
elif [ "$SEL" = "win64" ]; then
|
|
||||||
set_arch win64
|
|
||||||
elif [ "$SEL" = "arm32" ]; then
|
|
||||||
set_arch arm32
|
|
||||||
elif [ "$SEL" = "native" ]; then
|
|
||||||
set_arch native
|
|
||||||
elif [ "$SEL" = "make" ]; then
|
elif [ "$SEL" = "make" ]; then
|
||||||
build
|
build
|
||||||
elif [ "$SEL" = "config" ]; then
|
elif [ "$SEL" = "config" ]; then
|
||||||
@ -203,14 +238,22 @@ select SEL in $CC_SEL; do
|
|||||||
echo "--[ Building: $arch ]--"
|
echo "--[ Building: $arch ]--"
|
||||||
set_arch "$arch"
|
set_arch "$arch"
|
||||||
configure "$CC" "$LD" "$MAKE_HOST" "$LDFLAGS" "$LIBS"
|
configure "$CC" "$LD" "$MAKE_HOST" "$LDFLAGS" "$LIBS"
|
||||||
|
if [ $? -eq 1 ]; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
build
|
build
|
||||||
|
if [ $? -eq 1 ]; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
info "$BIN_SUFFIX"
|
info "$BIN_SUFFIX"
|
||||||
pub "$BIN_SUFFIX" "$ARCHIT"
|
pub "$BIN_SUFFIX" "$ARCHIT"
|
||||||
done
|
done
|
||||||
|
elif [ "$SEL" = "null" ]; then
|
||||||
|
echo "[.] This option is intentially left blank"
|
||||||
elif [ "$SEL" = "exit" ]; then
|
elif [ "$SEL" = "exit" ]; then
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
echo "--[ elinks build system ]--"
|
echo "--[ [=] elinks build system main menu ]--"
|
||||||
echo "--[ Compiler: " $CC " ]--"
|
echo "--[ Compiler: " $CC " ]--"
|
||||||
echo "--[ Host : " $MAKE_HOST " ]--"
|
echo "--[ Host : " $MAKE_HOST " ]--"
|
||||||
done
|
done
|
||||||
|
61
test.sh
61
test.sh
@ -1,8 +1,10 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#
|
#
|
||||||
# shell script to test elinks binary
|
# shell script menus for elinks binary testing
|
||||||
#
|
#
|
||||||
|
|
||||||
|
CUR_TEST=hello
|
||||||
|
|
||||||
clear
|
clear
|
||||||
|
|
||||||
echo ' --/ \--'
|
echo ' --/ \--'
|
||||||
@ -12,21 +14,62 @@ echo ' --[ [*] use option 1 to run dump test ]--'
|
|||||||
echo ' --\ /--'
|
echo ' --\ /--'
|
||||||
echo ' '
|
echo ' '
|
||||||
|
|
||||||
# SET TEST
|
# RUN TEST
|
||||||
prep_test() {
|
run_test() {
|
||||||
if [ "$1" = "hello" ]; then
|
if [ "$1" = "hello" ]; then
|
||||||
./src/elinks --dump ./test/hello.html
|
./src/elinks --dump ./test/hello.html
|
||||||
|
elif [ "$1" = "http" ]; then
|
||||||
|
./src/elinks http://elinks.or.cz | head
|
||||||
|
elif [ "$1" = "https" ]; then
|
||||||
|
echo "[=] assumes You're running https server on port 9453"
|
||||||
|
echo "[=] see https_server option"
|
||||||
|
./src/elinks \
|
||||||
|
-eval 'set connection.ssl.cert_verify = 0' \
|
||||||
|
--dump https://127.0.0.1:9453 | head
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# HTTPS SERVER MENU
|
||||||
|
https_menu() {
|
||||||
|
HTTPS_OPTS="start_https stop_https certgen return"
|
||||||
|
echo "--[ https server menu ]--"
|
||||||
|
echo ""
|
||||||
|
echo " [*] use certgen to generate server certificate"
|
||||||
|
echo ""
|
||||||
|
select SEL in $HTTPS_OPTS; do
|
||||||
|
echo " [*] https server menu "
|
||||||
|
if [ "$SEL" = "start_https" ]; then
|
||||||
|
python3 ./test/server/https.py &
|
||||||
|
PID=`echo $!`
|
||||||
|
echo $PID > /tmp/eltmp.pid
|
||||||
|
echo "[*} Starting https server (pid $PID)"
|
||||||
|
elif [ "$SEL" = "stop_https" ]; then
|
||||||
|
PID=`cat /tmp/eltmp.pid`
|
||||||
|
echo "[*] Stopping https server (pid $PID)"
|
||||||
|
kill $PID
|
||||||
|
elif [ "$SEL" = "certgen" ]; then
|
||||||
|
echo "[*] generation ssl certificate for the https server"
|
||||||
|
./test/server/gen.sh
|
||||||
|
elif [ "$SEL" = "return" ]; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
# MAIN LOOP
|
# MAIN LOOP
|
||||||
prep_test hello
|
SEL = "none"
|
||||||
OPTS="hello exit"
|
OPTS="hello http https null null null null null null null https_server exit"
|
||||||
select SEL in $OPTS; do
|
select SEL in $OPTS; do
|
||||||
if [ ! "$SEL" = "exit" ]; then
|
echo "--[ Current test : " $SEL" ]--"
|
||||||
prep_test $SEL
|
if [ "$SEL" = "hello" ]; then
|
||||||
else
|
run_test $SEL
|
||||||
|
elif [ "$SEL" = "http" ]; then
|
||||||
|
run_test $SEL
|
||||||
|
elif [ "$SEL" = "https" ]; then
|
||||||
|
run_test $SEL
|
||||||
|
elif [ "$SEL" = "https_server" ]; then
|
||||||
|
https_menu
|
||||||
|
elif [ "$SEL" = "exit" ]; then
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
echo "--[ Current test : " $SEL" ]--"
|
|
||||||
done
|
done
|
||||||
|
22
test/server/gen.sh
Executable file
22
test/server/gen.sh
Executable file
@ -0,0 +1,22 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# generate certificate for elinks testing python3 server
|
||||||
|
#
|
||||||
|
# just execute and the certificate will be stored
|
||||||
|
# in /tmp/eltmp.pem
|
||||||
|
#
|
||||||
|
|
||||||
|
openssl req \
|
||||||
|
-new \
|
||||||
|
-x509 \
|
||||||
|
-keyout /tmp/eltmp.pem \
|
||||||
|
-out /tmp/eltmp.pem \
|
||||||
|
-days 365 \
|
||||||
|
-nodes \
|
||||||
|
-passout pass:"" \
|
||||||
|
-config <(echo '[req]';
|
||||||
|
echo distinguished_name=req;
|
||||||
|
echo '[san]';
|
||||||
|
echo subjectAltName=DNS:localhost,IP:127.0.0.1
|
||||||
|
) \
|
||||||
|
-subj '/CN=localhost'
|
36
test/server/https.py
Executable file
36
test/server/https.py
Executable file
@ -0,0 +1,36 @@
|
|||||||
|
#!/usr/bin/python3
|
||||||
|
#
|
||||||
|
# testing server for elinks https
|
||||||
|
#
|
||||||
|
# Note: Don't forget to generate the certificate using
|
||||||
|
# gen.sh
|
||||||
|
#
|
||||||
|
# if You provide the directory it serves it. The idea
|
||||||
|
# is to be run in the elinks test directory to provide
|
||||||
|
# test files.
|
||||||
|
#
|
||||||
|
# Note: has to be run from the test directory e.g. like this:
|
||||||
|
#
|
||||||
|
# $ ./server/https.py index.html
|
||||||
|
#
|
||||||
|
|
||||||
|
PORT = 9453
|
||||||
|
CERTFILE='/tmp/eltmp.pem'
|
||||||
|
|
||||||
|
import ssl
|
||||||
|
import http.server
|
||||||
|
import socketserver
|
||||||
|
|
||||||
|
handler = http.server.SimpleHTTPRequestHandler
|
||||||
|
|
||||||
|
with socketserver.TCPServer(('127.0.0.1', PORT), handler) as httpd:
|
||||||
|
print("[*] https server started at localhost:" + str(PORT))
|
||||||
|
httpd.socket = ssl.wrap_socket(
|
||||||
|
httpd.socket,
|
||||||
|
certfile=CERTFILE,
|
||||||
|
server_side=True
|
||||||
|
)
|
||||||
|
httpd.serve_forever()
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
run()
|
Loading…
Reference in New Issue
Block a user