Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
quant
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
danet
quant
Commits
7e320e65
Commit
7e320e65
authored
1 year ago
by
Fabian Seidl
Browse files
Options
Downloads
Patches
Plain Diff
remove server, was wrong direction
parent
3936be61
No related branches found
No related tags found
1 merge request
!137
Resolve "Implement QKDN manager dummy"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
qkdnManager-simulator/server/httpHandlers.go
+0
-94
0 additions, 94 deletions
qkdnManager-simulator/server/httpHandlers.go
qkdnManager-simulator/server/httpServer.go
+0
-46
0 additions, 46 deletions
qkdnManager-simulator/server/httpServer.go
with
0 additions
and
140 deletions
qkdnManager-simulator/server/httpHandlers.go
deleted
100644 → 0
+
0
−
94
View file @
3936be61
package
managerServer
import
(
"encoding/json"
"net/http"
"github.com/google/uuid"
"github.com/sirupsen/logrus"
)
type
RequestBody
struct
{
KMS_ID
uuid
.
UUID
`json:"KMS_ID"`
Peers
[]
Peer
`json:"peers,omitempty"`
Running
bool
`json:"running,omitempty"`
}
type
Peer
struct
{
Peer_ID
uuid
.
UUID
`json:"peer_ID"`
Running
bool
`json:"running"`
}
func
handleHttpOperationalState
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
logrus
.
Infof
(
"Handler for OperationalState got request"
)
var
data
RequestBody
err
:=
json
.
NewDecoder
(
r
.
Body
)
.
Decode
(
&
data
)
if
err
!=
nil
{
http
.
Error
(
w
,
err
.
Error
(),
http
.
StatusBadRequest
)
}
logrus
.
Infof
(
"ID: %s, running: %t"
,
data
.
KMS_ID
,
data
.
Running
)
w
.
WriteHeader
(
http
.
StatusOK
)
_
,
err
=
w
.
Write
([]
byte
(
"OK
\n
"
))
if
err
!=
nil
{
logrus
.
Error
(
err
)
}
}
func
handleHttpQkdInterface
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
logrus
.
Infof
(
"Handler for QkdInterface got request"
)
var
data
RequestBody
err
:=
json
.
NewDecoder
(
r
.
Body
)
.
Decode
(
&
data
)
if
err
!=
nil
{
http
.
Error
(
w
,
err
.
Error
(),
http
.
StatusBadRequest
)
}
logrus
.
Infof
(
"ID: %s, running: %t"
,
data
.
KMS_ID
,
data
.
Running
)
w
.
WriteHeader
(
http
.
StatusOK
)
_
,
err
=
w
.
Write
([]
byte
(
"OK
\n
"
))
if
err
!=
nil
{
logrus
.
Error
(
err
)
}
}
func
handleHttpInterCKMSInterface
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
logrus
.
Infof
(
"Handler for InterCKMSInterface got request"
)
var
data
RequestBody
err
:=
json
.
NewDecoder
(
r
.
Body
)
.
Decode
(
&
data
)
if
err
!=
nil
{
http
.
Error
(
w
,
err
.
Error
(),
http
.
StatusBadRequest
)
}
for
_
,
peer
:=
range
data
.
Peers
{
logrus
.
Infof
(
"ID: %s, peerID:%s, running: %t"
,
data
.
KMS_ID
,
peer
.
Peer_ID
,
peer
.
Running
)
}
w
.
WriteHeader
(
http
.
StatusOK
)
_
,
err
=
w
.
Write
([]
byte
(
"OK
\n
"
))
if
err
!=
nil
{
logrus
.
Error
(
err
)
}
}
func
handleHttpAkmsInterface
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
logrus
.
Infof
(
"Handler for AkmsInterface got request"
)
var
data
RequestBody
err
:=
json
.
NewDecoder
(
r
.
Body
)
.
Decode
(
&
data
)
if
err
!=
nil
{
http
.
Error
(
w
,
err
.
Error
(),
http
.
StatusBadRequest
)
}
logrus
.
Infof
(
"ID: %s, running: %t"
,
data
.
KMS_ID
,
data
.
Running
)
w
.
WriteHeader
(
http
.
StatusOK
)
_
,
err
=
w
.
Write
([]
byte
(
"OK
\n
"
))
if
err
!=
nil
{
logrus
.
Error
(
err
)
}
}
This diff is collapsed.
Click to expand it.
qkdnManager-simulator/server/httpServer.go
deleted
100644 → 0
+
0
−
46
View file @
3936be61
package
managerServer
import
(
"errors"
"net/http"
"time"
"code.fbi.h-da.de/danet/quant/qkdnManager-simulator/config"
"github.com/sirupsen/logrus"
)
func
SetupHTTPServer
(
conf
config
.
ManagerServer
)
*
http
.
Server
{
logrus
.
Info
(
"Setting up server for management information..."
)
mux
:=
http
.
NewServeMux
()
addHandlersToMux
(
mux
,
conf
.
Endpoints
)
srv
:=
http
.
Server
{
Addr
:
conf
.
Address
,
Handler
:
mux
,
ReadHeaderTimeout
:
15
*
time
.
Second
,
ReadTimeout
:
15
*
time
.
Second
,
WriteTimeout
:
10
*
time
.
Second
,
IdleTimeout
:
30
*
time
.
Second
,
}
go
startServer
(
&
srv
)
logrus
.
Infof
(
"QKDN manager server running on %s ..."
,
conf
.
Address
)
return
&
srv
}
func
startServer
(
srv
*
http
.
Server
)
{
if
err
:=
srv
.
ListenAndServe
();
!
errors
.
Is
(
err
,
http
.
ErrServerClosed
)
{
logrus
.
Error
(
err
)
}
logrus
.
Info
(
"Stopped serving new connections."
)
}
func
addHandlersToMux
(
mux
*
http
.
ServeMux
,
endpoints
map
[
string
]
string
)
{
// add additional handlers if necessary
mux
.
HandleFunc
(
config
.
APIPrefix
+
endpoints
[
"operationalState"
],
handleHttpOperationalState
)
mux
.
HandleFunc
(
config
.
APIPrefix
+
endpoints
[
"qkdInterface"
],
handleHttpQkdInterface
)
mux
.
HandleFunc
(
config
.
APIPrefix
+
endpoints
[
"interCKMSInterface"
],
handleHttpInterCKMSInterface
)
mux
.
HandleFunc
(
config
.
APIPrefix
+
endpoints
[
"akmsInterface"
],
handleHttpAkmsInterface
)
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment