From 7f1f8ba3e7e6bc455cabc63af4a54671b618625f Mon Sep 17 00:00:00 2001 From: lensferno Date: Wed, 19 Jul 2023 12:16:55 +0800 Subject: [PATCH] tmp --- .flattened-pom.xml | 42 ------- backend-main/.flattened-pom.xml | 42 ------- backend-main/backend-data/pom.xml | 3 +- backend-main/backend-web/.flattened-pom.xml | 41 ------- backend-main/backend-web/pom.xml | 6 + .../internal/api/v1/FrpPluginHandler.java | 20 ---- .../api/v1/response/FrpPluginResponse.java | 14 --- .../main/web/{Main.java => BackendMain.java} | 6 +- .../v2/undergrade/UndergradController.java | 12 +- .../src/main/resources/application.yml | 11 +- backend-main/pom.xml | 9 ++ common/.flattened-pom.xml | 41 ------- external-library/.flattened-pom.xml | 42 ------- external-library/rpc-frp-consul/pom.xml | 2 +- .../internal/rpc/FrpConsulRegister.java | 15 ++- .../internal/rpc/client/ConsulClient.java | 14 ++- .../internal/rpc/client/FrpcClient.java | 6 +- .../internal/rpc/config/FrpConfig.java | 2 + .../internal/rpc/config/RegisterConfig.java | 4 + sub-services/.flattened-pom.xml | 60 ---------- sub-services/graduate/.flattened-pom.xml | 93 --------------- sub-services/graduate/pom.xml | 6 + .../src/main/resources/application.properties | 9 +- sub-services/library/.flattened-pom.xml | 93 --------------- sub-services/library/pom.xml | 6 + .../src/main/resources/application.properties | 9 +- sub-services/physics/.flattened-pom.xml | 93 --------------- sub-services/physics/pom.xml | 6 + .../src/main/resources/application.properties | 9 +- sub-services/undergrad/.flattened-pom.xml | 99 ---------------- sub-services/undergrad/pom.xml | 6 + .../api/http/v1/ExamActivitiesApi.java | 2 +- .../undergrad/rpc/FrpConsulRegister.java | 107 ------------------ .../internal/undergrad/rpc/Register.java | 41 +++++++ .../undergrad/rpc/client/ConsulClient.java | 60 ---------- .../undergrad/rpc/client/FrpcClient.java | 100 ---------------- .../undergrad/rpc/config/FrpConfig.java | 22 ---- .../undergrad/rpc/config/RpcConfig.java | 15 +++ .../rpc/entity/RegisterRequestBody.java | 13 --- .../src/main/resources/application.properties | 6 +- 40 files changed, 183 insertions(+), 1004 deletions(-) delete mode 100644 .flattened-pom.xml delete mode 100644 backend-main/.flattened-pom.xml delete mode 100644 backend-main/backend-web/.flattened-pom.xml delete mode 100644 backend-main/backend-web/src/main/java/cn/wustlinghang/internal/api/v1/FrpPluginHandler.java delete mode 100644 backend-main/backend-web/src/main/java/cn/wustlinghang/internal/api/v1/response/FrpPluginResponse.java rename backend-main/backend-web/src/main/java/cn/wustlinghang/main/web/{Main.java => BackendMain.java} (71%) delete mode 100644 common/.flattened-pom.xml delete mode 100644 external-library/.flattened-pom.xml delete mode 100644 sub-services/.flattened-pom.xml delete mode 100644 sub-services/graduate/.flattened-pom.xml delete mode 100644 sub-services/library/.flattened-pom.xml delete mode 100644 sub-services/physics/.flattened-pom.xml delete mode 100644 sub-services/undergrad/.flattened-pom.xml delete mode 100644 sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/rpc/FrpConsulRegister.java create mode 100644 sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/rpc/Register.java delete mode 100644 sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/rpc/client/ConsulClient.java delete mode 100644 sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/rpc/client/FrpcClient.java delete mode 100644 sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/rpc/config/FrpConfig.java delete mode 100644 sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/rpc/entity/RegisterRequestBody.java diff --git a/.flattened-pom.xml b/.flattened-pom.xml deleted file mode 100644 index 8d7a637..0000000 --- a/.flattened-pom.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - 4.0.0 - cn.wustlinghang.wusthelper - wusthelper-backend - 0.0.1-SNAPSHOT - pom - - - jakarta.annotation - jakarta.annotation-api - 2.1.1 - compile - - - javax.annotation - javax.annotation-api - 1.3.2 - compile - - - org.projectlombok - lombok - 1.18.26 - provided - - - - - central - https://repo1.maven.org/maven2 - - - - true - - github - https://maven.pkg.github.com/LingHangStudio/mywust - - - diff --git a/backend-main/.flattened-pom.xml b/backend-main/.flattened-pom.xml deleted file mode 100644 index bd164ed..0000000 --- a/backend-main/.flattened-pom.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - 4.0.0 - cn.wustlinghang.wusthelper - backend-main - 0.0.1-SNAPSHOT - pom - - - jakarta.annotation - jakarta.annotation-api - 2.1.1 - compile - - - javax.annotation - javax.annotation-api - 1.3.2 - compile - - - org.projectlombok - lombok - 1.18.26 - provided - - - - - central - https://repo1.maven.org/maven2 - - - - true - - github - https://maven.pkg.github.com/LingHangStudio/mywust - - - diff --git a/backend-main/backend-data/pom.xml b/backend-main/backend-data/pom.xml index 15ca3e0..03ca9a1 100644 --- a/backend-main/backend-data/pom.xml +++ b/backend-main/backend-data/pom.xml @@ -6,7 +6,8 @@ cn.wustlinghang.wusthelper backend-main - 0.0.1-SNAPSHOT + ${revision} + ../pom.xml backend-data diff --git a/backend-main/backend-web/.flattened-pom.xml b/backend-main/backend-web/.flattened-pom.xml deleted file mode 100644 index c493442..0000000 --- a/backend-main/backend-web/.flattened-pom.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - 4.0.0 - cn.wustlinghang.wusthelper - web - 0.0.1-SNAPSHOT - - - jakarta.annotation - jakarta.annotation-api - 2.1.1 - compile - - - javax.annotation - javax.annotation-api - 1.3.2 - compile - - - org.projectlombok - lombok - 1.18.26 - provided - - - - - central - https://repo1.maven.org/maven2 - - - - true - - github - https://maven.pkg.github.com/LingHangStudio/mywust - - - diff --git a/backend-main/backend-web/pom.xml b/backend-main/backend-web/pom.xml index 08a96b2..4620992 100644 --- a/backend-main/backend-web/pom.xml +++ b/backend-main/backend-web/pom.xml @@ -18,6 +18,7 @@ 3.1.1 2.0 + 4.0.2 4.0.3 @@ -51,6 +52,11 @@ spring-boot-starter-web + + org.springframework.cloud + spring-cloud-starter-consul-discovery + ${consul-discovery.version} + org.springframework.cloud spring-cloud-starter-openfeign diff --git a/backend-main/backend-web/src/main/java/cn/wustlinghang/internal/api/v1/FrpPluginHandler.java b/backend-main/backend-web/src/main/java/cn/wustlinghang/internal/api/v1/FrpPluginHandler.java deleted file mode 100644 index 07cce3c..0000000 --- a/backend-main/backend-web/src/main/java/cn/wustlinghang/internal/api/v1/FrpPluginHandler.java +++ /dev/null @@ -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(); - } -} diff --git a/backend-main/backend-web/src/main/java/cn/wustlinghang/internal/api/v1/response/FrpPluginResponse.java b/backend-main/backend-web/src/main/java/cn/wustlinghang/internal/api/v1/response/FrpPluginResponse.java deleted file mode 100644 index 731ab2a..0000000 --- a/backend-main/backend-web/src/main/java/cn/wustlinghang/internal/api/v1/response/FrpPluginResponse.java +++ /dev/null @@ -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; -} diff --git a/backend-main/backend-web/src/main/java/cn/wustlinghang/main/web/Main.java b/backend-main/backend-web/src/main/java/cn/wustlinghang/main/web/BackendMain.java similarity index 71% rename from backend-main/backend-web/src/main/java/cn/wustlinghang/main/web/Main.java rename to backend-main/backend-web/src/main/java/cn/wustlinghang/main/web/BackendMain.java index 27d10e0..c428d72 100644 --- a/backend-main/backend-web/src/main/java/cn/wustlinghang/main/web/Main.java +++ b/backend-main/backend-web/src/main/java/cn/wustlinghang/main/web/BackendMain.java @@ -2,14 +2,16 @@ package cn.wustlinghang.main.web; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.EnableScheduling; @EnableAsync @EnableScheduling +@EnableFeignClients @SpringBootApplication -public class Main { +public class BackendMain { public static void main(String[] args) { - SpringApplication.run(Main.class); + SpringApplication.run(BackendMain.class); } } diff --git a/backend-main/backend-web/src/main/java/cn/wustlinghang/main/web/api/v2/undergrade/UndergradController.java b/backend-main/backend-web/src/main/java/cn/wustlinghang/main/web/api/v2/undergrade/UndergradController.java index f151964..532da83 100644 --- a/backend-main/backend-web/src/main/java/cn/wustlinghang/main/web/api/v2/undergrade/UndergradController.java +++ b/backend-main/backend-web/src/main/java/cn/wustlinghang/main/web/api/v2/undergrade/UndergradController.java @@ -1,13 +1,23 @@ 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 org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping("/jwc") public class UndergradController { + private final UndergradCookieService undergradCookieService; + + public UndergradController(UndergradCookieService undergradCookieService) { + this.undergradCookieService = undergradCookieService; + } + + @PostMapping("/login") public Response login() { - return Response.success(""); + String cookie = undergradCookieService.getLoginCookie("202118194039", "-96387ee"); + return Response.success(cookie); } } \ No newline at end of file diff --git a/backend-main/backend-web/src/main/resources/application.yml b/backend-main/backend-web/src/main/resources/application.yml index 6897622..711216e 100644 --- a/backend-main/backend-web/src/main/resources/application.yml +++ b/backend-main/backend-web/src/main/resources/application.yml @@ -5,6 +5,15 @@ spring: config: import: optional:file:.env[.properties] + application: + name: wusthelper-backend-main + + cloud: + consul: + host: 127.0.0.1 + port: 8500 + discovery: + register: false server: - port: ${RUN_PORT} \ No newline at end of file + port: ${RUN_PORT} diff --git a/backend-main/pom.xml b/backend-main/pom.xml index 5433147..eb00bd4 100644 --- a/backend-main/pom.xml +++ b/backend-main/pom.xml @@ -7,6 +7,7 @@ cn.wustlinghang.wusthelper wusthelper-backend ${revision} + ../pom.xml backend-main @@ -20,9 +21,17 @@ 17 17 UTF-8 + + 3.1.6 + + com.github.ben-manes.caffeine + caffeine + ${caffeine.version} + + cn.wustlinghang.wusthelper common diff --git a/common/.flattened-pom.xml b/common/.flattened-pom.xml deleted file mode 100644 index 9c94544..0000000 --- a/common/.flattened-pom.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - 4.0.0 - cn.wustlinghang.wusthelper - common - 0.0.1-SNAPSHOT - - - jakarta.annotation - jakarta.annotation-api - 2.1.1 - compile - - - javax.annotation - javax.annotation-api - 1.3.2 - compile - - - org.projectlombok - lombok - 1.18.26 - provided - - - - - central - https://repo1.maven.org/maven2 - - - - true - - github - https://maven.pkg.github.com/LingHangStudio/mywust - - - diff --git a/external-library/.flattened-pom.xml b/external-library/.flattened-pom.xml deleted file mode 100644 index 40f6d06..0000000 --- a/external-library/.flattened-pom.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - 4.0.0 - cn.wustlinghang.wusthelper - external-library - 0.0.1-SNAPSHOT - pom - - - jakarta.annotation - jakarta.annotation-api - 2.1.1 - compile - - - javax.annotation - javax.annotation-api - 1.3.2 - compile - - - org.projectlombok - lombok - 1.18.26 - provided - - - - - central - https://repo1.maven.org/maven2 - - - - true - - github - https://maven.pkg.github.com/LingHangStudio/mywust - - - diff --git a/external-library/rpc-frp-consul/pom.xml b/external-library/rpc-frp-consul/pom.xml index 4428a92..26606f5 100644 --- a/external-library/rpc-frp-consul/pom.xml +++ b/external-library/rpc-frp-consul/pom.xml @@ -6,7 +6,7 @@ cn.wustlinghang.wusthelper external-library - 0.0.1-SNAPSHOT + ${revision} rpc-frp-consul diff --git a/external-library/rpc-frp-consul/src/main/java/cn/wustlinghang/wusthelper/internal/rpc/FrpConsulRegister.java b/external-library/rpc-frp-consul/src/main/java/cn/wustlinghang/wusthelper/internal/rpc/FrpConsulRegister.java index 0e69639..b44a455 100644 --- a/external-library/rpc-frp-consul/src/main/java/cn/wustlinghang/wusthelper/internal/rpc/FrpConsulRegister.java +++ b/external-library/rpc-frp-consul/src/main/java/cn/wustlinghang/wusthelper/internal/rpc/FrpConsulRegister.java @@ -7,6 +7,7 @@ import cn.wustlinghang.wusthelper.internal.rpc.client.ConsulClient; import cn.wustlinghang.wusthelper.internal.rpc.client.FrpcClient; import cn.wustlinghang.wusthelper.internal.rpc.config.FrpConfig; import cn.wustlinghang.wusthelper.internal.rpc.config.RegisterConfig; +import cn.wustlinghang.wusthelper.internal.rpc.entity.RegisterRequestBody; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import lombok.extern.slf4j.Slf4j; @@ -39,6 +40,7 @@ public class FrpConsulRegister { try { log.info("连接frp并注册consul..."); this.doRegister(); + this.registered = true; log.info("注册完毕"); } catch (Exception e) { log.warn("注册服务时发生异常:", e); @@ -53,7 +55,7 @@ public class FrpConsulRegister { try { if (this.registered) { log.info("注销服务..."); - this.consulClient.deregister(); + this.consulClient.removeService(); this.frpcClientClient.removeProxy(); this.registered = false; log.info("服务注销完毕"); @@ -83,10 +85,15 @@ public class FrpConsulRegister { retry++; } while (retry < 3 && remote.length < 2); if (retry == 3) { - throw new Exception("获取frp隧道信息重试次数过多,请手动添加隧道和注册中心"); + throw new Exception("获取frp隧道信息重试超时,请手动添加隧道和注册中心"); } - this.consulClient.register(remoteAddress, Integer.parseInt(remote[1])); - this.registered = true; + RegisterRequestBody.HealthCheckOption healthCheckOption = RegisterRequestBody.HealthCheckOption.builder() + .http("http://" + remoteAddress + "/health") + .interval("3s") + .timeout("5s") + .build(); + + this.consulClient.addService(remote[0], Integer.parseInt(remote[1]), healthCheckOption); } } \ No newline at end of file diff --git a/external-library/rpc-frp-consul/src/main/java/cn/wustlinghang/wusthelper/internal/rpc/client/ConsulClient.java b/external-library/rpc-frp-consul/src/main/java/cn/wustlinghang/wusthelper/internal/rpc/client/ConsulClient.java index e0aef38..a1f7540 100644 --- a/external-library/rpc-frp-consul/src/main/java/cn/wustlinghang/wusthelper/internal/rpc/client/ConsulClient.java +++ b/external-library/rpc-frp-consul/src/main/java/cn/wustlinghang/wusthelper/internal/rpc/client/ConsulClient.java @@ -16,21 +16,25 @@ public class ConsulClient { private final String serviceId; private final String serviceName; private final String consulAddress; + private final String token; private final ObjectMapper objectMapper; private final Requester requester; - public ConsulClient(String serviceId, RegisterConfig registerConfig, ObjectMapper objectMapper, Requester requester) { + public ConsulClient(String serviceId, RegisterConfig registerConfig, + ObjectMapper objectMapper, Requester requester) { this.serviceId = serviceId; + this.serviceName = registerConfig.getServiceName(); this.consulAddress = registerConfig.getConsulAddress(); + this.token = registerConfig.getToken(); this.objectMapper = objectMapper; this.requester = requester; } - public void register(String remoteAddress, int remotePort, - RegisterRequestBody.HealthCheckOption... healthCheckOption + public void addService(String remoteAddress, int remotePort, + RegisterRequestBody.HealthCheckOption... healthCheckOption ) throws IOException { var registerRequestBody = RegisterRequestBody.builder() .id(serviceId) @@ -44,6 +48,7 @@ public class ConsulClient { var url = consulAddress + "/v1/agent/service/register"; var registerRequest = RequestFactory.makeHttpRequest(url, registerRequestData); + registerRequest.addHeaders("X-Consul-Token", token); var registerResponse = requester.put(registerRequest); if (registerResponse.getStatusCode() != HttpResponse.HTTP_OK) { @@ -51,9 +56,10 @@ public class ConsulClient { } } - public void deregister() throws IOException { + public void removeService() throws IOException { var url = String.format("%s/v1/agent/service/deregister/%s", consulAddress, serviceId); var deregisterRequest = RequestFactory.makeHttpRequest(url); + deregisterRequest.addHeaders("X-Consul-Token", token); var deregisterResponse = requester.put(deregisterRequest); if (deregisterResponse.getStatusCode() != HttpResponse.HTTP_OK) { diff --git a/external-library/rpc-frp-consul/src/main/java/cn/wustlinghang/wusthelper/internal/rpc/client/FrpcClient.java b/external-library/rpc-frp-consul/src/main/java/cn/wustlinghang/wusthelper/internal/rpc/client/FrpcClient.java index 7808530..eb1126b 100644 --- a/external-library/rpc-frp-consul/src/main/java/cn/wustlinghang/wusthelper/internal/rpc/client/FrpcClient.java +++ b/external-library/rpc-frp-consul/src/main/java/cn/wustlinghang/wusthelper/internal/rpc/client/FrpcClient.java @@ -1,6 +1,7 @@ package cn.wustlinghang.wusthelper.internal.rpc.client; import cn.hutool.core.codec.Base64; +import cn.wustlinghang.mywust.network.entitys.HttpResponse; import cn.wustlinghang.mywust.network.request.RequestFactory; import cn.wustlinghang.mywust.network.Requester; import cn.wustlinghang.wusthelper.internal.rpc.config.FrpConfig; @@ -76,7 +77,10 @@ public class FrpcClient { requester.put(uploadRequest); var reloadRequest = RequestFactory.makeHttpRequest(frpcAdminAddress + "/api/reload"); reloadRequest.addHeaders("Authorization", frpAuthHeaderValue); - requester.get(reloadRequest); + var reloadResponse = requester.get(reloadRequest); + if (reloadResponse.getStatusCode() != HttpResponse.HTTP_OK) { + throw new IOException("frpc配置重载失败"); + } } public JsonNode getProxyStatus(String serviceName, String serviceId) throws IOException { diff --git a/external-library/rpc-frp-consul/src/main/java/cn/wustlinghang/wusthelper/internal/rpc/config/FrpConfig.java b/external-library/rpc-frp-consul/src/main/java/cn/wustlinghang/wusthelper/internal/rpc/config/FrpConfig.java index 9fe9e73..139e194 100644 --- a/external-library/rpc-frp-consul/src/main/java/cn/wustlinghang/wusthelper/internal/rpc/config/FrpConfig.java +++ b/external-library/rpc-frp-consul/src/main/java/cn/wustlinghang/wusthelper/internal/rpc/config/FrpConfig.java @@ -1,8 +1,10 @@ package cn.wustlinghang.wusthelper.internal.rpc.config; +import lombok.Builder; import lombok.Data; @Data +@Builder public class FrpConfig { private String frpcAdminAddress; diff --git a/external-library/rpc-frp-consul/src/main/java/cn/wustlinghang/wusthelper/internal/rpc/config/RegisterConfig.java b/external-library/rpc-frp-consul/src/main/java/cn/wustlinghang/wusthelper/internal/rpc/config/RegisterConfig.java index f706f0f..20ca09f 100644 --- a/external-library/rpc-frp-consul/src/main/java/cn/wustlinghang/wusthelper/internal/rpc/config/RegisterConfig.java +++ b/external-library/rpc-frp-consul/src/main/java/cn/wustlinghang/wusthelper/internal/rpc/config/RegisterConfig.java @@ -1,12 +1,16 @@ package cn.wustlinghang.wusthelper.internal.rpc.config; +import lombok.Builder; import lombok.Data; @Data +@Builder public class RegisterConfig { private String localServicePort; private String serviceName; private String consulAddress; + + private String token; } diff --git a/sub-services/.flattened-pom.xml b/sub-services/.flattened-pom.xml deleted file mode 100644 index 9898197..0000000 --- a/sub-services/.flattened-pom.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - 4.0.0 - cn.wustlinghang.wusthelper - sub-services - 0.0.1-SNAPSHOT - pom - - - cn.wustlinghang.mywust - mywust-core - 0.0.2-SNAPSHOT - compile - - - cn.wustlinghang.mywust - mywust-network-okhttp - 0.0.2-SNAPSHOT - compile - - - cn.wustlinghang.wusthelper - common - 0.0.1-SNAPSHOT - compile - - - jakarta.annotation - jakarta.annotation-api - 2.1.1 - compile - - - javax.annotation - javax.annotation-api - 1.3.2 - compile - - - org.projectlombok - lombok - 1.18.26 - provided - - - - - central - https://repo1.maven.org/maven2 - - - - true - - github - https://maven.pkg.github.com/LingHangStudio/mywust - - - diff --git a/sub-services/graduate/.flattened-pom.xml b/sub-services/graduate/.flattened-pom.xml deleted file mode 100644 index afa31a6..0000000 --- a/sub-services/graduate/.flattened-pom.xml +++ /dev/null @@ -1,93 +0,0 @@ - - - 4.0.0 - cn.wustlinghang.wusthelper - graduate - 0.0.1-SNAPSHOT - - - io.quarkus - quarkus-resteasy-reactive-jackson - 3.1.3.Final - compile - - - io.quarkus - quarkus-hibernate-validator - 3.1.3.Final - compile - - - io.quarkus - quarkus-resteasy-reactive - 3.1.3.Final - compile - - - io.quarkus - quarkus-arc - 3.1.3.Final - compile - - - cn.wustlinghang.mywust - mywust-core - 0.0.2-SNAPSHOT - compile - - - cn.wustlinghang.mywust - mywust-network-okhttp - 0.0.2-SNAPSHOT - compile - - - cn.wustlinghang.wusthelper - common - 0.0.1-SNAPSHOT - compile - - - jakarta.annotation - jakarta.annotation-api - 2.1.1 - compile - - - javax.annotation - javax.annotation-api - 1.3.2 - compile - - - org.projectlombok - lombok - 1.18.26 - provided - - - - - central - https://repo1.maven.org/maven2 - - - - true - - github - https://maven.pkg.github.com/LingHangStudio/mywust - - - - - - io.quarkus.platform - quarkus-maven-plugin - 3.1.3.Final - true - - - - diff --git a/sub-services/graduate/pom.xml b/sub-services/graduate/pom.xml index 20830c4..b9b781b 100644 --- a/sub-services/graduate/pom.xml +++ b/sub-services/graduate/pom.xml @@ -69,6 +69,12 @@ rest-assured test + + + cn.wustlinghang.wusthelper + rpc-frp-consul + ${revision} + diff --git a/sub-services/graduate/src/main/resources/application.properties b/sub-services/graduate/src/main/resources/application.properties index 24869dc..e1be2cb 100644 --- a/sub-services/graduate/src/main/resources/application.properties +++ b/sub-services/graduate/src/main/resources/application.properties @@ -12,4 +12,11 @@ quarkus.package.type=uber-jar # 原生镜像编译附加参数,去掉后编译会失败 # 但也只是能编译完成,目前的编译产物完全不可用,有非常多的严重bug # 现阶段使用jar运行,启动效率虽不如原生程序,但速度尚可 -quarkus.native.additional-build-args=--initialize-at-run-time=cn.wustlinghang.mywust \ No newline at end of file +quarkus.native.additional-build-args=--initialize-at-run-time=cn.wustlinghang.mywust + +rpc.service.name=wusthelper.graduate +rpc.register.consul-api.address=http://127.0.0.1:8500 + +rpc.frpc.admin-api.address=http://127.0.0.1:7400 +rpc.frpc.admin.username=admin +rpc.frpc.admin.password=admin \ No newline at end of file diff --git a/sub-services/library/.flattened-pom.xml b/sub-services/library/.flattened-pom.xml deleted file mode 100644 index 351cbe3..0000000 --- a/sub-services/library/.flattened-pom.xml +++ /dev/null @@ -1,93 +0,0 @@ - - - 4.0.0 - cn.wustlinghang.wusthelper - library - 0.0.1-SNAPSHOT - - - io.quarkus - quarkus-resteasy-reactive-jackson - 3.1.3.Final - compile - - - io.quarkus - quarkus-hibernate-validator - 3.1.3.Final - compile - - - io.quarkus - quarkus-resteasy-reactive - 3.1.3.Final - compile - - - io.quarkus - quarkus-arc - 3.1.3.Final - compile - - - cn.wustlinghang.mywust - mywust-core - 0.0.2-beta - compile - - - cn.wustlinghang.mywust - mywust-network-okhttp - 0.0.2-beta - compile - - - cn.wustlinghang.wusthelper - common - 0.0.1-SNAPSHOT - compile - - - jakarta.annotation - jakarta.annotation-api - 2.1.1 - compile - - - javax.annotation - javax.annotation-api - 1.3.2 - compile - - - org.projectlombok - lombok - 1.18.26 - provided - - - - - central - https://repo1.maven.org/maven2 - - - - true - - github - https://maven.pkg.github.com/LingHangStudio/mywust - - - - - - io.quarkus.platform - quarkus-maven-plugin - 3.1.3.Final - true - - - - diff --git a/sub-services/library/pom.xml b/sub-services/library/pom.xml index bbe0e1a..9c7f8b5 100644 --- a/sub-services/library/pom.xml +++ b/sub-services/library/pom.xml @@ -69,6 +69,12 @@ rest-assured test + + + cn.wustlinghang.wusthelper + rpc-frp-consul + ${revision} + diff --git a/sub-services/library/src/main/resources/application.properties b/sub-services/library/src/main/resources/application.properties index 4e6d453..e44b813 100644 --- a/sub-services/library/src/main/resources/application.properties +++ b/sub-services/library/src/main/resources/application.properties @@ -8,4 +8,11 @@ quarkus.package.type=uber-jar # 原生镜像编译附加参数,去掉后编译会失败 # 但也只是能编译完成,目前的编译产物完全不可用,有非常多的严重bug # 现阶段使用jar运行,启动效率虽不如原生程序,但速度尚可 -quarkus.native.additional-build-args="--initialize-at-run-time=cn.wustlinghang.mywust" \ No newline at end of file +quarkus.native.additional-build-args="--initialize-at-run-time=cn.wustlinghang.mywust" + +rpc.service.name=wusthelper.library +rpc.register.consul-api.address=http://127.0.0.1:8500 + +rpc.frpc.admin-api.address=http://127.0.0.1:7400 +rpc.frpc.admin.username=admin +rpc.frpc.admin.password=admin \ No newline at end of file diff --git a/sub-services/physics/.flattened-pom.xml b/sub-services/physics/.flattened-pom.xml deleted file mode 100644 index 48c8b5c..0000000 --- a/sub-services/physics/.flattened-pom.xml +++ /dev/null @@ -1,93 +0,0 @@ - - - 4.0.0 - cn.wustlinghang.wusthelper - physics - 0.0.1-SNAPSHOT - - - io.quarkus - quarkus-resteasy-reactive-jackson - 3.1.3.Final - compile - - - io.quarkus - quarkus-hibernate-validator - 3.1.3.Final - compile - - - io.quarkus - quarkus-resteasy-reactive - 3.1.3.Final - compile - - - io.quarkus - quarkus-arc - 3.1.3.Final - compile - - - cn.wustlinghang.mywust - mywust-core - 0.0.2-SNAPSHOT - compile - - - cn.wustlinghang.mywust - mywust-network-okhttp - 0.0.2-SNAPSHOT - compile - - - cn.wustlinghang.wusthelper - common - 0.0.1-SNAPSHOT - compile - - - jakarta.annotation - jakarta.annotation-api - 2.1.1 - compile - - - javax.annotation - javax.annotation-api - 1.3.2 - compile - - - org.projectlombok - lombok - 1.18.26 - provided - - - - - central - https://repo1.maven.org/maven2 - - - - true - - github - https://maven.pkg.github.com/LingHangStudio/mywust - - - - - - io.quarkus.platform - quarkus-maven-plugin - 3.1.3.Final - true - - - - diff --git a/sub-services/physics/pom.xml b/sub-services/physics/pom.xml index 6eb5540..a5c3d04 100644 --- a/sub-services/physics/pom.xml +++ b/sub-services/physics/pom.xml @@ -69,6 +69,12 @@ rest-assured test + + + cn.wustlinghang.wusthelper + rpc-frp-consul + ${revision} + diff --git a/sub-services/physics/src/main/resources/application.properties b/sub-services/physics/src/main/resources/application.properties index fd06f24..b7ba48d 100644 --- a/sub-services/physics/src/main/resources/application.properties +++ b/sub-services/physics/src/main/resources/application.properties @@ -8,4 +8,11 @@ quarkus.package.type=uber-jar # 原生镜像编译附加参数,去掉后编译会失败 # 但也只是能编译完成,目前的编译产物完全不可用,有非常多的严重bug # 现阶段使用jar运行,启动效率虽不如原生程序,但速度尚可 -quarkus.native.additional-build-args="--initialize-at-run-time=cn.wustlinghang.mywust" \ No newline at end of file +quarkus.native.additional-build-args="--initialize-at-run-time=cn.wustlinghang.mywust" + +rpc.service.name=wusthelper.physics +rpc.register.consul-api.address=http://127.0.0.1:8500 + +rpc.frpc.admin-api.address=http://127.0.0.1:7400 +rpc.frpc.admin.username=admin +rpc.frpc.admin.password=admin \ No newline at end of file diff --git a/sub-services/undergrad/.flattened-pom.xml b/sub-services/undergrad/.flattened-pom.xml deleted file mode 100644 index 0de1689..0000000 --- a/sub-services/undergrad/.flattened-pom.xml +++ /dev/null @@ -1,99 +0,0 @@ - - - 4.0.0 - cn.wustlinghang.wusthelper - undergrad - 0.0.1-SNAPSHOT - - - io.quarkus - quarkus-resteasy-reactive-jackson - 3.1.3.Final - compile - - - io.quarkus - quarkus-hibernate-validator - 3.1.3.Final - compile - - - io.quarkus - quarkus-resteasy-reactive - 3.1.3.Final - compile - - - io.quarkus - quarkus-arc - 3.1.3.Final - compile - - - org.ini4j - ini4j - 0.5.4 - compile - - - cn.wustlinghang.mywust - mywust-core - 0.0.2-beta - compile - - - cn.wustlinghang.mywust - mywust-network-okhttp - 0.0.2-beta - compile - - - cn.wustlinghang.wusthelper - common - 0.0.1-SNAPSHOT - compile - - - jakarta.annotation - jakarta.annotation-api - 2.1.1 - compile - - - javax.annotation - javax.annotation-api - 1.3.2 - compile - - - org.projectlombok - lombok - 1.18.26 - provided - - - - - central - https://repo1.maven.org/maven2 - - - - true - - github - https://maven.pkg.github.com/LingHangStudio/mywust - - - - - - io.quarkus.platform - quarkus-maven-plugin - 3.1.3.Final - true - - - - diff --git a/sub-services/undergrad/pom.xml b/sub-services/undergrad/pom.xml index 89d256b..ad68d75 100644 --- a/sub-services/undergrad/pom.xml +++ b/sub-services/undergrad/pom.xml @@ -71,6 +71,12 @@ rest-assured test + + + cn.wustlinghang.wusthelper + rpc-frp-consul + ${revision} + diff --git a/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/http/v1/ExamActivitiesApi.java b/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/http/v1/ExamActivitiesApi.java index f27d585..f82c377 100644 --- a/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/http/v1/ExamActivitiesApi.java +++ b/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/http/v1/ExamActivitiesApi.java @@ -42,7 +42,7 @@ public class ExamActivitiesApi { @POST @Path("/parse") - public List parse() throws RpcException { + public List parse() throws RpcException { throw RpcException.ApiNotImplement(); } } diff --git a/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/rpc/FrpConsulRegister.java b/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/rpc/FrpConsulRegister.java deleted file mode 100644 index b5273f2..0000000 --- a/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/rpc/FrpConsulRegister.java +++ /dev/null @@ -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; - } -} diff --git a/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/rpc/Register.java b/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/rpc/Register.java new file mode 100644 index 0000000..4a8492e --- /dev/null +++ b/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/rpc/Register.java @@ -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(); + } +} diff --git a/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/rpc/client/ConsulClient.java b/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/rpc/client/ConsulClient.java deleted file mode 100644 index c33a913..0000000 --- a/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/rpc/client/ConsulClient.java +++ /dev/null @@ -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("服务注销不成功,请手动注册"); - } - } -} diff --git a/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/rpc/client/FrpcClient.java b/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/rpc/client/FrpcClient.java deleted file mode 100644 index a6a5f05..0000000 --- a/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/rpc/client/FrpcClient.java +++ /dev/null @@ -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(); - } -} diff --git a/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/rpc/config/FrpConfig.java b/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/rpc/config/FrpConfig.java deleted file mode 100644 index b1cf86f..0000000 --- a/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/rpc/config/FrpConfig.java +++ /dev/null @@ -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; -} diff --git a/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/rpc/config/RpcConfig.java b/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/rpc/config/RpcConfig.java index 3c5beae..ef8fc9a 100644 --- a/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/rpc/config/RpcConfig.java +++ b/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/rpc/config/RpcConfig.java @@ -15,4 +15,19 @@ public class RpcConfig { @DefaultValue("http://127.0.0.1:8500") @ConfigProperty(name = "rpc.register.consul-api.address") String consulAddress; + + @DefaultValue("http://127.0.0.1:7400") + @ConfigProperty(name = "rpc.frpc.admin-api.address") + String frpcAdminAddress; + + @DefaultValue("") + @ConfigProperty(name = "rpc.frpc.admin.username") + String frpcAdminUsername; + + @DefaultValue("") + @ConfigProperty(name = "rpc.frpc.admin.password") + String frpcAdminPassword; + + @ConfigProperty(name = "quarkus.http.port") + String localServicePort; } diff --git a/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/rpc/entity/RegisterRequestBody.java b/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/rpc/entity/RegisterRequestBody.java deleted file mode 100644 index 50573b9..0000000 --- a/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/rpc/entity/RegisterRequestBody.java +++ /dev/null @@ -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 checks, String name, String id) { - - @Builder - public record ChecksItem(String http, String interval) { - } -} \ No newline at end of file diff --git a/sub-services/undergrad/src/main/resources/application.properties b/sub-services/undergrad/src/main/resources/application.properties index cbf13fc..8e2f395 100644 --- a/sub-services/undergrad/src/main/resources/application.properties +++ b/sub-services/undergrad/src/main/resources/application.properties @@ -15,6 +15,6 @@ quarkus.native.additional-build-args=--initialize-at-run-time=cn.wustlinghang.my rpc.service.name=wusthelper.undergrad rpc.register.consul-api.address=http://127.0.0.1:8500 -frpc.admin-api.address=http://127.0.0.1:7400 -frpc.admin.username=admin -frpc.admin.password=admin \ No newline at end of file +rpc.frpc.admin-api.address=http://127.0.0.1:7400 +rpc.frpc.admin.username=admin +rpc.frpc.admin.password=admin \ No newline at end of file