@@ -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 }
@@ -276,20 +279,21 @@ func run(ctx context.Context, g *errgroup.Group, config *GvproxyConfig) error {
276279 g .Go (func () error {
277280 vfkitConn , err := transport .AcceptVfkit (conn )
278281 if err != nil {
279- notificationSender .Send (types.NotificationMessage {NotificationType : types .HypervisorError })
280282 return fmt .Errorf ("vfkit accept error: %w" , err )
281283 }
282284
283- notificationSender .Send (types.NotificationMessage {NotificationType : types .ConnectionEstablished })
284285 return vn .AcceptVfkit (ctx , vfkitConn )
285286 })
286287 }
287288
288289 if config .Interfaces .Stdio != "" {
289290 g .Go (func () error {
290291 conn := stdio .GetStdioConn ()
291- notificationSender .Send (types.NotificationMessage {NotificationType : types .ConnectionEstablished })
292- return vn .AcceptStdio (ctx , conn )
292+ err := vn .AcceptStdio (ctx , conn )
293+ if err != nil {
294+ notificationSender .Send (types.NotificationMessage {NotificationType : types .HypervisorError })
295+ }
296+ return err
293297 })
294298 }
295299
0 commit comments