MCPcopy Create free account
hub / github.com/DeNA/PacketProxy / queryByAddress

Method queryByAddress

src/main/java/core/packetproxy/model/Servers.java:99–122  ·  view source on GitHub ↗
(InetSocketAddress addr)

Source from the content-addressed store, hash-verified

97 }
98
99 public Server queryByAddress(InetSocketAddress addr) throws Exception {
100 List<Server> all = this.queryAll();
101 if (addr.getAddress() == null) {
102
103 throw new Exception(String.format("cannot resolv hostname: %s", addr.getHostName()));
104 }
105 if (addr.getPort() == 0) {
106
107 throw new Exception("cannot resolv portnumber: 0");
108 }
109 String target = addr.getAddress().getHostAddress();
110 for (Server server : all) {
111
112 List<InetAddress> ips = server.getIps();
113 for (InetAddress ip : ips) {
114
115 if (ip.getHostAddress().equals(target) && server.getPort() == addr.getPort()) {
116
117 return server;
118 }
119 }
120 }
121 return null;
122 }
123
124 public Server queryByHostName(String hostname) throws Exception {
125 List<Server> ret = cache.query("queryByHostName", hostname);

Callers 6

onClientChunkReceivedMethod · 0.80
onServerChunkReceivedMethod · 0.80
onChunkReceivedMethod · 0.80
createConnectionMethod · 0.80
createClientSSLSocketMethod · 0.80

Calls 7

queryAllMethod · 0.95
getIpsMethod · 0.80
getAddressMethod · 0.65
formatMethod · 0.45
getHostNameMethod · 0.45
getPortMethod · 0.45
equalsMethod · 0.45

Tested by

no test coverage detected