Fixed a bug where setting compression would crash the server on local routes, fixed some useless never-will-happen eventualities
Signed-off-by: arzumify <jliwin98@danwin1210.de>
This commit is contained in:
parent
eebe3763f5
commit
d40bc7dc8e
50
main.go
50
main.go
|
@ -644,7 +644,7 @@ func tryAuthAccess(message library.InterServiceMessage) {
|
|||
service, ok := activeServices[uuid.MustParse("00000000-0000-0000-0000-000000000004")]
|
||||
if ok {
|
||||
service.Inbox <- message
|
||||
} else if !ok {
|
||||
} else {
|
||||
// Send error message
|
||||
service, ok := activeServices[message.ServiceID]
|
||||
if ok {
|
||||
|
@ -660,22 +660,6 @@ func tryAuthAccess(message library.InterServiceMessage) {
|
|||
slog.Error("Bit flip error: Impossible service ID. Move away from radiation or use ECC memory.")
|
||||
os.Exit(1)
|
||||
}
|
||||
} else {
|
||||
// Send error message
|
||||
service, ok := activeServices[message.ServiceID]
|
||||
if ok {
|
||||
service.Inbox <- library.InterServiceMessage{
|
||||
ServiceID: uuid.MustParse("00000000-0000-0000-0000-000000000001"),
|
||||
ForServiceID: message.ServiceID,
|
||||
MessageType: 1,
|
||||
SentAt: time.Now(),
|
||||
Message: errors.New("authentication service not yet available"),
|
||||
}
|
||||
} else {
|
||||
// This should never happen
|
||||
slog.Error("Bit flip error: Impossible service ID. Move away from radiation or use ECC memory.")
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Send error message
|
||||
|
@ -704,7 +688,7 @@ func tryStorageAccess(message library.InterServiceMessage) {
|
|||
service, ok := activeServices[uuid.MustParse("00000000-0000-0000-0000-000000000003")]
|
||||
if ok {
|
||||
service.Inbox <- message
|
||||
} else if !ok {
|
||||
} else {
|
||||
// Send error message
|
||||
service, ok := activeServices[message.ServiceID]
|
||||
if ok {
|
||||
|
@ -720,22 +704,6 @@ func tryStorageAccess(message library.InterServiceMessage) {
|
|||
slog.Error("Bit flip error: Impossible service ID. Move away from radiation or use ECC memory.")
|
||||
os.Exit(1)
|
||||
}
|
||||
} else {
|
||||
// Send error message
|
||||
service, ok := activeServices[message.ServiceID]
|
||||
if ok {
|
||||
service.Inbox <- library.InterServiceMessage{
|
||||
ServiceID: uuid.MustParse("00000000-0000-0000-0000-000000000001"),
|
||||
ForServiceID: message.ServiceID,
|
||||
MessageType: 1,
|
||||
SentAt: time.Now(),
|
||||
Message: errors.New("blob storage is not yet available"),
|
||||
}
|
||||
} else {
|
||||
// This should never happen
|
||||
slog.Error("Bit flip error: Impossible service ID. Move away from radiation or use ECC memory.")
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Send error message
|
||||
|
@ -915,19 +883,18 @@ func parseConfig(path string) Config {
|
|||
|
||||
func iterateThroughSubdomains(globalOutbox chan library.InterServiceMessage) {
|
||||
for _, route := range config.Routes {
|
||||
var subdomainRouter *chi.Mux
|
||||
// Create the subdomain router
|
||||
if route.Compression.Level != 0 {
|
||||
compression[route.Subdomain] = CompressionSettings{
|
||||
Level: int(route.Compression.Level),
|
||||
Algorithm: route.Compression.Algorithm,
|
||||
}
|
||||
} else {
|
||||
subdomainRouter = chi.NewRouter()
|
||||
}
|
||||
|
||||
// Create the subdomain router
|
||||
subdomainRouter := chi.NewRouter()
|
||||
subdomainRouter.NotFound(func(w http.ResponseWriter, r *http.Request) {
|
||||
serverError(w, 404)
|
||||
})
|
||||
}
|
||||
|
||||
subdomains[route.Subdomain] = subdomainRouter
|
||||
subdomains[route.Subdomain].Use(logger)
|
||||
|
@ -1158,6 +1125,11 @@ func main() {
|
|||
|
||||
// Start the HTTP server
|
||||
err = http.ListenAndServe(config.Global.IP+":"+config.Global.HTTPPort, http.HandlerFunc(hostRouter))
|
||||
if err != nil {
|
||||
slog.Error("Error starting server: " + err.Error())
|
||||
} else {
|
||||
// This should never happen
|
||||
slog.Error("Bit flip error: Impossible service ID. Move away from radiation or use ECC memory.")
|
||||
}
|
||||
os.Exit(1)
|
||||
}
|
||||
|
|
|
@ -189,11 +189,6 @@ func Main(information library.ServiceInitializationInformation) {
|
|||
identifier := information.Configuration["identifier"].(string)
|
||||
adminKey := information.Configuration["adminKey"].(string)
|
||||
|
||||
var err error
|
||||
if err != nil {
|
||||
logFunc(err.Error(), 3, information)
|
||||
}
|
||||
|
||||
// Initiate a connection to the database
|
||||
// Call service ID 1 to get the database connection information
|
||||
information.Outbox <- library.InterServiceMessage{
|
||||
|
@ -246,7 +241,7 @@ func Main(information library.ServiceInitializationInformation) {
|
|||
}
|
||||
}
|
||||
// Set up the in-memory cache
|
||||
mem, err = sql.Open("sqlite3", "file:"+ServiceInformation.ServiceID.String()+"?mode=memory&cache=shared")
|
||||
mem, err := sql.Open("sqlite3", "file:"+ServiceInformation.ServiceID.String()+"?mode=memory&cache=shared")
|
||||
if err != nil {
|
||||
logFunc(err.Error(), 3, information)
|
||||
}
|
||||
|
@ -295,7 +290,7 @@ func Main(information library.ServiceInitializationInformation) {
|
|||
|
||||
// Set up the signing keys
|
||||
// Check if the global table has the keys
|
||||
err = conn.DB.QueryRow("SELECT key FROM global LIMIT 1").Scan(&privateKey)
|
||||
err := conn.DB.QueryRow("SELECT key FROM global LIMIT 1").Scan(&privateKey)
|
||||
if err != nil {
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
// Generate a new key
|
||||
|
|
Loading…
Reference in New Issue