Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: proxy config reload panic #808

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions pkg/base/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"golang.org/x/exp/slices"
"net/http"
"net/url"
"sync"
"time"
)

Expand Down Expand Up @@ -223,7 +224,7 @@
return nil
}
if cfg.System {
ieproxy.ReloadConf()
safeProxyReloadConf()

Check warning on line 227 in pkg/base/model.go

View check run for this annotation

Codecov / codecov/patch

pkg/base/model.go#L227

Added line #L227 was not covered by tests
return ieproxy.GetProxyFunc()
}
if cfg.Scheme == "" || cfg.Host == "" {
Expand All @@ -238,7 +239,7 @@
return nil
}
if cfg.System {
ieproxy.ReloadConf()
safeProxyReloadConf()

Check warning on line 242 in pkg/base/model.go

View check run for this annotation

Codecov / codecov/patch

pkg/base/model.go#L242

Added line #L242 was not covered by tests
static := ieproxy.GetConf().Static
if static.Active && len(static.Protocols) > 0 {
// If only one protocol, use it
Expand All @@ -264,6 +265,15 @@
return util.BuildProxyUrl(cfg.Scheme, cfg.Host, cfg.Usr, cfg.Pwd)
}

var prcLock sync.Mutex

func safeProxyReloadConf() {
prcLock.Lock()
defer prcLock.Unlock()

ieproxy.ReloadConf()

Check warning on line 274 in pkg/base/model.go

View check run for this annotation

Codecov / codecov/patch

pkg/base/model.go#L270-L274

Added lines #L270 - L274 were not covered by tests
}

func parseUrlSafe(rawUrl string) *url.URL {
u, err := url.Parse(rawUrl)
if err != nil {
Expand Down
Loading