-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace Python HTTP server with custom C++ one
- Loading branch information
Showing
14 changed files
with
493 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
project(annotate) | ||
cmake_minimum_required(VERSION 3.0) | ||
|
||
set(CMAKE_CXX_STANDARD 20) | ||
|
||
add_executable(webserver webserver/webserver.cpp) | ||
add_executable(genkey webserver/genkey.cpp) | ||
|
||
install(TARGETS webserver genkey DESTINATION bin) | ||
install(DIRECTORY www assets DESTINATION .) | ||
install(FILES annotate.apparmor | ||
annotate.desktop | ||
annotate-contenthub.json | ||
LICENSE | ||
manifest.json | ||
README.md | ||
DESTINATION .) | ||
install(PROGRAMS run.sh DESTINATION .) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
{ | ||
"template": "unconfined", | ||
"template": "ubuntu-webapp", | ||
"policy_groups": [ | ||
"webview", | ||
"networking", | ||
"content_exchange" | ||
"content_exchange", | ||
"content_exchange_source" | ||
], | ||
"policy_version": 20.04 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
clickable_minimum_required: 7.1.2 | ||
builder: pure | ||
clickable_minimum_required: 8.0.0 | ||
builder: cmake | ||
kill: webapp-container* | ||
framework: ubuntu-sdk-20.04 | ||
skip_review: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,7 @@ | ||
#!/bin/bash | ||
|
||
cd www | ||
|
||
# The key only provides weak security. The key can be obtained with `ps -aux`. It's mostly meant to avoid mistakes. | ||
export ANNOTATE_KEY="$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | head -c 64)" | ||
export ANNOTATE_KEY="$(./bin/genkey)" | ||
|
||
python3 -m http.server --cgi --bind 127.0.0.1 9283 & | ||
webapp-container --app-id="annotate.semphris" http://localhost:9283/?key=$ANNOTATE_KEY | ||
./bin/webserver & | ||
webapp-container --app-id="annotate.semphris" http://localhost:9283/index.html?key=$ANNOTATE_KEY |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include <iostream> | ||
#include <string> | ||
#include <sys/random.h> | ||
|
||
int main() { | ||
char buffer[65]; | ||
char *ptr = buffer; | ||
|
||
while (ptr != buffer + 64) { | ||
getrandom(ptr, 1, 0); | ||
char c = *ptr; | ||
if (c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z' || c >= '0' && c <= '9') { | ||
ptr++; | ||
} | ||
} | ||
*ptr = '\0'; | ||
|
||
std::cout << buffer << std::flush; | ||
return 0; | ||
} |
Oops, something went wrong.