fix SDLConfiguration
This commit is contained in:
parent
43d035e931
commit
3c69c4bc1f
@ -50,21 +50,11 @@ public class SDLConfiguration {
|
||||
|
||||
let serverHost: String
|
||||
let stunServers: [String]
|
||||
|
||||
lazy var stunSocketAddress: SocketAddress = {
|
||||
let stunServer = stunServers[0]
|
||||
return try! SocketAddress.makeAddressResolvingHost(stunServer, port: 1365)
|
||||
}()
|
||||
|
||||
|
||||
let stunSocketAddress: SocketAddress
|
||||
|
||||
// 网络探测地址信息
|
||||
lazy var stunProbeSocketAddressArray: [[SocketAddress]] = {
|
||||
return stunServers.map { stunServer in
|
||||
[
|
||||
try! SocketAddress.makeAddressResolvingHost(stunServer, port: 1365),
|
||||
try! SocketAddress.makeAddressResolvingHost(stunServer, port: 1366)
|
||||
]
|
||||
}
|
||||
}()
|
||||
let stunProbeSocketAddressArray: [[SocketAddress]]
|
||||
|
||||
let clientId: String
|
||||
let networkAddress: NetworkAddress
|
||||
@ -86,6 +76,13 @@ public class SDLConfiguration {
|
||||
self.version = version
|
||||
self.serverHost = serverHost
|
||||
self.stunServers = stunServers
|
||||
self.stunSocketAddress = Self.makeStunSocketAddress(host: stunServers[0], port: 1365)
|
||||
self.stunProbeSocketAddressArray = stunServers.map { stunServer in
|
||||
[
|
||||
Self.makeStunSocketAddress(host: stunServer, port: 1365),
|
||||
Self.makeStunSocketAddress(host: stunServer, port: 1366)
|
||||
]
|
||||
}
|
||||
self.clientId = clientId
|
||||
self.networkAddress = networkAddress
|
||||
self.accessToken = accessToken
|
||||
@ -96,6 +93,14 @@ public class SDLConfiguration {
|
||||
|
||||
}
|
||||
|
||||
private extension SDLConfiguration {
|
||||
|
||||
static func makeStunSocketAddress(host: String, port: Int) -> SocketAddress {
|
||||
return try! SocketAddress.makeAddressResolvingHost(host, port: port)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 解析配置文件
|
||||
extension SDLConfiguration {
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user