Fix proxy settings are not reverted after panic. (#183)

This commit is contained in:
Ledorub 2024-08-22 13:29:54 +03:00 committed by GitHub
parent aa04524565
commit e9311bf4db
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -38,6 +38,11 @@ func main() {
if err := util.SetOsProxy(*config.Port); err != nil {
logger.Fatal().Msgf("error while changing proxy settings: %s", err)
}
defer func() {
if err := util.UnsetOsProxy(); err != nil {
logger.Fatal().Msgf("error while disabling proxy: %s", err)
}
}()
}
go pxy.Start(context.Background())
@ -60,10 +65,4 @@ func main() {
}()
<-done
if *config.SystemProxy {
if err := util.UnsetOsProxy(); err != nil {
logger.Fatal().Msgf("%s", err)
}
}
}