Skip to content

Commit

Permalink
Merge branch '2.x' into add_jdk21_02
Browse files Browse the repository at this point in the history
  • Loading branch information
funky-eyes authored Jan 17, 2025
2 parents b6d47e7 + 4632770 commit 92505e8
Show file tree
Hide file tree
Showing 16 changed files with 241 additions and 27 deletions.
3 changes: 3 additions & 0 deletions changes/en-us/2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Add changes here for all PR submitted to the 2.x branch.
### bugfix:

- [[#7104](https://github.com/apache/incubator-seata/pull/7104)] fix impl of supportsSourceType is not defined
- [[#7116](https://github.com/apache/incubator-seata/pull/7116)] fix prefix: seata.server.raft.ssl should not be null
- [[#7112](https://github.com/apache/incubator-seata/pull/7112)] bugfix: remove the condition that IPv6 must start with fe80


### optimize:
Expand Down Expand Up @@ -47,6 +49,7 @@ Thanks to these contributors for their code commits. Please report an unintended
- [PeppaO](https://github.com/PeppaO)
- [funky-eyes](https://github.com/funky-eyes)
- [psxjoy](https://github.com/psxjoy)
- [xiaoxiangyeyu0](https://github.com/xiaoxiangyeyu0)


Also, we receive many valuable issues, questions and advices from our community. Thanks for you all.
3 changes: 3 additions & 0 deletions changes/zh-cn/2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
### bugfix:

- [[#7104](https://github.com/apache/incubator-seata/pull/7104)] 修复SeataApplicationListener在低版本springboot未实现supportsSourceType方法的问题
- [[#7116](https://github.com/apache/incubator-seata/pull/7116)] 修复 seata.server.raft.ssl 前缀不存在的问题
- [[#7112](https://github.com/apache/incubator-seata/pull/7112)] 校验是否IPv6网络ip取消必须以fe80开始的条件

### optimize:

Expand Down Expand Up @@ -46,5 +48,6 @@
- [PeppaO](https://github.com/PeppaO)
- [funky-eyes](https://github.com/funky-eyes)
- [psxjoy](https://github.com/psxjoy)
- [xiaoxiangyeyu0](https://github.com/xiaoxiangyeyu0)

同时,我们收到了社区反馈的很多有价值的issue和建议,非常感谢大家。
Original file line number Diff line number Diff line change
Expand Up @@ -966,14 +966,24 @@ public interface ConfigurationKeys {


/**
* The constant SERVER_RAFT_SSL_KEYSTORE_TYPE.
* The constant SERVER_RAFT_SSL_CLIENT_KEYSTORE_TYPE.
*/
String SERVER_RAFT_SSL_KEYSTORE_TYPE = SERVER_RAFT_SSL + "keystore.type";
String SERVER_RAFT_SSL_CLIENT_KEYSTORE_TYPE = SERVER_RAFT_SSL_CLIENT + "keystore.type";

/**
* The constant SERVER_RAFT_SSL_SERVER_KEYSTORE_TYPE.
*/
String SERVER_RAFT_SSL_SERVER_KEYSTORE_TYPE = SERVER_RAFT_SSL_SERVER + "keystore.type";

/**
* The constant SERVER_RAFT_SSL_KMF_ALGORITHM.
*/
String SERVER_RAFT_SSL_KMF_ALGORITHM = SERVER_RAFT_SSL + "kmfAlgorithm";

/**
* The constant SERVER_RAFT_SSL_KMF_ALGORITHM.
*/
String SERVER_RAFT_SSL_KMF_ALGORITHM = SERVER_RAFT_SSL + "kmf.algorithm";
String SERVER_RAFT_SSL_TMF_ALGORITHM = SERVER_RAFT_SSL + "tmfAlgorithm";

/**
* The constant SERVER_RAFT_MAX_APPEND_BUFFER_SIZE.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,10 @@ public class NetAddressValidatorUtil {

private static final String DOUBLE_COLON_FFFF = "::ffff:";

private static final String FE80 = "fe80:";

private static final int ZERO = 0;

private static final int SEVEN = 7;

private static final int FIVE = 5;

private static final Pattern IPV4_PATTERN = Pattern
.compile("^" + "(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)" + "(\\.(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)){3}" + "$");

Expand Down Expand Up @@ -133,19 +129,17 @@ public static boolean isIPv6IPv4MappedAddress(final String input) {
}

/**
* Check if <code>input</code> is a link local IPv6 address starting with "fe80:" and containing
* Check if <code>input</code> is a link local IPv6 address containing
* a zone index with "%xxx". The zone index will not be checked.
*
* @param input ip-address to check
* @return true if address part of <code>input</code> is in correct IPv6 notation.
*/
public static boolean isLinkLocalIPv6WithZoneIndex(String input) {
if (input.length() > FIVE && input.substring(ZERO, FIVE).equalsIgnoreCase(FE80)) {
int lastIndex = input.lastIndexOf(PERCENT);
if (lastIndex > ZERO && lastIndex < (input.length() - 1)) {
String ipPart = input.substring(ZERO, lastIndex);
return isIPv6StdAddress(ipPart) || isIPv6HexCompressedAddress(ipPart);
}
int lastIndex = input.lastIndexOf(PERCENT);
if (lastIndex > ZERO && lastIndex < (input.length() - 1)) {
String ipPart = input.substring(ZERO, lastIndex);
return isIPv6StdAddress(ipPart) || isIPv6HexCompressedAddress(ipPart);
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,10 @@ public void isIPv4Address() {
assertThat(NetAddressValidatorUtil.isIPv4Address("127.0.0.1")).isTrue();
assertThat(NetAddressValidatorUtil.isIPv4Address("999.999.999.999")).isFalse();
}

@Test
public void isLinkLocalIPv6WithZoneIndex() {
assertThat(NetAddressValidatorUtil.isLinkLocalIPv6WithZoneIndex("2409:8a5c:6730:4490:f0e8:b9ad:3b3d:e739%br0")).isTrue();
assertThat(NetAddressValidatorUtil.isLinkLocalIPv6WithZoneIndex("2409:8a5c:6730:4490:f0e8:b9ad:3b3d:e739%")).isFalse();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ public interface StarterConstants {
String SERVER_PREFIX = SEATA_PREFIX + ".server";
String SERVER_UNDO_PREFIX = SERVER_PREFIX + ".undo";
String SERVER_RAFT_PREFIX = SERVER_PREFIX + ".raft";
String SERVER_RAFT_SSL_PREFIX = SERVER_RAFT_PREFIX + ".ssl";
String SERVER_RAFT_SSL_CLIENT_KEYSTORE_PREFIX = SERVER_RAFT_SSL_PREFIX + ".client.keystore";
String SERVER_RAFT_SSL_SERVER_KEYSTORE_PREFIX = SERVER_RAFT_SSL_PREFIX + ".server.keystore";
String SERVER_RECOVERY_PREFIX = SERVER_PREFIX + ".recovery";

String METRICS_PREFIX = SEATA_PREFIX + ".metrics";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@
package org.apache.seata.spring.boot.autoconfigure;

import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.seata.spring.boot.autoconfigure.properties.server.raft.ServerRaftSSLClientProperties;
import org.apache.seata.spring.boot.autoconfigure.properties.server.raft.ServerRaftSSLProperties;
import org.apache.seata.spring.boot.autoconfigure.properties.server.raft.ServerRaftSSLServerProperties;
import org.apache.seata.spring.boot.autoconfigure.properties.server.store.StoreProperties;
import org.apache.seata.spring.boot.autoconfigure.properties.server.MetricsProperties;
import org.apache.seata.spring.boot.autoconfigure.properties.server.ServerProperties;
import org.apache.seata.spring.boot.autoconfigure.properties.server.ServerRaftProperties;
import org.apache.seata.spring.boot.autoconfigure.properties.server.raft.ServerRaftProperties;
import org.apache.seata.spring.boot.autoconfigure.properties.server.ServerRecoveryProperties;
import org.apache.seata.spring.boot.autoconfigure.properties.server.ServerUndoProperties;
import org.apache.seata.spring.boot.autoconfigure.properties.server.session.SessionProperties;
Expand All @@ -38,6 +41,9 @@
import static org.apache.seata.spring.boot.autoconfigure.StarterConstants.PROPERTY_BEAN_MAP;
import static org.apache.seata.spring.boot.autoconfigure.StarterConstants.SERVER_PREFIX;
import static org.apache.seata.spring.boot.autoconfigure.StarterConstants.SERVER_RAFT_PREFIX;
import static org.apache.seata.spring.boot.autoconfigure.StarterConstants.SERVER_RAFT_SSL_CLIENT_KEYSTORE_PREFIX;
import static org.apache.seata.spring.boot.autoconfigure.StarterConstants.SERVER_RAFT_SSL_PREFIX;
import static org.apache.seata.spring.boot.autoconfigure.StarterConstants.SERVER_RAFT_SSL_SERVER_KEYSTORE_PREFIX;
import static org.apache.seata.spring.boot.autoconfigure.StarterConstants.SERVER_RECOVERY_PREFIX;
import static org.apache.seata.spring.boot.autoconfigure.StarterConstants.SERVER_UNDO_PREFIX;
import static org.apache.seata.spring.boot.autoconfigure.StarterConstants.SESSION_PREFIX;
Expand Down Expand Up @@ -79,6 +85,9 @@ public static void init() {
PROPERTY_BEAN_MAP.put(STORE_REDIS_SINGLE_PREFIX, StoreRedisProperties.Single.class);
PROPERTY_BEAN_MAP.put(STORE_REDIS_SENTINEL_PREFIX, StoreRedisProperties.Sentinel.class);
PROPERTY_BEAN_MAP.put(SERVER_RAFT_PREFIX, ServerRaftProperties.class);
PROPERTY_BEAN_MAP.put(SERVER_RAFT_SSL_SERVER_KEYSTORE_PREFIX, ServerRaftSSLServerProperties.class);
PROPERTY_BEAN_MAP.put(SERVER_RAFT_SSL_PREFIX, ServerRaftSSLProperties.class);
PROPERTY_BEAN_MAP.put(SERVER_RAFT_SSL_CLIENT_KEYSTORE_PREFIX, ServerRaftSSLClientProperties.class);
PROPERTY_BEAN_MAP.put(SESSION_PREFIX, SessionProperties.class);
PROPERTY_BEAN_MAP.put(STORE_PREFIX, StoreProperties.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.seata.spring.boot.autoconfigure.properties.server;
package org.apache.seata.spring.boot.autoconfigure.properties.server.raft;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.seata.spring.boot.autoconfigure.properties.server.raft;

import static org.apache.seata.spring.boot.autoconfigure.StarterConstants.SERVER_RAFT_SSL_CLIENT_KEYSTORE_PREFIX;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

@Component
@ConfigurationProperties(prefix = SERVER_RAFT_SSL_CLIENT_KEYSTORE_PREFIX)
public class ServerRaftSSLClientProperties {

private String path = "ssl/cbolt.pfx";

private String password;

private String type = "pkcs12";

public String getPath() {
return path;
}

public void setPath(String path) {
this.path = path;
}

public String getPassword() {
return password;
}

public void setPassword(String password) {
this.password = password;
}

public String getType() {
return type;
}

public void setType(String type) {
this.type = type;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.seata.spring.boot.autoconfigure.properties.server.raft;

import static org.apache.seata.spring.boot.autoconfigure.StarterConstants.SERVER_RAFT_SSL_PREFIX;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

@Component
@ConfigurationProperties(prefix = SERVER_RAFT_SSL_PREFIX)
public class ServerRaftSSLProperties {

private Boolean enabled = false;

private String kmfAlgorithm = "SunX509";

private String tmfAlgorithm = "SunX509";

public Boolean getEnabled() {
return enabled;
}

public void setEnabled(Boolean enabled) {
this.enabled = enabled;
}

public String getKmfAlgorithm() {
return kmfAlgorithm;
}

public void setKmfAlgorithm(String kmfAlgorithm) {
this.kmfAlgorithm = kmfAlgorithm;
}

public String getTmfAlgorithm() {
return tmfAlgorithm;
}

public void setTmfAlgorithm(String tmfAlgorithm) {
this.tmfAlgorithm = tmfAlgorithm;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.seata.spring.boot.autoconfigure.properties.server.raft;

import static org.apache.seata.spring.boot.autoconfigure.StarterConstants.SERVER_RAFT_SSL_SERVER_KEYSTORE_PREFIX;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

@Component
@ConfigurationProperties(prefix = SERVER_RAFT_SSL_SERVER_KEYSTORE_PREFIX)
public class ServerRaftSSLServerProperties {

private String path = "ssl/cbolt.pfx";

private String password;

private String type = "pkcs12";

public String getPath() {
return path;
}

public void setPath(String path) {
this.path = path;
}

public String getPassword() {
return password;
}

public void setPassword(String password) {
this.password = password;
}

public String getType() {
return type;
}

public void setType(String type) {
this.type = type;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package org.apache.seata.spring.boot.autoconfigure.properties.server;

import org.apache.seata.spring.boot.autoconfigure.properties.server.raft.ServerRaftProperties;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@
import static org.apache.seata.common.ConfigurationKeys.SERVER_RAFT_REPORTER_INITIAL_DELAY;
import static org.apache.seata.common.ConfigurationKeys.SERVER_RAFT_SSL_CLIENT_KEYSTORE_PASSWORD;
import static org.apache.seata.common.ConfigurationKeys.SERVER_RAFT_SSL_CLIENT_KEYSTORE_PATH;
import static org.apache.seata.common.ConfigurationKeys.SERVER_RAFT_SSL_CLIENT_KEYSTORE_TYPE;
import static org.apache.seata.common.ConfigurationKeys.SERVER_RAFT_SSL_ENABLED;
import static org.apache.seata.common.ConfigurationKeys.SERVER_RAFT_SSL_KEYSTORE_TYPE;
import static org.apache.seata.common.ConfigurationKeys.SERVER_RAFT_SSL_KMF_ALGORITHM;
import static org.apache.seata.common.ConfigurationKeys.SERVER_RAFT_SSL_SERVER_KEYSTORE_PASSWORD;
import static org.apache.seata.common.ConfigurationKeys.SERVER_RAFT_SSL_SERVER_KEYSTORE_PATH;
import static org.apache.seata.common.ConfigurationKeys.SERVER_RAFT_SSL_SERVER_KEYSTORE_TYPE;
import static org.apache.seata.common.ConfigurationKeys.SERVER_RAFT_SSL_TMF_ALGORITHM;
import static org.apache.seata.common.DefaultValues.DEFAULT_RAFT_SSL_ENABLED;

/**
Expand Down Expand Up @@ -143,13 +145,13 @@ private void enableSSL() {
setSystemProperty("bolt.server.ssl.keystore", instance.getConfig(SERVER_RAFT_SSL_SERVER_KEYSTORE_PATH));
setSystemProperty("bolt.server.ssl.keystore.password",
instance.getConfig(SERVER_RAFT_SSL_SERVER_KEYSTORE_PASSWORD));
setSystemProperty("bolt.server.ssl.keystore.type", instance.getConfig(SERVER_RAFT_SSL_KEYSTORE_TYPE));
setSystemProperty("bolt.server.ssl.keystore.type", instance.getConfig(SERVER_RAFT_SSL_SERVER_KEYSTORE_TYPE));
setSystemProperty("bolt.server.ssl.kmf.algorithm", instance.getConfig(SERVER_RAFT_SSL_KMF_ALGORITHM));
setSystemProperty("bolt.client.ssl.keystore", instance.getConfig(SERVER_RAFT_SSL_CLIENT_KEYSTORE_PATH));
setSystemProperty("bolt.client.ssl.keystore.password",
instance.getConfig(SERVER_RAFT_SSL_CLIENT_KEYSTORE_PASSWORD));
setSystemProperty("bolt.client.ssl.keystore.type", instance.getConfig(SERVER_RAFT_SSL_KEYSTORE_TYPE));
setSystemProperty("bolt.client.ssl.tmf.algorithm", instance.getConfig(SERVER_RAFT_SSL_KMF_ALGORITHM));
setSystemProperty("bolt.client.ssl.keystore.type", instance.getConfig(SERVER_RAFT_SSL_CLIENT_KEYSTORE_TYPE));
setSystemProperty("bolt.client.ssl.tmf.algorithm", instance.getConfig(SERVER_RAFT_SSL_TMF_ALGORITHM));

logger.info("Enable ssl communication between raft nodes");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ public class ServerInstanceFactory {
private static final Logger LOGGER = LoggerFactory.getLogger(Server.class);

public void serverInstanceInit() {
VGroupMappingStoreManager vGroupMappingStoreManager = SessionHolder.getRootVGroupMappingManager();
ConfigurableEnvironment environment =
(ConfigurableEnvironment)ObjectHolder.INSTANCE.getObject(OBJECT_KEY_SPRING_CONFIGURABLE_ENVIRONMENT);

Expand Down Expand Up @@ -101,6 +100,7 @@ public void serverInstanceInit() {
}
instance.setTransaction(new Node.Endpoint(XID.getIpAddress(), XID.getPort(), "netty"));
if (StringUtils.equals(registryProperties.getType(), NAMING_SERVER)) {
VGroupMappingStoreManager vGroupMappingStoreManager = SessionHolder.getRootVGroupMappingManager();
// load vgroup mapping relationship
instance.addMetadata("vGroup", vGroupMappingStoreManager.loadVGroups());
EXECUTOR_SERVICE =
Expand Down
Loading

0 comments on commit 92505e8

Please sign in to comment.