Coap: noSec one Endpoint
This commit is contained in:
parent
e83064ece7
commit
ac18585e17
@ -27,8 +27,6 @@ import org.springframework.stereotype.Component;
|
|||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
import javax.annotation.PreDestroy;
|
import javax.annotation.PreDestroy;
|
||||||
import java.net.InetAddress;
|
|
||||||
import java.net.InetSocketAddress;
|
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.concurrent.ConcurrentMap;
|
import java.util.concurrent.ConcurrentMap;
|
||||||
@ -87,12 +85,6 @@ public class DefaultCoapServerService implements CoapServerService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private CoapServer createCoapServer() throws UnknownHostException {
|
private CoapServer createCoapServer() throws UnknownHostException {
|
||||||
server = new CoapServer();
|
|
||||||
|
|
||||||
CoapEndpoint.Builder noSecCoapEndpointBuilder = new CoapEndpoint.Builder();
|
|
||||||
InetAddress addr = InetAddress.getByName(coapServerContext.getHost());
|
|
||||||
InetSocketAddress sockAddr = new InetSocketAddress(addr, coapServerContext.getPort());
|
|
||||||
noSecCoapEndpointBuilder.setInetSocketAddress(sockAddr);
|
|
||||||
NetworkConfig networkConfig = new NetworkConfig();
|
NetworkConfig networkConfig = new NetworkConfig();
|
||||||
networkConfig.setBoolean(NetworkConfig.Keys.BLOCKWISE_STRICT_BLOCK2_OPTION, true);
|
networkConfig.setBoolean(NetworkConfig.Keys.BLOCKWISE_STRICT_BLOCK2_OPTION, true);
|
||||||
networkConfig.setBoolean(NetworkConfig.Keys.BLOCKWISE_ENTITY_TOO_LARGE_AUTO_FAILOVER, true);
|
networkConfig.setBoolean(NetworkConfig.Keys.BLOCKWISE_ENTITY_TOO_LARGE_AUTO_FAILOVER, true);
|
||||||
@ -102,10 +94,7 @@ public class DefaultCoapServerService implements CoapServerService {
|
|||||||
networkConfig.setInt(NetworkConfig.Keys.PREFERRED_BLOCK_SIZE, 1024);
|
networkConfig.setInt(NetworkConfig.Keys.PREFERRED_BLOCK_SIZE, 1024);
|
||||||
networkConfig.setInt(NetworkConfig.Keys.MAX_MESSAGE_SIZE, 1024);
|
networkConfig.setInt(NetworkConfig.Keys.MAX_MESSAGE_SIZE, 1024);
|
||||||
networkConfig.setInt(NetworkConfig.Keys.MAX_RETRANSMIT, 4);
|
networkConfig.setInt(NetworkConfig.Keys.MAX_RETRANSMIT, 4);
|
||||||
noSecCoapEndpointBuilder.setNetworkConfig(networkConfig);
|
server = new CoapServer(networkConfig, coapServerContext.getPort());
|
||||||
CoapEndpoint noSecCoapEndpoint = noSecCoapEndpointBuilder.build();
|
|
||||||
server.addEndpoint(noSecCoapEndpoint);
|
|
||||||
|
|
||||||
if (isDtlsEnabled()) {
|
if (isDtlsEnabled()) {
|
||||||
CoapEndpoint.Builder dtlsCoapEndpointBuilder = new CoapEndpoint.Builder();
|
CoapEndpoint.Builder dtlsCoapEndpointBuilder = new CoapEndpoint.Builder();
|
||||||
TbCoapDtlsSettings dtlsSettings = coapServerContext.getDtlsSettings();
|
TbCoapDtlsSettings dtlsSettings = coapServerContext.getDtlsSettings();
|
||||||
|
|||||||
@ -18,7 +18,6 @@ package org.thingsboard.server.transport.coap;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.eclipse.californium.core.CoapResource;
|
import org.eclipse.californium.core.CoapResource;
|
||||||
import org.eclipse.californium.core.CoapServer;
|
import org.eclipse.californium.core.CoapServer;
|
||||||
import org.eclipse.californium.core.network.config.NetworkConfig;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.thingsboard.server.coapserver.CoapServerService;
|
import org.thingsboard.server.coapserver.CoapServerService;
|
||||||
@ -31,8 +30,6 @@ import javax.annotation.PostConstruct;
|
|||||||
import javax.annotation.PreDestroy;
|
import javax.annotation.PreDestroy;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
|
|
||||||
import static org.eclipse.californium.core.network.config.NetworkConfigDefaults.DEFAULT_BLOCKWISE_STATUS_LIFETIME;
|
|
||||||
|
|
||||||
@Service("CoapTransportService")
|
@Service("CoapTransportService")
|
||||||
@TbCoapServerComponent
|
@TbCoapServerComponent
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@ -55,14 +52,6 @@ public class CoapTransportService implements TbTransportService {
|
|||||||
public void init() throws UnknownHostException {
|
public void init() throws UnknownHostException {
|
||||||
log.info("Starting CoAP transport...");
|
log.info("Starting CoAP transport...");
|
||||||
coapServer = coapServerService.getCoapServer();
|
coapServer = coapServerService.getCoapServer();
|
||||||
coapServer.getConfig().setBoolean(NetworkConfig.Keys.BLOCKWISE_STRICT_BLOCK2_OPTION, true);
|
|
||||||
coapServer.getConfig().setBoolean(NetworkConfig.Keys.BLOCKWISE_ENTITY_TOO_LARGE_AUTO_FAILOVER, true);
|
|
||||||
coapServer.getConfig().setLong(NetworkConfig.Keys.BLOCKWISE_STATUS_LIFETIME, DEFAULT_BLOCKWISE_STATUS_LIFETIME);
|
|
||||||
coapServer.getConfig().setInt(NetworkConfig.Keys.MAX_RESOURCE_BODY_SIZE, 256 * 1024 * 1024);
|
|
||||||
coapServer.getConfig().setString(NetworkConfig.Keys.RESPONSE_MATCHING, "RELAXED");
|
|
||||||
coapServer.getConfig().setInt(NetworkConfig.Keys.PREFERRED_BLOCK_SIZE, 1024);
|
|
||||||
coapServer.getConfig().setInt(NetworkConfig.Keys.MAX_MESSAGE_SIZE, 1024);
|
|
||||||
coapServer.getConfig().setInt(NetworkConfig.Keys.MAX_RETRANSMIT, 10);
|
|
||||||
CoapResource api = new CoapResource(API);
|
CoapResource api = new CoapResource(API);
|
||||||
api.add(new CoapTransportResource(coapTransportContext, coapServerService, V1));
|
api.add(new CoapTransportResource(coapTransportContext, coapServerService, V1));
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user