-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
171 additions
and
2 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,13 @@ | ||
|
||
const info = { | ||
os_version: 'my os version', | ||
locale: 'fr', | ||
timestamp: new Date().toISOString(), | ||
fresh: true, | ||
type: "poll", // poll or error emun | ||
current_version: '1.2.3', | ||
prev_version: '0.1.2', | ||
}; | ||
|
||
process.stdout.write(JSON.stringify(info)); | ||
|
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,9 @@ | ||
|
||
#curl -v http://localhost:8080 | ||
#curl -H "Authorization: EDRLAB " -v http://localhost:8080 | ||
#curl -H "Authorization: EDRLAB rocks" -v http://localhost:8080 | ||
|
||
res=`node hmac.js` | ||
hmac=`echo $res | cut -d ' ' -f1` | ||
data=`echo $res | cut -d ' ' -f2-` | ||
echo "curl -H \"Authorization: EDRLAB $hmac\" -d '$data' -v http://localhost:8080" |
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 @@ | ||
|
||
# create database telemetry; | ||
|
||
# use telemetry; | ||
|
||
create table if not exists logs ( | ||
id int not null auto_increment, | ||
ts timestamp DEFAULT CURRENT_TIMESTAMP, | ||
os_version varchar(512) not null, | ||
locale varchar(8) not null, | ||
os_ts timestamp not null, | ||
fresh_install boolean not null, | ||
entry_type enum('poll', 'error') not null, | ||
current_version varchar(64) not null, | ||
prev_version varchar(64) not null, | ||
new_install boolean not null, | ||
error text, | ||
primary key(id) | ||
); | ||
|
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,16 @@ | ||
|
||
|
||
docker stop resty && docker rm resty | ||
docker build -f Dockerfile -t resty:latest . | ||
|
||
docker image inspect resty:latest | head | ||
|
||
docker run \ | ||
--env SECRET_KEY="hello world" \ | ||
--env DB_HOST="192.168.65.2" \ | ||
--env DB_NAME="telemetry" \ | ||
--env DB_USER="root" \ | ||
--env DB_PASS="hello" \ | ||
--name resty \ | ||
--publish 8080:80 \ | ||
resty:latest |
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 @@ | ||
const { createHmac } =require("crypto"); | ||
const { spawn } = require('node:child_process'); | ||
|
||
|
||
const bat = spawn('node', ['body.js']); | ||
|
||
bat.stdout.on('data', (data) => { | ||
process.stdout.write(`${telemetryHmac(data.toString())} ${data.toString()}`); | ||
}); | ||
|
||
const telemetryHmac = (body) => { | ||
|
||
const key = "hello world"; | ||
// find the key from fs or env-var // cf Daniel to hide it | ||
|
||
const hmac = createHmac("sha1", key); | ||
hmac.update(body, "utf8"); | ||
return hmac.digest("hex"); // length always 40 | ||
}; |
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,88 @@ | ||
# nginx.conf -- docker-openresty | ||
# | ||
# This file is installed to: | ||
# `/usr/local/openresty/nginx/conf/nginx.conf` | ||
# and is the file loaded by nginx at startup, | ||
# unless the user specifies otherwise. | ||
# | ||
# It tracks the upstream OpenResty's `nginx.conf`, but removes the `server` | ||
# section and adds this directive: | ||
# `include /etc/nginx/conf.d/*.conf;` | ||
# | ||
# The `docker-openresty` file `nginx.vh.default.conf` is copied to | ||
# `/etc/nginx/conf.d/default.conf`. It contains the `server section | ||
# of the upstream `nginx.conf`. | ||
# | ||
# See https://github.com/openresty/docker-openresty/blob/master/README.md#nginx-config-files | ||
# | ||
|
||
#user nobody; | ||
#worker_processes 1; | ||
|
||
# Enables the use of JIT for regular expressions to speed-up their processing. | ||
pcre_jit on; | ||
|
||
#error_log logs/error.log; | ||
error_log /dev/stdout notice; | ||
#error_log logs/error.log info; | ||
|
||
#pid logs/nginx.pid; | ||
|
||
|
||
events { | ||
worker_connections 1024; | ||
} | ||
|
||
|
||
http { | ||
include mime.types; | ||
default_type application/octet-stream; | ||
|
||
# Enables or disables the use of underscores in client request header fields. | ||
# When the use of underscores is disabled, request header fields whose names contain underscores are marked as invalid and become subject to the ignore_invalid_headers directive. | ||
# underscores_in_headers off; | ||
|
||
#log_format main '$remote_addr - $remote_user [$time_local] "$request" ' | ||
# '$status $body_bytes_sent "$http_referer" ' | ||
# '"$http_user_agent" "$http_x_forwarded_for"'; | ||
|
||
#access_log logs/access.log main; | ||
|
||
# Log in JSON Format | ||
log_format nginxlog_json escape=json '{ "timestamp": "$time_iso8601", ' | ||
'"remote_addr": "$remote_addr", ' | ||
'"body_bytes_sent": $body_bytes_sent, ' | ||
'"request_time": $request_time, ' | ||
'"response_status": $status, ' | ||
'"request": "$request", ' | ||
'"request_method": "$request_method", ' | ||
'"host": "$host",' | ||
'"upstream_addr": "$upstream_addr",' | ||
'"http_x_forwarded_for": "$http_x_forwarded_for",' | ||
'"http_referrer": "$http_referer", ' | ||
'"http_user_agent": "$http_user_agent", ' | ||
'"http_version": "$server_protocol", ' | ||
'"nginx_access": true }'; | ||
access_log /dev/stdout nginxlog_json; | ||
|
||
# See Move default writable paths to a dedicated directory (#119) | ||
# https://github.com/openresty/docker-openresty/issues/119 | ||
client_body_temp_path /var/run/openresty/nginx-client-body; | ||
#proxy_temp_path /var/run/openresty/nginx-proxy; | ||
#fastcgi_temp_path /var/run/openresty/nginx-fastcgi; | ||
#uwsgi_temp_path /var/run/openresty/nginx-uwsgi; | ||
#scgi_temp_path /var/run/openresty/nginx-scgi; | ||
|
||
#sendfile on; | ||
#tcp_nopush on; | ||
|
||
#keepalive_timeout 0; | ||
keepalive_timeout 65; | ||
|
||
#gzip on; | ||
|
||
include /etc/nginx/conf.d/nginx.conf; | ||
|
||
# Don't reveal OpenResty version to clients. | ||
server_tokens off; | ||
} |
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 @@ | ||
|