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