parent
ea314be257
commit
7f1f8ba3e7
@ -1,42 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="UTF-8"?> |
|
||||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" |
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> |
|
||||||
<modelVersion>4.0.0</modelVersion> |
|
||||||
<groupId>cn.wustlinghang.wusthelper</groupId> |
|
||||||
<artifactId>wusthelper-backend</artifactId> |
|
||||||
<version>0.0.1-SNAPSHOT</version> |
|
||||||
<packaging>pom</packaging> |
|
||||||
<dependencies> |
|
||||||
<dependency> |
|
||||||
<groupId>jakarta.annotation</groupId> |
|
||||||
<artifactId>jakarta.annotation-api</artifactId> |
|
||||||
<version>2.1.1</version> |
|
||||||
<scope>compile</scope> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<groupId>javax.annotation</groupId> |
|
||||||
<artifactId>javax.annotation-api</artifactId> |
|
||||||
<version>1.3.2</version> |
|
||||||
<scope>compile</scope> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<groupId>org.projectlombok</groupId> |
|
||||||
<artifactId>lombok</artifactId> |
|
||||||
<version>1.18.26</version> |
|
||||||
<scope>provided</scope> |
|
||||||
</dependency> |
|
||||||
</dependencies> |
|
||||||
<repositories> |
|
||||||
<repository> |
|
||||||
<id>central</id> |
|
||||||
<url>https://repo1.maven.org/maven2</url> |
|
||||||
</repository> |
|
||||||
<repository> |
|
||||||
<snapshots> |
|
||||||
<enabled>true</enabled> |
|
||||||
</snapshots> |
|
||||||
<id>github</id> |
|
||||||
<url>https://maven.pkg.github.com/LingHangStudio/mywust</url> |
|
||||||
</repository> |
|
||||||
</repositories> |
|
||||||
</project> |
|
@ -1,42 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="UTF-8"?> |
|
||||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" |
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> |
|
||||||
<modelVersion>4.0.0</modelVersion> |
|
||||||
<groupId>cn.wustlinghang.wusthelper</groupId> |
|
||||||
<artifactId>backend-main</artifactId> |
|
||||||
<version>0.0.1-SNAPSHOT</version> |
|
||||||
<packaging>pom</packaging> |
|
||||||
<dependencies> |
|
||||||
<dependency> |
|
||||||
<groupId>jakarta.annotation</groupId> |
|
||||||
<artifactId>jakarta.annotation-api</artifactId> |
|
||||||
<version>2.1.1</version> |
|
||||||
<scope>compile</scope> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<groupId>javax.annotation</groupId> |
|
||||||
<artifactId>javax.annotation-api</artifactId> |
|
||||||
<version>1.3.2</version> |
|
||||||
<scope>compile</scope> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<groupId>org.projectlombok</groupId> |
|
||||||
<artifactId>lombok</artifactId> |
|
||||||
<version>1.18.26</version> |
|
||||||
<scope>provided</scope> |
|
||||||
</dependency> |
|
||||||
</dependencies> |
|
||||||
<repositories> |
|
||||||
<repository> |
|
||||||
<id>central</id> |
|
||||||
<url>https://repo1.maven.org/maven2</url> |
|
||||||
</repository> |
|
||||||
<repository> |
|
||||||
<snapshots> |
|
||||||
<enabled>true</enabled> |
|
||||||
</snapshots> |
|
||||||
<id>github</id> |
|
||||||
<url>https://maven.pkg.github.com/LingHangStudio/mywust</url> |
|
||||||
</repository> |
|
||||||
</repositories> |
|
||||||
</project> |
|
@ -1,41 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="UTF-8"?> |
|
||||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" |
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> |
|
||||||
<modelVersion>4.0.0</modelVersion> |
|
||||||
<groupId>cn.wustlinghang.wusthelper</groupId> |
|
||||||
<artifactId>web</artifactId> |
|
||||||
<version>0.0.1-SNAPSHOT</version> |
|
||||||
<dependencies> |
|
||||||
<dependency> |
|
||||||
<groupId>jakarta.annotation</groupId> |
|
||||||
<artifactId>jakarta.annotation-api</artifactId> |
|
||||||
<version>2.1.1</version> |
|
||||||
<scope>compile</scope> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<groupId>javax.annotation</groupId> |
|
||||||
<artifactId>javax.annotation-api</artifactId> |
|
||||||
<version>1.3.2</version> |
|
||||||
<scope>compile</scope> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<groupId>org.projectlombok</groupId> |
|
||||||
<artifactId>lombok</artifactId> |
|
||||||
<version>1.18.26</version> |
|
||||||
<scope>provided</scope> |
|
||||||
</dependency> |
|
||||||
</dependencies> |
|
||||||
<repositories> |
|
||||||
<repository> |
|
||||||
<id>central</id> |
|
||||||
<url>https://repo1.maven.org/maven2</url> |
|
||||||
</repository> |
|
||||||
<repository> |
|
||||||
<snapshots> |
|
||||||
<enabled>true</enabled> |
|
||||||
</snapshots> |
|
||||||
<id>github</id> |
|
||||||
<url>https://maven.pkg.github.com/LingHangStudio/mywust</url> |
|
||||||
</repository> |
|
||||||
</repositories> |
|
||||||
</project> |
|
@ -1,20 +0,0 @@ |
|||||||
package cn.wustlinghang.internal.api.v1; |
|
||||||
|
|
||||||
import cn.wustlinghang.internal.api.v1.response.FrpPluginResponse; |
|
||||||
import lombok.extern.slf4j.Slf4j; |
|
||||||
import org.springframework.web.bind.annotation.RequestMapping; |
|
||||||
import org.springframework.web.bind.annotation.RestController; |
|
||||||
|
|
||||||
@Slf4j |
|
||||||
@RestController |
|
||||||
@RequestMapping("/internal/frp") |
|
||||||
public class FrpPluginHandler { |
|
||||||
@RequestMapping("/handler") |
|
||||||
public FrpPluginResponse handle(String request) { |
|
||||||
log.info(request); |
|
||||||
return FrpPluginResponse.builder() |
|
||||||
.reject(false) |
|
||||||
.unchange(true) |
|
||||||
.build(); |
|
||||||
} |
|
||||||
} |
|
@ -1,14 +0,0 @@ |
|||||||
package cn.wustlinghang.internal.api.v1.response; |
|
||||||
|
|
||||||
import lombok.Builder; |
|
||||||
import lombok.Data; |
|
||||||
|
|
||||||
@Data |
|
||||||
@Builder |
|
||||||
public class FrpPluginResponse { |
|
||||||
private boolean reject; |
|
||||||
|
|
||||||
private boolean unchange; |
|
||||||
|
|
||||||
// private String rejectReason;
|
|
||||||
} |
|
@ -1,13 +1,23 @@ |
|||||||
package cn.wustlinghang.main.web.api.v2.undergrade; |
package cn.wustlinghang.main.web.api.v2.undergrade; |
||||||
|
|
||||||
|
import cn.wustlinghang.main.web.service.campus.undergrad.UndergradCookieService; |
||||||
import cn.wustlinghang.wusthelper.main.response.Response; |
import cn.wustlinghang.wusthelper.main.response.Response; |
||||||
|
import org.springframework.web.bind.annotation.PostMapping; |
||||||
import org.springframework.web.bind.annotation.RequestMapping; |
import org.springframework.web.bind.annotation.RequestMapping; |
||||||
import org.springframework.web.bind.annotation.RestController; |
import org.springframework.web.bind.annotation.RestController; |
||||||
|
|
||||||
@RestController |
@RestController |
||||||
@RequestMapping("/jwc") |
@RequestMapping("/jwc") |
||||||
public class UndergradController { |
public class UndergradController { |
||||||
|
private final UndergradCookieService undergradCookieService; |
||||||
|
|
||||||
|
public UndergradController(UndergradCookieService undergradCookieService) { |
||||||
|
this.undergradCookieService = undergradCookieService; |
||||||
|
} |
||||||
|
|
||||||
|
@PostMapping("/login") |
||||||
public Response<String> login() { |
public Response<String> login() { |
||||||
return Response.success(""); |
String cookie = undergradCookieService.getLoginCookie("202118194039", "-96387ee"); |
||||||
|
return Response.success(cookie); |
||||||
} |
} |
||||||
} |
} |
@ -1,41 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="UTF-8"?> |
|
||||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" |
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> |
|
||||||
<modelVersion>4.0.0</modelVersion> |
|
||||||
<groupId>cn.wustlinghang.wusthelper</groupId> |
|
||||||
<artifactId>common</artifactId> |
|
||||||
<version>0.0.1-SNAPSHOT</version> |
|
||||||
<dependencies> |
|
||||||
<dependency> |
|
||||||
<groupId>jakarta.annotation</groupId> |
|
||||||
<artifactId>jakarta.annotation-api</artifactId> |
|
||||||
<version>2.1.1</version> |
|
||||||
<scope>compile</scope> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<groupId>javax.annotation</groupId> |
|
||||||
<artifactId>javax.annotation-api</artifactId> |
|
||||||
<version>1.3.2</version> |
|
||||||
<scope>compile</scope> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<groupId>org.projectlombok</groupId> |
|
||||||
<artifactId>lombok</artifactId> |
|
||||||
<version>1.18.26</version> |
|
||||||
<scope>provided</scope> |
|
||||||
</dependency> |
|
||||||
</dependencies> |
|
||||||
<repositories> |
|
||||||
<repository> |
|
||||||
<id>central</id> |
|
||||||
<url>https://repo1.maven.org/maven2</url> |
|
||||||
</repository> |
|
||||||
<repository> |
|
||||||
<snapshots> |
|
||||||
<enabled>true</enabled> |
|
||||||
</snapshots> |
|
||||||
<id>github</id> |
|
||||||
<url>https://maven.pkg.github.com/LingHangStudio/mywust</url> |
|
||||||
</repository> |
|
||||||
</repositories> |
|
||||||
</project> |
|
@ -1,42 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="UTF-8"?> |
|
||||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" |
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> |
|
||||||
<modelVersion>4.0.0</modelVersion> |
|
||||||
<groupId>cn.wustlinghang.wusthelper</groupId> |
|
||||||
<artifactId>external-library</artifactId> |
|
||||||
<version>0.0.1-SNAPSHOT</version> |
|
||||||
<packaging>pom</packaging> |
|
||||||
<dependencies> |
|
||||||
<dependency> |
|
||||||
<groupId>jakarta.annotation</groupId> |
|
||||||
<artifactId>jakarta.annotation-api</artifactId> |
|
||||||
<version>2.1.1</version> |
|
||||||
<scope>compile</scope> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<groupId>javax.annotation</groupId> |
|
||||||
<artifactId>javax.annotation-api</artifactId> |
|
||||||
<version>1.3.2</version> |
|
||||||
<scope>compile</scope> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<groupId>org.projectlombok</groupId> |
|
||||||
<artifactId>lombok</artifactId> |
|
||||||
<version>1.18.26</version> |
|
||||||
<scope>provided</scope> |
|
||||||
</dependency> |
|
||||||
</dependencies> |
|
||||||
<repositories> |
|
||||||
<repository> |
|
||||||
<id>central</id> |
|
||||||
<url>https://repo1.maven.org/maven2</url> |
|
||||||
</repository> |
|
||||||
<repository> |
|
||||||
<snapshots> |
|
||||||
<enabled>true</enabled> |
|
||||||
</snapshots> |
|
||||||
<id>github</id> |
|
||||||
<url>https://maven.pkg.github.com/LingHangStudio/mywust</url> |
|
||||||
</repository> |
|
||||||
</repositories> |
|
||||||
</project> |
|
@ -1,12 +1,16 @@ |
|||||||
package cn.wustlinghang.wusthelper.internal.rpc.config; |
package cn.wustlinghang.wusthelper.internal.rpc.config; |
||||||
|
|
||||||
|
import lombok.Builder; |
||||||
import lombok.Data; |
import lombok.Data; |
||||||
|
|
||||||
@Data |
@Data |
||||||
|
@Builder |
||||||
public class RegisterConfig { |
public class RegisterConfig { |
||||||
private String localServicePort; |
private String localServicePort; |
||||||
|
|
||||||
private String serviceName; |
private String serviceName; |
||||||
|
|
||||||
private String consulAddress; |
private String consulAddress; |
||||||
|
|
||||||
|
private String token; |
||||||
} |
} |
||||||
|
@ -1,60 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="UTF-8"?> |
|
||||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" |
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> |
|
||||||
<modelVersion>4.0.0</modelVersion> |
|
||||||
<groupId>cn.wustlinghang.wusthelper</groupId> |
|
||||||
<artifactId>sub-services</artifactId> |
|
||||||
<version>0.0.1-SNAPSHOT</version> |
|
||||||
<packaging>pom</packaging> |
|
||||||
<dependencies> |
|
||||||
<dependency> |
|
||||||
<groupId>cn.wustlinghang.mywust</groupId> |
|
||||||
<artifactId>mywust-core</artifactId> |
|
||||||
<version>0.0.2-SNAPSHOT</version> |
|
||||||
<scope>compile</scope> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<groupId>cn.wustlinghang.mywust</groupId> |
|
||||||
<artifactId>mywust-network-okhttp</artifactId> |
|
||||||
<version>0.0.2-SNAPSHOT</version> |
|
||||||
<scope>compile</scope> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<groupId>cn.wustlinghang.wusthelper</groupId> |
|
||||||
<artifactId>common</artifactId> |
|
||||||
<version>0.0.1-SNAPSHOT</version> |
|
||||||
<scope>compile</scope> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<groupId>jakarta.annotation</groupId> |
|
||||||
<artifactId>jakarta.annotation-api</artifactId> |
|
||||||
<version>2.1.1</version> |
|
||||||
<scope>compile</scope> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<groupId>javax.annotation</groupId> |
|
||||||
<artifactId>javax.annotation-api</artifactId> |
|
||||||
<version>1.3.2</version> |
|
||||||
<scope>compile</scope> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<groupId>org.projectlombok</groupId> |
|
||||||
<artifactId>lombok</artifactId> |
|
||||||
<version>1.18.26</version> |
|
||||||
<scope>provided</scope> |
|
||||||
</dependency> |
|
||||||
</dependencies> |
|
||||||
<repositories> |
|
||||||
<repository> |
|
||||||
<id>central</id> |
|
||||||
<url>https://repo1.maven.org/maven2</url> |
|
||||||
</repository> |
|
||||||
<repository> |
|
||||||
<snapshots> |
|
||||||
<enabled>true</enabled> |
|
||||||
</snapshots> |
|
||||||
<id>github</id> |
|
||||||
<url>https://maven.pkg.github.com/LingHangStudio/mywust</url> |
|
||||||
</repository> |
|
||||||
</repositories> |
|
||||||
</project> |
|
@ -1,93 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="UTF-8"?> |
|
||||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" |
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> |
|
||||||
<modelVersion>4.0.0</modelVersion> |
|
||||||
<groupId>cn.wustlinghang.wusthelper</groupId> |
|
||||||
<artifactId>graduate</artifactId> |
|
||||||
<version>0.0.1-SNAPSHOT</version> |
|
||||||
<dependencies> |
|
||||||
<dependency> |
|
||||||
<groupId>io.quarkus</groupId> |
|
||||||
<artifactId>quarkus-resteasy-reactive-jackson</artifactId> |
|
||||||
<version>3.1.3.Final</version> |
|
||||||
<scope>compile</scope> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<groupId>io.quarkus</groupId> |
|
||||||
<artifactId>quarkus-hibernate-validator</artifactId> |
|
||||||
<version>3.1.3.Final</version> |
|
||||||
<scope>compile</scope> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<groupId>io.quarkus</groupId> |
|
||||||
<artifactId>quarkus-resteasy-reactive</artifactId> |
|
||||||
<version>3.1.3.Final</version> |
|
||||||
<scope>compile</scope> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<groupId>io.quarkus</groupId> |
|
||||||
<artifactId>quarkus-arc</artifactId> |
|
||||||
<version>3.1.3.Final</version> |
|
||||||
<scope>compile</scope> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<groupId>cn.wustlinghang.mywust</groupId> |
|
||||||
<artifactId>mywust-core</artifactId> |
|
||||||
<version>0.0.2-SNAPSHOT</version> |
|
||||||
<scope>compile</scope> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<groupId>cn.wustlinghang.mywust</groupId> |
|
||||||
<artifactId>mywust-network-okhttp</artifactId> |
|
||||||
<version>0.0.2-SNAPSHOT</version> |
|
||||||
<scope>compile</scope> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<groupId>cn.wustlinghang.wusthelper</groupId> |
|
||||||
<artifactId>common</artifactId> |
|
||||||
<version>0.0.1-SNAPSHOT</version> |
|
||||||
<scope>compile</scope> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<groupId>jakarta.annotation</groupId> |
|
||||||
<artifactId>jakarta.annotation-api</artifactId> |
|
||||||
<version>2.1.1</version> |
|
||||||
<scope>compile</scope> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<groupId>javax.annotation</groupId> |
|
||||||
<artifactId>javax.annotation-api</artifactId> |
|
||||||
<version>1.3.2</version> |
|
||||||
<scope>compile</scope> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<groupId>org.projectlombok</groupId> |
|
||||||
<artifactId>lombok</artifactId> |
|
||||||
<version>1.18.26</version> |
|
||||||
<scope>provided</scope> |
|
||||||
</dependency> |
|
||||||
</dependencies> |
|
||||||
<repositories> |
|
||||||
<repository> |
|
||||||
<id>central</id> |
|
||||||
<url>https://repo1.maven.org/maven2</url> |
|
||||||
</repository> |
|
||||||
<repository> |
|
||||||
<snapshots> |
|
||||||
<enabled>true</enabled> |
|
||||||
</snapshots> |
|
||||||
<id>github</id> |
|
||||||
<url>https://maven.pkg.github.com/LingHangStudio/mywust</url> |
|
||||||
</repository> |
|
||||||
</repositories> |
|
||||||
<build> |
|
||||||
<plugins> |
|
||||||
<plugin> |
|
||||||
<groupId>io.quarkus.platform</groupId> |
|
||||||
<artifactId>quarkus-maven-plugin</artifactId> |
|
||||||
<version>3.1.3.Final</version> |
|
||||||
<extensions>true</extensions> |
|
||||||
</plugin> |
|
||||||
</plugins> |
|
||||||
</build> |
|
||||||
</project> |
|
@ -1,93 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="UTF-8"?> |
|
||||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" |
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> |
|
||||||
<modelVersion>4.0.0</modelVersion> |
|
||||||
<groupId>cn.wustlinghang.wusthelper</groupId> |
|
||||||
<artifactId>library</artifactId> |
|
||||||
<version>0.0.1-SNAPSHOT</version> |
|
||||||
<dependencies> |
|
||||||
<dependency> |
|
||||||
<groupId>io.quarkus</groupId> |
|
||||||
<artifactId>quarkus-resteasy-reactive-jackson</artifactId> |
|
||||||
<version>3.1.3.Final</version> |
|
||||||
<scope>compile</scope> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<groupId>io.quarkus</groupId> |
|
||||||
<artifactId>quarkus-hibernate-validator</artifactId> |
|
||||||
<version>3.1.3.Final</version> |
|
||||||
<scope>compile</scope> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<groupId>io.quarkus</groupId> |
|
||||||
<artifactId>quarkus-resteasy-reactive</artifactId> |
|
||||||
<version>3.1.3.Final</version> |
|
||||||
<scope>compile</scope> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<groupId>io.quarkus</groupId> |
|
||||||
<artifactId>quarkus-arc</artifactId> |
|
||||||
<version>3.1.3.Final</version> |
|
||||||
<scope>compile</scope> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<groupId>cn.wustlinghang.mywust</groupId> |
|
||||||
<artifactId>mywust-core</artifactId> |
|
||||||
<version>0.0.2-beta</version> |
|
||||||
<scope>compile</scope> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<groupId>cn.wustlinghang.mywust</groupId> |
|
||||||
<artifactId>mywust-network-okhttp</artifactId> |
|
||||||
<version>0.0.2-beta</version> |
|
||||||
<scope>compile</scope> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<groupId>cn.wustlinghang.wusthelper</groupId> |
|
||||||
<artifactId>common</artifactId> |
|
||||||
<version>0.0.1-SNAPSHOT</version> |
|
||||||
<scope>compile</scope> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<groupId>jakarta.annotation</groupId> |
|
||||||
<artifactId>jakarta.annotation-api</artifactId> |
|
||||||
<version>2.1.1</version> |
|
||||||
<scope>compile</scope> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<groupId>javax.annotation</groupId> |
|
||||||
<artifactId>javax.annotation-api</artifactId> |
|
||||||
<version>1.3.2</version> |
|
||||||
<scope>compile</scope> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<groupId>org.projectlombok</groupId> |
|
||||||
<artifactId>lombok</artifactId> |
|
||||||
<version>1.18.26</version> |
|
||||||
<scope>provided</scope> |
|
||||||
</dependency> |
|
||||||
</dependencies> |
|
||||||
<repositories> |
|
||||||
<repository> |
|
||||||
<id>central</id> |
|
||||||
<url>https://repo1.maven.org/maven2</url> |
|
||||||
</repository> |
|
||||||
<repository> |
|
||||||
<snapshots> |
|
||||||
<enabled>true</enabled> |
|
||||||
</snapshots> |
|
||||||
<id>github</id> |
|
||||||
<url>https://maven.pkg.github.com/LingHangStudio/mywust</url> |
|
||||||
</repository> |
|
||||||
</repositories> |
|
||||||
<build> |
|
||||||
<plugins> |
|
||||||
<plugin> |
|
||||||
<groupId>io.quarkus.platform</groupId> |
|
||||||
<artifactId>quarkus-maven-plugin</artifactId> |
|
||||||
<version>3.1.3.Final</version> |
|
||||||
<extensions>true</extensions> |
|
||||||
</plugin> |
|
||||||
</plugins> |
|
||||||
</build> |
|
||||||
</project> |
|
@ -1,93 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="UTF-8"?> |
|
||||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" |
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> |
|
||||||
<modelVersion>4.0.0</modelVersion> |
|
||||||
<groupId>cn.wustlinghang.wusthelper</groupId> |
|
||||||
<artifactId>physics</artifactId> |
|
||||||
<version>0.0.1-SNAPSHOT</version> |
|
||||||
<dependencies> |
|
||||||
<dependency> |
|
||||||
<groupId>io.quarkus</groupId> |
|
||||||
<artifactId>quarkus-resteasy-reactive-jackson</artifactId> |
|
||||||
<version>3.1.3.Final</version> |
|
||||||
<scope>compile</scope> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<groupId>io.quarkus</groupId> |
|
||||||
<artifactId>quarkus-hibernate-validator</artifactId> |
|
||||||
<version>3.1.3.Final</version> |
|
||||||
<scope>compile</scope> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<groupId>io.quarkus</groupId> |
|
||||||
<artifactId>quarkus-resteasy-reactive</artifactId> |
|
||||||
<version>3.1.3.Final</version> |
|
||||||
<scope>compile</scope> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<groupId>io.quarkus</groupId> |
|
||||||
<artifactId>quarkus-arc</artifactId> |
|
||||||
<version>3.1.3.Final</version> |
|
||||||
<scope>compile</scope> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<groupId>cn.wustlinghang.mywust</groupId> |
|
||||||
<artifactId>mywust-core</artifactId> |
|
||||||
<version>0.0.2-SNAPSHOT</version> |
|
||||||
<scope>compile</scope> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<groupId>cn.wustlinghang.mywust</groupId> |
|
||||||
<artifactId>mywust-network-okhttp</artifactId> |
|
||||||
<version>0.0.2-SNAPSHOT</version> |
|
||||||
<scope>compile</scope> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<groupId>cn.wustlinghang.wusthelper</groupId> |
|
||||||
<artifactId>common</artifactId> |
|
||||||
<version>0.0.1-SNAPSHOT</version> |
|
||||||
<scope>compile</scope> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<groupId>jakarta.annotation</groupId> |
|
||||||
<artifactId>jakarta.annotation-api</artifactId> |
|
||||||
<version>2.1.1</version> |
|
||||||
<scope>compile</scope> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<groupId>javax.annotation</groupId> |
|
||||||
<artifactId>javax.annotation-api</artifactId> |
|
||||||
<version>1.3.2</version> |
|
||||||
<scope>compile</scope> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<groupId>org.projectlombok</groupId> |
|
||||||
<artifactId>lombok</artifactId> |
|
||||||
<version>1.18.26</version> |
|
||||||
<scope>provided</scope> |
|
||||||
</dependency> |
|
||||||
</dependencies> |
|
||||||
<repositories> |
|
||||||
<repository> |
|
||||||
<id>central</id> |
|
||||||
<url>https://repo1.maven.org/maven2</url> |
|
||||||
</repository> |
|
||||||
<repository> |
|
||||||
<snapshots> |
|
||||||
<enabled>true</enabled> |
|
||||||
</snapshots> |
|
||||||
<id>github</id> |
|
||||||
<url>https://maven.pkg.github.com/LingHangStudio/mywust</url> |
|
||||||
</repository> |
|
||||||
</repositories> |
|
||||||
<build> |
|
||||||
<plugins> |
|
||||||
<plugin> |
|
||||||
<groupId>io.quarkus.platform</groupId> |
|
||||||
<artifactId>quarkus-maven-plugin</artifactId> |
|
||||||
<version>3.1.3.Final</version> |
|
||||||
<extensions>true</extensions> |
|
||||||
</plugin> |
|
||||||
</plugins> |
|
||||||
</build> |
|
||||||
</project> |
|
@ -1,99 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="UTF-8"?> |
|
||||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" |
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> |
|
||||||
<modelVersion>4.0.0</modelVersion> |
|
||||||
<groupId>cn.wustlinghang.wusthelper</groupId> |
|
||||||
<artifactId>undergrad</artifactId> |
|
||||||
<version>0.0.1-SNAPSHOT</version> |
|
||||||
<dependencies> |
|
||||||
<dependency> |
|
||||||
<groupId>io.quarkus</groupId> |
|
||||||
<artifactId>quarkus-resteasy-reactive-jackson</artifactId> |
|
||||||
<version>3.1.3.Final</version> |
|
||||||
<scope>compile</scope> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<groupId>io.quarkus</groupId> |
|
||||||
<artifactId>quarkus-hibernate-validator</artifactId> |
|
||||||
<version>3.1.3.Final</version> |
|
||||||
<scope>compile</scope> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<groupId>io.quarkus</groupId> |
|
||||||
<artifactId>quarkus-resteasy-reactive</artifactId> |
|
||||||
<version>3.1.3.Final</version> |
|
||||||
<scope>compile</scope> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<groupId>io.quarkus</groupId> |
|
||||||
<artifactId>quarkus-arc</artifactId> |
|
||||||
<version>3.1.3.Final</version> |
|
||||||
<scope>compile</scope> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<groupId>org.ini4j</groupId> |
|
||||||
<artifactId>ini4j</artifactId> |
|
||||||
<version>0.5.4</version> |
|
||||||
<scope>compile</scope> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<groupId>cn.wustlinghang.mywust</groupId> |
|
||||||
<artifactId>mywust-core</artifactId> |
|
||||||
<version>0.0.2-beta</version> |
|
||||||
<scope>compile</scope> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<groupId>cn.wustlinghang.mywust</groupId> |
|
||||||
<artifactId>mywust-network-okhttp</artifactId> |
|
||||||
<version>0.0.2-beta</version> |
|
||||||
<scope>compile</scope> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<groupId>cn.wustlinghang.wusthelper</groupId> |
|
||||||
<artifactId>common</artifactId> |
|
||||||
<version>0.0.1-SNAPSHOT</version> |
|
||||||
<scope>compile</scope> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<groupId>jakarta.annotation</groupId> |
|
||||||
<artifactId>jakarta.annotation-api</artifactId> |
|
||||||
<version>2.1.1</version> |
|
||||||
<scope>compile</scope> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<groupId>javax.annotation</groupId> |
|
||||||
<artifactId>javax.annotation-api</artifactId> |
|
||||||
<version>1.3.2</version> |
|
||||||
<scope>compile</scope> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<groupId>org.projectlombok</groupId> |
|
||||||
<artifactId>lombok</artifactId> |
|
||||||
<version>1.18.26</version> |
|
||||||
<scope>provided</scope> |
|
||||||
</dependency> |
|
||||||
</dependencies> |
|
||||||
<repositories> |
|
||||||
<repository> |
|
||||||
<id>central</id> |
|
||||||
<url>https://repo1.maven.org/maven2</url> |
|
||||||
</repository> |
|
||||||
<repository> |
|
||||||
<snapshots> |
|
||||||
<enabled>true</enabled> |
|
||||||
</snapshots> |
|
||||||
<id>github</id> |
|
||||||
<url>https://maven.pkg.github.com/LingHangStudio/mywust</url> |
|
||||||
</repository> |
|
||||||
</repositories> |
|
||||||
<build> |
|
||||||
<plugins> |
|
||||||
<plugin> |
|
||||||
<groupId>io.quarkus.platform</groupId> |
|
||||||
<artifactId>quarkus-maven-plugin</artifactId> |
|
||||||
<version>3.1.3.Final</version> |
|
||||||
<extensions>true</extensions> |
|
||||||
</plugin> |
|
||||||
</plugins> |
|
||||||
</build> |
|
||||||
</project> |
|
@ -1,107 +0,0 @@ |
|||||||
package cn.wustlinghang.wusthelper.internal.undergrad.rpc; |
|
||||||
|
|
||||||
import cn.hutool.core.thread.ThreadUtil; |
|
||||||
import cn.hutool.core.util.RandomUtil; |
|
||||||
import cn.wustlinghang.mywust.network.Requester; |
|
||||||
import cn.wustlinghang.wusthelper.internal.undergrad.rpc.client.ConsulClient; |
|
||||||
import cn.wustlinghang.wusthelper.internal.undergrad.rpc.client.FrpcClient; |
|
||||||
import cn.wustlinghang.wusthelper.internal.undergrad.rpc.config.RpcConfig; |
|
||||||
import com.fasterxml.jackson.databind.JsonNode; |
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper; |
|
||||||
import io.quarkus.runtime.Startup; |
|
||||||
import jakarta.annotation.PostConstruct; |
|
||||||
import jakarta.annotation.PreDestroy; |
|
||||||
import jakarta.enterprise.context.ApplicationScoped; |
|
||||||
import lombok.extern.slf4j.Slf4j; |
|
||||||
import org.eclipse.microprofile.config.inject.ConfigProperty; |
|
||||||
|
|
||||||
@Slf4j |
|
||||||
@Startup |
|
||||||
@ApplicationScoped |
|
||||||
public class FrpConsulRegister { |
|
||||||
|
|
||||||
@ConfigProperty(name = "quarkus.http.port") |
|
||||||
String localServicePort; |
|
||||||
|
|
||||||
private final String serviceId; |
|
||||||
|
|
||||||
private final RpcConfig rpcConfig; |
|
||||||
|
|
||||||
private final FrpcClient frpcClientClient; |
|
||||||
|
|
||||||
private final ConsulClient consulClient; |
|
||||||
|
|
||||||
private boolean registered = false; |
|
||||||
|
|
||||||
public FrpConsulRegister(RpcConfig rpcConfig, FrpcClient frpcClientClient, Requester requester, |
|
||||||
ObjectMapper objectMapper) { |
|
||||||
this.rpcConfig = rpcConfig; |
|
||||||
|
|
||||||
this.frpcClientClient = frpcClientClient; |
|
||||||
|
|
||||||
this.serviceId = RandomUtil.randomString(8); |
|
||||||
|
|
||||||
this.consulClient = new ConsulClient( |
|
||||||
rpcConfig.getServiceName(), this.serviceId, |
|
||||||
rpcConfig.getConsulAddress(), |
|
||||||
objectMapper, requester); |
|
||||||
} |
|
||||||
|
|
||||||
@PostConstruct |
|
||||||
public void onStartup() { |
|
||||||
ThreadUtil.execute(() -> { |
|
||||||
try { |
|
||||||
log.info("连接frp并注册consul..."); |
|
||||||
this.doRegister(); |
|
||||||
log.info("注册完毕"); |
|
||||||
} catch (Exception e) { |
|
||||||
log.warn("注册服务时发生异常:", e); |
|
||||||
log.warn("不进行转发注册,直接服务"); |
|
||||||
} |
|
||||||
}); |
|
||||||
|
|
||||||
Runtime.getRuntime().addShutdownHook(new Thread(this::onShutdown, "ShutdownHookThread")); |
|
||||||
} |
|
||||||
|
|
||||||
@PreDestroy |
|
||||||
public void onShutdown() { |
|
||||||
try { |
|
||||||
if (this.registered) { |
|
||||||
log.info("注销服务..."); |
|
||||||
this.consulClient.deregister(); |
|
||||||
this.frpcClientClient.removeProxy(); |
|
||||||
log.info("服务注销完毕"); |
|
||||||
this.registered = false; |
|
||||||
} |
|
||||||
} catch (Exception e) { |
|
||||||
log.warn("注销服务时发生异常:", e); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
private void doRegister() throws Exception { |
|
||||||
frpcClientClient.addFrpProxy( |
|
||||||
rpcConfig.getServiceName(), serviceId, |
|
||||||
"127.0.0.1", localServicePort |
|
||||||
); |
|
||||||
|
|
||||||
String remoteAddress; |
|
||||||
String[] remote; |
|
||||||
int retry = 0; |
|
||||||
do { |
|
||||||
// 先睡个0.5秒等待连接成功再获取状态读端口
|
|
||||||
ThreadUtil.sleep(500); |
|
||||||
|
|
||||||
JsonNode proxy = frpcClientClient.getProxyStatus(rpcConfig.getServiceName(), serviceId); |
|
||||||
remoteAddress = proxy.path("remote_addr") |
|
||||||
.asText("127.0.0.1:" + localServicePort); |
|
||||||
remote = remoteAddress.split(":"); |
|
||||||
retry++; |
|
||||||
} while (retry < 3 && remote.length < 2); |
|
||||||
if (retry == 3) { |
|
||||||
throw new Exception("获取frp隧道信息重试次数过多,请手动添加隧道和注册中心"); |
|
||||||
} |
|
||||||
|
|
||||||
this.consulClient.register(remoteAddress, Integer.parseInt(remote[1])); |
|
||||||
this.registered = true; |
|
||||||
} |
|
||||||
} |
|
@ -0,0 +1,41 @@ |
|||||||
|
package cn.wustlinghang.wusthelper.internal.undergrad.rpc; |
||||||
|
|
||||||
|
import cn.wustlinghang.mywust.network.Requester; |
||||||
|
import cn.wustlinghang.wusthelper.internal.rpc.FrpConsulRegister; |
||||||
|
import cn.wustlinghang.wusthelper.internal.rpc.config.FrpConfig; |
||||||
|
import cn.wustlinghang.wusthelper.internal.rpc.config.RegisterConfig; |
||||||
|
import cn.wustlinghang.wusthelper.internal.undergrad.rpc.config.RpcConfig; |
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper; |
||||||
|
import io.quarkus.runtime.Startup; |
||||||
|
import jakarta.annotation.PostConstruct; |
||||||
|
import jakarta.enterprise.context.ApplicationScoped; |
||||||
|
import lombok.extern.slf4j.Slf4j; |
||||||
|
import org.eclipse.microprofile.config.inject.ConfigProperty; |
||||||
|
|
||||||
|
@Slf4j |
||||||
|
@Startup |
||||||
|
@ApplicationScoped |
||||||
|
public class Register { |
||||||
|
|
||||||
|
private final FrpConsulRegister register; |
||||||
|
|
||||||
|
public Register(RpcConfig rpcConfig, Requester requester, ObjectMapper objectMapper) { |
||||||
|
FrpConfig frpConfig = FrpConfig.builder() |
||||||
|
.frpcAdminAddress(rpcConfig.getFrpcAdminAddress()) |
||||||
|
.frpcAdminUsername(rpcConfig.getFrpcAdminUsername()) |
||||||
|
.frpcAdminPassword(rpcConfig.getFrpcAdminPassword()) |
||||||
|
.build(); |
||||||
|
RegisterConfig registerConfig = RegisterConfig.builder() |
||||||
|
.consulAddress(rpcConfig.getConsulAddress()) |
||||||
|
.localServicePort(rpcConfig.getLocalServicePort()) |
||||||
|
.serviceName(rpcConfig.getServiceName()) |
||||||
|
.build(); |
||||||
|
|
||||||
|
this.register = new FrpConsulRegister(registerConfig, frpConfig, requester, objectMapper); |
||||||
|
} |
||||||
|
|
||||||
|
@PostConstruct |
||||||
|
public void onStartup() { |
||||||
|
register.register(); |
||||||
|
} |
||||||
|
} |
@ -1,60 +0,0 @@ |
|||||||
package cn.wustlinghang.wusthelper.internal.undergrad.rpc.client; |
|
||||||
|
|
||||||
import cn.wustlinghang.mywust.network.request.RequestFactory; |
|
||||||
import cn.wustlinghang.mywust.network.Requester; |
|
||||||
import cn.wustlinghang.mywust.network.entitys.HttpResponse; |
|
||||||
import cn.wustlinghang.wusthelper.internal.undergrad.rpc.entity.RegisterRequestBody; |
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper; |
|
||||||
import com.google.common.collect.Lists; |
|
||||||
import lombok.extern.slf4j.Slf4j; |
|
||||||
|
|
||||||
import java.io.IOException; |
|
||||||
|
|
||||||
@Slf4j |
|
||||||
public class ConsulClient { |
|
||||||
private final String serviceId; |
|
||||||
private final String serviceName; |
|
||||||
private final String consulAddress; |
|
||||||
private final ObjectMapper objectMapper; |
|
||||||
private final Requester requester; |
|
||||||
|
|
||||||
public ConsulClient(String serviceName, String serviceId, String consulAddress, |
|
||||||
ObjectMapper objectMapper, Requester requester) { |
|
||||||
this.serviceId = serviceId; |
|
||||||
this.serviceName = serviceName; |
|
||||||
this.consulAddress = consulAddress; |
|
||||||
|
|
||||||
this.objectMapper = objectMapper; |
|
||||||
this.requester = requester; |
|
||||||
} |
|
||||||
|
|
||||||
public void register(String remoteAddress, int remotePort) throws IOException { |
|
||||||
var checksItem = RegisterRequestBody.ChecksItem.builder() |
|
||||||
.http("http://" + remoteAddress + "/health") |
|
||||||
.interval("3s") |
|
||||||
.build(); |
|
||||||
|
|
||||||
var registerRequestBody = RegisterRequestBody.builder() |
|
||||||
.id(serviceId) |
|
||||||
.name(serviceName) |
|
||||||
.address("127.0.0.1") |
|
||||||
.port(remotePort) |
|
||||||
.checks(Lists.newArrayList(checksItem)) |
|
||||||
.build(); |
|
||||||
|
|
||||||
byte[] registerRequestData = objectMapper.writeValueAsBytes(registerRequestBody); |
|
||||||
var registerRequest = RequestFactory.makeHttpRequest(consulAddress + "/v1/agent/service/register", registerRequestData); |
|
||||||
var registerResponse = requester.put(registerRequest); |
|
||||||
if (registerResponse.getStatusCode() != HttpResponse.HTTP_OK) { |
|
||||||
log.warn("注册中心注册不成功,请手动注册"); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public void deregister() throws IOException { |
|
||||||
var deregisterRequest = RequestFactory.makeHttpRequest(consulAddress + "/v1/agent/service/deregister/" + serviceId); |
|
||||||
var deregisterResponse = requester.put(deregisterRequest); |
|
||||||
if (deregisterResponse.getStatusCode() != HttpResponse.HTTP_OK) { |
|
||||||
log.warn("服务注销不成功,请手动注册"); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,100 +0,0 @@ |
|||||||
package cn.wustlinghang.wusthelper.internal.undergrad.rpc.client; |
|
||||||
|
|
||||||
import cn.hutool.core.codec.Base64; |
|
||||||
import cn.wustlinghang.mywust.network.request.RequestFactory; |
|
||||||
import cn.wustlinghang.mywust.network.Requester; |
|
||||||
import cn.wustlinghang.wusthelper.internal.undergrad.rpc.config.FrpConfig; |
|
||||||
import com.fasterxml.jackson.databind.JsonNode; |
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper; |
|
||||||
import com.fasterxml.jackson.databind.node.MissingNode; |
|
||||||
import jakarta.inject.Singleton; |
|
||||||
import org.ini4j.Ini; |
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream; |
|
||||||
import java.io.ByteArrayOutputStream; |
|
||||||
import java.io.IOException; |
|
||||||
|
|
||||||
@Singleton |
|
||||||
public class FrpcClient { |
|
||||||
|
|
||||||
private final String frpcAdminAddress; |
|
||||||
|
|
||||||
private final String frpAuthHeaderValue; |
|
||||||
|
|
||||||
private final Requester requester; |
|
||||||
|
|
||||||
private final ObjectMapper objectMapper; |
|
||||||
|
|
||||||
private String frpProxyName; |
|
||||||
|
|
||||||
public FrpcClient(FrpConfig frpConfig, |
|
||||||
Requester requester, ObjectMapper objectMapper) { |
|
||||||
|
|
||||||
this.frpcAdminAddress = frpConfig.getFrpcAdminAddress(); |
|
||||||
|
|
||||||
this.requester = requester; |
|
||||||
this.objectMapper = objectMapper; |
|
||||||
|
|
||||||
String username = frpConfig.getFrpcAdminUsername(); |
|
||||||
String password = frpConfig.getFrpcAdminPassword(); |
|
||||||
this.frpAuthHeaderValue = "Basic " + Base64.encode(username + ":" + password); |
|
||||||
} |
|
||||||
|
|
||||||
public void addFrpProxy(String serviceName, String serviceId, String localAddress, String localPort) |
|
||||||
throws IOException { |
|
||||||
this.frpProxyName = String.format("%s-%s", serviceName, serviceId); |
|
||||||
|
|
||||||
Ini ini = this.getFrpConfig(); |
|
||||||
ini.put(frpProxyName, "type", "tcp"); |
|
||||||
ini.put(frpProxyName, "local_address", localAddress); |
|
||||||
ini.put(frpProxyName, "local_port", localPort); |
|
||||||
ini.put(frpProxyName, "use_compression", "true"); |
|
||||||
|
|
||||||
var output = new ByteArrayOutputStream(); |
|
||||||
ini.store(output); |
|
||||||
|
|
||||||
this.reloadFrpConfig(ini); |
|
||||||
} |
|
||||||
|
|
||||||
public void removeProxy() throws IOException { |
|
||||||
Ini ini = this.getFrpConfig(); |
|
||||||
ini.remove(this.frpProxyName); |
|
||||||
|
|
||||||
this.reloadFrpConfig(ini); |
|
||||||
} |
|
||||||
|
|
||||||
public Ini getFrpConfig() throws IOException { |
|
||||||
var frpConfigRequest = RequestFactory.makeHttpRequest(frpcAdminAddress + "/api/config"); |
|
||||||
frpConfigRequest.addHeaders("Authorization", frpAuthHeaderValue); |
|
||||||
var response = requester.get(frpConfigRequest); |
|
||||||
|
|
||||||
return new Ini(new ByteArrayInputStream(response.getBody())); |
|
||||||
} |
|
||||||
|
|
||||||
public void reloadFrpConfig(Ini ini) throws IOException { |
|
||||||
var output = new ByteArrayOutputStream(); |
|
||||||
ini.store(output); |
|
||||||
|
|
||||||
var uploadRequest = RequestFactory.makeHttpRequest(frpcAdminAddress + "/api/config", output.toByteArray()); |
|
||||||
uploadRequest.addHeaders("Authorization", frpAuthHeaderValue); |
|
||||||
requester.put(uploadRequest); |
|
||||||
var reloadRequest = RequestFactory.makeHttpRequest(frpcAdminAddress + "/api/reload"); |
|
||||||
reloadRequest.addHeaders("Authorization", frpAuthHeaderValue); |
|
||||||
requester.get(reloadRequest); |
|
||||||
} |
|
||||||
|
|
||||||
public JsonNode getProxyStatus(String serviceName, String serviceId) throws IOException { |
|
||||||
var statusRequest = RequestFactory.makeHttpRequest(frpcAdminAddress + "/api/status"); |
|
||||||
statusRequest.addHeaders("Authorization", frpAuthHeaderValue); |
|
||||||
var statusResponse = requester.get(statusRequest); |
|
||||||
|
|
||||||
JsonNode proxies = objectMapper.readTree(statusResponse.getBody()).path("tcp"); |
|
||||||
for (JsonNode proxy : proxies) { |
|
||||||
if (proxy.path("name").asText().equals(serviceName + "-" + serviceId)) { |
|
||||||
return proxy; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
return MissingNode.getInstance(); |
|
||||||
} |
|
||||||
} |
|
@ -1,22 +0,0 @@ |
|||||||
package cn.wustlinghang.wusthelper.internal.undergrad.rpc.config; |
|
||||||
|
|
||||||
import jakarta.inject.Singleton; |
|
||||||
import jakarta.ws.rs.DefaultValue; |
|
||||||
import lombok.Data; |
|
||||||
import org.eclipse.microprofile.config.inject.ConfigProperty; |
|
||||||
|
|
||||||
@Data |
|
||||||
@Singleton |
|
||||||
public class FrpConfig { |
|
||||||
@DefaultValue("http://127.0.0.1:7400") |
|
||||||
@ConfigProperty(name = "frpc.admin-api.address") |
|
||||||
String frpcAdminAddress; |
|
||||||
|
|
||||||
@DefaultValue("") |
|
||||||
@ConfigProperty(name = "frpc.admin.username") |
|
||||||
String frpcAdminUsername; |
|
||||||
|
|
||||||
@DefaultValue("") |
|
||||||
@ConfigProperty(name = "frpc.admin.password") |
|
||||||
String frpcAdminPassword; |
|
||||||
} |
|
@ -1,13 +0,0 @@ |
|||||||
package cn.wustlinghang.wusthelper.internal.undergrad.rpc.entity; |
|
||||||
|
|
||||||
import lombok.Builder; |
|
||||||
|
|
||||||
import java.util.List; |
|
||||||
|
|
||||||
@Builder |
|
||||||
public record RegisterRequestBody(String address, int port, List<ChecksItem> checks, String name, String id) { |
|
||||||
|
|
||||||
@Builder |
|
||||||
public record ChecksItem(String http, String interval) { |
|
||||||
} |
|
||||||
} |
|
Loading…
Reference in new issue