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

log ip #811

Closed
wants to merge 1 commit into from
Closed

log ip #811

wants to merge 1 commit into from

Conversation

Dmole
Copy link
Contributor

@Dmole Dmole commented Jan 28, 2025

Every log relating to data sent from a connection should log the IP for fail2ban etc.

Copy link
Contributor

@markt-asf markt-asf left a comment

Choose a reason for hiding this comment

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

This PR also triggers a compilation error in the test cases.

I am minded to close this PR due to the low quality, particularly that it doesn't compile.

Even with the compilation and other issues fixed, I am not convinced this is the right approach or even necessary. The access log is where I'd expect the underlying requirement to be handled.

Comment on lines 40 to 42
Http2AsyncParser(String connectionId, Input input, Output output, SocketWrapperBase<?> socketWrapper,
Http2AsyncUpgradeHandler upgradeHandler) {
Http2AsyncUpgradeHandler upgradeHandler,String rip) {
super(connectionId, input, output);
Copy link
Contributor

Choose a reason for hiding this comment

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

Failed to compile

Comment on lines 84 to 86
@Override
protected Http2Parser getParser(String connectionId) {
protected Http2Parser getParser(String connectionId, String rip) {
return new Http2AsyncParser(connectionId, this, this, socketWrapper, this);
Copy link
Contributor

Choose a reason for hiding this comment

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

Fails to compile

Comment on lines 331 to 333
if (key == Setting.UNKNOWN) {
log.warn(sm.getString("connectionSettings.unknown", connectionId, Integer.toString(id),
log.warn(sm.getString("connectionSettings.unknown", rip + "_" + connectionId, Integer.toString(id),
Long.toString(value)));
Copy link
Contributor

Choose a reason for hiding this comment

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

The right way to add information to a log message is by adding an additional argument to the i18n string.

Comment on lines 205 to 216
String rip = "-";
if (webConnection != null) {
try {
stream = getStream(1, true);
rip = stream.getCoyoteRequest().getRequestProcessor().getRemoteAddr();
} catch (Http2Exception e) {
throw new ProtocolException(sm.getString("upgradeHandler.upgrade.fail", connectionId));
}
}

parser = getParser(connectionId, rip);

Copy link
Contributor

Choose a reason for hiding this comment

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

Duplicates code later in the method.

Comment on lines 238 to 241
if (key == Setting.UNKNOWN) {
log.warn(sm.getString("connectionSettings.unknown", connectionId, Integer.toString(id),
String rip = stream.getCoyoteRequest().getRequestProcessor().getRemoteAddr();
log.warn(sm.getString("connectionSettings.unknown", rip + "_" + connectionId, Integer.toString(id),
Long.toString(value)));
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't compile.

@Dmole
Copy link
Contributor Author

Dmole commented Jan 29, 2025

The access log is where I'd expect the underlying requirement to be handled.

Is there a way to log connectionId in the access log with something like %{xxx}r ?
Is the access log guaranteed to get output for any packet that could cause an error to log ?

@markt-asf
Copy link
Contributor

I have relatively little tolerance for PRs that fail to compile. I have even less tolerance for PRs that still fail to compile after this problem has been pointed out once.

Logging the connection ID in the access log looks like a candidate for an addition to the ExtendedAccessLogValve.

If a request gets as far as sending at least one byte to Tomcat it should appear in the access log. Dedicated, separate loggers are provided for TLS handshake failures

@Dmole
Copy link
Contributor Author

Dmole commented Jan 30, 2025

#814

@Dmole Dmole closed this Jan 30, 2025
@Dmole Dmole deleted the main_logIp branch January 30, 2025 22:10
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