mirror of https://github.com/jetkvm/kvm.git
Compare commits
4 Commits
c6d2a3d078
...
26d24eff20
| Author | SHA1 | Date |
|---|---|---|
|
|
26d24eff20 | |
|
|
79098d3546 | |
|
|
50fc88aae1 | |
|
|
118e03301f |
|
|
@ -305,11 +305,11 @@ func wakeDisplay(force bool, reason string) {
|
|||
displayLogger.Warn().Err(err).Msg("failed to wake display")
|
||||
}
|
||||
|
||||
if config.DisplayDimAfterSec != 0 {
|
||||
if config.DisplayDimAfterSec != 0 && dimTicker != nil {
|
||||
dimTicker.Reset(time.Duration(config.DisplayDimAfterSec) * time.Second)
|
||||
}
|
||||
|
||||
if config.DisplayOffAfterSec != 0 {
|
||||
if config.DisplayOffAfterSec != 0 && offTicker != nil {
|
||||
offTicker.Reset(time.Duration(config.DisplayOffAfterSec) * time.Second)
|
||||
}
|
||||
backlightState = 0
|
||||
|
|
|
|||
|
|
@ -111,6 +111,7 @@ type Client struct {
|
|||
var (
|
||||
defaultTimerDuration = 1 * time.Second
|
||||
defaultLinkUpTimeout = 30 * time.Second
|
||||
defaultDHCPTimeout = 5 * time.Second // DHCP request timeout (not link up timeout)
|
||||
maxRenewalAttemptDuration = 2 * time.Hour
|
||||
)
|
||||
|
||||
|
|
@ -125,11 +126,11 @@ func NewClient(ctx context.Context, ifaces []string, c *Config, l *zerolog.Logge
|
|||
}
|
||||
|
||||
if cfg.Timeout == 0 {
|
||||
cfg.Timeout = defaultLinkUpTimeout
|
||||
cfg.Timeout = defaultDHCPTimeout
|
||||
}
|
||||
|
||||
if cfg.Retries == 0 {
|
||||
cfg.Retries = 3
|
||||
cfg.Retries = 4
|
||||
}
|
||||
|
||||
return &Client{
|
||||
|
|
@ -153,9 +154,15 @@ func NewClient(ctx context.Context, ifaces []string, c *Config, l *zerolog.Logge
|
|||
}, nil
|
||||
}
|
||||
|
||||
func resetTimer(t *time.Timer, l *zerolog.Logger) {
|
||||
l.Debug().Dur("delay", defaultTimerDuration).Msg("will retry later")
|
||||
t.Reset(defaultTimerDuration)
|
||||
func resetTimer(t *time.Timer, attempt int, l *zerolog.Logger) {
|
||||
// Exponential backoff: 1s, 2s, 4s, 8s, max 8s
|
||||
backoffAttempt := attempt
|
||||
if backoffAttempt > 3 {
|
||||
backoffAttempt = 3
|
||||
}
|
||||
delay := time.Duration(1<<backoffAttempt) * time.Second
|
||||
l.Debug().Dur("delay", delay).Int("attempt", attempt).Msg("will retry later")
|
||||
t.Reset(delay)
|
||||
}
|
||||
|
||||
func getRenewalTime(lease *Lease) time.Duration {
|
||||
|
|
@ -168,12 +175,14 @@ func getRenewalTime(lease *Lease) time.Duration {
|
|||
|
||||
func (c *Client) requestLoop(t *time.Timer, family int, ifname string) {
|
||||
l := c.l.With().Str("interface", ifname).Int("family", family).Logger()
|
||||
attempt := 0
|
||||
for range t.C {
|
||||
l.Info().Msg("requesting lease")
|
||||
l.Info().Int("attempt", attempt).Msg("requesting lease")
|
||||
|
||||
if _, err := c.ensureInterfaceUp(ifname); err != nil {
|
||||
l.Error().Err(err).Msg("failed to ensure interface up")
|
||||
resetTimer(t, c.l)
|
||||
l.Error().Err(err).Int("attempt", attempt).Msg("failed to ensure interface up")
|
||||
resetTimer(t, attempt, c.l)
|
||||
attempt++
|
||||
continue
|
||||
}
|
||||
|
||||
|
|
@ -188,11 +197,14 @@ func (c *Client) requestLoop(t *time.Timer, family int, ifname string) {
|
|||
lease, err = c.requestLease6(ifname)
|
||||
}
|
||||
if err != nil {
|
||||
l.Error().Err(err).Msg("failed to request lease")
|
||||
resetTimer(t, c.l)
|
||||
l.Error().Err(err).Int("attempt", attempt).Msg("failed to request lease")
|
||||
resetTimer(t, attempt, c.l)
|
||||
attempt++
|
||||
continue
|
||||
}
|
||||
|
||||
// Successfully obtained lease, reset attempt counter
|
||||
attempt = 0
|
||||
c.handleLeaseChange(lease)
|
||||
|
||||
nextRenewal := getRenewalTime(lease)
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@
|
|||
"recharts": "^3.3.0",
|
||||
"tailwind-merge": "^3.3.1",
|
||||
"usehooks-ts": "^3.1.1",
|
||||
"validator": "^13.15.15",
|
||||
"validator": "^13.15.20",
|
||||
"zustand": "^4.5.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
@ -2198,6 +2198,66 @@
|
|||
"node": ">=14.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tailwindcss/oxide-wasm32-wasi/node_modules/@emnapi/core": {
|
||||
"version": "1.5.0",
|
||||
"dev": true,
|
||||
"inBundle": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"dependencies": {
|
||||
"@emnapi/wasi-threads": "1.1.0",
|
||||
"tslib": "^2.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tailwindcss/oxide-wasm32-wasi/node_modules/@emnapi/runtime": {
|
||||
"version": "1.5.0",
|
||||
"dev": true,
|
||||
"inBundle": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"dependencies": {
|
||||
"tslib": "^2.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tailwindcss/oxide-wasm32-wasi/node_modules/@emnapi/wasi-threads": {
|
||||
"version": "1.1.0",
|
||||
"dev": true,
|
||||
"inBundle": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"dependencies": {
|
||||
"tslib": "^2.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tailwindcss/oxide-wasm32-wasi/node_modules/@napi-rs/wasm-runtime": {
|
||||
"version": "1.0.7",
|
||||
"dev": true,
|
||||
"inBundle": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"dependencies": {
|
||||
"@emnapi/core": "^1.5.0",
|
||||
"@emnapi/runtime": "^1.5.0",
|
||||
"@tybys/wasm-util": "^0.10.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@tailwindcss/oxide-wasm32-wasi/node_modules/@tybys/wasm-util": {
|
||||
"version": "0.10.1",
|
||||
"dev": true,
|
||||
"inBundle": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"dependencies": {
|
||||
"tslib": "^2.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tailwindcss/oxide-wasm32-wasi/node_modules/tslib": {
|
||||
"version": "2.8.1",
|
||||
"dev": true,
|
||||
"inBundle": true,
|
||||
"license": "0BSD",
|
||||
"optional": true
|
||||
},
|
||||
"node_modules/@tailwindcss/oxide-win32-arm64-msvc": {
|
||||
"version": "4.1.16",
|
||||
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide-win32-arm64-msvc/-/oxide-win32-arm64-msvc-4.1.16.tgz",
|
||||
|
|
@ -7570,9 +7630,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/validator": {
|
||||
"version": "13.15.15",
|
||||
"resolved": "https://registry.npmjs.org/validator/-/validator-13.15.15.tgz",
|
||||
"integrity": "sha512-BgWVbCI72aIQy937xbawcs+hrVaN/CZ2UwutgaJ36hGqRrLNM+f5LUT/YPRbo8IV/ASeFzXszezV+y2+rq3l8A==",
|
||||
"version": "13.15.20",
|
||||
"resolved": "https://registry.npmjs.org/validator/-/validator-13.15.20.tgz",
|
||||
"integrity": "sha512-KxPOq3V2LmfQPP4eqf3Mq/zrT0Dqp2Vmx2Bn285LwVahLc+CsxOM0crBHczm8ijlcjZ0Q5Xd6LW3z3odTPnlrw==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.10"
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@
|
|||
"recharts": "^3.3.0",
|
||||
"tailwind-merge": "^3.3.1",
|
||||
"usehooks-ts": "^3.1.1",
|
||||
"validator": "^13.15.15",
|
||||
"validator": "^13.15.20",
|
||||
"zustand": "^4.5.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
|
|||
|
|
@ -46,10 +46,10 @@ export default function SettingsHardwareRoute() {
|
|||
}
|
||||
|
||||
setBacklightSettings(settings);
|
||||
handleBacklightSettingsSave();
|
||||
handleBacklightSettingsSave(settings);
|
||||
};
|
||||
|
||||
const handleBacklightSettingsSave = () => {
|
||||
const handleBacklightSettingsSave = (backlightSettings: BacklightSettings) => {
|
||||
send("setBacklightSettings", { params: backlightSettings }, (resp: JsonRpcResponse) => {
|
||||
if ("error" in resp) {
|
||||
notifications.error(
|
||||
|
|
@ -81,7 +81,7 @@ export default function SettingsHardwareRoute() {
|
|||
const duration = enabled ? 90 : -1;
|
||||
send("setVideoSleepMode", { duration }, (resp: JsonRpcResponse) => {
|
||||
if ("error" in resp) {
|
||||
notifications.error(m.hardware_power_saving_failed_error({ error: resp.error.data ||m.unknown_error() }));
|
||||
notifications.error(m.hardware_power_saving_failed_error({ error: resp.error.data || m.unknown_error() }));
|
||||
setPowerSavingEnabled(!enabled); // Attempt to revert on error
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue