@@ -128,13 +128,15 @@ func run(ctx context.Context, g *errgroup.Group, config *GvproxyConfig) error {
128128 }
129129 log .Info ("waiting for clients..." )
130130
131+ // Start the notification sender in a goroutine
131132 notificationSender := notification .NewNotificationSender (config .NotificationSocket )
132133 if config .NotificationSocket != "" {
133134 g .Go (func () error {
134135 notificationSender .Start (ctx )
135136 return nil
136137 })
137138 }
139+ vn .SetNotificationSender (notificationSender )
138140 for _ , endpoint := range config .Listen {
139141 log .Infof ("listening %s" , endpoint )
140142 ln , err := transport .Listen (endpoint )
@@ -182,6 +184,7 @@ func run(ctx context.Context, g *errgroup.Group, config *GvproxyConfig) error {
182184 if config .Interfaces .VPNKit != "" {
183185 vpnkitListener , err := transport .Listen (config .Interfaces .VPNKit )
184186 if err != nil {
187+ notificationSender .Send (types.NotificationMessage {NotificationType : types .HypervisorError })
185188 return fmt .Errorf ("vpnkit listen error: %w" , err )
186189 }
187190 g .Go (func () error {
@@ -195,10 +198,10 @@ func run(ctx context.Context, g *errgroup.Group, config *GvproxyConfig) error {
195198 }
196199 conn , err := vpnkitListener .Accept ()
197200 if err != nil {
201+ notificationSender .Send (types.NotificationMessage {NotificationType : types .HypervisorError })
198202 log .Errorf ("vpnkit accept error: %s" , err )
199203 continue
200204 }
201- notificationSender .Send (types.NotificationMessage {NotificationType : types .ConnectionEstablished })
202205 g .Go (func () error {
203206 return vn .AcceptVpnKit (conn )
204207 })
@@ -210,6 +213,7 @@ func run(ctx context.Context, g *errgroup.Group, config *GvproxyConfig) error {
210213 if config .Interfaces .Qemu != "" {
211214 qemuListener , err := transport .Listen (config .Interfaces .Qemu )
212215 if err != nil {
216+ notificationSender .Send (types.NotificationMessage {NotificationType : types .HypervisorError })
213217 return fmt .Errorf ("qemu listen error: %w" , err )
214218 }
215219
@@ -227,14 +231,14 @@ func run(ctx context.Context, g *errgroup.Group, config *GvproxyConfig) error {
227231 notificationSender .Send (types.NotificationMessage {NotificationType : types .HypervisorError })
228232 return fmt .Errorf ("qemu accept error: %w" , err )
229233 }
230- notificationSender .Send (types.NotificationMessage {NotificationType : types .ConnectionEstablished })
231234 return vn .AcceptQemu (ctx , conn )
232235 })
233236 }
234237
235238 if config .Interfaces .Bess != "" {
236239 bessListener , err := transport .Listen (config .Interfaces .Bess )
237240 if err != nil {
241+ notificationSender .Send (types.NotificationMessage {NotificationType : types .HypervisorError })
238242 return fmt .Errorf ("bess listen error: %w" , err )
239243 }
240244
@@ -252,7 +256,6 @@ func run(ctx context.Context, g *errgroup.Group, config *GvproxyConfig) error {
252256 notificationSender .Send (types.NotificationMessage {NotificationType : types .HypervisorError })
253257 return fmt .Errorf ("bess accept error: %w" , err )
254258 }
255- notificationSender .Send (types.NotificationMessage {NotificationType : types .ConnectionEstablished })
256259 return vn .AcceptBess (ctx , conn )
257260 })
258261 }
@@ -280,16 +283,18 @@ func run(ctx context.Context, g *errgroup.Group, config *GvproxyConfig) error {
280283 return fmt .Errorf ("vfkit accept error: %w" , err )
281284 }
282285
283- notificationSender .Send (types.NotificationMessage {NotificationType : types .ConnectionEstablished })
284286 return vn .AcceptVfkit (ctx , vfkitConn )
285287 })
286288 }
287289
288290 if config .Interfaces .Stdio != "" {
289291 g .Go (func () error {
290292 conn := stdio .GetStdioConn ()
291- notificationSender .Send (types.NotificationMessage {NotificationType : types .ConnectionEstablished })
292- return vn .AcceptStdio (ctx , conn )
293+ err := vn .AcceptStdio (ctx , conn )
294+ if err != nil {
295+ notificationSender .Send (types.NotificationMessage {NotificationType : types .HypervisorError })
296+ }
297+ return err
293298 })
294299 }
295300
0 commit comments