Skip to content

Conversation

@Starrah
Copy link
Collaborator

@Starrah Starrah commented Feb 11, 2025

此前的讨论见#40

根据 #40 (comment) 的建议,本PR实现了keepAliveLoop并不会在请求失败就立即退出,而是重复尝试可定义的次数,只有连续失败若干次后才会退出。同时,两次重试之间的时间间隔现在也可定义了(之前是写死的3s)。

具体实现:

  1. commit 7ef821d,修复了d0b9776中的不完善之处:auth-thu auth --keep-online的keepAlive,应该根据--campus-only的有无决定keepAlive的校内校外,而不应固定写死keepAlive校内。
  2. commit 73227cb 是核心的commit,添加了两个配置项:
    • onlineRetry,决定keepAliveLoop在退出之前应当尝试的次数,默认值为2,即只有连续两次keepAlive请求报错,keepAliveLoop才会退出。
      • 注意这轻微改变了online的行为,如果想要和原来一样的行为(一次请求失败就立即退出),则需要显式指定onlineRetry为1:auth-thu online -r 1

    • onlineInterval,决定两次keepAlive请求之间的间隔,默认值为3s(和原来写死在代码里的值一致)
  3. commit 7ef821d 是小修改,把auth-thu online --auth--auth增加一个alias名为--campus-only。这是因为--auth原本在旧版的系统下表示只auth不login,但目前login功能已被完全移除,故该名称也失去了其含义;改为--campus-only,是和auth-thu auth中的同义选项保持一致的选择。

Close #40.

…rns error.

See z4yx#40-L3.

Add 2 setting items: `onlineRetry`, which determines the maximum retry number (default 2); `onlineInterval`, which controls the interval between two keepalive requests (default 3s).

Note that this commit will change the behaviour of `auth-thu online`: When the device is not authed, now `auth-thu online` will exit after 3 seconds, but for previous behaviour, `auth-thu online` will exit immediately. For equivalent with previous behaviour, you should use `auth-thu online -r 1`.
…auth".

 Since legacy `auth-thu login` had been removed in 506a920, there should not be this legacy option too.
 To keep consistency with flags in `auth-thu auth`, the flag is renamed to "campus-only"; but for backward compatibility, "auth" is still kept as an alias.
@jiegec jiegec merged commit 763d956 into z4yx:master Feb 11, 2025
2 checks passed
@jiegec
Copy link
Collaborator

jiegec commented Feb 11, 2025

@z4yx Please invite @Starrah as maintainer.

@z4yx
Copy link
Owner

z4yx commented Feb 12, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants