Day 4: Simple proof oc concept
Signed-off-by: Aaron Fischer <mail@aaron-fischer.net>
This commit is contained in:
parent
e1b698f82a
commit
3ef14ce028
7 changed files with 134 additions and 12 deletions
10
gemini-server-test/cmd/entries.log.gmi
Normal file
10
gemini-server-test/cmd/entries.log.gmi
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
# Server log
|
||||||
|
|
||||||
|
## 2024-12-04 23:34 UTC
|
||||||
|
This is a simple entry, with multiple lines of text. This should showcase how this is intended.
|
||||||
|
|
||||||
|
## 2024-12-04 23:36 UTC
|
||||||
|
Another entry. This is a good start and template what to build with Zig. Sadly, twins can not redirect the path to the command, so I can not do the routing in the command and it need to be inside the twins config file. But I am fine with that for now.
|
||||||
|
|
||||||
|
## 2024-12-04 23:38 UTC
|
||||||
|
What's missing is checking for a client certificate. I am not sure if twins is supporting this. Maybe open up an issue in the bugtracker?
|
18
gemini-server-test/cmd/run.sh
Normal file
18
gemini-server-test/cmd/run.sh
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
case $1 in
|
||||||
|
"list")
|
||||||
|
echo "=> /create Create new entry"
|
||||||
|
cat /app/cmd/entries.log.gmi
|
||||||
|
;;
|
||||||
|
"create")
|
||||||
|
echo "" >> /app/cmd/entries.log.gmi
|
||||||
|
date=$(date -u +"%Y-%m-%d %H:%M %Z")
|
||||||
|
echo "## $date" >> /app/cmd/entries.log.gmi
|
||||||
|
while IFS= read -r line; do
|
||||||
|
echo $line >> /app/cmd/entries.log.gmi
|
||||||
|
done
|
||||||
|
echo "Entry created."
|
||||||
|
echo "=> / Back to the log entries"
|
||||||
|
;;
|
||||||
|
esac
|
|
@ -7,12 +7,13 @@ services:
|
||||||
volumes:
|
volumes:
|
||||||
- ./config:/app/config
|
- ./config:/app/config
|
||||||
- ./public_gmi:/public_gmi
|
- ./public_gmi:/public_gmi
|
||||||
|
- ./cmd:/app/cmd
|
||||||
|
|
||||||
december-adventure:
|
# december-adventure:
|
||||||
image: alpine:latest
|
# image: alpine:latest
|
||||||
restart: unless-stopped
|
# restart: unless-stopped
|
||||||
ports:
|
# ports:
|
||||||
- 9001:9001
|
# - 9001:9001
|
||||||
volumes:
|
# volumes:
|
||||||
- ../zig-out/bin/:/run
|
# - ../zig-out/bin/:/run
|
||||||
command: ["sh", "-c", "cd /run && ./december-adventure-2024"]
|
# command: ["sh", "-c", "cd /run && ./december-adventure-2024"]
|
||||||
|
|
34
gemini-server-test/config/cert.pem
Normal file
34
gemini-server-test/config/cert.pem
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIF1zCCA7+gAwIBAgIUCaVblWWDFz3pw7eTn3ODyA4o73kwDQYJKoZIhvcNAQEL
|
||||||
|
BQAwezELMAkGA1UEBhMCWFgxEjAQBgNVBAgMCVN0YXRlTmFtZTERMA8GA1UEBwwI
|
||||||
|
Q2l0eU5hbWUxFDASBgNVBAoMC0NvbXBhbnlOYW1lMRswGQYDVQQLDBJDb21wYW55
|
||||||
|
U2VjdGlvbk5hbWUxEjAQBgNVBAMMCWxvY2FsaG9zdDAeFw0yNDEyMDIyMjQ1MTBa
|
||||||
|
Fw0zNDExMzAyMjQ1MTBaMHsxCzAJBgNVBAYTAlhYMRIwEAYDVQQIDAlTdGF0ZU5h
|
||||||
|
bWUxETAPBgNVBAcMCENpdHlOYW1lMRQwEgYDVQQKDAtDb21wYW55TmFtZTEbMBkG
|
||||||
|
A1UECwwSQ29tcGFueVNlY3Rpb25OYW1lMRIwEAYDVQQDDAlsb2NhbGhvc3QwggIi
|
||||||
|
MA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC3c57FScdRymWU1K4ScAwzJ46V
|
||||||
|
bxAMItfWoNuG3CQusu14K56fnpvyHlRWGZTrlyWZOf/+3FDx4Y01iqbiwhneGsfO
|
||||||
|
LIgES0iCnou1Xk26bbTUSf6HnV6pdOG85T2SmSiMz8yJQb7SdypaHqjwYIPxn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M5CKjta/z6u93ba15PfoBvl1vSTLHPlGR
|
||||||
|
Y3sOj9uphabC2jc1SWVVobA5IuD8Wx5pqUpzEJpJFS7sauXmzyUuh5z+SbFVvkR+
|
||||||
|
IF/+hYn/G7emMG8q4UqET5mdftFBLEIC4NBsNjEItBUnZxUKW8KAA8FRYKfh1+Ly
|
||||||
|
0tzDedHe6UOrqXBisDhakx7GX66VVpBQqeS0+BrTk0SIHFli2fUG++t/E7pefS1f
|
||||||
|
qsOo/6TK6v5hqblqBXbG8fWA9Oo0zRj9i59WhxJTN4SPoK49LdR0p5JvtZ3unvrq
|
||||||
|
NnqdV5/zkA5gPhuoILjE7V5U6Q/JdxHDsPgaGQ1HvQ0mX8cHXLmiVCm4elbluAzG
|
||||||
|
Z52yP7rbanu0IVE3l7aNizD8T4VsH7GbgJl9b+S2Wk+5dZdekuFjNrjbXYmEroiM
|
||||||
|
dHOiUuTzTfU8JV0=
|
||||||
|
-----END CERTIFICATE-----
|
52
gemini-server-test/config/key.pem
Normal file
52
gemini-server-test/config/key.pem
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
-----BEGIN PRIVATE KEY-----
|
||||||
|
MIIJQQIBADANBgkqhkiG9w0BAQEFAASCCSswggknAgEAAoICAQC3c57FScdRymWU
|
||||||
|
1K4ScAwzJ46VbxAMItfWoNuG3CQusu14K56fnpvyHlRWGZTrlyWZOf/+3FDx4Y01
|
||||||
|
iqbiwhneGsfOLIgES0iCnou1Xk26bbTUSf6HnV6pdOG85T2SmSiMz8yJQb7Sdypa
|
||||||
|
HqjwYIPxnUUykC7qGa7giyr+OGqq+i/tp3hyuOD4RTXfvJMV614p4+NrkzIkt8bt
|
||||||
|
JmSEywcPsl/BI7LA8TOkPbllF/BkdZYOzvFqr9jW+3n1Y2/eo/Dfi203slL58LhY
|
||||||
|
av04bAZhguVMU5U3yJEIN0Za9Ti1pmj1iHTWm/VIqmpYgco+iwQJzjdSkNDeTnwB
|
||||||
|
EFWrgCg7JzRNAXM5Dib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+
|
||||||
|
TXkv0W2Yf4SB/X+FhsJ+ImGo6jeh/rzg7HbONDduP0rWJraPdOTaHuLJTHN7dwye
|
||||||
|
NLxd0jxYLLs5QVmtKkSPB91e13UdQtcWpvytrX2jGcZUtOtQeZ+AHFUUkj+AwFJH
|
||||||
|
1bevqAEZTNpFhgkJfsA9M3R2gvZ2MYC70GOJciUCggEAbbB1Ql88mBr3juNFgbk5
|
||||||
|
9tB2RO5hMNvHGP6VVuhJP6PmZ4F5FYjvmi1be52/0rvJU+FMA3QqrB0QM9R6x/Hd
|
||||||
|
npoanGdGQgR2tN57Y5ihd0dwKzrWxYqLSQPt27JB8JPwJv3JTlzg4UYmwbdP2pMF
|
||||||
|
mSNQ+JF24Q135bwWNWew+rKFGvavGTR0eMtACrT5VnDchie6acWqnhzWmErk/aZd
|
||||||
|
oOoRvQo2DhNGQvbXM4jzgfSTSqiPM9aLX7W5Ce/HggeYHSZNtSY2jlgGSycj7+kO
|
||||||
|
9ROrGS6hhOWJGryaDSoIQbigquhvRUN6pvSeTjpbEpmatYgJq2L+YfWcTCcCEPnw
|
||||||
|
SQKCAQAO0bf/1FCFdMqYZWjElSdRnEaZfknqybrVZln4mLKUzj7JC4BbLOLTBcd6
|
||||||
|
1PfPTNO/HROaia5K8IRLhL8dZONnVxHY4iubGQ31RzN5AOAFwfffax0q5v9BWthy
|
||||||
|
s5SsCQMsdcYw6qSLGidCNl6/JJ+qIXoAeo/xSVlzv/MpU478eCfq1Za1dGcvFWDt
|
||||||
|
zEb/jWCn2FNRNHMU9Zj8+d95dVpO88uvL1UZzwgLtS0h9MgHUBiUlpJflTQ1rfVO
|
||||||
|
5eZbHzhNMHdKLLtJ+2QMA5rnXcULBjH8AlyP9yskQ/3c5/cBMAWNnkaL6z/JwW1X
|
||||||
|
8HBMyLiVB0L3BJYT3REa+l9egX9r
|
||||||
|
-----END PRIVATE KEY-----
|
|
@ -1,9 +1,16 @@
|
||||||
listen: :1965
|
listen: :1965
|
||||||
|
|
||||||
hosts:
|
hosts:
|
||||||
default:
|
localhost:
|
||||||
|
cert: /app/config/cert.pem
|
||||||
|
key: /app/config/key.pem
|
||||||
paths:
|
paths:
|
||||||
|
-
|
||||||
|
path: /create
|
||||||
|
input: Provide new Log entry
|
||||||
|
command: /bin/sh /app/cmd/run.sh create "$USERINPUT"
|
||||||
|
cache: 0
|
||||||
-
|
-
|
||||||
path: /
|
path: /
|
||||||
root: /public_gmi
|
command: /bin/sh /app/cmd/run.sh list
|
||||||
fastcgi: tcp://december-adventure:9001
|
cache: 0
|
|
@ -3,7 +3,7 @@ const net = std.net;
|
||||||
const posix = std.posix;
|
const posix = std.posix;
|
||||||
|
|
||||||
pub fn main() !void {
|
pub fn main() !void {
|
||||||
const address = try std.net.Address.parseIp("127.0.0.1", 5882);
|
const address = try std.net.Address.parseIp("0.0.0.0", 9001);
|
||||||
|
|
||||||
const tpe: u32 = posix.SOCK.STREAM;
|
const tpe: u32 = posix.SOCK.STREAM;
|
||||||
const protocol = posix.IPPROTO.TCP;
|
const protocol = posix.IPPROTO.TCP;
|
||||||
|
|
Loading…
Reference in a new issue