mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-11-13 16:45:03 +03:00
fix(server): bound the public-IP lookup and accept only an address
getPublicIP read a third-party IP echo service's body whole and cached whatever came back as the panel's address, so one misbehaving service could make the panel inflate an endless response at startup, and an error page became the address shown in every status sample. The read is capped at 64 bytes and only a parsable IP is accepted; anything else counts as unavailable. The GitHub release lookups are capped as well.
This commit is contained in:
@@ -43,6 +43,7 @@ type PanelUpdateInfo struct {
|
||||
const (
|
||||
panelUpdaterURL = "https://raw.githubusercontent.com/MHSanaei/3x-ui/main/update.sh"
|
||||
maxPanelUpdaterBytes = 2 << 20
|
||||
maxPanelReleaseBytes = 2 << 20
|
||||
// devReleaseTag is the fixed-tag rolling pre-release the CI force-moves to the
|
||||
// newest main commit; the dev update channel installs from it.
|
||||
devReleaseTag = "dev-latest"
|
||||
@@ -450,7 +451,7 @@ func fetchPanelRelease(tag string) (*service.Release, error) {
|
||||
}
|
||||
|
||||
var release service.Release
|
||||
if err := json.NewDecoder(resp.Body).Decode(&release); err != nil {
|
||||
if err := json.NewDecoder(io.LimitReader(resp.Body, maxPanelReleaseBytes)).Decode(&release); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &release, nil
|
||||
|
||||
Reference in New Issue
Block a user