mirror of
https://github.com/ading2210/libcurl.js.git
synced 2025-05-12 22:10:01 -04:00
reorganize client code
This commit is contained in:
parent
27aa9ff74c
commit
643fc8e463
8 changed files with 32 additions and 26 deletions
10
.gitignore
vendored
10
.gitignore
vendored
|
@ -1,8 +1,6 @@
|
||||||
/curl
|
/client/build
|
||||||
/curl-wasm
|
/client/out
|
||||||
/openssl
|
/client/cacert.pem
|
||||||
/openssl-wasm
|
/client/libcurl.data
|
||||||
/srelay*
|
/srelay*
|
||||||
/websockify
|
/websockify
|
||||||
/a.out*
|
|
||||||
/cacert.pem
|
|
6
build.sh
6
build.sh
|
@ -1,6 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
if [ ! -f cacert.pem ]; then
|
|
||||||
wget "https://curl.se/ca/cacert.pem"
|
|
||||||
fi
|
|
||||||
emcc main.c -lcurl -lssl -lcrypto -I curl-wasm/include/ -L curl-wasm/lib/ -lwebsocket.js -sWEBSOCKET_URL=wss://debug.ading.dev/ws -pthread -sPROXY_TO_PTHREAD --preload-file cacert.pem -Os
|
|
19
client/build.sh
Executable file
19
client/build.sh
Executable file
|
@ -0,0 +1,19 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
INCLUDE_DIR="build/curl-wasm/include/"
|
||||||
|
LIB_DIR="build/curl-wasm/lib/"
|
||||||
|
CACERT_FILE="cacert.pem"
|
||||||
|
OUT_FILE="out/libcurl.js"
|
||||||
|
|
||||||
|
EXPORTED_FUNCS="_main"
|
||||||
|
COMPILER_OPTIONS="-o $OUT_FILE -Os -lcurl -lssl -lcrypto -I $INCLUDE_DIR -L $LIB_DIR"
|
||||||
|
EMSCRIPTEN_OPTIONS="-lwebsocket.js -sWEBSOCKET_URL=wss://debug.ading.dev/ws -pthread -sPROXY_TO_PTHREAD -sEXPORTED_FUNCTIONS=$EXPORTED_FUNCS --preload-file $CACERT_FILE"
|
||||||
|
|
||||||
|
if [ ! -f $CACERT_FILE ]; then
|
||||||
|
wget "https://curl.se/ca/cacert.pem" -O $CACERT_FILE
|
||||||
|
fi
|
||||||
|
|
||||||
|
COMPILE_CMD="emcc main.c $COMPILER_OPTIONS $EMSCRIPTEN_OPTIONS"
|
||||||
|
echo $COMPILE_CMD
|
||||||
|
$COMPILE_CMD
|
||||||
|
mv out/libcurl.data ./
|
|
@ -1,7 +1,7 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<script src="./a.out.js"></script>
|
<script src="./out/libcurl.js"></script>
|
||||||
<script src="./main.js"></script>
|
<script src="./main.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
|
@ -1,21 +1,16 @@
|
||||||
const wsproxy_base = "wss://anura.pro/";
|
const cacert_path = "./out/cacert.peem";
|
||||||
|
const websocket_url = `wss://${location.hostname}/ws`;
|
||||||
|
|
||||||
function allocate_str(str) {
|
function allocate_str(str) {
|
||||||
return allocate(intArrayFromString(str), ALLOC_NORMAL);
|
return allocate(intArrayFromString(str), ALLOC_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
function websocket_connect(websocket) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
websocket.onopen = () => {resolve()}
|
|
||||||
websocket.onerror = () => {reject()}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
window.onload = () => {
|
window.onload = () => {
|
||||||
console.log("page loaded, waiting for emscripten module load");
|
console.log("page loaded, waiting for emscripten module load");
|
||||||
|
//Module.websocket.url = websocket_url;
|
||||||
Module.onRuntimeInitialized = main;
|
Module.onRuntimeInitialized = main;
|
||||||
};
|
};
|
|
@ -3,8 +3,8 @@
|
||||||
#compile openssl for use with emscripten
|
#compile openssl for use with emscripten
|
||||||
|
|
||||||
CORE_COUNT=$(nproc --all)
|
CORE_COUNT=$(nproc --all)
|
||||||
PREFIX=$(realpath curl-wasm)
|
PREFIX=$(realpath build/curl-wasm)
|
||||||
OPENSSL_PREFIX=$(realpath openssl-wasm)
|
OPENSSL_PREFIX=$(realpath build/openssl-wasm)
|
||||||
mkdir -p $PREFIX
|
mkdir -p $PREFIX
|
||||||
|
|
||||||
rm -rf curl
|
rm -rf curl
|
|
@ -3,7 +3,7 @@
|
||||||
#compile openssl for use with emscripten
|
#compile openssl for use with emscripten
|
||||||
|
|
||||||
CORE_COUNT=$(nproc --all)
|
CORE_COUNT=$(nproc --all)
|
||||||
PREFIX=$(realpath openssl-wasm)
|
PREFIX=$(realpath build/openssl-wasm)
|
||||||
mkdir -p $PREFIX
|
mkdir -p $PREFIX
|
||||||
|
|
||||||
rm -rf openssl
|
rm -rf openssl
|
Loading…
Add table
Add a link
Reference in a new issue