기술 자료

지원

Relay

Relay

DTLS 암호화 활성화

Configure your Relay client to use Datagram Transport Layer Security for encrypted connections.
읽는 시간 1분최근 업데이트: 한 달 전

Relay는 Relay 서버와 주고받는 모든 UDP 커뮤니케이션에 DTLS 암호화를 지원합니다. 호스트 플레이어로 할당을 생성할 때 Relay 서버의
connectionType
dtls
로 설정하여 DTLS 암호화를 활성화할 수 있습니다.
다음 코드 스니핏은
AllocateRelayServerAndGetJoinCode
함수를 사용한 것으로, Relay SDK를 사용하여 할당을 생성하고, 참여 코드를 요청하고, 연결 유형을 DTLS로 설정하는 방법을 보여 줍니다.
public static async Task<(string ipv4address, ushort port, byte[] allocationIdBytes, byte[] connectionData, byte[] key, string joinCode)> AllocateRelayServerAndGetJoinCode(int maxConnections, string region = null){ Allocation allocation; string createJoinCode; try { allocation = await RelayService.Instance.CreateAllocationAsync(maxConnections, region); } catch (Exception e) { Debug.LogError($"Relay create allocation request failed {e.Message}"); throw; } Debug.Log($"server connection data: {allocation.ConnectionData[0]} {allocation.ConnectionData[1]}"); Debug.Log($"server allocation ID: {allocation.AllocationId}"); try { createJoinCode = await RelayService.Instance.GetJoinCodeAsync(allocation.AllocationId); } catch { Debug.LogError("Relay create join code request failed"); throw; } var dtlsEndpoint = allocation.ServerEndpoints.First(e => e.ConnectionType == "dtls"); return (dtlsEndpoint.Host, (ushort)dtlsEndpoint.Port, allocation.AllocationIdBytes, allocation.ConnectionData, allocation.Key, createJoinCode);}