1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

[ build ] added aarch64, testing https server

This commit is contained in:
Unknown 2022-04-23 20:14:21 +02:00
parent 77c98ab2a4
commit 1048811386
5 changed files with 170 additions and 25 deletions

1
.gitignore vendored
View File

@ -20,3 +20,4 @@ elinks
*.o
features.log
src/elinks.exe
test/server/__pycache__

View File

@ -1,8 +1,6 @@
#!/bin/bash
#
# shell script to build static elinks
# for differenct architectures with
# the same configuration
# shell script menus for elinks binaries building
#
clear
@ -28,6 +26,9 @@ configure() {
echo "--[ Host : " $2 "]--"
sleep 2
rm -f config.cache
# Thanks rkd77 for discovery of jemmaloc needed
# to correct openssl functionality
# LIBS="-ljemalloc -lpthread -lm" \
time \
CC=$1 \
LD=$2 \
@ -40,8 +41,8 @@ configure() {
--prefix=/usr \
--enable-256-colors \
--enable-fastmem \
--with-static \
--enable-utf-8 \
--with-static \
--without-openssl \
--without-quickjs \
--disable-88-colors \
@ -73,9 +74,13 @@ configure() {
# turn off warnings
sed -i 's/-Wall/-w/g' Makefile.config
#sed -i 's/-lpthread/-pthread/g' Makefile.config
build
#build
return 0
else
echo "--[ Listing errors in config.log ]--"
cat config.log | grep error
echo "--[ Configuration failed... ]--"
return 1
fi
}
@ -89,8 +94,10 @@ build() {
echo "--[ Build Sucessfull ]--"
echo "--[ All Done. ]--"
echo "--[ ................ ]--"
return 0
else
echo "--[ Build failed... ]--"
return 1
fi
}
@ -153,6 +160,14 @@ set_arch() {
BIN_SUFFIX=""
LDFLAGS=""
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
ARCHIT="$1"
CC="gcc"
@ -164,11 +179,37 @@ set_arch() {
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
ARCHIT=""
BIN_SUFFIX=""
ARCHS="lin64 win64 arm32"
CC_SEL="lin64 win64 arm32 native \
ARCHS="lin64 win64 arm32 arm64 native"
CC_SEL="arch null null null \
config make test \
pub debug \
info \
@ -176,14 +217,8 @@ build_all \
exit"
set_arch native
select SEL in $CC_SEL; do
if [ "$SEL" = "lin64" ]; then
set_arch lin64
elif [ "$SEL" = "win64" ]; then
set_arch win64
elif [ "$SEL" = "arm32" ]; then
set_arch arm32
elif [ "$SEL" = "native" ]; then
set_arch native
if [ "$SEL" = "arch" ]; then
arch_menu
elif [ "$SEL" = "make" ]; then
build
elif [ "$SEL" = "config" ]; then
@ -203,14 +238,22 @@ select SEL in $CC_SEL; do
echo "--[ Building: $arch ]--"
set_arch "$arch"
configure "$CC" "$LD" "$MAKE_HOST" "$LDFLAGS" "$LIBS"
if [ $? -eq 1 ]; then
break
fi
build
if [ $? -eq 1 ]; then
break
fi
info "$BIN_SUFFIX"
pub "$BIN_SUFFIX" "$ARCHIT"
done
elif [ "$SEL" = "null" ]; then
echo "[.] This option is intentially left blank"
elif [ "$SEL" = "exit" ]; then
exit
fi
echo "--[ elinks build system ]--"
echo "--[ [=] elinks build system main menu ]--"
echo "--[ Compiler: " $CC " ]--"
echo "--[ Host : " $MAKE_HOST " ]--"
done

61
test.sh
View File

@ -1,8 +1,10 @@
#!/bin/bash
#
# shell script to test elinks binary
# shell script menus for elinks binary testing
#
CUR_TEST=hello
clear
echo ' --/ \--'
@ -12,21 +14,62 @@ echo ' --[ [*] use option 1 to run dump test ]--'
echo ' --\ /--'
echo ' '
# SET TEST
prep_test() {
# RUN TEST
run_test() {
if [ "$1" = "hello" ]; then
./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
}
# 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
prep_test hello
OPTS="hello exit"
SEL = "none"
OPTS="hello http https null null null null null null null https_server exit"
select SEL in $OPTS; do
if [ ! "$SEL" = "exit" ]; then
prep_test $SEL
else
echo "--[ Current test : " $SEL" ]--"
if [ "$SEL" = "hello" ]; then
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
fi
echo "--[ Current test : " $SEL" ]--"
done

22
test/server/gen.sh Executable file
View 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
View 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()