|
26 | 26 | package com.github.games647.fastlogin.core.shared; |
27 | 27 |
|
28 | 28 | import com.github.games647.craftapi.resolver.MojangResolver; |
| 29 | +import com.github.games647.craftapi.resolver.Options; |
29 | 30 | import com.github.games647.craftapi.resolver.http.RotatingProxySelector; |
30 | 31 | import com.github.games647.fastlogin.core.CommonUtil; |
31 | 32 | import com.github.games647.fastlogin.core.ProxyAgnosticMojangResolver; |
|
48 | 49 | import java.io.IOException; |
49 | 50 | import java.io.InputStream; |
50 | 51 | import java.io.Reader; |
51 | | -import java.net.InetAddress; |
52 | 52 | import java.net.InetSocketAddress; |
53 | 53 | import java.net.Proxy; |
54 | 54 | import java.net.Proxy.Type; |
55 | | -import java.net.UnknownHostException; |
56 | 55 | import java.nio.file.Files; |
57 | 56 | import java.nio.file.Path; |
58 | 57 | import java.time.Duration; |
@@ -121,30 +120,35 @@ public void load() { |
121 | 120 | return; |
122 | 121 | } |
123 | 122 |
|
124 | | - // Initialize the resolver based on the config parameter |
125 | | - this.resolver = this.config.getBoolean("useProxyAgnosticResolver", false) |
126 | | - ? new ProxyAgnosticMojangResolver() : new MojangResolver(); |
| 123 | + Options resolverOptions = new Options(); |
| 124 | + resolverOptions.setMaxNameRequests(config.getInt("mojang-request-limit", 600)); |
127 | 125 |
|
128 | | - antiBot = createAntiBotService(config.getSection("anti-bot")); |
129 | 126 | Set<Proxy> proxies = config.getStringList("proxies") |
130 | 127 | .stream() |
131 | 128 | .map(proxy -> proxy.split(":")) |
132 | 129 | .map(proxy -> new InetSocketAddress(proxy[0], Integer.parseInt(proxy[1]))) |
133 | 130 | .map(sa -> new Proxy(Type.HTTP, sa)) |
134 | 131 | .collect(toSet()); |
135 | | - |
136 | | - Collection<InetAddress> addresses = new HashSet<>(); |
137 | | - for (String localAddress : config.getStringList("ip-addresses")) { |
138 | | - try { |
139 | | - addresses.add(InetAddress.getByName(localAddress.replace('-', '.'))); |
140 | | - } catch (UnknownHostException ex) { |
141 | | - plugin.getLog().error("IP-Address is unknown to us", ex); |
142 | | - } |
| 132 | + if (!proxies.isEmpty()) { |
| 133 | + resolverOptions.setProxySelector(new RotatingProxySelector(proxies)); |
143 | 134 | } |
144 | 135 |
|
145 | | - resolver.setMaxNameRequests(config.getInt("mojang-request-limit")); |
146 | | - resolver.setProxySelector(new RotatingProxySelector(proxies)); |
147 | | - resolver.setOutgoingAddresses(addresses); |
| 136 | +// TODO: Not available currently in craftapi? |
| 137 | +// Collection<InetAddress> addresses = new HashSet<>(); |
| 138 | +// for (String localAddress : config.getStringList("ip-addresses")) { |
| 139 | +// try { |
| 140 | +// addresses.add(InetAddress.getByName(localAddress.replace('-', '.'))); |
| 141 | +// } catch (UnknownHostException ex) { |
| 142 | +// plugin.getLog().error("IP-Address is unknown to us", ex); |
| 143 | +// } |
| 144 | +// } |
| 145 | +// resolver.setOutgoingAddresses(addresses); |
| 146 | + |
| 147 | + // Initialize the resolver based on the config parameter |
| 148 | + this.resolver = this.config.getBoolean("useProxyAgnosticResolver", false) |
| 149 | + ? new ProxyAgnosticMojangResolver(resolverOptions) : new MojangResolver(resolverOptions); |
| 150 | + |
| 151 | + antiBot = createAntiBotService(config.getSection("anti-bot")); |
148 | 152 | } |
149 | 153 |
|
150 | 154 | private AntiBotService createAntiBotService(Configuration botSection) { |
|
0 commit comments