From fbb81e5f2c5542d86ffbb0cb8e05ce2640ed65de Mon Sep 17 00:00:00 2001 From: Jasper Ras Date: Sat, 21 Jun 2025 11:11:59 +0200 Subject: vault backup: 2025-06-21 11:11:59 --- .trash/15-Jun-2025.md | 1 + Building Skypiea an OpenStack Dashboard.md | 21 ++++++++ Golang.md | 1 + IP migration API.md | 56 ++++++++++++++++++++++ TCP.md | 1 + ...e Type Assertions in Go and when to use them.md | 12 +++++ What is TCP KeepAlive.md | 9 ++++ daily/15-Jun-2025.md | 1 - daily/17-May-2025.md | 4 +- daily/18-Jun-2025.md | 1 + 10 files changed, 105 insertions(+), 2 deletions(-) create mode 100644 .trash/15-Jun-2025.md create mode 100644 Building Skypiea an OpenStack Dashboard.md create mode 100644 Golang.md create mode 100644 IP migration API.md create mode 100644 TCP.md create mode 100644 What are Type Assertions in Go and when to use them.md create mode 100644 What is TCP KeepAlive.md delete mode 100644 daily/15-Jun-2025.md create mode 100644 daily/18-Jun-2025.md diff --git a/.trash/15-Jun-2025.md b/.trash/15-Jun-2025.md new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/.trash/15-Jun-2025.md @@ -0,0 +1 @@ + diff --git a/Building Skypiea an OpenStack Dashboard.md b/Building Skypiea an OpenStack Dashboard.md new file mode 100644 index 0000000..a290653 --- /dev/null +++ b/Building Skypiea an OpenStack Dashboard.md @@ -0,0 +1,21 @@ +[[OpenStack]] + +--- + +### To JS Framework or not to JS Framework +I was in doubt whether or not to use a JavaScript framework. I conversed with Gemini about this. I gave the context that I was considering a JavaScript Framework or just using minimal JavaScript with HTML/CSS using HTMX and a Golang backend which I was leaning towards. +It confirmed my gut feeling that the latter, not using a full blown JavaScript framework, is the good option especially for learning. + +So my decision: use purely HTML/CSS with HTMX and a Golang backend that drives it. + +### Can I do real-time feedback? +Using SSE or WebSockets it is possible. HTMX supports this out-of-the box. We can listen for events from OpenStack and then push updates from the server to the client. +##### SSE or WebSockets? +SSE is useful when the traffic flows mostly from the server to the client. WebSockets is a full-duplex connection and thus more likely candidate when the client also converses with the server alot. +In our case I think **SSE** would be the best fit as the client mostly just listens. + +#### SSE +It works by exposing an endpoint of which the connection is kept alive by the backend when a client connects to it. It can then periodically send its events over this connection. +`Content-Type` header should be set by the server to: `text/event-stream`. +`Cache-Control` set to `no-cache`. **Not yet sure why. Let's investigate.** +`Connection` set to `keepalive`. This is to ensure the connection is kept open so we can send our events. \ No newline at end of file diff --git a/Golang.md b/Golang.md new file mode 100644 index 0000000..3b3438f --- /dev/null +++ b/Golang.md @@ -0,0 +1 @@ +[[What are Type Assertions in Go and when to use them]] \ No newline at end of file diff --git a/IP migration API.md b/IP migration API.md new file mode 100644 index 0000000..c6bd91b --- /dev/null +++ b/IP migration API.md @@ -0,0 +1,56 @@ +--- +tags: + - work +--- +# Previous IP migration API +Stateful: sqlite db: +- subnet state (mode: `migrating`) +- ip state: active location (`CPH|AMS`) + +config: +- LR map file +- db config +- tls +- ip announcement file +- hosts +- key +- user +IP announcement file. + +Flow: +- Prepare subnet (out-of-band) + - Creates a record for the subnet, and puts it in "migrating" mode. +- Call migrate IP (ip, dest) + - Fails if subnet not prepared prior. + - Fails if destination not exists. + - Fails if invalid ip address + + +# New IP migration API + +What is a "link scope"? + +API: +- Prepare subnet : cidr +- Migrate IP + - os set allowed address pair + - tun src: add /32 +- Migrate gateway + +Kevin meet: +tunnel-dst vm in openstack +tunnel-src hardware ding +puppet op tunnels + +stap 1 paars = api doet: op os router route voor elk ip in subnet aanmaken en proxy arp shit per subnet. AllowedAddrPair op port tunnel-dst. In eerste instantie gewoon alle IPs uit het subnet toevoegen. + +Beide IPv4 en IPv6 (6 kan iets later) + +Alle stappen moeten reversable zijn. + +stap 2 roze: test vm, routes op os verwijderen, op src net toevoegen +stap 3 geel: switch network naar openstack, switch gateway ip + + +**How ARP works** +Host A thinks it has direct conn to Host B, thus sends ARP request to learn its MAC. \ No newline at end of file diff --git a/TCP.md b/TCP.md new file mode 100644 index 0000000..9f3fef8 --- /dev/null +++ b/TCP.md @@ -0,0 +1 @@ +[[What is TCP KeepAlive]] diff --git a/What are Type Assertions in Go and when to use them.md b/What are Type Assertions in Go and when to use them.md new file mode 100644 index 0000000..d23dd66 --- /dev/null +++ b/What are Type Assertions in Go and when to use them.md @@ -0,0 +1,12 @@ +[[Golang]] + +--- +**Form**: `w.(http.Flusher)` where `w` is a variable and `http.Flusher` is an interface. We assert here that `w` implements the `http.Flusher` interface. + +A *type assertion* has two return values: first the original value of `w` cast to the type your asserting, and second a boolean that we can check to see if the assertion was successful, generally called `ok`. +i.e.: `flusher, ok := w.(http.Flusher)`. If we don't assign `ok` the program would panic. + +### When is this useful? +In the above example where we assert `w.(http.Flusher)` the original specified type of `w` was a `http.ResponseWriter` as per the function argument definition `func x(w http.ResponseWriter). +So we would only be able to call the methods that interface exposes. However, the actual object passed as `w` possibly implements a lot more than just that interface, for example, the `http.Flusher` interface. +By type asserting it and receiving the cast value, we can then call the Flush method on the object. \ No newline at end of file diff --git a/What is TCP KeepAlive.md b/What is TCP KeepAlive.md new file mode 100644 index 0000000..6b25179 --- /dev/null +++ b/What is TCP KeepAlive.md @@ -0,0 +1,9 @@ +TCP KeepAlive: Keeps TCP Alive. + +A timer is set up together with the TCP connection, if the timer reaches zero a probe packet is sent without any data. It has a flag set for ACK. The peer only has to support TCP/IP, not specifically keepalive. If alive it will respond with a zero data packet as well that has the ACK flag set. + +Because TCP lets your program handle a stream, not packets, a zero length data packet is not dangerous for the program listening on the socket. + +Two use cases for keepalive: +- Detecting dead peers +- Prevent disconnects due to inactivity \ No newline at end of file diff --git a/daily/15-Jun-2025.md b/daily/15-Jun-2025.md deleted file mode 100644 index 8b13789..0000000 --- a/daily/15-Jun-2025.md +++ /dev/null @@ -1 +0,0 @@ - diff --git a/daily/17-May-2025.md b/daily/17-May-2025.md index 3729110..7872d2a 100644 --- a/daily/17-May-2025.md +++ b/daily/17-May-2025.md @@ -25,4 +25,6 @@ All parts gone: loop forever. Only condition is like a while x == true; `range` keyword to loop over a slice or array with `for index, arg := range slice` -`_` is the blank identifier, thus above if we don' need the index we can put `_`. \ No newline at end of file +`_` is the blank identifier, thus above if we don' need the index we can put `_`. + +**Type assertion** diff --git a/daily/18-Jun-2025.md b/daily/18-Jun-2025.md new file mode 100644 index 0000000..c7c35a1 --- /dev/null +++ b/daily/18-Jun-2025.md @@ -0,0 +1 @@ +Gin bool required bind fails if false, needs ptr to bool. https://github.com/gin-gonic/gin/issues/814 \ No newline at end of file -- cgit v1.2.3