diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c1dde64 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,87 @@ + +# --==--==--==--==--==--==--==--==--==--==--==--==--==--==-- # +# Base image +# --==--==--==--==--==--==--==--==--==--==--==--==--==--==-- # +FROM kalilinux/kali-rolling:latest + +# --==--==--==--==--==--==--==--==--==--==--==--==--==--==-- # +# Environnement +# --==--==--==--==--==--==--==--==--==--==--==--==--==--==-- # +WORKDIR /www +ENV PATH="/root/.nimble/bin:$PATH" +RUN echo "export PATH=/root/.nimble/bin:$PATH" >> /root/.bashrc + +# --==--==--==--==--==--==--==--==--==--==--==--==--==--==-- # +# update and install os requirements +# --==--==--==--==--==--==--==--==--==--==--==--==--==--==-- # +RUN apt-get update +RUN apt-get install -y bash +# RUN curl -sL https://deb.nodesource.com/setup_16.x | bash - +RUN apt-get install -y curl wget gcc xz-utils git libsqlite3-dev +RUN apt-get install -y npm nodejs + +# --==--==--==--==--==--==--==--==--==--==--==--==--==--==-- # +# install pkgs for DEV and debug +# --==--==--==--==--==--==--==--==--==--==--==--==--==--==-- # +RUN apt-get install -y htop net-tools + +# --==--==--==--==--==--==--==--==--==--==--==--==--==--==-- # +# install Joplin terminal +# --==--==--==--==--==--==--==--==--==--==--==--==--==--==-- # +RUN node -v +RUN npm -v +RUN NPM_CONFIG_PREFIX=~/.joplin-bin npm install -g joplin +RUN ln -s /root/.joplin-bin/bin/joplin /usr/bin/joplin + +# --==--==--==--==--==--==--==--==--==--==-- # +# Joplin DEV Configuration +# --==--==--==--==--==--==--==--==--==--==-- # +RUN joplin config sync.target 9 +RUN joplin config sync.9.path https://joplinlab.bcmaison.cf +RUN joplin config sync.9.username joplinlab@zohomail.com +RUN joplin config sync.9.password Chab30017405 +RUN joplin config locale en_US +COPY config/settings.json /root/.config/joplin +RUN joplin sync + +# --==--==--==--==--==--==--==--==--==--==--==--==--==--==-- # +# install nim language +# --==--==--==--==--==--==--==--==--==--==--==--==--==--==-- # +RUN wget https://nim-lang.org/choosenim/init.sh +RUN sh init.sh -y + +# --==--==--==--==--==--==--==--==--==--==--==--==--==--==-- # +# install nim requirments +# --==--==--==--==--==--==--==--==--==--==--==--==--==--==-- # +RUN nimble install -y jester bcrypt templates xlsx zip + +# --==--==--==--==--==--==--==--==--==--==--==--==--==--==-- # +# copy reverse proxy +# --==--==--==--==--==--==--==--==--==--==--==--==--==--==-- # +COPY mitmproxy/mitmweb /www/mitmproxy/mitmweb + +# --==--==--==--==--==--==--==--==--==--==--==--==--==--==-- # +# copy project +# --==--==--==--==--==--==--==--==--==--==--==--==--==--==-- # +COPY config /www/config +ADD data /www/data +ADD nim-lib /www/nim-lib +ADD public /www/public +ADD tmpl /www/tmpl +COPY config.nims /www +COPY main.nim /www +COPY start_main.sh /www + + +# --==--==--==--==--==--==--==--==--==--==--==--==--==--==-- # +# Project nim compilation +# --==--==--==--==--==--==--==--==--==--==--==--==--==--==-- # +RUN nimble list -i +RUN nim c -f ./main.nim + +# --==--==--==--==--==--==--==--==--==--==--==--==--==--==-- # +# Start Joplin-TheNewWeb +# --==--==--==--==--==--==--==--==--==--==--==--==--==--==-- # + +CMD ["/www/start_main.sh"] + diff --git a/build_main.sh b/build_main.sh index 148ab48..5669247 100755 --- a/build_main.sh +++ b/build_main.sh @@ -1,6 +1,9 @@ +#!/bin/bash # --==--==--==--==--==--==--==--==--==--==-- # # All configuration are inside the file: # ==> config.nims # -nim c -r main.nim # --==--==--==--==--==--==--==--==--==--==-- # + +nim c -r ./main.nim + diff --git a/code/Dockerfile b/code/Dockerfile deleted file mode 100644 index 2fe02ae..0000000 --- a/code/Dockerfile +++ /dev/null @@ -1,39 +0,0 @@ -# For more information, please refer to https://aka.ms/vscode-docker-python -FROM python:3.9-alpine as compile-image -# Install pip requirements -COPY requirements.txt . -RUN apk add --virtual .build-deps gcc libffi-dev musl-dev -RUN pip install --user -r requirements.txt - - - -FROM python:3.9-alpine - -# add nginx -EXPOSE 80 -RUN apk add --no-cache nginx -RUN adduser -D -g 'www' www -RUN mkdir /www -RUN chown -R www:www /var/lib/nginx -RUN chown -R www:www /www -RUN mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.orig -COPY settings/nginx.conf /etc/nginx/nginx.conf - -# Keeps Python from generating .pyc files in the container -ENV PYTHONDONTWRITEBYTECODE=1 -# Turns off buffering for easier container logging -ENV PYTHONUNBUFFERED=1 - -COPY --from=compile-image /root/.local /root/.local -ENV PATH=/root/.local/bin:$PATH -WORKDIR /app -COPY . /app - -# Creates a non-root user with an explicit UID and adds permission to access the /app folder -# For more info, please refer to https://aka.ms/vscode-docker-python-configure-containers -#RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /app -#USER appuser - -# During debugging, this entry point will be overridden. For more information, please refer to https://aka.ms/vscode-docker-python-debug -RUN chmod +x /app/runserver.sh -CMD ["/bin/sh", "/app/runserver.sh"] \ No newline at end of file diff --git a/config/config.cfg b/config/config.cfg index af3d5da..04adc8d 100644 --- a/config/config.cfg +++ b/config/config.cfg @@ -13,7 +13,7 @@ pass = "" # Server : informations related to server side # --==--==--==--==--==--==--==--==--==--==-- # [Server] -website = "https://127.0.0.1:7000" +website = "http://127.0.0.1:7000" title = "Joplin The New Web" url = "127.0.0.1" port = "7000" @@ -26,7 +26,7 @@ port = "7000" #Joplin DESKTOP token #token = "e5f6644fbf6a97ddc55648dae72b11caecda6c6642d8ce0d3b20129b89b196385737eb908923542c3343649ebbf865b55bda031ab4c3a16edc7723ef2ad77d8f" # Joplin CLI token -token = "76d06ec328466c872f3a944f8237fd96f18d2b953ff013c8689304b7384f2f2232b3aedff079902217760e8fa180d1b89d2650ee1819dd628678fccdc0a140a6" +token = "20e85386579acca0040dcb5da3b4996dc142aef4500ff50b907f701cdc50bb11694f715e567d8d4a4b35f95172cba8fd3b5c5eb98ff889b1118e94a9cbd296db" joplin_server = "https://joplinlab.bcmaison.cf" joplin_server_user = "joplinlab@zohomail.com" joplin_server_pwd = "Chab30017405" \ No newline at end of file diff --git a/config/settings.json b/config/settings.json new file mode 100644 index 0000000..b1881a0 --- /dev/null +++ b/config/settings.json @@ -0,0 +1,10 @@ +{ + "$schema": "https://joplinapp.org/schema/settings.json", + "locale": "en_US", + "api.token": "20e85386579acca0040dcb5da3b4996dc142aef4500ff50b907f701cdc50bb11694f715e567d8d4a4b35f95172cba8fd3b5c5eb98ff889b1118e94a9cbd296db", + "markdown.plugin.softbreaks": false, + "markdown.plugin.typographer": false, + "sync.target": 9, + "sync.9.path": "https://joplinlab.bcmaison.cf", + "sync.9.username": "joplinlab@zohomail.com" +} \ No newline at end of file diff --git a/data/toto.txt b/data/toto.txt deleted file mode 100644 index 42e5029..0000000 --- a/data/toto.txt +++ /dev/null @@ -1 +0,0 @@ -SQLiteDatabase \ No newline at end of file diff --git a/data/~$dashbord.xlsx b/data/~$dashbord.xlsx new file mode 100644 index 0000000..6a5a056 Binary files /dev/null and b/data/~$dashbord.xlsx differ diff --git a/docker_build.sh b/docker_build.sh new file mode 100644 index 0000000..41a84aa --- /dev/null +++ b/docker_build.sh @@ -0,0 +1 @@ +docker build -t joplin-thenewweb:latest . diff --git a/docker_run.sh b/docker_run.sh new file mode 100644 index 0000000..e5b0da4 --- /dev/null +++ b/docker_run.sh @@ -0,0 +1 @@ +docker run --rm -d -p 7000:7000 -p 8081:8081 -p 7777:7777 --name joplin-thenewweb joplin-thenewweb diff --git a/main.nim b/main.nim index 698b00f..e8b1e29 100644 --- a/main.nim +++ b/main.nim @@ -50,7 +50,7 @@ let db_host = dict.getSectionValue("Database", "host") # Website let mainURL = dict.getSectionValue("Server", "url") let mainPort = parseInt dict.getSectionValue("Server", "port") - #let mainWebsite = dict.getSectionValue("Server", "website") +let mainWebsite = dict.getSectionValue("Server", "website") # Joplin let joplin_token = dict.getSectionValue("Joplin", "token") @@ -359,16 +359,18 @@ routes: elif @"msg" == "sendFeedBack": echo "Todo" - resp Http200, {"Access-Control-Allow-Origin": "http://127.0.0.1:7000"}, - genSecret(c, cld, crd) + #resp Http200, {"Access-Control-Allow-Origin": "http://127.0.0.1:7000"}, + #resp Http200, + resp genSecret(c, cld, crd) # Login route # --==--==--==--==--==--==--==--==--==--==-- # get "/login": createTFD() - resp Http200, {"Access-Control-Allow-Origin": "http://127.0.0.1:7000"}, - genLogin(c, @"msg") + #resp Http200, {"Access-Control-Allow-Origin": "http://127.0.0.1:7000"}, + #resp Http200, + resp genLogin(c, @"msg") # action route during login # --==--==--==--==--==--==--==--==--==--==-- # diff --git a/mitmproxy/cors.py b/mitmproxy/cors.py new file mode 100644 index 0000000..e1ecfed --- /dev/null +++ b/mitmproxy/cors.py @@ -0,0 +1,16 @@ +from mitmproxy import http + +def response(flow): + flow.response.headers["Access-Control-Allow-Origin"] = "*" + + # Use this if the application sends auth info via header + flow.response.headers["Access-Control-Expose-Headers"] = "Authorization" + +def request(flow): + # Hijack CORS OPTIONS request + if flow.request.method == "OPTIONS": + flow.response = http.HTTPResponse.make(200, b"", + {"Access-Control-Allow-Origin": "*", + "Access-Control-Allow-Methods": "GET,POST", + "Access-Control-Allow-Headers": "Authorization", + "Access-Control-Max-Age": "1728000"}) \ No newline at end of file diff --git a/mitmproxy/mitmdump b/mitmproxy/mitmdump new file mode 100644 index 0000000..cfcab1c Binary files /dev/null and b/mitmproxy/mitmdump differ diff --git a/mitmproxy/mitmproxy b/mitmproxy/mitmproxy new file mode 100644 index 0000000..20863db Binary files /dev/null and b/mitmproxy/mitmproxy differ diff --git a/mitmproxy/mitmweb b/mitmproxy/mitmweb new file mode 100644 index 0000000..14ad103 Binary files /dev/null and b/mitmproxy/mitmweb differ diff --git a/start_main.sh b/start_main.sh new file mode 100644 index 0000000..3186725 --- /dev/null +++ b/start_main.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +# Start Proxy +# /www/mitmproxy/mitmweb -s cors.py -p 7777 --mode reverse:http://127.0.0.1:7000/ & + +#/www/mitmproxy/mitmweb -s cors.py -R http://192.168.0.163:7777 -b localhost -p 7000 + +# Start main Program +/www/main \ No newline at end of file diff --git a/tmpl/website.nim b/tmpl/website.nim index 561c814..7ad88e2 100644 --- a/tmpl/website.nim +++ b/tmpl/website.nim @@ -23,8 +23,7 @@ - - +