iRedmail 中 Dovecot 的 Pop-before-smtp $pat 正则表达式

iRedmail 中 Dovecot 的 Pop-before-smtp $pat 正则表达式

我已经在邮件服务器 (iredmail) 中安装了 pop-before-smtp。我需要帮助来配置 $pat 以读取我的 Dovecot 文件的模式。Dovecote 日志文件如下:

2011-05-14 14:01:21 pop3-login: Info: Login: user=<[email protected]>, method=PLAIN, rip=180.234.45.133, lip=66.165.162.157
2011-05-14 14:01:22 POP3([email protected]): Info: Disconnected: Logged out top=0/0, retr=0/0, del=0/0, size=0
2011-05-14 14:01:52 pop3-login: Info: Login: user=<[email protected]>, method=PLAIN, rip=180.234.45.133, lip=66.165.162.157
2011-05-14 14:01:53 POP3([email protected]): Info: Disconnected: Logged out top=0/0, retr=0/0, del=0/0, size=0

Pop-before-smtp 脚本默认为 Dovecot 提供此模式。但对我来说不起作用。这三种模式都不是。

# For Dovecot POP3/IMAP when using syslog.
$pat = '^[LOGTIME] \S+ (?:dovecot: )?(?:imap|pop3)-login: ' .
    'Login: .*? (?:\[|rip=)[:f]*(\d+\.\d+\.\d+\.\d+)[],]';
$out_pat = '^[LOGTIME] \S+ (?:dovecot: )?(?:imap|pop3)-login: ' .
    'Disconnected.*? (?:\[|rip=)[:f]*(\d+\.\d+\.\d+\.\d+)[],]';

# For Dovecot POP3/IMAP when it does its own logging.
$logtime_pat = '(\d\d\d\d-\d+-\d+ \d+:\d+:\d+)';
$pat = '^dovecot: [LOGTIME] Info: (?:imap|pop3)-login: ' .
    'Login: .+? rip=[:f]*(\d+\.\d+\.\d+\.\d+),';
$out_pat = '^dovecot: [LOGTIME] Info: (?:imap|pop3)-login: ' .
    'Disconnected.*? rip=[:f]*(\d+\.\d+\.\d+\.\d+),';

# For older Dovecot POP3/IMAP when it does its own logging.
$pat = '^(?:imap|pop3)-login: [LOGTIME] Info: ' .
    'Login: \S+ \[[:f]*(\d+\.\d+\.\d+\.\d+)\]';
$out_pat = '^(?:imap|pop3)-login: [LOGTIME] Info: ' .
    'Disconnected.*? \[[:f]*(\d+\.\d+\.\d+\.\d+)\]';

Pop-before-smtp 需要通过正则表达式从日志中读取 IP。请帮我解决此问题。谢谢

答案1

我已经使用这个正则表达式格式来工作:

$pat = '^(\d\d\d\d-\d+-\d+ \d+:\d+:\d+) (?:imap|pop3)-login: Info: ' .
'Login: .*? (?:\[|rip=)[:f]*(\d+\.\d+\.\d+\.\d+)[],]';

相关内容