Skip to content

Commit d952be1

Browse files
authored
Merge pull request #5119 from wubin01/acquisition_ip
feat(net): optimize ip acquisition logic of gRPC interface
2 parents b4b1444 + c64da6e commit d952be1

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

framework/src/main/java/org/tron/core/services/ratelimiter/RuntimeData.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import io.grpc.Grpc;
44
import io.grpc.ServerCall;
5+
import java.net.InetSocketAddress;
56
import javax.servlet.http.HttpServletRequest;
67
import lombok.extern.slf4j.Slf4j;
78

@@ -16,7 +17,9 @@ public RuntimeData(Object o) {
1617
address = ((HttpServletRequest) o).getRemoteAddr();
1718
} else if (o instanceof ServerCall) {
1819
try {
19-
address = ((ServerCall) o).getAttributes().get(Grpc.TRANSPORT_ATTR_REMOTE_ADDR).toString();
20+
InetSocketAddress s = (InetSocketAddress)
21+
((ServerCall) o).getAttributes().get(Grpc.TRANSPORT_ATTR_REMOTE_ADDR);
22+
address = s.getAddress().getHostAddress();
2023
} catch (Exception npe) {
2124
logger.warn("the address get from the runtime data is a null value unexpected.");
2225
}

0 commit comments

Comments
 (0)