// The Network pane: how a machine name becomes an address, and which addresses // are allowed to become a connection. // // "IP address mapping" / "Resolve machine's IP address using manually entered // mappings below" / "Example: MyLaptop 192.168.0.24" / "Validate remote machine // IP" / "Same subnet only" are the modern page's // (`MouseWithoutBordersPage.xaml:274-286, 399-425`). The per-line format is // `Name2IP` as the resolver reads it (docs/protocol.md §7). import Foundation import MWBCore import SwiftUI /// Name resolution and the two connection filters. struct NetworkPane: View { @ObservedObject var model: SettingsViewModel var body: some View { SettingsPaneLayout { SettingsSection( "IP address mapping", note: "Resolve a machine's IP address using the mappings below, for machines DNS " + "and Bonjour cannot find. One per line: the machine name, a space, then " + "its address. Example: MyLaptop 192.168.0.24" ) { TextEditor(text: $model.name2IPDraft) .font(.system(.body, design: .monospaced)) .frame(height: 110) .border(.separator) HStack { Button("Save mappings") { model.saveName2IP() } Spacer() } } SettingsSection("Connection rules") { SettingsToggle( "Validate remote machine IP", help: "Reverse DNS lookup to validate the machine's IP address.", isOn: model.binding(\.validateRemoteMachineIP)) SettingsToggle( "Same subnet only", help: "Only connect to machines in the same intranet NNN.NNN.*.* (only works " + "when both machines have IPv4 enabled).", isOn: model.binding(\.sameSubnetOnly)) } SettingsSection( "If nothing connects", note: "Both machines must use the same security key and port, must list each " + "other's host name in the device layout, and must be able to resolve that " + "name. macOS asks for permission the first time the app accepts an " + "incoming connection — allow it, or the listener never opens." ) { EmptyView() } } } }