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

Issue 29: Parse logins.bad #30

Merged

Conversation

ifanchu
Copy link
Contributor

@ifanchu ifanchu commented Jan 1, 2021

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

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/<x>/<user>/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
Copy link
Member

@PichuChen PichuChen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@PichuChen PichuChen merged commit fd1f00b into Ptt-official-app:master Jan 1, 2021
@ifanchu ifanchu mentioned this pull request Jan 28, 2021
16 tasks
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.

2 participants