mirror of
https://github.com/utmapp/UTM
synced 2024-11-12 22:17:05 +00:00
parent
c197864054
commit
6bb5b20670
2 changed files with 6 additions and 3 deletions
|
@ -223,9 +223,12 @@ struct ServerSettingsView: View {
|
|||
.multilineTextAlignment(.trailing)
|
||||
.help("Specify a port number to listen on. This is required if external clients are permitted.")
|
||||
.onChange(of: serverPort) { newValue in
|
||||
if serverPort == 0 {
|
||||
if newValue == 0 {
|
||||
isServerExternal = false
|
||||
}
|
||||
if newValue < 0 || newValue >= UInt16.max {
|
||||
serverPort = defaultPort
|
||||
}
|
||||
}
|
||||
}
|
||||
Section(header: Text("Authentication")) {
|
||||
|
|
|
@ -131,7 +131,7 @@ actor UTMRemoteServer {
|
|||
registerNotifications()
|
||||
listener = Task {
|
||||
await withErrorNotification {
|
||||
if isServerExternal && serverPort > 0 {
|
||||
if isServerExternal && serverPort > 0 && serverPort <= UInt16.max {
|
||||
natPort = Port.TCP(internalPort: UInt16(serverPort))
|
||||
natPort!.mappingChangedHandler = { port in
|
||||
Task {
|
||||
|
@ -146,7 +146,7 @@ actor UTMRemoteServer {
|
|||
}
|
||||
}
|
||||
}
|
||||
let port = serverPort > 0 ? NWEndpoint.Port(integerLiteral: UInt16(serverPort)) : .any
|
||||
let port = serverPort > 0 && serverPort <= UInt16.max ? NWEndpoint.Port(integerLiteral: UInt16(serverPort)) : .any
|
||||
for try await connection in Connection.advertise(on: port, forServiceType: service, txtRecord: metadata, connectionQueue: connectionQueue, identity: keyManager.identity) {
|
||||
let connection = try? await Connection(connection: connection, connectionQueue: connectionQueue) { connection, error in
|
||||
Task {
|
||||
|
|
Loading…
Reference in a new issue