upgrade(nacos server): up nacos 2.4.1

This commit is contained in:
冷冷 2024-08-17 15:33:59 +08:00
parent 62ba7cf04a
commit de56d3dfcb
10 changed files with 84 additions and 39 deletions

View File

@ -21,44 +21,45 @@
<version>${revision}</version> <version>${revision}</version>
</parent> </parent>
<artifactId>pig-register</artifactId> <artifactId>pig-register</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>pig-register</name> <name>pig-register</name>
<description>nacos 注册配置中心</description> <description>nacos 注册配置中心</description>
<properties> <properties>
<nacos.version>2.3.2-OEM</nacos.version> <nacos.version>2.4.1.0</nacos.version>
<spring-boot.version>2.7.18</spring-boot.version> <spring-boot.version>2.7.18</spring-boot.version>
<spring-boot-admin.version>2.7.16</spring-boot-admin.version> <spring-boot-admin.version>2.7.16</spring-boot-admin.version>
</properties> </properties>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>group.springframework.nacos</groupId> <groupId>io.github.pig-mesh.nacos</groupId>
<artifactId>nacos-config</artifactId> <artifactId>nacos-config</artifactId>
<version>${nacos.version}</version> <version>${nacos.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>group.springframework.nacos</groupId> <groupId>io.github.pig-mesh.nacos</groupId>
<artifactId>nacos-naming</artifactId> <artifactId>nacos-naming</artifactId>
<version>${nacos.version}</version> <version>${nacos.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>group.springframework.nacos</groupId> <groupId>io.github.pig-mesh.nacos</groupId>
<artifactId>nacos-istio</artifactId> <artifactId>nacos-istio</artifactId>
<version>${nacos.version}</version> <version>${nacos.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>group.springframework.nacos</groupId> <groupId>io.github.pig-mesh.nacos</groupId>
<artifactId>nacos-default-plugin-all</artifactId> <artifactId>nacos-default-plugin-all</artifactId>
<version>${nacos.version}</version> <version>${nacos.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>group.springframework.nacos</groupId> <groupId>io.github.pig-mesh.nacos</groupId>
<artifactId>nacos-prometheus</artifactId> <artifactId>nacos-prometheus</artifactId>
<version>${nacos.version}</version> <version>${nacos.version}</version>
</dependency> </dependency>
@ -81,6 +82,7 @@
</dependencies> </dependencies>
<!--依赖版本声明--> <!--依赖版本声明-->
<dependencyManagement> <dependencyManagement>
<dependencies> <dependencies>

View File

@ -16,7 +16,7 @@
package com.alibaba.nacos; package com.alibaba.nacos;
import com.alibaba.nacos.config.ConfigConstants; import com.alibaba.nacos.console.config.ConfigConstants;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;

View File

@ -15,7 +15,7 @@
* Author: lengleng (wangiegie@gmail.com) * Author: lengleng (wangiegie@gmail.com)
*/ */
package com.alibaba.nacos.config; package com.alibaba.nacos.console.config;
/** /**
* @author lengleng * @author lengleng

View File

@ -14,8 +14,9 @@
* limitations under the License. * limitations under the License.
*/ */
package com.alibaba.nacos.config; package com.alibaba.nacos.console.config;
import com.alibaba.nacos.console.filter.XssFilter;
import com.alibaba.nacos.core.code.ControllerMethodsCache; import com.alibaba.nacos.core.code.ControllerMethodsCache;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
@ -49,10 +50,6 @@ public class ConsoleConfig {
@Value("${nacos.console.ui.enabled:true}") @Value("${nacos.console.ui.enabled:true}")
private boolean consoleUiEnabled; private boolean consoleUiEnabled;
public boolean isConsoleUiEnabled() {
return consoleUiEnabled;
}
/** /**
* Init. * Init.
*/ */
@ -61,25 +58,34 @@ public class ConsoleConfig {
methodsCache.initClassMethod("com.alibaba.nacos.core.controller"); methodsCache.initClassMethod("com.alibaba.nacos.core.controller");
methodsCache.initClassMethod("com.alibaba.nacos.naming.controllers"); methodsCache.initClassMethod("com.alibaba.nacos.naming.controllers");
methodsCache.initClassMethod("com.alibaba.nacos.config.server.controller"); methodsCache.initClassMethod("com.alibaba.nacos.config.server.controller");
methodsCache.initClassMethod("com.alibaba.nacos.controller"); methodsCache.initClassMethod("com.alibaba.nacos.console.controller");
} }
@Bean @Bean
public CorsFilter corsFilter() { public CorsFilter corsFilter() {
CorsConfiguration config = new CorsConfiguration(); CorsConfiguration config = new CorsConfiguration();
config.setAllowCredentials(true); config.setAllowCredentials(true);
config.addAllowedOriginPattern("*");
config.addAllowedHeader("*"); config.addAllowedHeader("*");
config.setMaxAge(18000L); config.setMaxAge(18000L);
config.addAllowedMethod("*"); config.addAllowedMethod("*");
config.addAllowedOriginPattern("*");
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", config); source.registerCorsConfiguration("/**", config);
return new CorsFilter(source); return new CorsFilter(source);
} }
@Bean
public XssFilter xssFilter() {
return new XssFilter();
}
@Bean @Bean
public Jackson2ObjectMapperBuilderCustomizer jacksonObjectMapperCustomization() { public Jackson2ObjectMapperBuilderCustomizer jacksonObjectMapperCustomization() {
return jacksonObjectMapperBuilder -> jacksonObjectMapperBuilder.timeZone(ZoneId.systemDefault().toString()); return jacksonObjectMapperBuilder -> jacksonObjectMapperBuilder.timeZone(ZoneId.systemDefault().toString());
} }
public boolean isConsoleUiEnabled() {
return consoleUiEnabled;
}
} }

View File

@ -16,7 +16,6 @@
package com.alibaba.nacos.console.config; package com.alibaba.nacos.console.config;
import com.alibaba.nacos.config.ConsoleConfig;
import com.alibaba.nacos.sys.module.ModuleState; import com.alibaba.nacos.sys.module.ModuleState;
import com.alibaba.nacos.sys.module.ModuleStateBuilder; import com.alibaba.nacos.sys.module.ModuleStateBuilder;
import com.alibaba.nacos.sys.utils.ApplicationUtils; import com.alibaba.nacos.sys.utils.ApplicationUtils;

View File

@ -20,17 +20,22 @@ import com.alibaba.nacos.common.model.RestResult;
import com.alibaba.nacos.common.model.RestResultUtils; import com.alibaba.nacos.common.model.RestResultUtils;
import com.alibaba.nacos.console.paramcheck.ConsoleDefaultHttpParamExtractor; import com.alibaba.nacos.console.paramcheck.ConsoleDefaultHttpParamExtractor;
import com.alibaba.nacos.core.paramcheck.ExtractorManager; import com.alibaba.nacos.core.paramcheck.ExtractorManager;
import com.alibaba.nacos.sys.env.EnvUtil;
import com.alibaba.nacos.sys.module.ModuleState; import com.alibaba.nacos.sys.module.ModuleState;
import com.alibaba.nacos.sys.module.ModuleStateHolder; import com.alibaba.nacos.sys.module.ModuleStateHolder;
import com.alibaba.nacos.sys.utils.DiskUtils;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.io.File;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import static com.alibaba.nacos.common.utils.StringUtils.*;
/** /**
* Server state controller. * Server state controller.
* *
@ -41,6 +46,10 @@ import java.util.Map;
@ExtractorManager.Extractor(httpExtractor = ConsoleDefaultHttpParamExtractor.class) @ExtractorManager.Extractor(httpExtractor = ConsoleDefaultHttpParamExtractor.class)
public class ServerStateController { public class ServerStateController {
private static final String ANNOUNCEMENT_FILE = "announcement.conf";
private static final String GUIDE_FILE = "console-guide.conf";
/** /**
* Get server state of current server. * Get server state of current server.
* @return state json. * @return state json.
@ -57,12 +66,26 @@ public class ServerStateController {
@GetMapping("/announcement") @GetMapping("/announcement")
public RestResult<String> getAnnouncement( public RestResult<String> getAnnouncement(
@RequestParam(required = false, name = "language", defaultValue = "zh-CN") String language) { @RequestParam(required = false, name = "language", defaultValue = "zh-CN") String language) {
return RestResultUtils.success(); String file = ANNOUNCEMENT_FILE.substring(0, ANNOUNCEMENT_FILE.length() - 5) + "_" + language + ".conf";
if (file.contains(TOP_PATH) || file.contains(FOLDER_SEPARATOR) || file.contains(WINDOWS_FOLDER_SEPARATOR)) {
throw new IllegalArgumentException("Invalid filename");
}
File announcementFile = new File(EnvUtil.getConfPath(), file);
String announcement = null;
if (announcementFile.exists() && announcementFile.isFile()) {
announcement = DiskUtils.readFile(announcementFile);
}
return RestResultUtils.success(announcement);
} }
@GetMapping("/guide") @GetMapping("/guide")
public RestResult<String> getConsoleUiGuide() { public RestResult<String> getConsoleUiGuide() {
return RestResultUtils.success(); File guideFile = new File(EnvUtil.getConfPath(), GUIDE_FILE);
String guideInformation = null;
if (guideFile.exists() && guideFile.isFile()) {
guideInformation = DiskUtils.readFile(guideFile);
}
return RestResultUtils.success(guideInformation);
} }
} }

View File

@ -1 +1 @@
version=2.3.2-OEM version=2.4.1

File diff suppressed because one or more lines are too long

View File

@ -35,7 +35,7 @@
<link rel="stylesheet" type="text/css" href="console-ui/public/css/icon.css"> <link rel="stylesheet" type="text/css" href="console-ui/public/css/icon.css">
<link rel="stylesheet" type="text/css" href="console-ui/public/css/font-awesome.css"> <link rel="stylesheet" type="text/css" href="console-ui/public/css/font-awesome.css">
<!-- 第三方css结束 --> <!-- 第三方css结束 -->
<link href="./css/main.css?c02a3284f12026e72980" rel="stylesheet"></head> <link href="./css/main.css?0c44b904d360f744c82e" rel="stylesheet"></head>
<body> <body>
<div id="root" style="overflow:hidden"></div> <div id="root" style="overflow:hidden"></div>
@ -56,6 +56,6 @@
<script src="console-ui/public/js/merge.js"></script> <script src="console-ui/public/js/merge.js"></script>
<script src="console-ui/public/js/loader.js"></script> <script src="console-ui/public/js/loader.js"></script>
<!-- 第三方js结束 --> <!-- 第三方js结束 -->
<script type="text/javascript" src="./js/main.js?c02a3284f12026e72980"></script></body> <script type="text/javascript" src="./js/main.js?0c44b904d360f744c82e"></script></body>
</html> </html>

File diff suppressed because one or more lines are too long