Browse Source

traceinfo

master
gsd 2 years ago
parent
commit
b10783ba7a
  1. 3
      ext/python-a2s-rcon-api/service.py
  2. 46
      src/test/java/app/servers/TestServersA2S.java
  3. 15
      src/test/java/app/updates/VkSocialGetter.java

3
ext/python-a2s-rcon-api/service.py

@ -68,6 +68,7 @@ class SourceBackend:
passwd = request.password
)
except:
print(request.__dict__)
return Response(status_code = 400)
@self.app.post("/api/a2s/info")
@ -78,6 +79,7 @@ class SourceBackend:
try:
return JSONResponse(content=dict(await VALVE_SERVER_INFO(request.tuple_address)))
except:
print(request.__dict__)
traceback.print_exc()
return Response(status_code = 400)
@ -89,6 +91,7 @@ class SourceBackend:
try:
return JSONResponse(content=dict(await VALVE_SERVER_PLAYERS(request.tuple_address)))
except:
print(request.__dict__)
traceback.print_exc()
return Response(status_code = 400)

46
src/test/java/app/servers/TestServersA2S.java

@ -0,0 +1,46 @@
package app.servers;
import app.entities.server.Server;
import com.ibasco.agql.protocols.valve.source.query.SourceQueryClient;
import org.junit.Test;
import java.io.IOException;
import java.util.concurrent.*;
public class TestServersA2S {
SourceQueryClient sourceQueryClient;
public void check() throws InterruptedException {
int count = 1;
Server server = new Server();
server.setAddress("192.168.3.3:27005");
while (true) {
try (SourceQueryClient sourceQueryClient = getClient()) {
int finalCount = count;
final CountDownLatch latch = new CountDownLatch(1);
System.out.printf("[%d] Request\n", finalCount);
sourceQueryClient.getInfo(null).whenComplete((info, error) -> {
latch.countDown();
if (error != null) {
server.SetDownStatus();
return;
}
System.out.printf("[%d] Player count: %d\n", finalCount, info.getResult().getNumOfPlayers());
});
latch.await();
count++;
} catch (CompletionException | IOException err) {
err.printStackTrace();
}
Thread.sleep(500);
}
}
public SourceQueryClient getClient() {
//if (sourceQueryClient == null) sourceQueryClient = new SourceQueryClient();
//return sourceQueryClient;
return new SourceQueryClient();
}
}

15
src/test/java/app/updates/VkSocialGetter.java

@ -1,13 +1,26 @@
package app.updates;
import org.junit.Test;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpRequest;
import org.springframework.http.client.ClientHttpRequestExecution;
import org.springframework.http.client.ClientHttpRequestInterceptor;
import org.springframework.http.client.ClientHttpResponse;
import org.springframework.web.client.RestTemplate;
import java.io.IOException;
import java.util.Map;
public class VkSocialGetter {
@Test
public void Check() {
int count = 0;
String response = new RestTemplate().getForEntity("https://m.vk.com/facti13?act=members", String.class).getBody();
RestTemplate restTemplate = new RestTemplate();
String response = restTemplate.exchange("https://m.vk.com/facti13?act=members", HttpMethod.GET, new HttpEntity<>(Map.of("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4584.0 Safari/537.36")), String.class).getBody();
//String response = restTemplate.getForEntity("https://m.vk.com/facti13?act=members", String.class).getBody();
int k_start = response.indexOf("<h3 class=\"slim_header\">") + "<h3 class=\"slim_header\">".length();
int k_end = response.indexOf("<", k_start);
System.out.printf("%d %d\n", k_start, k_end);

Loading…
Cancel
Save