Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
logins.bad 有兩種,一個在BBSHOME,一個在User下面
https://github.com/ptt/pttbbs/blob/master/include/common.h#L56
https://github.com/ptt/pttbbs/blob/master/common/bbs/passwd.c#L255
BBSHOME/logins.bad: 這個檔裡有每個 user的login attempt且包含成功與失敗。第一個字元若是"-"代表失敗。
test03 [01/01/2021 10:11:45 Fri] [email protected]
test04 [01/01/2021 10:13:35 Fri] [email protected]
test05 [01/01/2021 10:13:45 Fri] [email protected]
SYSOP [01/01/2021 10:13:53 Fri] [email protected]
test06 [01/01/2021 10:14:38 Fri] [email protected]
SYSOP [01/01/2021 10:14:46 Fri] [email protected]
-test01 [01/01/2021 10:15:16 Fri] [email protected]
-test02 [01/01/2021 10:15:19 Fri] [email protected]
-test03 [01/01/2021 10:15:22 Fri] [email protected]
test04 [01/01/2021 10:15:38 Fri] [email protected]
BBSHOME/home///logins.bad: 這個檔裡只有該user的 失敗 login attempt
╰─➤ cat home/T/test01/logins.bad
[01/01/2021 10:15:16 Fri] 172.22.0.1
目前想法是用同一個struct來parse這2種logins.bad
type LoginAttempt struct {
Success bool
UserId string
LoginStartTime time.Time
FromHost string
}
For BBSHOME/logins.bad ,這個檔裡四個field都有,所以沒問題。
但在user/logins.bad,缺少 UserId ,所以parse出來的struct就沒有 UserId,需要caller assign