@@ -16,6 +16,7 @@ import (
1616
1717 "github.com/device-management-toolkit/console/config"
1818 consolehttp "github.com/device-management-toolkit/console/internal/controller/http"
19+ "github.com/device-management-toolkit/console/internal/controller/tcp/cira"
1920 wsv1 "github.com/device-management-toolkit/console/internal/controller/ws/v1"
2021 "github.com/device-management-toolkit/console/internal/usecase"
2122 "github.com/device-management-toolkit/console/pkg/db"
@@ -76,6 +77,16 @@ func Run(cfg *config.Config) {
7677 }
7778
7879 wsv1 .RegisterRoutes (handler , log , usecases .Devices , upgrader )
80+
81+ // Use the same certificates that were generated in main.go
82+ ciraCertFile := fmt .Sprintf ("config/%s_cert.pem" , cfg .CommonName )
83+ ciraKeyFile := fmt .Sprintf ("config/%s_key.pem" , cfg .CommonName )
84+
85+ ciraServer , err := cira .NewServer (ciraCertFile , ciraKeyFile , usecases .Devices )
86+ if err != nil {
87+ log .Fatal ("CIRA Server failed: %v" , err )
88+ }
89+
7990 // Configure TLS based on config
8091 tlsEnabled := cfg .TLS .Enabled
8192 certFile := cfg .TLS .CertFile
@@ -97,11 +108,17 @@ func Run(cfg *config.Config) {
97108 log .Info ("app - Run - signal: " + s .String ())
98109 case err = <- httpServer .Notify ():
99110 log .Error (fmt .Errorf ("app - Run - httpServer.Notify: %w" , err ))
111+ case ciraErr := <- ciraServer .Notify ():
112+ log .Error (fmt .Errorf ("app - Run - ciraServer.Notify: %w" , ciraErr ))
100113 }
101114
102115 // Shutdown
103116 err = httpServer .Shutdown ()
104117 if err != nil {
105118 log .Error (fmt .Errorf ("app - Run - httpServer.Shutdown: %w" , err ))
106119 }
120+ err = ciraServer .Shutdown ()
121+ if err != nil {
122+ log .Error (fmt .Errorf ("app - Run - ciraServer.Shutdown: %w" , err ))
123+ }
107124}
0 commit comments