-
Notifications
You must be signed in to change notification settings - Fork 642
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Include forwarded client IP address in access log (#2606)
This PR addresses #2603 issue, and allows any custom AccessLogFactory to get more informations about the connection on which the request has been received. The AccessLogArgProvider interface has a new connectionInformation() method which returns a new ConnectionInformationinterface, which has the following methods: - hostAddress()/remoteAddress()/scheme(): provides the host address/remote address/scheme that is derived from all proxies (using Forwarded/X-Fowarded-* headers. - connectionHostAddress()/connectionRemoteAddress()/connectionScheme(): provides the host/remote address/scheme of the connection from which the request is received. Fixes #2603
- Loading branch information
Showing
12 changed files
with
208 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
reactor-netty-http/src/main/java/reactor/netty/http/server/ConnectionInformation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* Copyright (c) 2022 VMware, Inc. or its affiliates, All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package reactor.netty.http.server; | ||
|
||
import reactor.util.annotation.Nullable; | ||
|
||
import java.net.SocketAddress; | ||
|
||
/** | ||
* Resolve informations about the connection from which an http request is received. | ||
* | ||
* @since 1.0.26 | ||
*/ | ||
public interface ConnectionInformation { | ||
|
||
/** | ||
* Returns the address of the host which received the request, possibly {@code null} in case of Unix Domain Sockets. | ||
* The returned address is the merged informations from all proxies. | ||
* | ||
* @return the address merged from all proxies of the host which received the request | ||
*/ | ||
@Nullable | ||
SocketAddress hostAddress(); | ||
|
||
/** | ||
* Returns the address of the host which received the request, possibly {@code null} in case of Unix Domain Sockets. | ||
* | ||
* @return the address of the host which received the request | ||
*/ | ||
@Nullable | ||
SocketAddress connectionHostAddress(); | ||
|
||
/** | ||
* Returns the address of the client that initiated the request, possibly {@code null} in case of Unix Domain Sockets. | ||
* The returned address is the merged informations from all proxies. | ||
* | ||
* @return the address merged from all proxies of the client that initiated the request | ||
*/ | ||
@Nullable | ||
SocketAddress remoteAddress(); | ||
|
||
/** | ||
* Returns the address of the client that initiated the request, possibly {@code null} in case of Unix Domain Sockets. | ||
* | ||
* @return the address of the client that initiated the request | ||
*/ | ||
@Nullable | ||
SocketAddress connectionRemoteAddress(); | ||
|
||
/** | ||
* Returns the current protocol scheme. | ||
* The returned address is the merged informations from all proxies. | ||
* | ||
* @return the protocol scheme merged from all proxies | ||
*/ | ||
String scheme(); | ||
|
||
/** | ||
* Returns the current protocol scheme. | ||
* | ||
* @return the protocol scheme | ||
*/ | ||
String connectionScheme(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.