diff --git a/.gitignore b/.gitignore index f04f5a9..d1ca2a8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,6 @@ -/curl -/curl-wasm -/openssl -/openssl-wasm +/client/build +/client/out +/client/cacert.pem +/client/libcurl.data /srelay* -/websockify -/a.out* -/cacert.pem \ No newline at end of file +/websockify \ No newline at end of file diff --git a/build.sh b/build.sh deleted file mode 100755 index bd74d52..0000000 --- a/build.sh +++ /dev/null @@ -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 \ No newline at end of file diff --git a/client/build.sh b/client/build.sh new file mode 100755 index 0000000..5db64ab --- /dev/null +++ b/client/build.sh @@ -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 ./ \ No newline at end of file diff --git a/index.html b/client/index.html similarity index 74% rename from index.html rename to client/index.html index bf8d038..55bd031 100644 --- a/index.html +++ b/client/index.html @@ -1,7 +1,7 @@
- + diff --git a/main.c b/client/main.c similarity index 99% rename from main.c rename to client/main.c index 8fb91d0..37e4e61 100644 --- a/main.c +++ b/client/main.c @@ -31,4 +31,4 @@ int main() { curl_easy_cleanup(curl); } return 0; -} +} \ No newline at end of file diff --git a/main.js b/client/main.js similarity index 53% rename from main.js rename to client/main.js index d758e1f..03b568e 100644 --- a/main.js +++ b/client/main.js @@ -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) { return allocate(intArrayFromString(str), ALLOC_NORMAL); } -function websocket_connect(websocket) { - return new Promise((resolve, reject) => { - websocket.onopen = () => {resolve()} - websocket.onerror = () => {reject()} - }) -} - async function main() { } window.onload = () => { console.log("page loaded, waiting for emscripten module load"); + //Module.websocket.url = websocket_url; Module.onRuntimeInitialized = main; }; \ No newline at end of file diff --git a/curl.sh b/client/tools/curl.sh similarity index 88% rename from curl.sh rename to client/tools/curl.sh index 949bf96..9bdd4ed 100755 --- a/curl.sh +++ b/client/tools/curl.sh @@ -3,8 +3,8 @@ #compile openssl for use with emscripten CORE_COUNT=$(nproc --all) -PREFIX=$(realpath curl-wasm) -OPENSSL_PREFIX=$(realpath openssl-wasm) +PREFIX=$(realpath build/curl-wasm) +OPENSSL_PREFIX=$(realpath build/openssl-wasm) mkdir -p $PREFIX rm -rf curl diff --git a/openssl.sh b/client/tools/openssl.sh similarity index 94% rename from openssl.sh rename to client/tools/openssl.sh index a39b5f2..4ab8ae3 100755 --- a/openssl.sh +++ b/client/tools/openssl.sh @@ -3,7 +3,7 @@ #compile openssl for use with emscripten CORE_COUNT=$(nproc --all) -PREFIX=$(realpath openssl-wasm) +PREFIX=$(realpath build/openssl-wasm) mkdir -p $PREFIX rm -rf openssl