Fixed the request and added a timeout

This commit is contained in:
Arzumify 2024-10-03 17:17:24 +01:00
parent e34d766bf5
commit 5fc1c8fb95

20
main.go
View file

@ -157,8 +157,17 @@ func Main(information library.ServiceInitializationInformation) {
Message: nil, Message: nil,
} }
var publicKey ed25519.PublicKey = nil
// 10 second timeout
go func() {
time.Sleep(10 * time.Second)
if publicKey == nil {
logFunc("Timeout while waiting for the public key from the authentication service", 3, information)
}
}()
// Wait for the response // Wait for the response
var publicKey ed25519.PublicKey
response = <-information.Inbox response = <-information.Inbox
if response.MessageType == 2 { if response.MessageType == 2 {
// This is the public key // This is the public key
@ -169,15 +178,6 @@ func Main(information library.ServiceInitializationInformation) {
logFunc(response.Message.(error).Error(), 3, information) logFunc(response.Message.(error).Error(), 3, information)
} }
// Ask the authentication service for its host name
information.Outbox <- library.InterServiceMessage{
ServiceID: ServiceInformation.ServiceID,
ForServiceID: uuid.MustParse("00000000-0000-0000-0000-000000000004"), // Authentication service
MessageType: 0, // Request host name
SentAt: time.Now(),
Message: nil,
}
// Set up the router // Set up the router
router := information.Router router := information.Router