Skip to content
Snippets Groups Projects
Commit db64ead1 authored by Martin Stiemerling's avatar Martin Stiemerling :speech_balloon:
Browse files

Add docker-compose

parent 2fee6177
Branches
No related tags found
1 merge request!3Add docker-compose
ARG GOLANG_VERSION=1.20.5
FROM golang:$GOLANG_VERSION-alpine as builder
WORKDIR /proto-kms/
RUN apk add build-base
COPY . .
RUN --mount=type=cache,target=/root/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
make build-proto-kms
FROM ${GITLAB_PROXY}golang:$GOLANG_VERSION-buster
WORKDIR /app/
COPY --from=builder /proto-kms/artifacts/proto-kms ./proto-kms
ENTRYPOINT ["./proto-kms"]
Makefile 0 → 100644
GOCMD=go
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
BUILD_ARTIFACTS_PATH=artifacts
pre:
mkdir -p $(BUILD_ARTIFACTS_PATH)
build-proto-kms: pre
CGO_ENABLED=0 $(GOBUILD) -o $(BUILD_ARTIFACTS_PATH)/proto-kms .
containerize-proto-kms:
docker buildx build --rm -t proto-kms --load -f Dockerfile .
clean:
$(GOCLEAN)
rm -rf $(BUILD_ARTIFACTS_PATH)
version: '3'
services:
proto-kms1:
build:
dockerfile: Dockerfile
command: ["-address", "172.100.20.11:55059", "-name", "proto-kms1"]
networks:
proto-kms-net:
ipv4_address: 172.100.20.10
proto-kms2:
build:
dockerfile: Dockerfile
command: ["-address", "172.100.20.10:55059","-name", "proto-kms2"]
networks:
proto-kms-net:
ipv4_address: 172.100.20.11
networks:
proto-kms-net:
ipam:
driver: default
config:
- subnet: "172.100.20.0/24"
name: proto-kms-net
package main
import (
"flag"
"log"
"net"
......@@ -9,11 +10,34 @@ import (
)
func main() {
// my own Name
var qlName1, udpQL1AddrString string
// a name for potential self-testing
var qlName2, udpQL2AddrString string
// Setup flags that allows to initially provide a address to a second
// quantumlayer so generated keys can be fetched. This is mainly to simplify
// the initial setup process.
flag.StringVar(&udpQL2AddrString, "address", "[::1]:50900",
"The UDP address for my quantumlayer so keys can be fetched")
log.Println("Welcome to the proto-kms")
flag.StringVar(&ql1Name, "name", "ekms-ql1",
"The name of the quantumlayer")
go emulatedKMS("kms-ql1", "[::1]:50900", "[::1]:50901")
emulatedKMS("kms-ql2", "[::1]:50901", "[::1]:50900")
flag.StringVar(&udpQL2AddrString, "address", "[::1]:50901",
"The UDP address to a second quantumlayer so keys can be fetched")
flag.StringVar(&ql2Name, "name", "ekms-ql2",
"The name of the quantumlayer")
// Parse the provided flags
flag.Parse()
log.Println("Welcome to the proto-kms called: ", qlName)
go emulatedKMS(ql2Name, udpQL2AddrString, udpQL1AddrString)
emulatedKMS(ql1Name, udpQL1AddrString, udpQL2AddrString)
return
}
......
......@@ -23,9 +23,9 @@ import (
)
type QuantumPayloadElement struct {
BulkKeyId int64 // the unique ID of this bulk of keys
BulkKeyLength int // the length, counted in bytes, of bulkKey
BulkKey *[]byte // the bulk key
BulkKeyId int64 `json:"bulk-key-id"` // the unique ID of this bulk of keys
BulkKeyLength int `json:"bulk-key-length"` // the length, counted in bytes, of bulkKey
BulkKey *[]byte `json:"bulk-key"` // the bulk key
}
type QuantumlayerEmuPRNG struct {
......@@ -74,6 +74,7 @@ func (qlemuprng *QuantumlayerEmuPRNG) PowerOn(localQLAddress ...string) {
udpAddrString = localQLAddress[0]
}
log.Printf("localQLAddress is %s", localQLAddress[0])
// This reads random numbers from other Quantum end
udpSrvPort, err := net.ResolveUDPAddr("udp", udpAddrString)
if err != nil {
......@@ -178,7 +179,6 @@ func (qlemuprng *QuantumlayerEmuPRNG) AddPeer(addr net.UDPAddr) {
}
}
}(ctx)
}
func (qlemuprng *QuantumlayerEmuPRNG) RemovePeer() {
......@@ -297,5 +297,4 @@ func (store *NumberStore) receiveNumbers(incoming chan QuantumPayloadElement) {
store.mu.Unlock()
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment