Skip to content

Commit

Permalink
Keyserver package:
Browse files Browse the repository at this point in the history
* Implement key lookup & monitoring functions

* Refactor HandleOps response

* Server tests:

- Refactor directory_test.go

Protocol package:

* Implement: KeyLookup, KeyLookupInEpoch, Monitoring
  • Loading branch information
vqhuy committed Aug 22, 2016
1 parent 645bd07 commit a70b35c
Show file tree
Hide file tree
Showing 7 changed files with 730 additions and 52 deletions.
17 changes: 12 additions & 5 deletions keyserver/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,20 @@ func UnmarshalRequest(msg []byte) (*Request, error) {
if err := json.Unmarshal(msg, &req); err != nil {
return nil, err
}
var request interface{}
switch req.Type {
case RegistrationType:
var request RegistrationRequest
if err := json.Unmarshal(content, &request); err != nil {
return nil, err
}
req.Request = &request
request = new(RegistrationRequest)
case KeyLookupType:
request = new(KeyLookupRequest)
case KeyLookupInEpochType:
request = new(KeyLookupInEpochRequest)
case MonitoringType:
request = new(MonitoringRequest)
}
if err := json.Unmarshal(content, &request); err != nil {
return nil, err
}
req.Request = request
return &req, nil
}
4 changes: 4 additions & 0 deletions keyserver/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,15 @@ func (server *ConiksServer) makeHandler(acceptableTypes map[int]bool) func(msg [
}

switch req.Type {
case KeyLookupType, KeyLookupInEpochType, MonitoringType:
server.RLock()
default:
server.Lock()
}
response, e := server.dir.HandleOps(req)
switch req.Type {
case KeyLookupType, KeyLookupInEpochType, MonitoringType:
server.RLock()
default:
server.Unlock()
}
Expand Down
3 changes: 3 additions & 0 deletions keyserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ func (server *ConiksServer) Run(tc *TLSConnection) {

// acceptable types for public connection
publicTypes := make(map[int]bool)
publicTypes[protocol.KeyLookupType] = true
publicTypes[protocol.KeyLookupInEpochType] = true
publicTypes[protocol.MonitoringType] = true
server.waitStop.Add(1)
go func() {
server.listenForRequests(publicLn, server.makeHandler(publicTypes))
Expand Down
Loading

0 comments on commit a70b35c

Please sign in to comment.