diff --git a/docker-compose.yml b/docker-compose.yml index 32355fb8cdc1d8074579e1d6e4bb62430ff3bc35..69fdd74d960292dc0f74fa6724130da5a6512c1a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,128 +1,134 @@ services: - kms01: - image: gokms - command: ["--log", "debug", "--kms_config", "/tmp/kms/config/kms01.yaml"] - volumes: - - ./config/goKMS/example01.yaml:/tmp/kms/config/kms01.yaml - - ./artifacts/ssl:/ssl - ports: - - "127.0.0.1:4401:1337" - - "127.0.0.1:9696:9696" - - kms02: - image: gokms - command: ["--log", "debug", "--kms_config", "/tmp/kms/config/kms02.yaml"] - volumes: - - ./config/goKMS/example02.yaml:/tmp/kms/config/kms02.yaml - - ./artifacts/ssl:/ssl - ports: - - "127.0.0.1:4402:1337" - - kms03: - image: gokms - command: ["--log", "debug", "--kms_config", "/tmp/kms/config/kms03.yaml"] - volumes: - - ./config/goKMS/example03.yaml:/tmp/kms/config/kms03.yaml - - ./artifacts/ssl:/ssl - ports: - - "127.0.0.1:4403:1337" - - kms04: - image: gokms - command: ["--log", "debug", "--kms_config", "/tmp/kms/config/kms04.yaml"] - volumes: - - ./config/goKMS/example04.yaml:/tmp/kms/config/kms04.yaml - - ./artifacts/ssl:/ssl - ports: - - "127.0.0.1:4404:1337" - - "127.0.0.1:9697:9696" - - qlayer01: - image: quantumlayer - command: ["--config", "/tmp/quantumlayer/config/quantumlayer01.yaml"] - volumes: - - ./config/quantumlayer/example01.yaml:/tmp/quantumlayer/config/quantumlayer01.yaml - - qlayer02: - image: quantumlayer - command: ["--config", "/tmp/quantumlayer/config/quantumlayer02.yaml"] - volumes: - - ./config/quantumlayer/example02.yaml:/tmp/quantumlayer/config/quantumlayer02.yaml - - qlayer03: - image: quantumlayer - command: ["--config", "/tmp/quantumlayer/config/quantumlayer03.yaml"] - volumes: - - ./config/quantumlayer/example03.yaml:/tmp/quantumlayer/config/quantumlayer03.yaml - - qlayer04: - image: quantumlayer - command: ["--config", "/tmp/quantumlayer/config/quantumlayer04.yaml"] - volumes: - - ./config/quantumlayer/example04.yaml:/tmp/quantumlayer/config/quantumlayer04.yaml - - qlayer05: - image: quantumlayer - command: ["--config", "/tmp/quantumlayer/config/quantumlayer05.yaml"] - volumes: - - ./config/quantumlayer/example05.yaml:/tmp/quantumlayer/config/quantumlayer05.yaml - - qlayer06: - image: quantumlayer - command: ["--config", "/tmp/quantumlayer/config/quantumlayer06.yaml"] - volumes: - - ./config/quantumlayer/example06.yaml:/tmp/quantumlayer/config/quantumlayer06.yaml - - qlayer07: - image: quantumlayer - command: ["--config", "/tmp/quantumlayer/config/quantumlayer07.yaml"] - volumes: - - ./config/quantumlayer/example07.yaml:/tmp/quantumlayer/config/quantumlayer07.yaml - - qlayer08: - image: quantumlayer - command: ["--config", "/tmp/quantumlayer/config/quantumlayer08.yaml"] - volumes: - - ./config/quantumlayer/example08.yaml:/tmp/quantumlayer/config/quantumlayer08.yaml - - akms-receiver01: - image: akms-simulator - - akms-receiver02: - image: akms-simulator - - qkdn-controller: - image: registry.code.fbi.h-da.de/demoquandt/qkdn-controller:qkdn-main - volumes: - - ./config/controller/qkdn-gosdn.toml:/app/configs/qkdn-gosdn.toml - - ./config/controller/gNMISubscriptions.txt:/app/configs/gNMISubscriptions.txt - command: --config ./configs/qkdn-gosdn.toml - ports: - - "127.0.0.1:55055:55055" - environment: - GOSDN_ADMIN_PASSWORD: TestPassword - - gosdnc: - image: registry.code.fbi.h-da.de/demoquandt/qkdn-controller/gosdnc:qkdn-main - volumes: - - ./config/controller/add_devices.sh:/scripts/add_devices.sh - entrypoint: ["/scripts/add_devices.sh"] - - plugin-registry: - image: registry.code.fbi.h-da.de/demoquandt/qkdn-controller/plugin-registry:qkdn-main - - mongo: - image: mongo:7 - environment: - MONGO_INITDB_ROOT_USERNAME: root - MONGO_INITDB_ROOT_PASSWORD: example - - rabbitmq: - image: rabbitmq:3-management - - routing-app: - image: registry.code.fbi.h-da.de/demoquandt/qkdn-controller/routing-app:qkdn-main - entrypoint: ["./start_ra_sleep.sh"] - volumes: - - ./config/controller/start_ra_sleep.sh:/app/start_ra_sleep.sh - - ./config/controller/routing-config.yaml:/new/routing-config.yaml + kms01: + image: gokms + command: + ["--log", "debug", "--kms_config", "/tmp/kms/config/kms01.yaml"] + volumes: + - ./config/goKMS/example01.yaml:/tmp/kms/config/kms01.yaml + - ./artifacts/ssl:/ssl + ports: + - "127.0.0.1:4401:1337" + - "127.0.0.1:9696:9696" + + kms02: + image: gokms + command: + ["--log", "debug", "--kms_config", "/tmp/kms/config/kms02.yaml"] + volumes: + - ./config/goKMS/example02.yaml:/tmp/kms/config/kms02.yaml + - ./artifacts/ssl:/ssl + ports: + - "127.0.0.1:4402:1337" + - "127.0.0.1:8090:8090" + - "127.0.0.1:7030:7030" + + kms03: + image: gokms + command: + ["--log", "debug", "--kms_config", "/tmp/kms/config/kms03.yaml"] + volumes: + - ./config/goKMS/example03.yaml:/tmp/kms/config/kms03.yaml + - ./artifacts/ssl:/ssl + ports: + - "127.0.0.1:4403:1337" + + kms04: + image: gokms + command: + ["--log", "debug", "--kms_config", "/tmp/kms/config/kms04.yaml"] + volumes: + - ./config/goKMS/example04.yaml:/tmp/kms/config/kms04.yaml + - ./artifacts/ssl:/ssl + ports: + - "127.0.0.1:4404:1337" + - "127.0.0.1:9697:9696" + + qlayer01: + image: quantumlayer + command: ["--config", "/tmp/quantumlayer/config/quantumlayer01.yaml"] + volumes: + - ./config/quantumlayer/example01.yaml:/tmp/quantumlayer/config/quantumlayer01.yaml + + qlayer02: + image: quantumlayer + command: ["--config", "/tmp/quantumlayer/config/quantumlayer02.yaml"] + volumes: + - ./config/quantumlayer/example02.yaml:/tmp/quantumlayer/config/quantumlayer02.yaml + + qlayer03: + image: quantumlayer + command: ["--config", "/tmp/quantumlayer/config/quantumlayer03.yaml"] + volumes: + - ./config/quantumlayer/example03.yaml:/tmp/quantumlayer/config/quantumlayer03.yaml + + qlayer04: + image: quantumlayer + command: ["--config", "/tmp/quantumlayer/config/quantumlayer04.yaml"] + volumes: + - ./config/quantumlayer/example04.yaml:/tmp/quantumlayer/config/quantumlayer04.yaml + + qlayer05: + image: quantumlayer + command: ["--config", "/tmp/quantumlayer/config/quantumlayer05.yaml"] + volumes: + - ./config/quantumlayer/example05.yaml:/tmp/quantumlayer/config/quantumlayer05.yaml + + qlayer06: + image: quantumlayer + command: ["--config", "/tmp/quantumlayer/config/quantumlayer06.yaml"] + volumes: + - ./config/quantumlayer/example06.yaml:/tmp/quantumlayer/config/quantumlayer06.yaml + + qlayer07: + image: quantumlayer + command: ["--config", "/tmp/quantumlayer/config/quantumlayer07.yaml"] + volumes: + - ./config/quantumlayer/example07.yaml:/tmp/quantumlayer/config/quantumlayer07.yaml + + qlayer08: + image: quantumlayer + command: ["--config", "/tmp/quantumlayer/config/quantumlayer08.yaml"] + volumes: + - ./config/quantumlayer/example08.yaml:/tmp/quantumlayer/config/quantumlayer08.yaml + + akms-receiver01: + image: akms-simulator + + akms-receiver02: + image: akms-simulator + + qkdn-controller: + image: registry.code.fbi.h-da.de/demoquandt/qkdn-controller:qkdn-main + volumes: + - ./config/controller/qkdn-gosdn.toml:/app/configs/qkdn-gosdn.toml + - ./config/controller/gNMISubscriptions.txt:/app/configs/gNMISubscriptions.txt + command: --config ./configs/qkdn-gosdn.toml + ports: + - "127.0.0.1:55055:55055" + environment: + GOSDN_ADMIN_PASSWORD: TestPassword + + gosdnc: + image: registry.code.fbi.h-da.de/demoquandt/qkdn-controller/gosdnc:qkdn-main + volumes: + - ./config/controller/add_devices.sh:/scripts/add_devices.sh + entrypoint: ["/scripts/add_devices.sh"] + + plugin-registry: + image: registry.code.fbi.h-da.de/demoquandt/qkdn-controller/plugin-registry:qkdn-main + + mongo: + image: mongo:7 + environment: + MONGO_INITDB_ROOT_USERNAME: root + MONGO_INITDB_ROOT_PASSWORD: example + + rabbitmq: + image: rabbitmq:3-management + + routing-app: + image: registry.code.fbi.h-da.de/demoquandt/qkdn-controller/routing-app:qkdn-main + entrypoint: ["./start_ra_sleep.sh"] + volumes: + - ./config/controller/start_ra_sleep.sh:/app/start_ra_sleep.sh + - ./config/controller/routing-config.yaml:/new/routing-config.yaml diff --git a/goKMS/qkdnManager/server.go b/goKMS/qkdnManager/server.go index 405f1a7c3da1badd955bedac41157cde5b6f51b5..c91cd81924e5a1c68ca72c1e0c6e0e90096b6c8c 100644 --- a/goKMS/qkdnManager/server.go +++ b/goKMS/qkdnManager/server.go @@ -9,7 +9,6 @@ import ( "code.fbi.h-da.de/danet/quant/goKMS/config" "code.fbi.h-da.de/danet/quant/goKMS/kms" - "code.fbi.h-da.de/danet/quant/goKMS/kms/peers" "github.com/google/uuid" "github.com/sirupsen/logrus" ) @@ -27,7 +26,7 @@ var endpoints = map[string]string{ qkdInterface: "/qkdInterface", interCKMSInterface: "/interCKMSInterface", akmsInterface: "/akmsInterface", - setKeyStore: "/setKeyStore", + setKeyStore: "/set_key_store", } type QkdnManagerServer struct { @@ -182,23 +181,21 @@ func (qs *QkdnManagerServer) handleHttpAkmsInterface(w http.ResponseWriter, r *h func (qs *QkdnManagerServer) handleSetKeyStore(w http.ResponseWriter, r *http.Request) { logrus.Debugf("Handler for SetKeyStore got request from: %s", r.RemoteAddr) - err := r.ParseForm() - if err != nil { - http.Error(w, err.Error(), http.StatusBadRequest) - return + var parsedRequest struct { + KeyFillLevel int `json:"key_fill_level"` + PeerIDs []string `json:"peer_ids"` + Fetch bool `json:"fetch"` } - keyFillLevel := r.Form.Get("KeyFillLevel") - peerIDs, ok := r.Form["PeerIds"] - if !ok { - http.Error(w, fmt.Sprintf("No peer IDs provided."), http.StatusBadRequest) + err := json.NewDecoder(r.Body).Decode(&parsedRequest) + if err != nil { + http.Error(w, err.Error(), http.StatusBadRequest) return } - fetch := r.Form.Get("Fetch") - logrus.Debugf("KeyFillLevel: %s, PeerIDs: %v, Fetch: %s", keyFillLevel, peerIDs, fetch) + logrus.Debugf("KeyFillLevel: %d, PeerIDs: %v, Fetch: %t", parsedRequest.KeyFillLevel, parsedRequest.PeerIDs, parsedRequest.Fetch) - for _, peerID := range peerIDs { + for _, peerID := range parsedRequest.PeerIDs { peerUUID, err := uuid.Parse(peerID) if err != nil { http.Error(w, err.Error(), http.StatusBadRequest) @@ -209,17 +206,13 @@ func (qs *QkdnManagerServer) handleSetKeyStore(w http.ResponseWriter, r *http.Re http.Error(w, err.Error(), http.StatusBadRequest) return } - eqm, ok := peer.QuantumModule().(*peers.ETSI014HTTPQuantumModule) - if !ok { - http.Error(w, fmt.Sprintf("QuantumModule is not of Type ETSI014"), http.StatusBadRequest) - return - } - if fetch == "true" { + eqm := peer.QuantumModule() + if parsedRequest.Fetch == true { if err := eqm.Initialize(); err != nil { http.Error(w, fmt.Sprintf("Failed to restart fetching for quantum module of peer: %s", peerID), http.StatusBadRequest) return } - } else if fetch == "false" { + } else if parsedRequest.Fetch == false { eqm.SetActive(false) if err := peer.ResetKeyStore(qs.kms.GetID().String()); err != nil { eqm.SetActive(true)