Spaces:
Sleeping
Sleeping
htr
commited on
Commit
·
53a26de
1
Parent(s):
e71345c
- pom - Copy.xml → pom-b.xml +0 -0
- pom-local.xml +95 -0
- src/main/java/com/example/demo/DemoApplication.java +20 -10
- src/main/java/com/example/demo/Test.java +52 -0
- src/main/java/com/example/demo/entity/User_test.java +9 -0
- src/main/java/tqtk/Entity/Accounts.java +29 -0
- src/main/java/tqtk/Entity/SessionEntity.java +88 -50
- src/main/java/tqtk/Entity/User.java +100 -0
- src/main/java/tqtk/Tqtk.java +35 -11
- src/main/java/tqtk/Utils/Util.java +150 -88
- src/main/java/tqtk/XuLy/Worker.java +288 -216
- src/main/java/tqtk/XuLy/login/LayThongTinSession.java +2 -7
- truyna-b.properties +9 -0
- truyna.properties +1 -9
pom - Copy.xml → pom-b.xml
RENAMED
File without changes
|
pom-local.xml
ADDED
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
3 |
+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
4 |
+
<modelVersion>4.0.0</modelVersion>
|
5 |
+
<groupId>com.example</groupId>
|
6 |
+
<artifactId>demo</artifactId>
|
7 |
+
<version>0.0.1-SNAPSHOT</version>
|
8 |
+
<name>demo</name>
|
9 |
+
<description>Demo project for Spring Boot</description>
|
10 |
+
<properties>
|
11 |
+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
12 |
+
<maven.compiler.source>1.8</maven.compiler.source>
|
13 |
+
<maven.compiler.target>1.8</maven.compiler.target>
|
14 |
+
</properties>
|
15 |
+
<dependencies>
|
16 |
+
<dependency>
|
17 |
+
<groupId>org.apache.commons</groupId>
|
18 |
+
<artifactId>commons-lang3</artifactId>
|
19 |
+
<version>3.9</version>
|
20 |
+
</dependency>
|
21 |
+
<dependency>
|
22 |
+
<groupId>com.fasterxml.jackson.core</groupId>
|
23 |
+
<artifactId>jackson-annotations</artifactId>
|
24 |
+
<version>2.13.3</version>
|
25 |
+
|
26 |
+
</dependency>
|
27 |
+
<dependency>
|
28 |
+
<groupId>com.fasterxml.jackson.core</groupId>
|
29 |
+
<artifactId>jackson-core</artifactId>
|
30 |
+
<version>2.13.3</version>
|
31 |
+
|
32 |
+
</dependency>
|
33 |
+
<dependency>
|
34 |
+
<groupId>com.fasterxml.jackson.core</groupId>
|
35 |
+
<artifactId>jackson-databind</artifactId>
|
36 |
+
<version>2.12.7.1</version>
|
37 |
+
|
38 |
+
</dependency>
|
39 |
+
<dependency>
|
40 |
+
<groupId>org.springframework</groupId>
|
41 |
+
<artifactId>spring-webmvc</artifactId>
|
42 |
+
<version>4.3.2.RELEASE</version>
|
43 |
+
</dependency>
|
44 |
+
<dependency>
|
45 |
+
<groupId>org.springframework</groupId>
|
46 |
+
<artifactId>spring-jdbc</artifactId>
|
47 |
+
<version>4.3.3.RELEASE</version>
|
48 |
+
|
49 |
+
</dependency>
|
50 |
+
<dependency>
|
51 |
+
<groupId>org.springframework.data</groupId>
|
52 |
+
<artifactId>spring-data-jpa</artifactId>
|
53 |
+
<version>1.10.2.RELEASE</version>
|
54 |
+
</dependency>
|
55 |
+
<!-- https://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple -->
|
56 |
+
<dependency>
|
57 |
+
<groupId>com.googlecode.json-simple</groupId>
|
58 |
+
<artifactId>json-simple</artifactId>
|
59 |
+
<version>1.1.1</version>
|
60 |
+
</dependency>
|
61 |
+
<dependency>
|
62 |
+
<groupId>org.apache.httpcomponents</groupId>
|
63 |
+
<artifactId>httpcore</artifactId>
|
64 |
+
<version>4.0-alpha6</version>
|
65 |
+
</dependency>
|
66 |
+
|
67 |
+
</dependencies>
|
68 |
+
|
69 |
+
<repositories>
|
70 |
+
<repository>
|
71 |
+
<id>central</id>
|
72 |
+
<name>Central Repository</name>
|
73 |
+
<url>https://repo.maven.apache.org/maven2</url>
|
74 |
+
<layout>default</layout>
|
75 |
+
<snapshots>
|
76 |
+
<enabled>false</enabled>
|
77 |
+
</snapshots>
|
78 |
+
</repository>
|
79 |
+
</repositories>
|
80 |
+
<pluginRepositories>
|
81 |
+
<pluginRepository>
|
82 |
+
<id>central</id>
|
83 |
+
<name>Central Repository</name>
|
84 |
+
<url>https://repo.maven.apache.org/maven2</url>
|
85 |
+
<layout>default</layout>
|
86 |
+
<snapshots>
|
87 |
+
<enabled>false</enabled>
|
88 |
+
</snapshots>
|
89 |
+
<releases>
|
90 |
+
<updatePolicy>never</updatePolicy>
|
91 |
+
</releases>
|
92 |
+
</pluginRepository>
|
93 |
+
</pluginRepositories>
|
94 |
+
|
95 |
+
</project>
|
src/main/java/com/example/demo/DemoApplication.java
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
package com.example.demo;
|
2 |
|
3 |
-
import com.example.demo.entity.
|
4 |
import com.example.demo.repository.UserRepository;
|
5 |
import org.springframework.beans.factory.annotation.Autowired;
|
6 |
import org.springframework.boot.SpringApplication;
|
@@ -32,6 +32,8 @@ import org.springframework.context.ApplicationContext;
|
|
32 |
import tqtk.Entity.SessionEntity;
|
33 |
import tqtk.Entity.Params;
|
34 |
import tqtk.Tqtk;
|
|
|
|
|
35 |
import tqtk.XuLy.Worker;
|
36 |
import tqtk.XuLy.XuLyPacket;
|
37 |
import tqtk.XuLy.login.LayThongTinSession;
|
@@ -50,10 +52,9 @@ public class DemoApplication {
|
|
50 |
|
51 |
@GetMapping("exit")
|
52 |
public String getExit() throws IOException {
|
53 |
-
List<SessionEntity> ss =
|
54 |
for (int i = 0; i < ss.size(); ++i) {
|
55 |
ss.get(i).getSocket().close();
|
56 |
-
ss.get(i).getSocketApi().close();
|
57 |
}
|
58 |
SpringApplication.exit(context);
|
59 |
return "exit";
|
@@ -67,7 +68,7 @@ public class DemoApplication {
|
|
67 |
|
68 |
@GetMapping("start")
|
69 |
public String start() {
|
70 |
-
if (
|
71 |
Thread t = new Thread() {
|
72 |
public void run() {
|
73 |
tqtk.Tqtk.main();
|
@@ -78,11 +79,20 @@ public class DemoApplication {
|
|
78 |
return "ok";
|
79 |
}
|
80 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
@RequestMapping(value = "/sendcmd", method = RequestMethod.POST)
|
82 |
@ResponseBody
|
83 |
public String sendcmd(@RequestBody String cmd,
|
84 |
@RequestParam(value = "id", required = true) String id) throws IOException, UnknownHostException, InterruptedException {
|
85 |
-
List<SessionEntity> ss =
|
86 |
for (int i = 0; i < ss.size(); ++i) {
|
87 |
if (id.equals(ss.get(i).getUserId())) {
|
88 |
XuLyPacket.GuiPacketHTTP(ss.get(i), cmd);
|
@@ -113,12 +123,12 @@ public class DemoApplication {
|
|
113 |
// }
|
114 |
// }
|
115 |
// }.start();
|
116 |
-
List<SessionEntity> ss =
|
117 |
for (int i = 0; i < ss.size(); ++i) {
|
118 |
if (id.equals(ss.get(i).getUserId())) {
|
119 |
try {
|
120 |
XuLyPacket.GuiPacketHTTP2(ss.get(i), cmd);
|
121 |
-
|
122 |
} catch (IOException ex) {
|
123 |
Logger.getLogger(DemoApplication.class.getName()).log(Level.SEVERE, null, ex);
|
124 |
} catch (InterruptedException ex) {
|
@@ -132,7 +142,7 @@ public class DemoApplication {
|
|
132 |
@GetMapping("createSocket")
|
133 |
public String createSocket(@RequestParam(value = "id", required = true) String id) throws Exception {
|
134 |
String output = "";
|
135 |
-
List<SessionEntity> ss =
|
136 |
for (int i = 0; i < ss.size(); ++i) {
|
137 |
if (id.equals(ss.get(i).getUserId())) {
|
138 |
Worker.createSocket(ss.get(i));
|
@@ -145,7 +155,7 @@ public class DemoApplication {
|
|
145 |
@GetMapping("createSocketapi")
|
146 |
public String createSocketApi(@RequestParam(value = "id", required = true) String id) throws Exception {
|
147 |
String output = "";
|
148 |
-
List<SessionEntity> ss =
|
149 |
for (int i = 0; i < ss.size(); ++i) {
|
150 |
if (id.equals(ss.get(i).getUserId())) {
|
151 |
Worker.createSocketApi(ss.get(i));
|
@@ -159,7 +169,7 @@ public class DemoApplication {
|
|
159 |
public String setSessionId(@RequestParam(value = "id", required = true) String id,
|
160 |
@RequestParam(value = "session", required = true) String session) throws Exception {
|
161 |
String output = "";
|
162 |
-
List<SessionEntity> ss =
|
163 |
for (int i = 0; i < ss.size(); ++i) {
|
164 |
if (id.equals(ss.get(i).getUserId())) {
|
165 |
ss.get(i).setSessionKey(session);
|
|
|
1 |
package com.example.demo;
|
2 |
|
3 |
+
import com.example.demo.entity.User_test;
|
4 |
import com.example.demo.repository.UserRepository;
|
5 |
import org.springframework.beans.factory.annotation.Autowired;
|
6 |
import org.springframework.boot.SpringApplication;
|
|
|
32 |
import tqtk.Entity.SessionEntity;
|
33 |
import tqtk.Entity.Params;
|
34 |
import tqtk.Tqtk;
|
35 |
+
import static tqtk.Tqtk.listSession;
|
36 |
+
import tqtk.Utils.Util;
|
37 |
import tqtk.XuLy.Worker;
|
38 |
import tqtk.XuLy.XuLyPacket;
|
39 |
import tqtk.XuLy.login.LayThongTinSession;
|
|
|
52 |
|
53 |
@GetMapping("exit")
|
54 |
public String getExit() throws IOException {
|
55 |
+
List<SessionEntity> ss = Tqtk.listSession;
|
56 |
for (int i = 0; i < ss.size(); ++i) {
|
57 |
ss.get(i).getSocket().close();
|
|
|
58 |
}
|
59 |
SpringApplication.exit(context);
|
60 |
return "exit";
|
|
|
68 |
|
69 |
@GetMapping("start")
|
70 |
public String start() {
|
71 |
+
if (Tqtk.listSession.size() < 1) {
|
72 |
Thread t = new Thread() {
|
73 |
public void run() {
|
74 |
tqtk.Tqtk.main();
|
|
|
79 |
return "ok";
|
80 |
}
|
81 |
|
82 |
+
@RequestMapping(value = "/updateInfo", method = RequestMethod.POST)
|
83 |
+
@ResponseBody
|
84 |
+
public String updateInfo(
|
85 |
+
@RequestParam(value = "id", required = true) String id) throws IOException, UnknownHostException, InterruptedException, Exception {
|
86 |
+
|
87 |
+
Util.updateData(id);
|
88 |
+
return "ok";
|
89 |
+
}
|
90 |
+
|
91 |
@RequestMapping(value = "/sendcmd", method = RequestMethod.POST)
|
92 |
@ResponseBody
|
93 |
public String sendcmd(@RequestBody String cmd,
|
94 |
@RequestParam(value = "id", required = true) String id) throws IOException, UnknownHostException, InterruptedException {
|
95 |
+
List<SessionEntity> ss = Tqtk.listSession;
|
96 |
for (int i = 0; i < ss.size(); ++i) {
|
97 |
if (id.equals(ss.get(i).getUserId())) {
|
98 |
XuLyPacket.GuiPacketHTTP(ss.get(i), cmd);
|
|
|
123 |
// }
|
124 |
// }
|
125 |
// }.start();
|
126 |
+
List<SessionEntity> ss = Tqtk.listSession;
|
127 |
for (int i = 0; i < ss.size(); ++i) {
|
128 |
if (id.equals(ss.get(i).getUserId())) {
|
129 |
try {
|
130 |
XuLyPacket.GuiPacketHTTP2(ss.get(i), cmd);
|
131 |
+
return "ok";
|
132 |
} catch (IOException ex) {
|
133 |
Logger.getLogger(DemoApplication.class.getName()).log(Level.SEVERE, null, ex);
|
134 |
} catch (InterruptedException ex) {
|
|
|
142 |
@GetMapping("createSocket")
|
143 |
public String createSocket(@RequestParam(value = "id", required = true) String id) throws Exception {
|
144 |
String output = "";
|
145 |
+
List<SessionEntity> ss = Tqtk.listSession;
|
146 |
for (int i = 0; i < ss.size(); ++i) {
|
147 |
if (id.equals(ss.get(i).getUserId())) {
|
148 |
Worker.createSocket(ss.get(i));
|
|
|
155 |
@GetMapping("createSocketapi")
|
156 |
public String createSocketApi(@RequestParam(value = "id", required = true) String id) throws Exception {
|
157 |
String output = "";
|
158 |
+
List<SessionEntity> ss = Tqtk.listSession;
|
159 |
for (int i = 0; i < ss.size(); ++i) {
|
160 |
if (id.equals(ss.get(i).getUserId())) {
|
161 |
Worker.createSocketApi(ss.get(i));
|
|
|
169 |
public String setSessionId(@RequestParam(value = "id", required = true) String id,
|
170 |
@RequestParam(value = "session", required = true) String session) throws Exception {
|
171 |
String output = "";
|
172 |
+
List<SessionEntity> ss = Tqtk.listSession;
|
173 |
for (int i = 0; i < ss.size(); ++i) {
|
174 |
if (id.equals(ss.get(i).getUserId())) {
|
175 |
ss.get(i).setSessionKey(session);
|
src/main/java/com/example/demo/Test.java
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
package com.example.demo;
|
2 |
+
|
3 |
+
import com.example.demo.entity.User_test;
|
4 |
+
import com.example.demo.repository.UserRepository;
|
5 |
+
import com.fasterxml.jackson.databind.DeserializationFeature;
|
6 |
+
import com.fasterxml.jackson.databind.ObjectMapper;
|
7 |
+
import java.io.BufferedInputStream;
|
8 |
+
import org.springframework.beans.factory.annotation.Autowired;
|
9 |
+
import org.springframework.web.bind.annotation.GetMapping;
|
10 |
+
import org.springframework.web.bind.annotation.RestController;
|
11 |
+
import org.springframework.web.bind.annotation.RequestParam;
|
12 |
+
|
13 |
+
import org.springframework.web.bind.annotation.RequestBody;
|
14 |
+
import org.springframework.web.bind.annotation.RequestMapping;
|
15 |
+
import org.springframework.web.bind.annotation.RequestMethod;
|
16 |
+
import org.springframework.web.bind.annotation.RequestParam;
|
17 |
+
import org.springframework.web.bind.annotation.ResponseBody;
|
18 |
+
|
19 |
+
import java.io.BufferedReader;
|
20 |
+
import java.io.BufferedWriter;
|
21 |
+
import java.io.File;
|
22 |
+
import java.io.FileOutputStream;
|
23 |
+
import java.io.IOException;
|
24 |
+
import java.io.InputStreamReader;
|
25 |
+
import java.io.OutputStreamWriter;
|
26 |
+
import java.io.Writer;
|
27 |
+
import java.net.HttpURLConnection;
|
28 |
+
import java.net.URL;
|
29 |
+
import java.net.UnknownHostException;
|
30 |
+
import java.util.List;
|
31 |
+
import java.util.logging.Level;
|
32 |
+
import java.util.logging.Logger;
|
33 |
+
import javax.net.ssl.HttpsURLConnection;
|
34 |
+
import org.apache.http.util.ByteArrayBuffer;
|
35 |
+
import org.springframework.context.ApplicationContext;
|
36 |
+
import tqtk.Entity.Accounts;
|
37 |
+
import tqtk.Entity.SessionEntity;
|
38 |
+
import tqtk.Entity.Params;
|
39 |
+
import tqtk.Tqtk;
|
40 |
+
import tqtk.XuLy.Worker;
|
41 |
+
import tqtk.XuLy.XuLyPacket;
|
42 |
+
import tqtk.XuLy.login.LayThongTinSession;
|
43 |
+
|
44 |
+
public class Test {
|
45 |
+
|
46 |
+
|
47 |
+
|
48 |
+
public void main(String[] args) throws Exception {
|
49 |
+
tqtk.Tqtk.main();
|
50 |
+
}
|
51 |
+
|
52 |
+
}
|
src/main/java/com/example/demo/entity/User_test.java
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
package com.example.demo.entity;
|
2 |
+
|
3 |
+
|
4 |
+
import java.io.Serializable;
|
5 |
+
|
6 |
+
|
7 |
+
public class User_test implements Serializable {
|
8 |
+
|
9 |
+
}
|
src/main/java/tqtk/Entity/Accounts.java
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*
|
2 |
+
* To change this license header, choose License Headers in Project Properties.
|
3 |
+
* To change this template file, choose Tools | Templates
|
4 |
+
* and open the template in the editor.
|
5 |
+
*/
|
6 |
+
package tqtk.Entity;
|
7 |
+
|
8 |
+
import com.fasterxml.jackson.annotation.JsonProperty;
|
9 |
+
import java.util.List;
|
10 |
+
|
11 |
+
/**
|
12 |
+
*
|
13 |
+
* @author Alex
|
14 |
+
*/
|
15 |
+
public class Accounts {
|
16 |
+
|
17 |
+
@JsonProperty("accounts")
|
18 |
+
List<SessionEntity> accounts;
|
19 |
+
|
20 |
+
public List<SessionEntity> getAccounts() {
|
21 |
+
return accounts;
|
22 |
+
}
|
23 |
+
|
24 |
+
public void setAccounts(List<SessionEntity> accounts) {
|
25 |
+
this.accounts = accounts;
|
26 |
+
}
|
27 |
+
|
28 |
+
|
29 |
+
}
|
src/main/java/tqtk/Entity/SessionEntity.java
CHANGED
@@ -5,10 +5,12 @@
|
|
5 |
*/
|
6 |
package tqtk.Entity;
|
7 |
|
|
|
8 |
import java.io.IOException;
|
9 |
import java.net.InetAddress;
|
10 |
import java.net.InetSocketAddress;
|
11 |
import java.net.Socket;
|
|
|
12 |
|
13 |
/**
|
14 |
*
|
@@ -16,17 +18,97 @@ import java.net.Socket;
|
|
16 |
*/
|
17 |
public class SessionEntity {
|
18 |
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
private Socket socket;
|
25 |
private boolean isConnected;
|
26 |
private String stringName;
|
27 |
private Socket socketApi;
|
28 |
private Socket socketTN;
|
29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
public Socket getSocketTN() {
|
31 |
return socketTN;
|
32 |
}
|
@@ -51,10 +133,6 @@ public class SessionEntity {
|
|
51 |
this.stringName = stringName;
|
52 |
}
|
53 |
|
54 |
-
public SessionEntity(String stringName, String pass) {
|
55 |
-
this.stringName = stringName;
|
56 |
-
this.pass = pass;
|
57 |
-
}
|
58 |
|
59 |
public SessionEntity() {
|
60 |
}
|
@@ -62,16 +140,9 @@ public class SessionEntity {
|
|
62 |
public void resetSocket() throws IOException {
|
63 |
this.socket.close();
|
64 |
this.socket = new Socket();
|
65 |
-
this.socket.connect(new InetSocketAddress(InetAddress.getByName(
|
66 |
}
|
67 |
|
68 |
-
public String getPass() {
|
69 |
-
return pass;
|
70 |
-
}
|
71 |
-
|
72 |
-
public void setPass(String pass) {
|
73 |
-
this.pass = pass;
|
74 |
-
}
|
75 |
|
76 |
public boolean isIsConnected() {
|
77 |
return isConnected;
|
@@ -98,37 +169,4 @@ public class SessionEntity {
|
|
98 |
public void setMessage(StringBuilder message) {
|
99 |
this.message = message;
|
100 |
}
|
101 |
-
|
102 |
-
public String getUserId() {
|
103 |
-
return userId;
|
104 |
-
}
|
105 |
-
|
106 |
-
public void setUserId(String userId) {
|
107 |
-
this.userId = userId;
|
108 |
-
}
|
109 |
-
|
110 |
-
public String getIp() {
|
111 |
-
return ip;
|
112 |
-
}
|
113 |
-
|
114 |
-
public void setIp(String ip) {
|
115 |
-
this.ip = ip;
|
116 |
-
}
|
117 |
-
|
118 |
-
public int getPorts() {
|
119 |
-
return ports;
|
120 |
-
}
|
121 |
-
|
122 |
-
public void setPorts(int ports) {
|
123 |
-
this.ports = ports;
|
124 |
-
}
|
125 |
-
|
126 |
-
public String getSessionKey() {
|
127 |
-
return sessionKey;
|
128 |
-
}
|
129 |
-
|
130 |
-
public void setSessionKey(String sessionKey) {
|
131 |
-
this.sessionKey = sessionKey;
|
132 |
-
}
|
133 |
-
|
134 |
}
|
|
|
5 |
*/
|
6 |
package tqtk.Entity;
|
7 |
|
8 |
+
import com.fasterxml.jackson.annotation.JsonProperty;
|
9 |
import java.io.IOException;
|
10 |
import java.net.InetAddress;
|
11 |
import java.net.InetSocketAddress;
|
12 |
import java.net.Socket;
|
13 |
+
import java.util.List;
|
14 |
|
15 |
/**
|
16 |
*
|
|
|
18 |
*/
|
19 |
public class SessionEntity {
|
20 |
|
21 |
+
@JsonProperty("Ip")
|
22 |
+
String Ip;
|
23 |
+
@JsonProperty("Port")
|
24 |
+
String Port;
|
25 |
+
@JsonProperty("SessionKey")
|
26 |
+
String SessionKey;
|
27 |
+
@JsonProperty("UserId")
|
28 |
+
String UserId;
|
29 |
+
@JsonProperty("ItemIds")
|
30 |
+
List<String> ItemIds;
|
31 |
+
@JsonProperty("HeroIds")
|
32 |
+
List<String> HeroIds;
|
33 |
+
@JsonProperty("BuildingIds")
|
34 |
+
List<String> BuildingIds;
|
35 |
+
@JsonProperty("SkillIds")
|
36 |
+
List<String> SkillIds;
|
37 |
+
|
38 |
private Socket socket;
|
39 |
private boolean isConnected;
|
40 |
private String stringName;
|
41 |
private Socket socketApi;
|
42 |
private Socket socketTN;
|
43 |
|
44 |
+
public String getIp() {
|
45 |
+
return Ip;
|
46 |
+
}
|
47 |
+
|
48 |
+
public void setIp(String Ip) {
|
49 |
+
this.Ip = Ip;
|
50 |
+
}
|
51 |
+
|
52 |
+
public String getPort() {
|
53 |
+
return Port;
|
54 |
+
}
|
55 |
+
|
56 |
+
public void setPort(String Port) {
|
57 |
+
this.Port = Port;
|
58 |
+
}
|
59 |
+
|
60 |
+
public String getSessionKey() {
|
61 |
+
return SessionKey;
|
62 |
+
}
|
63 |
+
|
64 |
+
public void setSessionKey(String SessionKey) {
|
65 |
+
this.SessionKey = SessionKey;
|
66 |
+
}
|
67 |
+
|
68 |
+
public String getUserId() {
|
69 |
+
return UserId;
|
70 |
+
}
|
71 |
+
|
72 |
+
public void setUserId(String UserId) {
|
73 |
+
this.UserId = UserId;
|
74 |
+
}
|
75 |
+
|
76 |
+
public List<String> getItemIds() {
|
77 |
+
return ItemIds;
|
78 |
+
}
|
79 |
+
|
80 |
+
public void setItemIds(List<String> ItemIds) {
|
81 |
+
this.ItemIds = ItemIds;
|
82 |
+
}
|
83 |
+
|
84 |
+
|
85 |
+
|
86 |
+
public List<String> getHeroIds() {
|
87 |
+
return HeroIds;
|
88 |
+
}
|
89 |
+
|
90 |
+
public void setHeroIds(List<String> HeroIds) {
|
91 |
+
this.HeroIds = HeroIds;
|
92 |
+
}
|
93 |
+
|
94 |
+
public List<String> getBuildingIds() {
|
95 |
+
return BuildingIds;
|
96 |
+
}
|
97 |
+
|
98 |
+
public void setBuildingIds(List<String> BuildingIds) {
|
99 |
+
this.BuildingIds = BuildingIds;
|
100 |
+
}
|
101 |
+
|
102 |
+
public List<String> getSkillIds() {
|
103 |
+
return SkillIds;
|
104 |
+
}
|
105 |
+
|
106 |
+
public void setSkillIds(List<String> SkillIds) {
|
107 |
+
this.SkillIds = SkillIds;
|
108 |
+
}
|
109 |
+
|
110 |
+
|
111 |
+
|
112 |
public Socket getSocketTN() {
|
113 |
return socketTN;
|
114 |
}
|
|
|
133 |
this.stringName = stringName;
|
134 |
}
|
135 |
|
|
|
|
|
|
|
|
|
136 |
|
137 |
public SessionEntity() {
|
138 |
}
|
|
|
140 |
public void resetSocket() throws IOException {
|
141 |
this.socket.close();
|
142 |
this.socket = new Socket();
|
143 |
+
this.socket.connect(new InetSocketAddress(InetAddress.getByName(Ip), Integer.parseInt(Port)), 7000);
|
144 |
}
|
145 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
|
147 |
public boolean isIsConnected() {
|
148 |
return isConnected;
|
|
|
169 |
public void setMessage(StringBuilder message) {
|
170 |
this.message = message;
|
171 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
172 |
}
|
src/main/java/tqtk/Entity/User.java
ADDED
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*
|
2 |
+
* To change this license header, choose License Headers in Project Properties.
|
3 |
+
* To change this template file, choose Tools | Templates
|
4 |
+
* and open the template in the editor.
|
5 |
+
*/
|
6 |
+
package tqtk.Entity;
|
7 |
+
|
8 |
+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
9 |
+
import com.fasterxml.jackson.annotation.JsonProperty;
|
10 |
+
import java.util.List;
|
11 |
+
|
12 |
+
/**
|
13 |
+
*
|
14 |
+
* @author Alex
|
15 |
+
*/
|
16 |
+
@JsonIgnoreProperties
|
17 |
+
public class User {
|
18 |
+
|
19 |
+
@JsonProperty("Ip")
|
20 |
+
String Ip;
|
21 |
+
@JsonProperty("Port")
|
22 |
+
String Port;
|
23 |
+
@JsonProperty("SessionKey")
|
24 |
+
String SessionKey;
|
25 |
+
@JsonProperty("UserId")
|
26 |
+
String UserId;
|
27 |
+
@JsonProperty("ItemId")
|
28 |
+
List<String> ItemId;
|
29 |
+
@JsonProperty("HeroIds")
|
30 |
+
List<String> HeroIds;
|
31 |
+
@JsonProperty("BuildingIds")
|
32 |
+
List<String> BuildingIds;
|
33 |
+
@JsonProperty("SkillIds")
|
34 |
+
List<String> SkillIds;
|
35 |
+
|
36 |
+
public List<String> getHeroIds() {
|
37 |
+
return HeroIds;
|
38 |
+
}
|
39 |
+
|
40 |
+
public void setHeroIds(List<String> HeroIds) {
|
41 |
+
this.HeroIds = HeroIds;
|
42 |
+
}
|
43 |
+
|
44 |
+
public List<String> getBuildingIds() {
|
45 |
+
return BuildingIds;
|
46 |
+
}
|
47 |
+
|
48 |
+
public void setBuildingIds(List<String> BuildingIds) {
|
49 |
+
this.BuildingIds = BuildingIds;
|
50 |
+
}
|
51 |
+
|
52 |
+
public List<String> getSkillIds() {
|
53 |
+
return SkillIds;
|
54 |
+
}
|
55 |
+
|
56 |
+
public void setSkillIds(List<String> SkillIds) {
|
57 |
+
this.SkillIds = SkillIds;
|
58 |
+
}
|
59 |
+
|
60 |
+
public String getIp() {
|
61 |
+
return Ip;
|
62 |
+
}
|
63 |
+
|
64 |
+
public void setIp(String Ip) {
|
65 |
+
this.Ip = Ip;
|
66 |
+
}
|
67 |
+
|
68 |
+
public String getPort() {
|
69 |
+
return Port;
|
70 |
+
}
|
71 |
+
|
72 |
+
public void setPort(String Port) {
|
73 |
+
this.Port = Port;
|
74 |
+
}
|
75 |
+
|
76 |
+
public String getSessionKey() {
|
77 |
+
return SessionKey;
|
78 |
+
}
|
79 |
+
|
80 |
+
public void setSessionKey(String SessionKey) {
|
81 |
+
this.SessionKey = SessionKey;
|
82 |
+
}
|
83 |
+
|
84 |
+
public String getUserId() {
|
85 |
+
return UserId;
|
86 |
+
}
|
87 |
+
|
88 |
+
public void setUserId(String UserId) {
|
89 |
+
this.UserId = UserId;
|
90 |
+
}
|
91 |
+
|
92 |
+
public List<String> getItemId() {
|
93 |
+
return ItemId;
|
94 |
+
}
|
95 |
+
|
96 |
+
public void setItemId(List<String> ItemId) {
|
97 |
+
this.ItemId = ItemId;
|
98 |
+
}
|
99 |
+
|
100 |
+
}
|
src/main/java/tqtk/Tqtk.java
CHANGED
@@ -5,6 +5,7 @@
|
|
5 |
*/
|
6 |
package tqtk;
|
7 |
|
|
|
8 |
import java.net.InetAddress;
|
9 |
import java.net.InetSocketAddress;
|
10 |
import java.net.Socket;
|
@@ -33,31 +34,54 @@ public class Tqtk {
|
|
33 |
public static List<String> loaiTruyna = new ArrayList<>();
|
34 |
public static List<TruyNa> listtruyna = new ArrayList<>();
|
35 |
public static List<Object> listruong = new ArrayList<>();
|
|
|
|
|
|
|
36 |
|
37 |
static {
|
38 |
loaiTruyna = Collections.synchronizedList(loaiTruyna);
|
39 |
listruong = Collections.synchronizedList(listruong);
|
40 |
listtruyna = Collections.synchronizedList(listtruyna);
|
|
|
|
|
41 |
}
|
42 |
|
43 |
public static void main() {
|
44 |
// TODO code application logic here
|
45 |
try {
|
46 |
-
|
47 |
-
List<SessionEntity> ss = LayThongTinSession.getListSession();
|
48 |
-
String x = GetTextFromGit.getStringFromGithubRaw("https://raw.githubusercontent.com/alexTvirus/Static-Resource/main/user-main");
|
49 |
-
Util.setData1(x, ss);
|
50 |
loaiTruyna = Util.docFileTruyNa("truyna.properties");
|
51 |
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
executor.schedule(worker, 300L, TimeUnit.MILLISECONDS);
|
56 |
}
|
57 |
-
|
58 |
-
while (
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
}
|
60 |
-
System.out.println("tqtk.Tqtk.main()");
|
61 |
|
62 |
} catch (Exception ex) {
|
63 |
System.out.println(ex.getMessage());
|
|
|
5 |
*/
|
6 |
package tqtk;
|
7 |
|
8 |
+
import com.example.demo.entity.User_test;
|
9 |
import java.net.InetAddress;
|
10 |
import java.net.InetSocketAddress;
|
11 |
import java.net.Socket;
|
|
|
34 |
public static List<String> loaiTruyna = new ArrayList<>();
|
35 |
public static List<TruyNa> listtruyna = new ArrayList<>();
|
36 |
public static List<Object> listruong = new ArrayList<>();
|
37 |
+
public static List<User_test> listUser = new ArrayList<>();
|
38 |
+
public static List<SessionEntity> listSession = new ArrayList<>();
|
39 |
+
public static List<Worker> listWorker = new ArrayList<>();
|
40 |
|
41 |
static {
|
42 |
loaiTruyna = Collections.synchronizedList(loaiTruyna);
|
43 |
listruong = Collections.synchronizedList(listruong);
|
44 |
listtruyna = Collections.synchronizedList(listtruyna);
|
45 |
+
listUser = Collections.synchronizedList(listUser);
|
46 |
+
listSession = Collections.synchronizedList(listSession);
|
47 |
}
|
48 |
|
49 |
public static void main() {
|
50 |
// TODO code application logic here
|
51 |
try {
|
52 |
+
listSession = Util.setData1(listSession);
|
|
|
|
|
|
|
53 |
loaiTruyna = Util.docFileTruyNa("truyna.properties");
|
54 |
|
55 |
+
for (int i = 0; i < listSession.size(); ++i) {
|
56 |
+
Runnable worker = new Worker(listSession.get(i));
|
57 |
+
listWorker.add((Worker) worker);
|
|
|
58 |
}
|
59 |
+
ScheduledExecutorService executor = null;
|
60 |
+
while (true) {
|
61 |
+
try {
|
62 |
+
executor = Executors.newScheduledThreadPool(listSession.size());
|
63 |
+
for (int i = 0; i < listSession.size(); ++i) {
|
64 |
+
executor.schedule(listWorker.get(i), 300L, TimeUnit.MILLISECONDS);
|
65 |
+
}
|
66 |
+
executor.shutdown();
|
67 |
+
while (!executor.isTerminated()) {
|
68 |
+
}
|
69 |
+
for (Worker worker : listWorker) {
|
70 |
+
if (!worker.getSs().getUserId().equals("2301230011011923")) {
|
71 |
+
worker.getIdTruyNa();
|
72 |
+
}
|
73 |
+
if (worker.getSs().getUserId().equals("2301230011011923")) {
|
74 |
+
worker.TruyNa();
|
75 |
+
} else {
|
76 |
+
worker.TruyNa2();
|
77 |
+
}
|
78 |
+
|
79 |
+
}
|
80 |
+
} catch (Exception e) {
|
81 |
+
System.out.println(e.getMessage());
|
82 |
+
}
|
83 |
+
|
84 |
}
|
|
|
85 |
|
86 |
} catch (Exception ex) {
|
87 |
System.out.println(ex.getMessage());
|
src/main/java/tqtk/Utils/Util.java
CHANGED
@@ -5,6 +5,9 @@
|
|
5 |
*/
|
6 |
package tqtk.Utils;
|
7 |
|
|
|
|
|
|
|
8 |
import java.io.BufferedReader;
|
9 |
import java.io.DataOutputStream;
|
10 |
import java.io.FileInputStream;
|
@@ -32,32 +35,34 @@ import org.apache.commons.lang3.StringUtils;
|
|
32 |
import tqtk.Entity.SessionEntity;
|
33 |
import java.io.FileReader;
|
34 |
import java.util.Iterator;
|
|
|
35 |
import org.json.simple.JSONArray;
|
36 |
import org.json.simple.JSONObject;
|
37 |
|
38 |
import org.json.simple.parser.JSONParser;
|
|
|
39 |
|
40 |
/**
|
41 |
*
|
42 |
* @author Alex
|
43 |
*/
|
44 |
public class Util {
|
45 |
-
|
46 |
public CookieManager msCookieManager = null;
|
47 |
-
|
48 |
public Util() {
|
49 |
msCookieManager = new CookieManager();
|
50 |
}
|
51 |
-
|
52 |
public void setCookie(CookieManager msCookieManager) {
|
53 |
CookieHandler.setDefault(msCookieManager);
|
54 |
}
|
55 |
-
|
56 |
public String getPageSource(String url) throws Exception {
|
57 |
HttpURLConnection con = null;
|
58 |
try {
|
59 |
URL obj = new URL(url);
|
60 |
-
|
61 |
String pro = obj.getProtocol();
|
62 |
if (pro.equals("http")) {
|
63 |
con = (HttpURLConnection) obj.openConnection();
|
@@ -71,10 +76,10 @@ public class Util {
|
|
71 |
con.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36");
|
72 |
con.setUseCaches(false);
|
73 |
con.setDoOutput(true);
|
74 |
-
|
75 |
int responseCode = con.getResponseCode();
|
76 |
if (200 <= responseCode && responseCode <= 399) {
|
77 |
-
|
78 |
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8"));
|
79 |
StringBuffer response = new StringBuffer();
|
80 |
String inputLine;
|
@@ -82,13 +87,13 @@ public class Util {
|
|
82 |
response.append(inputLine);
|
83 |
}
|
84 |
in.close();
|
85 |
-
|
86 |
return response.toString();
|
87 |
-
|
88 |
} else {
|
89 |
return "Hệ thống đang quá tải vui lòng";
|
90 |
}
|
91 |
-
|
92 |
} catch (Exception e) {
|
93 |
if (e instanceof SocketTimeoutException) {
|
94 |
throw new SocketTimeoutException("");
|
@@ -96,7 +101,7 @@ public class Util {
|
|
96 |
throw e;
|
97 |
}
|
98 |
}
|
99 |
-
|
100 |
public static String getToken(String htmlCode) {
|
101 |
String prefix = "name=\"_token\" value=\"";
|
102 |
int index = htmlCode.indexOf(prefix);
|
@@ -104,7 +109,7 @@ public class Util {
|
|
104 |
// Could not find the prefix string.
|
105 |
return null;
|
106 |
}
|
107 |
-
|
108 |
index += prefix.length();
|
109 |
|
110 |
// Login token has a fixed length of 40.
|
@@ -113,11 +118,11 @@ public class Util {
|
|
113 |
// Given html code is not long enough.
|
114 |
return null;
|
115 |
}
|
116 |
-
|
117 |
String token = htmlCode.substring(index, index + TokenLength);
|
118 |
return token;
|
119 |
}
|
120 |
-
|
121 |
public static String getRefer(String htmlCode) throws UnsupportedEncodingException {
|
122 |
String prefix = "action=\"";
|
123 |
int prefixIndex = htmlCode.indexOf(prefix);
|
@@ -127,19 +132,19 @@ public class Util {
|
|
127 |
}
|
128 |
String suffix = "\" accept-charset";
|
129 |
int suffixIndex = htmlCode.indexOf(suffix);
|
130 |
-
|
131 |
int beginIndex = prefixIndex + prefix.length();
|
132 |
int endIndex = suffixIndex;
|
133 |
String address = htmlCode.substring(beginIndex, endIndex);
|
134 |
String result = java.net.URLDecoder.decode(address, StandardCharsets.UTF_8.toString());
|
135 |
return result.replace("&", "&");
|
136 |
}
|
137 |
-
|
138 |
public String dangNhap(String url, String user, String pass, String token, String Refer) throws Exception {
|
139 |
HttpURLConnection con = null;
|
140 |
try {
|
141 |
URL obj = new URL(Refer);
|
142 |
-
|
143 |
String pro = obj.getProtocol();
|
144 |
if (pro.equals("http")) {
|
145 |
con = (HttpURLConnection) obj.openConnection();
|
@@ -159,14 +164,14 @@ public class Util {
|
|
159 |
con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
|
160 |
con.setUseCaches(false);
|
161 |
con.setDoOutput(true);
|
162 |
-
|
163 |
DataOutputStream wr = new DataOutputStream(con.getOutputStream());
|
164 |
wr.write(postData);
|
165 |
wr.flush();
|
166 |
wr.close();
|
167 |
int responseCode = con.getResponseCode();
|
168 |
if (200 <= responseCode && responseCode <= 399) {
|
169 |
-
|
170 |
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8"));
|
171 |
StringBuffer response = new StringBuffer();
|
172 |
String inputLine;
|
@@ -174,13 +179,13 @@ public class Util {
|
|
174 |
response.append(inputLine);
|
175 |
}
|
176 |
in.close();
|
177 |
-
|
178 |
return response.toString();
|
179 |
-
|
180 |
} else {
|
181 |
return "Hệ thống đang quá tải vui lòng";
|
182 |
}
|
183 |
-
|
184 |
} catch (Exception e) {
|
185 |
if (e instanceof SocketTimeoutException) {
|
186 |
throw new SocketTimeoutException("");
|
@@ -188,12 +193,12 @@ public class Util {
|
|
188 |
throw e;
|
189 |
}
|
190 |
}
|
191 |
-
|
192 |
public String getThongTinFrame(String url) throws Exception {
|
193 |
HttpURLConnection con = null;
|
194 |
try {
|
195 |
URL obj = new URL(url);
|
196 |
-
|
197 |
String pro = obj.getProtocol();
|
198 |
if (pro.equals("http")) {
|
199 |
con = (HttpURLConnection) obj.openConnection();
|
@@ -207,10 +212,10 @@ public class Util {
|
|
207 |
// con.setRequestProperty("Upgrade-Insecure-Requests", "1");
|
208 |
con.setUseCaches(false);
|
209 |
con.setDoOutput(true);
|
210 |
-
|
211 |
int responseCode = con.getResponseCode();
|
212 |
if (200 <= responseCode && responseCode <= 399) {
|
213 |
-
|
214 |
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8"));
|
215 |
StringBuffer response = new StringBuffer();
|
216 |
String inputLine;
|
@@ -218,13 +223,13 @@ public class Util {
|
|
218 |
response.append(inputLine);
|
219 |
}
|
220 |
in.close();
|
221 |
-
|
222 |
return response.toString();
|
223 |
-
|
224 |
} else {
|
225 |
return "Hệ thống đang quá tải vui lòng";
|
226 |
}
|
227 |
-
|
228 |
} catch (Exception e) {
|
229 |
if (e instanceof SocketTimeoutException) {
|
230 |
throw new SocketTimeoutException("");
|
@@ -232,12 +237,12 @@ public class Util {
|
|
232 |
throw e;
|
233 |
}
|
234 |
}
|
235 |
-
|
236 |
public String getThongTinPort(String url) throws Exception {
|
237 |
HttpURLConnection con = null;
|
238 |
try {
|
239 |
URL obj = new URL(url);
|
240 |
-
|
241 |
String pro = obj.getProtocol();
|
242 |
if (pro.equals("http")) {
|
243 |
con = (HttpURLConnection) obj.openConnection();
|
@@ -252,10 +257,10 @@ public class Util {
|
|
252 |
con.setRequestProperty("Upgrade-Insecure-Requests", "1");
|
253 |
con.setUseCaches(false);
|
254 |
con.setDoOutput(true);
|
255 |
-
|
256 |
int responseCode = con.getResponseCode();
|
257 |
if (200 <= responseCode && responseCode <= 399) {
|
258 |
-
|
259 |
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8"));
|
260 |
StringBuffer response = new StringBuffer();
|
261 |
String inputLine;
|
@@ -264,11 +269,11 @@ public class Util {
|
|
264 |
}
|
265 |
in.close();
|
266 |
return response.toString();
|
267 |
-
|
268 |
} else {
|
269 |
return "Hệ thống đang quá tải vui lòng";
|
270 |
}
|
271 |
-
|
272 |
} catch (Exception e) {
|
273 |
if (e instanceof SocketTimeoutException) {
|
274 |
throw new SocketTimeoutException("");
|
@@ -276,7 +281,7 @@ public class Util {
|
|
276 |
throw e;
|
277 |
}
|
278 |
}
|
279 |
-
|
280 |
public static String getFrameString(String htmlCode) throws UnsupportedEncodingException {
|
281 |
String prefix = "src=\"";
|
282 |
int index = htmlCode.indexOf(prefix);
|
@@ -284,40 +289,40 @@ public class Util {
|
|
284 |
// Could not find the prefix string.
|
285 |
return null;
|
286 |
}
|
287 |
-
|
288 |
index += prefix.length();
|
289 |
int suffixIndex = htmlCode.indexOf("\" frameborder");
|
290 |
if (suffixIndex == -1) {
|
291 |
// Could not find the suffix string.
|
292 |
return null;
|
293 |
}
|
294 |
-
|
295 |
String address = htmlCode.substring(index, suffixIndex);
|
296 |
return java.net.URLDecoder.decode(address, StandardCharsets.UTF_8.toString()).replace("&", "&");
|
297 |
}
|
298 |
-
|
299 |
public static String getInfoSocket(String htmlCode, String token) {
|
300 |
token = token + " : ";
|
301 |
int index = htmlCode.indexOf(token);
|
302 |
if (index == -1) {
|
303 |
return null;
|
304 |
}
|
305 |
-
|
306 |
index += token.length();
|
307 |
int suffixIndex = htmlCode.indexOf(",", index);
|
308 |
if (suffixIndex == -1) {
|
309 |
return null;
|
310 |
}
|
311 |
-
|
312 |
String value = htmlCode.substring(index, suffixIndex);
|
313 |
value = value.replaceAll("[\'||\"]", "");
|
314 |
return value;
|
315 |
}
|
316 |
-
|
317 |
public static String TaoMsg(String commandId, List<String> list, SessionEntity ss) throws NoSuchAlgorithmException, UnsupportedEncodingException {
|
318 |
String what_is_this = "5dcd73d391c90e8769618d42a916ea1b";
|
319 |
String input = commandId + ss.getUserId();
|
320 |
-
|
321 |
String msg = String.format("%s\u0001%s\t%s\u0002", commandId, ss.getUserId(), ss.getSessionKey());
|
322 |
Date date = new Date();
|
323 |
long millisecondsSinceEpoch = date.getTime();
|
@@ -327,17 +332,17 @@ public class Util {
|
|
327 |
msg += string + '\t';
|
328 |
}
|
329 |
}
|
330 |
-
|
331 |
input += what_is_this;
|
332 |
if (list != null && list.size() > 0) {
|
333 |
msg = msg.substring(0, msg.length());
|
334 |
}
|
335 |
-
|
336 |
String checksum = hash(input);
|
337 |
msg += String.format("\u0003%s\u0004%d\u0005\0", checksum, millisecondsSinceEpoch);
|
338 |
return msg;
|
339 |
}
|
340 |
-
|
341 |
public static String hash(String input) throws NoSuchAlgorithmException, UnsupportedEncodingException {
|
342 |
MessageDigest md = MessageDigest.getInstance("MD5");
|
343 |
byte[] buffer = md.digest(input.getBytes("UTF8"));
|
@@ -347,9 +352,9 @@ public class Util {
|
|
347 |
}
|
348 |
return builder.toString();
|
349 |
}
|
350 |
-
|
351 |
public static Properties loadProperties(String file_name) {
|
352 |
-
|
353 |
final Properties pr = new Properties();
|
354 |
//window
|
355 |
// String x = "D:\\7-Project\\Java\\1. Netbean\\2. nghien-cuu\\TQTK\\runshell\\"+file_name;
|
@@ -364,7 +369,7 @@ public class Util {
|
|
364 |
}
|
365 |
return pr;
|
366 |
}
|
367 |
-
|
368 |
public static void setData(String file_name, List<SessionEntity> ss) {
|
369 |
org.json.simple.JSONObject jSONObject = null;
|
370 |
JSONParser jsonParser = new JSONParser();
|
@@ -373,49 +378,68 @@ public class Util {
|
|
373 |
try (FileReader reader = new FileReader(x)) {
|
374 |
//Read JSON file
|
375 |
jSONObject = (org.json.simple.JSONObject) jsonParser.parse(reader);
|
376 |
-
|
377 |
JSONArray jSONArray = (JSONArray) jSONObject.get("accounts");
|
378 |
-
|
379 |
for (Iterator it = jSONArray.iterator(); it.hasNext();) {
|
380 |
jSONObject = (JSONObject) it.next();
|
381 |
-
SessionEntity s1 = new SessionEntity(
|
382 |
s1.setIp((String) jSONObject.get("Ip"));
|
383 |
-
s1.
|
384 |
s1.setSessionKey((String) jSONObject.get("SessionKey"));
|
385 |
s1.setUserId((String) jSONObject.get("UserId"));
|
386 |
ss.add(s1);
|
387 |
}
|
388 |
-
|
389 |
} catch (Exception e) {
|
390 |
e.printStackTrace();
|
391 |
}
|
392 |
}
|
393 |
-
|
394 |
-
public static
|
395 |
-
org.json.simple.JSONObject jSONObject = null;
|
396 |
-
JSONParser jsonParser = new JSONParser();
|
397 |
-
JSONObject jSONObjecttemp = null;
|
398 |
try {
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
412 |
}
|
413 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
414 |
} catch (Exception e) {
|
415 |
e.printStackTrace();
|
416 |
}
|
417 |
}
|
418 |
-
|
419 |
public static List<String> docFileTruyNa(String file_name) {
|
420 |
//window
|
421 |
// String x = "D:\\7-Project\\Java\\1. Netbean\\2. nghien-cuu\\TQTK\\tqtk-render.com-main\\"+file_name;
|
@@ -427,9 +451,47 @@ public class Util {
|
|
427 |
return null;
|
428 |
}
|
429 |
}
|
430 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
431 |
public static List<String> docFileCauHoiThuThue(String file_name) {
|
432 |
-
|
433 |
final Properties pr = new Properties();
|
434 |
//window
|
435 |
// String x = "D:\\7-Project\\Java\\1. Netbean\\2. nghien-cuu\\TQTK\\runshell\\cauhoi\\"+file_name;
|
@@ -441,12 +503,12 @@ public class Util {
|
|
441 |
return null;
|
442 |
}
|
443 |
}
|
444 |
-
|
445 |
public String test2(String url) throws Exception {
|
446 |
HttpURLConnection con = null;
|
447 |
try {
|
448 |
URL obj = new URL(url);
|
449 |
-
|
450 |
String pro = obj.getProtocol();
|
451 |
if (pro.equals("http")) {
|
452 |
con = (HttpURLConnection) obj.openConnection();
|
@@ -461,10 +523,10 @@ public class Util {
|
|
461 |
con.setRequestProperty("Upgrade-Insecure-Requests", "1");
|
462 |
con.setUseCaches(false);
|
463 |
con.setDoOutput(true);
|
464 |
-
|
465 |
int responseCode = con.getResponseCode();
|
466 |
if (200 <= responseCode && responseCode <= 399) {
|
467 |
-
|
468 |
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8"));
|
469 |
StringBuffer response = new StringBuffer();
|
470 |
String inputLine;
|
@@ -473,11 +535,11 @@ public class Util {
|
|
473 |
}
|
474 |
in.close();
|
475 |
return con.getHeaderField("Location");
|
476 |
-
|
477 |
} else {
|
478 |
return "rea2";
|
479 |
}
|
480 |
-
|
481 |
} catch (Exception e) {
|
482 |
if (e instanceof SocketTimeoutException) {
|
483 |
throw new SocketTimeoutException("");
|
@@ -485,12 +547,12 @@ public class Util {
|
|
485 |
throw e;
|
486 |
}
|
487 |
}
|
488 |
-
|
489 |
public String test1(String url) throws Exception {
|
490 |
HttpURLConnection con = null;
|
491 |
try {
|
492 |
URL obj = new URL(url);
|
493 |
-
|
494 |
String pro = obj.getProtocol();
|
495 |
if (pro.equals("http")) {
|
496 |
con = (HttpURLConnection) obj.openConnection();
|
@@ -505,10 +567,10 @@ public class Util {
|
|
505 |
con.setRequestProperty("Upgrade-Insecure-Requests", "1");
|
506 |
con.setUseCaches(false);
|
507 |
con.setDoOutput(true);
|
508 |
-
|
509 |
int responseCode = con.getResponseCode();
|
510 |
if (200 <= responseCode && responseCode <= 399) {
|
511 |
-
|
512 |
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8"));
|
513 |
StringBuffer response = new StringBuffer();
|
514 |
String inputLine;
|
@@ -517,11 +579,11 @@ public class Util {
|
|
517 |
}
|
518 |
in.close();
|
519 |
return response.toString();
|
520 |
-
|
521 |
} else {
|
522 |
return "tre1";
|
523 |
}
|
524 |
-
|
525 |
} catch (Exception e) {
|
526 |
if (e instanceof SocketTimeoutException) {
|
527 |
throw new SocketTimeoutException("");
|
|
|
5 |
*/
|
6 |
package tqtk.Utils;
|
7 |
|
8 |
+
import com.fasterxml.jackson.databind.DeserializationFeature;
|
9 |
+
import com.fasterxml.jackson.databind.ObjectMapper;
|
10 |
+
import java.io.BufferedInputStream;
|
11 |
import java.io.BufferedReader;
|
12 |
import java.io.DataOutputStream;
|
13 |
import java.io.FileInputStream;
|
|
|
35 |
import tqtk.Entity.SessionEntity;
|
36 |
import java.io.FileReader;
|
37 |
import java.util.Iterator;
|
38 |
+
import org.apache.http.util.ByteArrayBuffer;
|
39 |
import org.json.simple.JSONArray;
|
40 |
import org.json.simple.JSONObject;
|
41 |
|
42 |
import org.json.simple.parser.JSONParser;
|
43 |
+
import tqtk.Entity.Accounts;
|
44 |
|
45 |
/**
|
46 |
*
|
47 |
* @author Alex
|
48 |
*/
|
49 |
public class Util {
|
50 |
+
|
51 |
public CookieManager msCookieManager = null;
|
52 |
+
|
53 |
public Util() {
|
54 |
msCookieManager = new CookieManager();
|
55 |
}
|
56 |
+
|
57 |
public void setCookie(CookieManager msCookieManager) {
|
58 |
CookieHandler.setDefault(msCookieManager);
|
59 |
}
|
60 |
+
|
61 |
public String getPageSource(String url) throws Exception {
|
62 |
HttpURLConnection con = null;
|
63 |
try {
|
64 |
URL obj = new URL(url);
|
65 |
+
|
66 |
String pro = obj.getProtocol();
|
67 |
if (pro.equals("http")) {
|
68 |
con = (HttpURLConnection) obj.openConnection();
|
|
|
76 |
con.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36");
|
77 |
con.setUseCaches(false);
|
78 |
con.setDoOutput(true);
|
79 |
+
|
80 |
int responseCode = con.getResponseCode();
|
81 |
if (200 <= responseCode && responseCode <= 399) {
|
82 |
+
|
83 |
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8"));
|
84 |
StringBuffer response = new StringBuffer();
|
85 |
String inputLine;
|
|
|
87 |
response.append(inputLine);
|
88 |
}
|
89 |
in.close();
|
90 |
+
|
91 |
return response.toString();
|
92 |
+
|
93 |
} else {
|
94 |
return "Hệ thống đang quá tải vui lòng";
|
95 |
}
|
96 |
+
|
97 |
} catch (Exception e) {
|
98 |
if (e instanceof SocketTimeoutException) {
|
99 |
throw new SocketTimeoutException("");
|
|
|
101 |
throw e;
|
102 |
}
|
103 |
}
|
104 |
+
|
105 |
public static String getToken(String htmlCode) {
|
106 |
String prefix = "name=\"_token\" value=\"";
|
107 |
int index = htmlCode.indexOf(prefix);
|
|
|
109 |
// Could not find the prefix string.
|
110 |
return null;
|
111 |
}
|
112 |
+
|
113 |
index += prefix.length();
|
114 |
|
115 |
// Login token has a fixed length of 40.
|
|
|
118 |
// Given html code is not long enough.
|
119 |
return null;
|
120 |
}
|
121 |
+
|
122 |
String token = htmlCode.substring(index, index + TokenLength);
|
123 |
return token;
|
124 |
}
|
125 |
+
|
126 |
public static String getRefer(String htmlCode) throws UnsupportedEncodingException {
|
127 |
String prefix = "action=\"";
|
128 |
int prefixIndex = htmlCode.indexOf(prefix);
|
|
|
132 |
}
|
133 |
String suffix = "\" accept-charset";
|
134 |
int suffixIndex = htmlCode.indexOf(suffix);
|
135 |
+
|
136 |
int beginIndex = prefixIndex + prefix.length();
|
137 |
int endIndex = suffixIndex;
|
138 |
String address = htmlCode.substring(beginIndex, endIndex);
|
139 |
String result = java.net.URLDecoder.decode(address, StandardCharsets.UTF_8.toString());
|
140 |
return result.replace("&", "&");
|
141 |
}
|
142 |
+
|
143 |
public String dangNhap(String url, String user, String pass, String token, String Refer) throws Exception {
|
144 |
HttpURLConnection con = null;
|
145 |
try {
|
146 |
URL obj = new URL(Refer);
|
147 |
+
|
148 |
String pro = obj.getProtocol();
|
149 |
if (pro.equals("http")) {
|
150 |
con = (HttpURLConnection) obj.openConnection();
|
|
|
164 |
con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
|
165 |
con.setUseCaches(false);
|
166 |
con.setDoOutput(true);
|
167 |
+
|
168 |
DataOutputStream wr = new DataOutputStream(con.getOutputStream());
|
169 |
wr.write(postData);
|
170 |
wr.flush();
|
171 |
wr.close();
|
172 |
int responseCode = con.getResponseCode();
|
173 |
if (200 <= responseCode && responseCode <= 399) {
|
174 |
+
|
175 |
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8"));
|
176 |
StringBuffer response = new StringBuffer();
|
177 |
String inputLine;
|
|
|
179 |
response.append(inputLine);
|
180 |
}
|
181 |
in.close();
|
182 |
+
|
183 |
return response.toString();
|
184 |
+
|
185 |
} else {
|
186 |
return "Hệ thống đang quá tải vui lòng";
|
187 |
}
|
188 |
+
|
189 |
} catch (Exception e) {
|
190 |
if (e instanceof SocketTimeoutException) {
|
191 |
throw new SocketTimeoutException("");
|
|
|
193 |
throw e;
|
194 |
}
|
195 |
}
|
196 |
+
|
197 |
public String getThongTinFrame(String url) throws Exception {
|
198 |
HttpURLConnection con = null;
|
199 |
try {
|
200 |
URL obj = new URL(url);
|
201 |
+
|
202 |
String pro = obj.getProtocol();
|
203 |
if (pro.equals("http")) {
|
204 |
con = (HttpURLConnection) obj.openConnection();
|
|
|
212 |
// con.setRequestProperty("Upgrade-Insecure-Requests", "1");
|
213 |
con.setUseCaches(false);
|
214 |
con.setDoOutput(true);
|
215 |
+
|
216 |
int responseCode = con.getResponseCode();
|
217 |
if (200 <= responseCode && responseCode <= 399) {
|
218 |
+
|
219 |
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8"));
|
220 |
StringBuffer response = new StringBuffer();
|
221 |
String inputLine;
|
|
|
223 |
response.append(inputLine);
|
224 |
}
|
225 |
in.close();
|
226 |
+
|
227 |
return response.toString();
|
228 |
+
|
229 |
} else {
|
230 |
return "Hệ thống đang quá tải vui lòng";
|
231 |
}
|
232 |
+
|
233 |
} catch (Exception e) {
|
234 |
if (e instanceof SocketTimeoutException) {
|
235 |
throw new SocketTimeoutException("");
|
|
|
237 |
throw e;
|
238 |
}
|
239 |
}
|
240 |
+
|
241 |
public String getThongTinPort(String url) throws Exception {
|
242 |
HttpURLConnection con = null;
|
243 |
try {
|
244 |
URL obj = new URL(url);
|
245 |
+
|
246 |
String pro = obj.getProtocol();
|
247 |
if (pro.equals("http")) {
|
248 |
con = (HttpURLConnection) obj.openConnection();
|
|
|
257 |
con.setRequestProperty("Upgrade-Insecure-Requests", "1");
|
258 |
con.setUseCaches(false);
|
259 |
con.setDoOutput(true);
|
260 |
+
|
261 |
int responseCode = con.getResponseCode();
|
262 |
if (200 <= responseCode && responseCode <= 399) {
|
263 |
+
|
264 |
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8"));
|
265 |
StringBuffer response = new StringBuffer();
|
266 |
String inputLine;
|
|
|
269 |
}
|
270 |
in.close();
|
271 |
return response.toString();
|
272 |
+
|
273 |
} else {
|
274 |
return "Hệ thống đang quá tải vui lòng";
|
275 |
}
|
276 |
+
|
277 |
} catch (Exception e) {
|
278 |
if (e instanceof SocketTimeoutException) {
|
279 |
throw new SocketTimeoutException("");
|
|
|
281 |
throw e;
|
282 |
}
|
283 |
}
|
284 |
+
|
285 |
public static String getFrameString(String htmlCode) throws UnsupportedEncodingException {
|
286 |
String prefix = "src=\"";
|
287 |
int index = htmlCode.indexOf(prefix);
|
|
|
289 |
// Could not find the prefix string.
|
290 |
return null;
|
291 |
}
|
292 |
+
|
293 |
index += prefix.length();
|
294 |
int suffixIndex = htmlCode.indexOf("\" frameborder");
|
295 |
if (suffixIndex == -1) {
|
296 |
// Could not find the suffix string.
|
297 |
return null;
|
298 |
}
|
299 |
+
|
300 |
String address = htmlCode.substring(index, suffixIndex);
|
301 |
return java.net.URLDecoder.decode(address, StandardCharsets.UTF_8.toString()).replace("&", "&");
|
302 |
}
|
303 |
+
|
304 |
public static String getInfoSocket(String htmlCode, String token) {
|
305 |
token = token + " : ";
|
306 |
int index = htmlCode.indexOf(token);
|
307 |
if (index == -1) {
|
308 |
return null;
|
309 |
}
|
310 |
+
|
311 |
index += token.length();
|
312 |
int suffixIndex = htmlCode.indexOf(",", index);
|
313 |
if (suffixIndex == -1) {
|
314 |
return null;
|
315 |
}
|
316 |
+
|
317 |
String value = htmlCode.substring(index, suffixIndex);
|
318 |
value = value.replaceAll("[\'||\"]", "");
|
319 |
return value;
|
320 |
}
|
321 |
+
|
322 |
public static String TaoMsg(String commandId, List<String> list, SessionEntity ss) throws NoSuchAlgorithmException, UnsupportedEncodingException {
|
323 |
String what_is_this = "5dcd73d391c90e8769618d42a916ea1b";
|
324 |
String input = commandId + ss.getUserId();
|
325 |
+
|
326 |
String msg = String.format("%s\u0001%s\t%s\u0002", commandId, ss.getUserId(), ss.getSessionKey());
|
327 |
Date date = new Date();
|
328 |
long millisecondsSinceEpoch = date.getTime();
|
|
|
332 |
msg += string + '\t';
|
333 |
}
|
334 |
}
|
335 |
+
|
336 |
input += what_is_this;
|
337 |
if (list != null && list.size() > 0) {
|
338 |
msg = msg.substring(0, msg.length());
|
339 |
}
|
340 |
+
|
341 |
String checksum = hash(input);
|
342 |
msg += String.format("\u0003%s\u0004%d\u0005\0", checksum, millisecondsSinceEpoch);
|
343 |
return msg;
|
344 |
}
|
345 |
+
|
346 |
public static String hash(String input) throws NoSuchAlgorithmException, UnsupportedEncodingException {
|
347 |
MessageDigest md = MessageDigest.getInstance("MD5");
|
348 |
byte[] buffer = md.digest(input.getBytes("UTF8"));
|
|
|
352 |
}
|
353 |
return builder.toString();
|
354 |
}
|
355 |
+
|
356 |
public static Properties loadProperties(String file_name) {
|
357 |
+
|
358 |
final Properties pr = new Properties();
|
359 |
//window
|
360 |
// String x = "D:\\7-Project\\Java\\1. Netbean\\2. nghien-cuu\\TQTK\\runshell\\"+file_name;
|
|
|
369 |
}
|
370 |
return pr;
|
371 |
}
|
372 |
+
|
373 |
public static void setData(String file_name, List<SessionEntity> ss) {
|
374 |
org.json.simple.JSONObject jSONObject = null;
|
375 |
JSONParser jsonParser = new JSONParser();
|
|
|
378 |
try (FileReader reader = new FileReader(x)) {
|
379 |
//Read JSON file
|
380 |
jSONObject = (org.json.simple.JSONObject) jsonParser.parse(reader);
|
381 |
+
|
382 |
JSONArray jSONArray = (JSONArray) jSONObject.get("accounts");
|
383 |
+
|
384 |
for (Iterator it = jSONArray.iterator(); it.hasNext();) {
|
385 |
jSONObject = (JSONObject) it.next();
|
386 |
+
SessionEntity s1 = new SessionEntity();
|
387 |
s1.setIp((String) jSONObject.get("Ip"));
|
388 |
+
s1.setPort((String) jSONObject.get("Port"));
|
389 |
s1.setSessionKey((String) jSONObject.get("SessionKey"));
|
390 |
s1.setUserId((String) jSONObject.get("UserId"));
|
391 |
ss.add(s1);
|
392 |
}
|
393 |
+
|
394 |
} catch (Exception e) {
|
395 |
e.printStackTrace();
|
396 |
}
|
397 |
}
|
398 |
+
|
399 |
+
public static List<SessionEntity> setData1(List<SessionEntity> ss) throws Exception {
|
|
|
|
|
|
|
400 |
try {
|
401 |
+
|
402 |
+
String x = HttpURLConnectionGet("http://subsixcyber13.pythonanywhere.com/main");
|
403 |
+
ObjectMapper mapper = new ObjectMapper();
|
404 |
+
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
|
405 |
+
Accounts response = mapper.readValue(x, Accounts.class);
|
406 |
+
ss = response.getAccounts();
|
407 |
+
return response.getAccounts();
|
408 |
+
} catch (Exception e) {
|
409 |
+
e.printStackTrace();
|
410 |
+
}
|
411 |
+
return null;
|
412 |
+
}
|
413 |
+
|
414 |
+
public static void updateData(String id) throws Exception {
|
415 |
+
try {
|
416 |
+
|
417 |
+
String x = HttpURLConnectionGet("http://subsixcyber13.pythonanywhere.com/main");
|
418 |
+
ObjectMapper mapper = new ObjectMapper();
|
419 |
+
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
|
420 |
+
Accounts response = mapper.readValue(x, Accounts.class);
|
421 |
+
List<SessionEntity> ss = response.getAccounts();
|
422 |
+
SessionEntity entity = null;
|
423 |
+
for (int i = 0; i < ss.size(); ++i) {
|
424 |
+
if (id.equals(ss.get(i).getUserId())) {
|
425 |
+
entity = ss.get(i);
|
426 |
+
}
|
427 |
}
|
428 |
+
for (SessionEntity item : tqtk.Tqtk.listSession) {
|
429 |
+
if (id.equals(item.getUserId())) {
|
430 |
+
item.setBuildingIds(entity.getBuildingIds());
|
431 |
+
item.setHeroIds(entity.getHeroIds());
|
432 |
+
item.setItemIds(entity.getItemIds());
|
433 |
+
item.setSkillIds(entity.getSkillIds());
|
434 |
+
item.setSessionKey(entity.getSessionKey());
|
435 |
+
}
|
436 |
+
}
|
437 |
+
|
438 |
} catch (Exception e) {
|
439 |
e.printStackTrace();
|
440 |
}
|
441 |
}
|
442 |
+
|
443 |
public static List<String> docFileTruyNa(String file_name) {
|
444 |
//window
|
445 |
// String x = "D:\\7-Project\\Java\\1. Netbean\\2. nghien-cuu\\TQTK\\tqtk-render.com-main\\"+file_name;
|
|
|
451 |
return null;
|
452 |
}
|
453 |
}
|
454 |
+
|
455 |
+
private static String HttpURLConnectionGet(final String url) throws Exception {
|
456 |
+
try {
|
457 |
+
final URL obj = new URL(url);
|
458 |
+
HttpURLConnection con;
|
459 |
+
if (obj.getProtocol().equals("http")) {
|
460 |
+
con = (HttpURLConnection) obj.openConnection();
|
461 |
+
} else {
|
462 |
+
con = (HttpsURLConnection) obj.openConnection();
|
463 |
+
}
|
464 |
+
con.setRequestMethod("GET");
|
465 |
+
con.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36");
|
466 |
+
con.setRequestProperty("Host", "subsixcyber13.pythonanywhere.com");
|
467 |
+
|
468 |
+
int responseCode = con.getResponseCode();
|
469 |
+
if (200 <= responseCode && responseCode <= 399) {
|
470 |
+
String queryResult = "";
|
471 |
+
BufferedInputStream bis = new BufferedInputStream(con.getInputStream());
|
472 |
+
ByteArrayBuffer baf = new ByteArrayBuffer(50);
|
473 |
+
int read = 0;
|
474 |
+
int bufSize = 512;
|
475 |
+
byte[] buffer = new byte[bufSize];
|
476 |
+
while (true) {
|
477 |
+
read = bis.read(buffer);
|
478 |
+
if (read == -1) {
|
479 |
+
break;
|
480 |
+
}
|
481 |
+
baf.append(buffer, 0, read);
|
482 |
+
}
|
483 |
+
queryResult = new String(baf.toByteArray());
|
484 |
+
return queryResult;
|
485 |
+
}
|
486 |
+
|
487 |
+
} catch (Exception e) {
|
488 |
+
e.getMessage();
|
489 |
+
}
|
490 |
+
return null;
|
491 |
+
}
|
492 |
+
|
493 |
public static List<String> docFileCauHoiThuThue(String file_name) {
|
494 |
+
|
495 |
final Properties pr = new Properties();
|
496 |
//window
|
497 |
// String x = "D:\\7-Project\\Java\\1. Netbean\\2. nghien-cuu\\TQTK\\runshell\\cauhoi\\"+file_name;
|
|
|
503 |
return null;
|
504 |
}
|
505 |
}
|
506 |
+
|
507 |
public String test2(String url) throws Exception {
|
508 |
HttpURLConnection con = null;
|
509 |
try {
|
510 |
URL obj = new URL(url);
|
511 |
+
|
512 |
String pro = obj.getProtocol();
|
513 |
if (pro.equals("http")) {
|
514 |
con = (HttpURLConnection) obj.openConnection();
|
|
|
523 |
con.setRequestProperty("Upgrade-Insecure-Requests", "1");
|
524 |
con.setUseCaches(false);
|
525 |
con.setDoOutput(true);
|
526 |
+
|
527 |
int responseCode = con.getResponseCode();
|
528 |
if (200 <= responseCode && responseCode <= 399) {
|
529 |
+
|
530 |
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8"));
|
531 |
StringBuffer response = new StringBuffer();
|
532 |
String inputLine;
|
|
|
535 |
}
|
536 |
in.close();
|
537 |
return con.getHeaderField("Location");
|
538 |
+
|
539 |
} else {
|
540 |
return "rea2";
|
541 |
}
|
542 |
+
|
543 |
} catch (Exception e) {
|
544 |
if (e instanceof SocketTimeoutException) {
|
545 |
throw new SocketTimeoutException("");
|
|
|
547 |
throw e;
|
548 |
}
|
549 |
}
|
550 |
+
|
551 |
public String test1(String url) throws Exception {
|
552 |
HttpURLConnection con = null;
|
553 |
try {
|
554 |
URL obj = new URL(url);
|
555 |
+
|
556 |
String pro = obj.getProtocol();
|
557 |
if (pro.equals("http")) {
|
558 |
con = (HttpURLConnection) obj.openConnection();
|
|
|
567 |
con.setRequestProperty("Upgrade-Insecure-Requests", "1");
|
568 |
con.setUseCaches(false);
|
569 |
con.setDoOutput(true);
|
570 |
+
|
571 |
int responseCode = con.getResponseCode();
|
572 |
if (200 <= responseCode && responseCode <= 399) {
|
573 |
+
|
574 |
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8"));
|
575 |
StringBuffer response = new StringBuffer();
|
576 |
String inputLine;
|
|
|
579 |
}
|
580 |
in.close();
|
581 |
return response.toString();
|
582 |
+
|
583 |
} else {
|
584 |
return "tre1";
|
585 |
}
|
586 |
+
|
587 |
} catch (Exception e) {
|
588 |
if (e instanceof SocketTimeoutException) {
|
589 |
throw new SocketTimeoutException("");
|
src/main/java/tqtk/XuLy/Worker.java
CHANGED
@@ -44,6 +44,14 @@ public class Worker extends Thread {
|
|
44 |
int Mo = 0;
|
45 |
int areaId = 0;
|
46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
public Worker(SessionEntity ss) {
|
48 |
|
49 |
this.ss = ss;
|
@@ -52,7 +60,7 @@ public class Worker extends Thread {
|
|
52 |
public void GuiPacketDeLogin() throws InterruptedException, IOException, Exception {
|
53 |
// packet duy tri dang nhap , neu muon truy cap vao 1 acc tu` nhieu noi thi , phai co'
|
54 |
// 1 noi dang nhap truoc roi , luc nay se ko can chay packet 10100
|
55 |
-
Thread.sleep(5000);
|
56 |
GuiPacketKhongKQ(ss, "10100", null);
|
57 |
// packet cap nhat thong tin lien tuc tu server
|
58 |
Thread.sleep(5000);
|
@@ -72,6 +80,41 @@ public class Worker extends Thread {
|
|
72 |
}
|
73 |
|
74 |
public void LuyenTuong() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
List<String> list1 = new ArrayList<>();
|
76 |
list1.add(0, "0");
|
77 |
List<String> list2 = new ArrayList<>();
|
@@ -98,18 +141,19 @@ public class Worker extends Thread {
|
|
98 |
}
|
99 |
|
100 |
List<Object> carMap1 = (List<Object>) ((Map<String, Object>) carMap.get("m")).get("general");
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
int idhero = 0;
|
105 |
String name = "";
|
106 |
int trainflag = 0;
|
107 |
int lvhero = 0;
|
108 |
|
109 |
list1.add(1, "1");
|
110 |
-
|
111 |
-
|
112 |
-
|
|
|
113 |
for (Object object : carMap1) {
|
114 |
|
115 |
idhero = (int) ((Map<Object, Object>) object).get("generalid");
|
@@ -148,22 +192,17 @@ public class Worker extends Thread {
|
|
148 |
GuiPacket(ss, "41102", list2);
|
149 |
Thread.sleep(5000);
|
150 |
|
151 |
-
}
|
152 |
-
|
153 |
-
else if ("伊奈忠次".equals(name) && trainflag == 0) {
|
154 |
// quach gia
|
155 |
|
156 |
GuiPacket(ss, "41101", list1);
|
157 |
Thread.sleep(5000);
|
158 |
-
|
159 |
|
160 |
-
}
|
161 |
-
else if ("村上義清".equals(name) && trainflag == 0) {
|
162 |
// luu bieu
|
163 |
|
164 |
GuiPacket(ss, "41101", list1);
|
165 |
Thread.sleep(5000);
|
166 |
-
|
167 |
|
168 |
} else if ("島津忠直--".equals(name) && trainflag == 0) {
|
169 |
// y tich
|
@@ -187,7 +226,6 @@ public class Worker extends Thread {
|
|
187 |
// hoa ham
|
188 |
GuiPacket(ss, "41101", list1);
|
189 |
Thread.sleep(5000);
|
190 |
-
|
191 |
|
192 |
} else if ("旭姫".equals(name) && trainflag == 0) {
|
193 |
// vu co
|
@@ -202,7 +240,6 @@ public class Worker extends Thread {
|
|
202 |
// thai diem
|
203 |
GuiPacket(ss, "41101", list1);
|
204 |
Thread.sleep(5000);
|
205 |
-
|
206 |
|
207 |
} else if ("内藤正成--".equals(name) && trainflag == 0) {
|
208 |
// duong tu
|
@@ -230,17 +267,13 @@ public class Worker extends Thread {
|
|
230 |
// ha hau uyen tdxk
|
231 |
GuiPacket(ss, "41101", list1);
|
232 |
Thread.sleep(5000);
|
233 |
-
|
234 |
|
235 |
-
}else if ("服部半藏".equals(name) && trainflag == 0) {
|
236 |
// tao thao
|
237 |
GuiPacket(ss, "41101", list1);
|
238 |
Thread.sleep(5000);
|
239 |
-
|
240 |
|
241 |
}
|
242 |
-
|
243 |
-
|
244 |
|
245 |
}
|
246 |
}
|
@@ -335,134 +368,11 @@ public class Worker extends Thread {
|
|
335 |
}
|
336 |
//}
|
337 |
}
|
338 |
-
|
339 |
-
public void TruyNa2() {
|
340 |
-
if (Truyna == 1) {
|
341 |
-
Truyna = 0;
|
342 |
-
List < String > list1 = new ArrayList < > ();
|
343 |
-
list1.add(0, "0");
|
344 |
-
try {
|
345 |
-
Thread.sleep(5000);
|
346 |
-
StringBuilder rs1 = GuiPacketTN(ss, "60605", null);
|
347 |
-
if (rs1 != null) {
|
348 |
-
try {
|
349 |
-
String[] temp = rs1.toString().split("");
|
350 |
-
|
351 |
-
ObjectMapper mapper = new ObjectMapper();
|
352 |
-
Map < String, Object > carMap = null;
|
353 |
-
int h = 0;
|
354 |
-
for (String string: temp) {
|
355 |
-
carMap = mapper.readValue(string, new TypeReference < Map < String, Object >> () {});
|
356 |
-
h = (int) carMap.get("h");
|
357 |
-
if (h == Integer.parseInt("60605")) {
|
358 |
-
break;
|
359 |
-
}
|
360 |
-
}
|
361 |
-
|
362 |
-
List < Object > carMap1 = (List < Object > )((Map < String, Object > ) carMap.get("m")).get("wantedMemberList");
|
363 |
-
int idarea = 0;
|
364 |
-
int id = 0;
|
365 |
-
int attactNum = 0;
|
366 |
-
int level = 0;
|
367 |
-
int isAttacked = 0;
|
368 |
-
long playerId = 0;
|
369 |
-
String tmp = "";
|
370 |
-
String playerName="";
|
371 |
-
Tqtk.sendMessage("tn " + ss.getStringName());
|
372 |
-
for (Object object: carMap1) {
|
373 |
-
idarea = (int)((Map < Object, Object > ) object).get("areaId");
|
374 |
-
id = (int)((Map < Object, Object > ) object).get("id");
|
375 |
-
attactNum = (int)((Map < Object, Object > ) object).get("attactNum");
|
376 |
-
level = (int)((Map < Object, Object > ) object).get("playerLevel");
|
377 |
-
isAttacked = (int)((Map < Object, Object > ) object).get("hasAttact");
|
378 |
-
playerId = (long)((Map < Object, Object > ) object).get("playerId");
|
379 |
-
playerName = (String) ((Map<Object, Object>) object).get("playerName");
|
380 |
-
playerName = playerName.toLowerCase();
|
381 |
-
list1.set(0, Integer.toString(id));
|
382 |
-
|
383 |
-
synchronized(tqtk.Tqtk.loaiTruyna) {
|
384 |
-
if (id != 0 && !Tqtk.loaiTruyna.contains(Long.toString(playerId)) &&
|
385 |
-
attactNum != 0
|
386 |
-
// && idarea == -1
|
387 |
-
&&
|
388 |
-
isAttacked == 0 &&
|
389 |
-
level < 88) {
|
390 |
-
rs1 = GuiPacketTN(ss, "60606", list1);
|
391 |
-
if (rs1 != null) {
|
392 |
-
tmp = rs1.toString();
|
393 |
-
}
|
394 |
-
if (tmp.contains("\"winside\":2") || tmp.contains("\"winside\": 2")) {
|
395 |
-
tqtk.Tqtk.loaiTruyna.add(playerName);
|
396 |
-
tqtk.Tqtk.loaiTruyna.add(Long.toString(playerId));
|
397 |
-
}else{
|
398 |
-
break;
|
399 |
-
}
|
400 |
-
|
401 |
-
|
402 |
-
}
|
403 |
-
}
|
404 |
-
Thread.sleep(5000);
|
405 |
-
MuaLinh();
|
406 |
-
}
|
407 |
-
} catch (Exception e) {
|
408 |
-
throw new JsonException();
|
409 |
-
}
|
410 |
-
|
411 |
-
//}
|
412 |
-
}
|
413 |
-
} catch (Exception ex) {
|
414 |
-
if (!(ex instanceof JsonException)) {
|
415 |
-
|
416 |
-
System.out.println("loi TruyNa " + ss.getStringName() + ex.getMessage());
|
417 |
-
} else {
|
418 |
-
|
419 |
-
System.out.println("loi TruyNa json " + ss.getStringName() + ex.getMessage());
|
420 |
-
}
|
421 |
-
}
|
422 |
-
}
|
423 |
-
}
|
424 |
|
425 |
-
public void
|
426 |
-
|
427 |
-
GuiPacketTN(ss, "11102", null);
|
428 |
-
Thread.sleep(5000);
|
429 |
-
} catch (Exception e) {
|
430 |
-
}
|
431 |
|
432 |
-
|
433 |
-
try {
|
434 |
-
List<String> list1 = new ArrayList<>();
|
435 |
-
list1.add(0, "0");
|
436 |
-
|
437 |
-
if (Tqtk.listtruyna.size() > 0 && Tqtk.loaiTruyna.size() > 0) {
|
438 |
-
String id = "";
|
439 |
-
String PlayerName = "";
|
440 |
-
String PlayerId = "";
|
441 |
-
int AttactNum = 0;
|
442 |
-
for (TruyNa tn : Tqtk.listtruyna) {
|
443 |
-
id = tn.getId();
|
444 |
-
AttactNum = tn.getAttactNum();
|
445 |
-
PlayerName = tn.getPlayerName();
|
446 |
-
PlayerId = tn.getPlayerId();
|
447 |
-
Tqtk.sendMessage("tn " + PlayerName + " " + PlayerId + " " + AttactNum + " " + id);
|
448 |
-
synchronized (Tqtk.listtruyna) {
|
449 |
-
if (!Tqtk.loaiTruyna.contains(PlayerName)
|
450 |
-
&& !Tqtk.loaiTruyna.contains(PlayerId)
|
451 |
-
&& AttactNum != 0) {
|
452 |
-
list1.set(0, id);
|
453 |
-
GuiPacketTN(ss, "60606", list1);
|
454 |
-
}
|
455 |
-
|
456 |
-
}
|
457 |
-
Thread.sleep(5000);
|
458 |
-
}
|
459 |
-
}
|
460 |
-
} catch (Exception e) {
|
461 |
-
System.out.println("GuiPacketTN 2 " + e.getMessage());
|
462 |
-
}
|
463 |
-
} else if (ss.getUserId().equals("2301211923397199")) {
|
464 |
-
|
465 |
-
List<String> list1 = new ArrayList<>();
|
466 |
list1.add(0, "0");
|
467 |
try {
|
468 |
Thread.sleep(5000);
|
@@ -472,10 +382,10 @@ public class Worker extends Thread {
|
|
472 |
String[] temp = rs1.toString().split("");
|
473 |
|
474 |
ObjectMapper mapper = new ObjectMapper();
|
475 |
-
Map<String, Object> carMap = null;
|
476 |
int h = 0;
|
477 |
for (String string : temp) {
|
478 |
-
carMap = mapper.readValue(string, new TypeReference<Map<String, Object>>() {
|
479 |
});
|
480 |
h = (int) carMap.get("h");
|
481 |
if (h == Integer.parseInt("60605")) {
|
@@ -483,46 +393,33 @@ public class Worker extends Thread {
|
|
483 |
}
|
484 |
}
|
485 |
|
486 |
-
List<Object> carMap1 = (List<Object>) ((Map<String, Object>) carMap.get("m")).get("wantedMemberList");
|
487 |
int idarea = 0;
|
488 |
int id = 0;
|
489 |
int attactNum = 0;
|
490 |
int level = 0;
|
491 |
int isAttacked = 0;
|
492 |
long playerId = 0;
|
493 |
-
String playerName = "";
|
494 |
String tmp = "";
|
495 |
-
|
496 |
Tqtk.sendMessage("tn " + ss.getStringName());
|
497 |
for (Object object : carMap1) {
|
498 |
-
idarea = (int) ((Map<Object, Object>) object).get("areaId");
|
499 |
-
id = (int) ((Map<Object, Object>) object).get("id");
|
500 |
-
attactNum = (int) ((Map<Object, Object>) object).get("attactNum");
|
501 |
-
level = (int) ((Map<Object, Object>) object).get("playerLevel");
|
502 |
-
isAttacked = (int) ((Map<Object, Object>) object).get("hasAttact");
|
503 |
-
playerId = (long) ((Map<Object, Object>) object).get("playerId");
|
504 |
playerName = (String) ((Map<Object, Object>) object).get("playerName");
|
505 |
playerName = playerName.toLowerCase();
|
506 |
list1.set(0, Integer.toString(id));
|
507 |
|
508 |
-
if (ss.getUserId().equals("2301211923397199")) {
|
509 |
-
synchronized (Tqtk.listtruyna) {
|
510 |
-
tn = new TruyNa();
|
511 |
-
tn.setAttactNum(attactNum);
|
512 |
-
tn.setId(Long.toString(id));
|
513 |
-
tn.setPlayerId(Long.toString(playerId));
|
514 |
-
tn.setPlayerName(playerName);
|
515 |
-
Tqtk.listtruyna.add(tn);
|
516 |
-
}
|
517 |
-
}
|
518 |
-
|
519 |
synchronized (tqtk.Tqtk.loaiTruyna) {
|
520 |
-
if (id != 0 && !Tqtk.loaiTruyna.contains(
|
521 |
-
&& !Tqtk.loaiTruyna.contains(Long.toString(playerId))
|
522 |
&& attactNum != 0
|
523 |
// && idarea == -1
|
524 |
&& isAttacked == 0
|
525 |
-
&& level <
|
526 |
rs1 = GuiPacketTN(ss, "60606", list1);
|
527 |
if (rs1 != null) {
|
528 |
tmp = rs1.toString();
|
@@ -530,10 +427,15 @@ public class Worker extends Thread {
|
|
530 |
if (tmp.contains("\"winside\":2") || tmp.contains("\"winside\": 2")) {
|
531 |
tqtk.Tqtk.loaiTruyna.add(playerName);
|
532 |
tqtk.Tqtk.loaiTruyna.add(Long.toString(playerId));
|
|
|
|
|
|
|
533 |
}
|
|
|
534 |
}
|
535 |
}
|
536 |
Thread.sleep(5000);
|
|
|
537 |
}
|
538 |
} catch (Exception e) {
|
539 |
throw new JsonException();
|
@@ -553,9 +455,132 @@ public class Worker extends Thread {
|
|
553 |
}
|
554 |
}
|
555 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
556 |
public void NangNha() {
|
557 |
List<String> list1 = new ArrayList<>();
|
558 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
559 |
try {
|
560 |
// nha chinh
|
561 |
list1.add(0, "5");
|
@@ -584,6 +609,22 @@ public class Worker extends Thread {
|
|
584 |
}
|
585 |
|
586 |
public void NangKiNang() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
587 |
List<String> list1 = new ArrayList<>();
|
588 |
try {
|
589 |
//binh khi , 42200 ,3
|
@@ -851,13 +892,13 @@ public class Worker extends Thread {
|
|
851 |
tqtk.Tqtk.listruong = (List<Object>) ((Map<String, Object>) carMap.get("m")).get("resource");
|
852 |
|
853 |
Tqtk.sendMessage("chiem ruong " + ss.getStringName());
|
854 |
-
|
855 |
int resourceid = 0;
|
856 |
if (tqtk.Tqtk.listruong != null) {
|
857 |
for (Object object : tqtk.Tqtk.listruong) {
|
858 |
-
|
859 |
resourceid = (int) ((Map<Object, Object>) object).get("resourceid");
|
860 |
-
if (
|
861 |
break;
|
862 |
}
|
863 |
}
|
@@ -922,13 +963,13 @@ public class Worker extends Thread {
|
|
922 |
List<Object> listmo = (List<Object>) ((Map<String, Object>) carMap.get("m")).get("city");
|
923 |
|
924 |
Tqtk.sendMessage("chiem mo " + ss.getStringName());
|
925 |
-
|
926 |
int resourceid = 0;
|
927 |
if (listmo != null) {
|
928 |
for (Object object : listmo) {
|
929 |
-
|
930 |
resourceid = (int) ((Map<Object, Object>) object).get("index");
|
931 |
-
if (
|
932 |
break;
|
933 |
}
|
934 |
}
|
@@ -1011,6 +1052,65 @@ public class Worker extends Thread {
|
|
1011 |
}
|
1012 |
|
1013 |
public void NangItem() throws IOException, UnknownHostException, InterruptedException, Exception {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1014 |
List<String> list1 = new ArrayList<>();
|
1015 |
list1.add(0, "0");
|
1016 |
list1.add(1, "0");
|
@@ -1142,14 +1242,14 @@ public class Worker extends Thread {
|
|
1142 |
|
1143 |
public void dangNhapLayThongTin() throws Exception {
|
1144 |
Socket socket = new Socket();
|
1145 |
-
socket.connect(new InetSocketAddress(InetAddress.getByName(ss.getIp()), ss.
|
1146 |
if (ss.getSocket() != null) {
|
1147 |
ss.getSocket().close();
|
1148 |
}
|
1149 |
ss.setSocket(socket);
|
1150 |
|
1151 |
Socket socket1 = new Socket();
|
1152 |
-
socket1.connect(new InetSocketAddress(InetAddress.getByName(ss.getIp()), ss.
|
1153 |
if (ss.getSocketApi() != null) {
|
1154 |
ss.getSocketApi().close();
|
1155 |
}
|
@@ -1158,7 +1258,7 @@ public class Worker extends Thread {
|
|
1158 |
|
1159 |
public void taoSocketTruyNa() throws Exception {
|
1160 |
Socket socket = new Socket();
|
1161 |
-
socket.connect(new InetSocketAddress(InetAddress.getByName(ss.getIp()), ss.
|
1162 |
if (ss.getSocketTN() != null) {
|
1163 |
ss.getSocketTN().close();
|
1164 |
}
|
@@ -1356,17 +1456,8 @@ public class Worker extends Thread {
|
|
1356 |
}
|
1357 |
|
1358 |
public static void createSocket(SessionEntity session) throws Exception {
|
1359 |
-
Socket socket1 = new Socket();
|
1360 |
-
socket1.connect(new InetSocketAddress(InetAddress.getByName(session.getIp()), session.getPorts()), 7000);
|
1361 |
-
socket1.setSoTimeout(350000);
|
1362 |
-
try {
|
1363 |
-
session.getSocketApi().close();
|
1364 |
-
} catch (Exception e) {
|
1365 |
-
}
|
1366 |
-
session.setSocketApi(socket1);
|
1367 |
-
|
1368 |
Socket socket = new Socket();
|
1369 |
-
socket.connect(new InetSocketAddress(InetAddress.getByName(session.getIp()), session.
|
1370 |
socket.setSoTimeout(350000);
|
1371 |
try {
|
1372 |
session.getSocket().close();
|
@@ -1377,7 +1468,7 @@ public class Worker extends Thread {
|
|
1377 |
|
1378 |
public static void createSocketApi(SessionEntity session) throws Exception {
|
1379 |
Socket socket1 = new Socket();
|
1380 |
-
socket1.connect(new InetSocketAddress(InetAddress.getByName(session.getIp()), session.
|
1381 |
socket1.setSoTimeout(350000);
|
1382 |
try {
|
1383 |
session.getSocketApi().close();
|
@@ -1391,28 +1482,10 @@ public class Worker extends Thread {
|
|
1391 |
try {
|
1392 |
dangNhapLayThongTin();
|
1393 |
GuiPacketDeLogin();
|
1394 |
-
|
1395 |
-
new Thread() {
|
1396 |
-
@Override
|
1397 |
-
public void run() {
|
1398 |
-
while (true) {
|
1399 |
-
try {
|
1400 |
-
|
1401 |
-
TruyNa2();
|
1402 |
-
|
1403 |
-
} catch (Exception e) {
|
1404 |
-
System.out.println("TruyNa .run() " + e.getMessage() + " " + ss.getStringName());
|
1405 |
-
}
|
1406 |
-
}
|
1407 |
-
}
|
1408 |
-
}.start();
|
1409 |
-
while (true) {
|
1410 |
-
try {
|
1411 |
|
1412 |
MuaLinh();
|
1413 |
-
|
1414 |
-
// DanhQuanDoan2();
|
1415 |
-
// DanhQuanDoan3();
|
1416 |
NangItem();
|
1417 |
LuyenTuong();
|
1418 |
NangNha();
|
@@ -1426,10 +1499,9 @@ public class Worker extends Thread {
|
|
1426 |
ChiemRuong();
|
1427 |
MuaRuong();
|
1428 |
CapNhatThongTin();
|
1429 |
-
|
1430 |
-
|
1431 |
-
|
1432 |
-
}
|
1433 |
}
|
1434 |
} catch (Exception ex) {
|
1435 |
System.out.println("all " + ss.getStringName() + ex.getMessage());
|
|
|
44 |
int Mo = 0;
|
45 |
int areaId = 0;
|
46 |
|
47 |
+
public SessionEntity getSs() {
|
48 |
+
return ss;
|
49 |
+
}
|
50 |
+
|
51 |
+
public void setSs(SessionEntity ss) {
|
52 |
+
this.ss = ss;
|
53 |
+
}
|
54 |
+
|
55 |
public Worker(SessionEntity ss) {
|
56 |
|
57 |
this.ss = ss;
|
|
|
60 |
public void GuiPacketDeLogin() throws InterruptedException, IOException, Exception {
|
61 |
// packet duy tri dang nhap , neu muon truy cap vao 1 acc tu` nhieu noi thi , phai co'
|
62 |
// 1 noi dang nhap truoc roi , luc nay se ko can chay packet 10100
|
63 |
+
// Thread.sleep(5000);
|
64 |
GuiPacketKhongKQ(ss, "10100", null);
|
65 |
// packet cap nhat thong tin lien tuc tu server
|
66 |
Thread.sleep(5000);
|
|
|
80 |
}
|
81 |
|
82 |
public void LuyenTuong() {
|
83 |
+
List<String> list1 = new ArrayList<>();
|
84 |
+
list1.add(0, "0");
|
85 |
+
list1.add(1, "1");
|
86 |
+
List<String> list2 = new ArrayList<>();
|
87 |
+
list2.add(0, "0");
|
88 |
+
list2.add(1, "1");
|
89 |
+
list2.add(2, "1");
|
90 |
+
|
91 |
+
try {
|
92 |
+
for (String entry : ss.getHeroIds()) {
|
93 |
+
list1.set(0, entry);
|
94 |
+
list2.set(0, entry);
|
95 |
+
|
96 |
+
GuiPacket(ss, "41101", list1);
|
97 |
+
Thread.sleep(5000);
|
98 |
+
GuiPacket(ss, "41102", list2);
|
99 |
+
Thread.sleep(5000);
|
100 |
+
GuiPacket(ss, "41102", list2);
|
101 |
+
Thread.sleep(5000);
|
102 |
+
GuiPacket(ss, "41102", list2);
|
103 |
+
Thread.sleep(5000);
|
104 |
+
}
|
105 |
+
|
106 |
+
} catch (Exception ex) {
|
107 |
+
if (!(ex instanceof JsonException)) {
|
108 |
+
System.out.println("loi LuyenTuong " + ss.getStringName() + ex.getMessage());
|
109 |
+
} else {
|
110 |
+
System.out.println("loi LuyenTuong json" + ss.getStringName() + ex.getMessage());
|
111 |
+
}
|
112 |
+
|
113 |
+
}
|
114 |
+
|
115 |
+
}
|
116 |
+
|
117 |
+
public void LuyenTuong1() {
|
118 |
List<String> list1 = new ArrayList<>();
|
119 |
list1.add(0, "0");
|
120 |
List<String> list2 = new ArrayList<>();
|
|
|
141 |
}
|
142 |
|
143 |
List<Object> carMap1 = (List<Object>) ((Map<String, Object>) carMap.get("m")).get("general");
|
144 |
+
|
145 |
+
Tqtk.sendMessage("lt " + ss.getStringName());
|
146 |
+
|
147 |
int idhero = 0;
|
148 |
String name = "";
|
149 |
int trainflag = 0;
|
150 |
int lvhero = 0;
|
151 |
|
152 |
list1.add(1, "1");
|
153 |
+
if (carMap1 != null) {
|
154 |
+
Collections.reverse(carMap1);
|
155 |
+
}
|
156 |
+
|
157 |
for (Object object : carMap1) {
|
158 |
|
159 |
idhero = (int) ((Map<Object, Object>) object).get("generalid");
|
|
|
192 |
GuiPacket(ss, "41102", list2);
|
193 |
Thread.sleep(5000);
|
194 |
|
195 |
+
} else if ("伊奈忠次".equals(name) && trainflag == 0) {
|
|
|
|
|
196 |
// quach gia
|
197 |
|
198 |
GuiPacket(ss, "41101", list1);
|
199 |
Thread.sleep(5000);
|
|
|
200 |
|
201 |
+
} else if ("村上義清".equals(name) && trainflag == 0) {
|
|
|
202 |
// luu bieu
|
203 |
|
204 |
GuiPacket(ss, "41101", list1);
|
205 |
Thread.sleep(5000);
|
|
|
206 |
|
207 |
} else if ("島津忠直--".equals(name) && trainflag == 0) {
|
208 |
// y tich
|
|
|
226 |
// hoa ham
|
227 |
GuiPacket(ss, "41101", list1);
|
228 |
Thread.sleep(5000);
|
|
|
229 |
|
230 |
} else if ("旭姫".equals(name) && trainflag == 0) {
|
231 |
// vu co
|
|
|
240 |
// thai diem
|
241 |
GuiPacket(ss, "41101", list1);
|
242 |
Thread.sleep(5000);
|
|
|
243 |
|
244 |
} else if ("内藤正成--".equals(name) && trainflag == 0) {
|
245 |
// duong tu
|
|
|
267 |
// ha hau uyen tdxk
|
268 |
GuiPacket(ss, "41101", list1);
|
269 |
Thread.sleep(5000);
|
|
|
270 |
|
271 |
+
} else if ("服部半藏".equals(name) && trainflag == 0) {
|
272 |
// tao thao
|
273 |
GuiPacket(ss, "41101", list1);
|
274 |
Thread.sleep(5000);
|
|
|
275 |
|
276 |
}
|
|
|
|
|
277 |
|
278 |
}
|
279 |
}
|
|
|
368 |
}
|
369 |
//}
|
370 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
371 |
|
372 |
+
public void TruyNa2() {
|
373 |
+
if (Truyna == 1) {
|
|
|
|
|
|
|
|
|
374 |
|
375 |
+
List< String> list1 = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
376 |
list1.add(0, "0");
|
377 |
try {
|
378 |
Thread.sleep(5000);
|
|
|
382 |
String[] temp = rs1.toString().split("");
|
383 |
|
384 |
ObjectMapper mapper = new ObjectMapper();
|
385 |
+
Map< String, Object> carMap = null;
|
386 |
int h = 0;
|
387 |
for (String string : temp) {
|
388 |
+
carMap = mapper.readValue(string, new TypeReference< Map< String, Object>>() {
|
389 |
});
|
390 |
h = (int) carMap.get("h");
|
391 |
if (h == Integer.parseInt("60605")) {
|
|
|
393 |
}
|
394 |
}
|
395 |
|
396 |
+
List< Object> carMap1 = (List< Object>) ((Map< String, Object>) carMap.get("m")).get("wantedMemberList");
|
397 |
int idarea = 0;
|
398 |
int id = 0;
|
399 |
int attactNum = 0;
|
400 |
int level = 0;
|
401 |
int isAttacked = 0;
|
402 |
long playerId = 0;
|
|
|
403 |
String tmp = "";
|
404 |
+
String playerName = "";
|
405 |
Tqtk.sendMessage("tn " + ss.getStringName());
|
406 |
for (Object object : carMap1) {
|
407 |
+
idarea = (int) ((Map< Object, Object>) object).get("areaId");
|
408 |
+
id = (int) ((Map< Object, Object>) object).get("id");
|
409 |
+
attactNum = (int) ((Map< Object, Object>) object).get("attactNum");
|
410 |
+
level = (int) ((Map< Object, Object>) object).get("playerLevel");
|
411 |
+
isAttacked = (int) ((Map< Object, Object>) object).get("hasAttact");
|
412 |
+
playerId = (long) ((Map< Object, Object>) object).get("playerId");
|
413 |
playerName = (String) ((Map<Object, Object>) object).get("playerName");
|
414 |
playerName = playerName.toLowerCase();
|
415 |
list1.set(0, Integer.toString(id));
|
416 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
417 |
synchronized (tqtk.Tqtk.loaiTruyna) {
|
418 |
+
if (id != 0 && !Tqtk.loaiTruyna.contains(Long.toString(playerId))
|
|
|
419 |
&& attactNum != 0
|
420 |
// && idarea == -1
|
421 |
&& isAttacked == 0
|
422 |
+
&& level < 88) {
|
423 |
rs1 = GuiPacketTN(ss, "60606", list1);
|
424 |
if (rs1 != null) {
|
425 |
tmp = rs1.toString();
|
|
|
427 |
if (tmp.contains("\"winside\":2") || tmp.contains("\"winside\": 2")) {
|
428 |
tqtk.Tqtk.loaiTruyna.add(playerName);
|
429 |
tqtk.Tqtk.loaiTruyna.add(Long.toString(playerId));
|
430 |
+
} else {
|
431 |
+
Truyna = 0;
|
432 |
+
break;
|
433 |
}
|
434 |
+
|
435 |
}
|
436 |
}
|
437 |
Thread.sleep(5000);
|
438 |
+
MuaLinh();
|
439 |
}
|
440 |
} catch (Exception e) {
|
441 |
throw new JsonException();
|
|
|
455 |
}
|
456 |
}
|
457 |
|
458 |
+
public void TruyNa() throws InterruptedException, IOException {
|
459 |
+
if (Truyna == 1) {
|
460 |
+
try {
|
461 |
+
List<String> list1 = new ArrayList<>();
|
462 |
+
list1.add(0, "0");
|
463 |
+
|
464 |
+
if (Tqtk.listtruyna.size() > 0 && Tqtk.loaiTruyna.size() > 0) {
|
465 |
+
String id = "";
|
466 |
+
String PlayerName = "";
|
467 |
+
String PlayerId = "";
|
468 |
+
int AttactNum = 0;
|
469 |
+
for (TruyNa tn : Tqtk.listtruyna) {
|
470 |
+
id = tn.getId();
|
471 |
+
AttactNum = tn.getAttactNum();
|
472 |
+
PlayerName = tn.getPlayerName();
|
473 |
+
PlayerId = tn.getPlayerId();
|
474 |
+
Tqtk.sendMessage("tn " + PlayerName + " " + PlayerId + " " + AttactNum + " " + id);
|
475 |
+
synchronized (Tqtk.listtruyna) {
|
476 |
+
if (!Tqtk.loaiTruyna.contains(PlayerName)
|
477 |
+
&& !Tqtk.loaiTruyna.contains(PlayerId)
|
478 |
+
&& AttactNum != 0) {
|
479 |
+
list1.set(0, id);
|
480 |
+
GuiPacketTN(ss, "60606", list1);
|
481 |
+
Truyna = 0;
|
482 |
+
}
|
483 |
+
|
484 |
+
}
|
485 |
+
Thread.sleep(2000);
|
486 |
+
}
|
487 |
+
}
|
488 |
+
} catch (Exception e) {
|
489 |
+
System.out.println("GuiPacketTN 2 " + e.getMessage());
|
490 |
+
}
|
491 |
+
}
|
492 |
+
|
493 |
+
}
|
494 |
+
|
495 |
+
public void getIdTruyNa() {
|
496 |
+
List<String> list1 = new ArrayList<>();
|
497 |
+
list1.add(0, "0");
|
498 |
+
try {
|
499 |
+
Thread.sleep(5000);
|
500 |
+
StringBuilder rs1 = GuiPacketTN(ss, "60605", null);
|
501 |
+
if (rs1 != null) {
|
502 |
+
try {
|
503 |
+
String[] temp = rs1.toString().split("");
|
504 |
+
|
505 |
+
ObjectMapper mapper = new ObjectMapper();
|
506 |
+
Map<String, Object> carMap = null;
|
507 |
+
int h = 0;
|
508 |
+
for (String string : temp) {
|
509 |
+
carMap = mapper.readValue(string, new TypeReference<Map<String, Object>>() {
|
510 |
+
});
|
511 |
+
h = (int) carMap.get("h");
|
512 |
+
if (h == Integer.parseInt("60605")) {
|
513 |
+
break;
|
514 |
+
}
|
515 |
+
}
|
516 |
+
|
517 |
+
List<Object> carMap1 = (List<Object>) ((Map<String, Object>) carMap.get("m")).get("wantedMemberList");
|
518 |
+
int idarea = 0;
|
519 |
+
int id = 0;
|
520 |
+
int attactNum = 0;
|
521 |
+
int level = 0;
|
522 |
+
int isAttacked = 0;
|
523 |
+
long playerId = 0;
|
524 |
+
String playerName = "";
|
525 |
+
String tmp = "";
|
526 |
+
TruyNa tn = null;
|
527 |
+
Tqtk.sendMessage("tn " + ss.getStringName());
|
528 |
+
for (Object object : carMap1) {
|
529 |
+
idarea = (int) ((Map<Object, Object>) object).get("areaId");
|
530 |
+
id = (int) ((Map<Object, Object>) object).get("id");
|
531 |
+
attactNum = (int) ((Map<Object, Object>) object).get("attactNum");
|
532 |
+
level = (int) ((Map<Object, Object>) object).get("playerLevel");
|
533 |
+
isAttacked = (int) ((Map<Object, Object>) object).get("hasAttact");
|
534 |
+
playerId = (long) ((Map<Object, Object>) object).get("playerId");
|
535 |
+
playerName = (String) ((Map<Object, Object>) object).get("playerName");
|
536 |
+
playerName = playerName.toLowerCase();
|
537 |
+
list1.set(0, Integer.toString(id));
|
538 |
+
|
539 |
+
tn = new TruyNa();
|
540 |
+
tn.setAttactNum(attactNum);
|
541 |
+
tn.setId(Long.toString(id));
|
542 |
+
tn.setPlayerId(Long.toString(playerId));
|
543 |
+
tn.setPlayerName(playerName);
|
544 |
+
Tqtk.listtruyna.add(tn);
|
545 |
+
|
546 |
+
Thread.sleep(1000);
|
547 |
+
}
|
548 |
+
} catch (Exception e) {
|
549 |
+
throw new JsonException();
|
550 |
+
}
|
551 |
+
|
552 |
+
//}
|
553 |
+
}
|
554 |
+
} catch (Exception ex) {
|
555 |
+
if (!(ex instanceof JsonException)) {
|
556 |
+
|
557 |
+
System.out.println("loi TruyNa " + ss.getStringName() + ex.getMessage());
|
558 |
+
} else {
|
559 |
+
|
560 |
+
System.out.println("loi TruyNa json " + ss.getStringName() + ex.getMessage());
|
561 |
+
}
|
562 |
+
}
|
563 |
+
}
|
564 |
+
|
565 |
public void NangNha() {
|
566 |
List<String> list1 = new ArrayList<>();
|
567 |
|
568 |
+
try {
|
569 |
+
list1.add(0, "5");
|
570 |
+
for (String buildingId : ss.getBuildingIds()) {
|
571 |
+
list1.set(0, buildingId);
|
572 |
+
Thread.sleep(5000);
|
573 |
+
GuiPacket(ss, "12100", list1);
|
574 |
+
}
|
575 |
+
|
576 |
+
} catch (Exception e) {
|
577 |
+
System.out.println("NangNha " + ss.getStringName() + e.getMessage());
|
578 |
+
}
|
579 |
+
}
|
580 |
+
|
581 |
+
public void NangNha1() {
|
582 |
+
List<String> list1 = new ArrayList<>();
|
583 |
+
|
584 |
try {
|
585 |
// nha chinh
|
586 |
list1.add(0, "5");
|
|
|
609 |
}
|
610 |
|
611 |
public void NangKiNang() {
|
612 |
+
List<String> list1 = new ArrayList<>();
|
613 |
+
try {
|
614 |
+
//binh khi , 42200 ,3
|
615 |
+
list1.add(0, "13");
|
616 |
+
Tqtk.sendMessage("nang kn " + ss.getStringName());
|
617 |
+
for (String skillId : ss.getSkillIds()) {
|
618 |
+
list1.set(0, skillId);
|
619 |
+
Thread.sleep(5000);
|
620 |
+
GuiPacket(ss, "42200", list1);
|
621 |
+
}
|
622 |
+
} catch (Exception e) {
|
623 |
+
System.out.println("NangKiNang " + ss.getStringName() + e.getMessage());
|
624 |
+
}
|
625 |
+
}
|
626 |
+
|
627 |
+
public void NangKiNang1() {
|
628 |
List<String> list1 = new ArrayList<>();
|
629 |
try {
|
630 |
//binh khi , 42200 ,3
|
|
|
892 |
tqtk.Tqtk.listruong = (List<Object>) ((Map<String, Object>) carMap.get("m")).get("resource");
|
893 |
|
894 |
Tqtk.sendMessage("chiem ruong " + ss.getStringName());
|
895 |
+
String playername = "";
|
896 |
int resourceid = 0;
|
897 |
if (tqtk.Tqtk.listruong != null) {
|
898 |
for (Object object : tqtk.Tqtk.listruong) {
|
899 |
+
playername = (String) ((Map<Object, Object>) object).get("playername");
|
900 |
resourceid = (int) ((Map<Object, Object>) object).get("resourceid");
|
901 |
+
if (playername.equals("地方勢力")) {
|
902 |
break;
|
903 |
}
|
904 |
}
|
|
|
963 |
List<Object> listmo = (List<Object>) ((Map<String, Object>) carMap.get("m")).get("city");
|
964 |
|
965 |
Tqtk.sendMessage("chiem mo " + ss.getStringName());
|
966 |
+
String playername = "";
|
967 |
int resourceid = 0;
|
968 |
if (listmo != null) {
|
969 |
for (Object object : listmo) {
|
970 |
+
playername = (String) ((Map<Object, Object>) object).get("playername");
|
971 |
resourceid = (int) ((Map<Object, Object>) object).get("index");
|
972 |
+
if (playername.equals("地方勢力")) {
|
973 |
break;
|
974 |
}
|
975 |
}
|
|
|
1052 |
}
|
1053 |
|
1054 |
public void NangItem() throws IOException, UnknownHostException, InterruptedException, Exception {
|
1055 |
+
List<String> list1 = new ArrayList<>();
|
1056 |
+
list1.add(0, "0");
|
1057 |
+
list1.add(1, "0");
|
1058 |
+
list1.add(2, "0");
|
1059 |
+
try {
|
1060 |
+
Thread.sleep(5000);
|
1061 |
+
StringBuilder rs1 = GuiPacket(ss, "39301", list1);
|
1062 |
+
if (rs1 != null && rs1.toString() != "") {
|
1063 |
+
try {
|
1064 |
+
String[] temp = rs1.toString().split("");
|
1065 |
+
|
1066 |
+
ObjectMapper mapper = new ObjectMapper();
|
1067 |
+
Map<String, Object> carMap = null;
|
1068 |
+
int h = 0;
|
1069 |
+
for (String string : temp) {
|
1070 |
+
carMap = mapper.readValue(string, new TypeReference<Map<String, Object>>() {
|
1071 |
+
});
|
1072 |
+
h = (int) carMap.get("h");
|
1073 |
+
if (h == Integer.parseInt("39301")) {
|
1074 |
+
break;
|
1075 |
+
}
|
1076 |
+
}
|
1077 |
+
List<Object> carMap1 = (List<Object>) ((Map<String, Object>) carMap.get("m")).get("equip");
|
1078 |
+
Object Magic = (Object) ((Map<String, Object>) carMap.get("m")).get("magic");
|
1079 |
+
int Upgradecdusable = (int) ((Map<String, Object>) carMap.get("m")).get("upgradecdusable");
|
1080 |
+
Tqtk.sendMessage("nang item " + ss.getStringName());
|
1081 |
+
for (String object : ss.getItemIds()) {
|
1082 |
+
|
1083 |
+
list1.set(0, object);
|
1084 |
+
list1.set(2, Magic.toString());
|
1085 |
+
if (Upgradecdusable == 1 && (int) Magic >= 89) {
|
1086 |
+
GuiPacket(ss, "39302", list1);
|
1087 |
+
Thread.sleep(5000);
|
1088 |
+
GuiPacket(ss, "39302", list1);
|
1089 |
+
Thread.sleep(5000);
|
1090 |
+
}
|
1091 |
+
|
1092 |
+
}
|
1093 |
+
} catch (Exception e) {
|
1094 |
+
throw new JsonException();
|
1095 |
+
}
|
1096 |
+
} else {
|
1097 |
+
dangNhapLayThongTin();
|
1098 |
+
GuiPacketDeLogin();
|
1099 |
+
}
|
1100 |
+
} catch (Exception ex) {
|
1101 |
+
if (!(ex instanceof JsonException)) {
|
1102 |
+
System.out.println("NangItem " + ss.getStringName() + ex.getMessage());
|
1103 |
+
dangNhapLayThongTin();
|
1104 |
+
GuiPacketDeLogin();
|
1105 |
+
} else {
|
1106 |
+
System.out.println("NangItem json " + ss.getStringName() + ex.getMessage());
|
1107 |
+
}
|
1108 |
+
|
1109 |
+
}
|
1110 |
+
|
1111 |
+
}
|
1112 |
+
|
1113 |
+
public void NangItem1() throws IOException, UnknownHostException, InterruptedException, Exception {
|
1114 |
List<String> list1 = new ArrayList<>();
|
1115 |
list1.add(0, "0");
|
1116 |
list1.add(1, "0");
|
|
|
1242 |
|
1243 |
public void dangNhapLayThongTin() throws Exception {
|
1244 |
Socket socket = new Socket();
|
1245 |
+
socket.connect(new InetSocketAddress(InetAddress.getByName(ss.getIp()), Integer.parseInt(ss.getPort())), 7000);
|
1246 |
if (ss.getSocket() != null) {
|
1247 |
ss.getSocket().close();
|
1248 |
}
|
1249 |
ss.setSocket(socket);
|
1250 |
|
1251 |
Socket socket1 = new Socket();
|
1252 |
+
socket1.connect(new InetSocketAddress(InetAddress.getByName(ss.getIp()), Integer.parseInt(ss.getPort())), 7000);
|
1253 |
if (ss.getSocketApi() != null) {
|
1254 |
ss.getSocketApi().close();
|
1255 |
}
|
|
|
1258 |
|
1259 |
public void taoSocketTruyNa() throws Exception {
|
1260 |
Socket socket = new Socket();
|
1261 |
+
socket.connect(new InetSocketAddress(InetAddress.getByName(ss.getIp()), Integer.parseInt(ss.getPort())), 7000);
|
1262 |
if (ss.getSocketTN() != null) {
|
1263 |
ss.getSocketTN().close();
|
1264 |
}
|
|
|
1456 |
}
|
1457 |
|
1458 |
public static void createSocket(SessionEntity session) throws Exception {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1459 |
Socket socket = new Socket();
|
1460 |
+
socket.connect(new InetSocketAddress(InetAddress.getByName(session.getIp()), Integer.parseInt(session.getPort())), 7000);
|
1461 |
socket.setSoTimeout(350000);
|
1462 |
try {
|
1463 |
session.getSocket().close();
|
|
|
1468 |
|
1469 |
public static void createSocketApi(SessionEntity session) throws Exception {
|
1470 |
Socket socket1 = new Socket();
|
1471 |
+
socket1.connect(new InetSocketAddress(InetAddress.getByName(session.getIp()), Integer.parseInt(session.getPort())), 7000);
|
1472 |
socket1.setSoTimeout(350000);
|
1473 |
try {
|
1474 |
session.getSocketApi().close();
|
|
|
1482 |
try {
|
1483 |
dangNhapLayThongTin();
|
1484 |
GuiPacketDeLogin();
|
1485 |
+
try {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1486 |
|
1487 |
MuaLinh();
|
1488 |
+
|
|
|
|
|
1489 |
NangItem();
|
1490 |
LuyenTuong();
|
1491 |
NangNha();
|
|
|
1499 |
ChiemRuong();
|
1500 |
MuaRuong();
|
1501 |
CapNhatThongTin();
|
1502 |
+
|
1503 |
+
} catch (Exception ex) {
|
1504 |
+
System.out.println("all " + ss.getStringName() + ex.getMessage());
|
|
|
1505 |
}
|
1506 |
} catch (Exception ex) {
|
1507 |
System.out.println("all " + ss.getStringName() + ex.getMessage());
|
src/main/java/tqtk/XuLy/login/LayThongTinSession.java
CHANGED
@@ -32,7 +32,7 @@ import static tqtk.Tqtk.sendMessage;
|
|
32 |
*/
|
33 |
public class LayThongTinSession {
|
34 |
|
35 |
-
|
36 |
|
37 |
public static synchronized SessionEntity getSessionEntity(String user, String pass, int id, Util u) throws Exception {
|
38 |
// login va lay thong tin session
|
@@ -48,16 +48,11 @@ public class LayThongTinSession {
|
|
48 |
String userID = Util.getInfoSocket(html, "userID");
|
49 |
SessionEntity ss = new SessionEntity();
|
50 |
ss.setIp(ip);
|
51 |
-
ss.
|
52 |
ss.setSessionKey(sessionKey);
|
53 |
ss.setUserId(userID);
|
54 |
ss.setStringName(user);
|
55 |
u.setCookie(null);
|
56 |
return ss;
|
57 |
}
|
58 |
-
|
59 |
-
public static List<SessionEntity> getListSession() {
|
60 |
-
return ListSession;
|
61 |
-
}
|
62 |
-
|
63 |
}
|
|
|
32 |
*/
|
33 |
public class LayThongTinSession {
|
34 |
|
35 |
+
|
36 |
|
37 |
public static synchronized SessionEntity getSessionEntity(String user, String pass, int id, Util u) throws Exception {
|
38 |
// login va lay thong tin session
|
|
|
48 |
String userID = Util.getInfoSocket(html, "userID");
|
49 |
SessionEntity ss = new SessionEntity();
|
50 |
ss.setIp(ip);
|
51 |
+
ss.setPort(ports);
|
52 |
ss.setSessionKey(sessionKey);
|
53 |
ss.setUserId(userID);
|
54 |
ss.setStringName(user);
|
55 |
u.setCookie(null);
|
56 |
return ss;
|
57 |
}
|
|
|
|
|
|
|
|
|
|
|
58 |
}
|
truyna-b.properties
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
manato
|
2 |
+
zyto
|
3 |
+
doraemon
|
4 |
+
風見
|
5 |
+
maruto
|
6 |
+
芽依五郎
|
7 |
+
樹共
|
8 |
+
ahihi2
|
9 |
+
だんでぃ~さかの
|
truyna.properties
CHANGED
@@ -1,9 +1 @@
|
|
1 |
-
manato
|
2 |
-
zyto
|
3 |
-
doraemon
|
4 |
-
風見
|
5 |
-
maruto
|
6 |
-
芽依五郎
|
7 |
-
樹共
|
8 |
-
ahihi2
|
9 |
-
だんでぃ~さかの
|
|
|
1 |
+
manato
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|