diff --git a/README.md b/README.md
index 29bb9f8..d9bbfa0 100644
--- a/README.md
+++ b/README.md
@@ -65,6 +65,8 @@ serves today.
While the server is running it exposes an OpenAI-compatible API at `http://localhost:8095/v1` (port configurable on the Run tab). Any client that speaks that API can point at it. For a quick start without any external tool, the engine also serves a built-in web chat page in the browser ("Built-in web chat page" toggle, on by default).
+Turn on "Serve on LAN" (Run tab) to let other machines on your network connect: the server binds every interface and the title bar shows this Mac's LAN address to copy. There is no API key — anyone on the network can use the model, so use it on a trusted network. macOS may prompt to allow incoming connections for the Splash engine the first time.
+
## Building from source
Requires the Swift 6.2 toolchain (Xcode 26 or the standalone toolchain).
diff --git a/Sources/SplashGUI/Core/AppConfig.swift b/Sources/SplashGUI/Core/AppConfig.swift
index d8ece17..a894527 100644
--- a/Sources/SplashGUI/Core/AppConfig.swift
+++ b/Sources/SplashGUI/Core/AppConfig.swift
@@ -13,6 +13,9 @@ struct RunConfig: Codable, Equatable {
var languageOnly: Bool = false
var decodeShare: Double = 0.5
var showWebUI: Bool = true
+ // Bind every IPv4 interface (0.0.0.0) so other machines on the LAN can connect.
+ // Off leaves the engine's 127.0.0.1 default: this Mac only.
+ var lanAccess: Bool = false
var defaultReasoningEffort: String? = nil
// How long the engine keeps its memory wired without a request. Its own default is 10m:
// the first request after an idle minute pays a weight restore and a slower first prefill,
@@ -32,7 +35,7 @@ struct RunConfig: Codable, Equatable {
// per-model profiles with it — back to factory defaults.
enum CodingKeys: String, CodingKey {
case modelID, port, auto, maxContext, maxMemory, kvFormat, maxCacheDisk
- case languageOnly, decodeShare, showWebUI, defaultReasoningEffort
+ case languageOnly, decodeShare, showWebUI, lanAccess, defaultReasoningEffort
case idleRelease, persistentCache, schemaVersion
}
@@ -49,6 +52,7 @@ struct RunConfig: Codable, Equatable {
languageOnly = try c.decodeIfPresent(Bool.self, forKey: .languageOnly) ?? d.languageOnly
decodeShare = try c.decodeIfPresent(Double.self, forKey: .decodeShare) ?? d.decodeShare
showWebUI = try c.decodeIfPresent(Bool.self, forKey: .showWebUI) ?? d.showWebUI
+ lanAccess = try c.decodeIfPresent(Bool.self, forKey: .lanAccess) ?? d.lanAccess
defaultReasoningEffort = try c.decodeIfPresent(String.self, forKey: .defaultReasoningEffort)
?? d.defaultReasoningEffort
idleRelease = try c.decodeIfPresent(String.self, forKey: .idleRelease) ?? d.idleRelease
diff --git a/Sources/SplashGUI/Core/MachineInfo.swift b/Sources/SplashGUI/Core/MachineInfo.swift
index a52c68e..ba87ebd 100644
--- a/Sources/SplashGUI/Core/MachineInfo.swift
+++ b/Sources/SplashGUI/Core/MachineInfo.swift
@@ -62,6 +62,37 @@ enum MachineInfo {
return (attrs[.systemFreeSize] as? Int64).map(Int.init)
}
+ // The address to hand LAN clients: IPv4 on an active non-loopback interface, preferring
+ // en0 (the built-in Wi-Fi on every Apple Silicon Mac), then any other "en*" (Thunderbolt
+ // Ethernet/docks), then anything else. Skips link-local 169.254.x addresses — those mean
+ // "no DHCP lease", so nothing off this Mac can reach them.
+ static var lanIPv4Address: String? {
+ var ifaddrPtr: UnsafeMutablePointer<ifaddrs>?
+ guard getifaddrs(&ifaddrPtr) == 0 else { return nil }
+ defer { freeifaddrs(ifaddrPtr) }
+ var en0: String?
+ var otherEn: String?
+ var any: String?
+ var ptr = ifaddrPtr
+ while let cur = ptr {
+ defer { ptr = cur.pointee.ifa_next }
+ guard let addr = cur.pointee.ifa_addr, addr.pointee.sa_family == UInt8(AF_INET) else { continue }
+ let flags = Int32(cur.pointee.ifa_flags)
+ guard flags & IFF_UP != 0, flags & IFF_RUNNING != 0, flags & IFF_LOOPBACK == 0 else { continue }
+ var host = [CChar](repeating: 0, count: Int(NI_MAXHOST))
+ let ok = getnameinfo(addr, socklen_t(addr.pointee.sa_len),
+ &host, socklen_t(host.count), nil, 0, NI_NUMERICHOST)
+ guard ok == 0 else { continue }
+ let ip = String(cString: host)
+ guard !ip.hasPrefix("169.254.") else { continue }
+ let name = String(cString: cur.pointee.ifa_name)
+ if name == "en0" { en0 = ip; break }
+ if name.hasPrefix("en"), otherEn == nil { otherEn = ip }
+ if any == nil { any = ip }
+ }
+ return en0 ?? otherEn ?? any
+ }
+
static func footprint(pid: Int) -> Int? {
var info = rusage_info_current()
let r = withUnsafeMutableBytes(of: &info) { rawBuf in
diff --git a/Sources/SplashGUI/Core/SplashServer.swift b/Sources/SplashGUI/Core/SplashServer.swift
index da4b08c..3ede59a 100644
--- a/Sources/SplashGUI/Core/SplashServer.swift
+++ b/Sources/SplashGUI/Core/SplashServer.swift
@@ -189,6 +189,9 @@ final class SplashServer {
static func buildArguments(for config: RunConfig, revision: String? = nil) -> [String] {
var args = ["serve", "--model", config.modelID, "--port", String(config.port)]
+ // LAN serving: bind every IPv4 interface. The engine accepts IP-address Host headers
+ // by default, so no --allowed-host is needed for clients connecting by address.
+ if config.lanAccess { args += ["--host", "0.0.0.0"] }
// A catalog entry pins an exact HF commit, so the pull is reproducible and a later
// re-upload under the same name cannot change what this Mac loads.
if let revision, !revision.isEmpty { args += ["--revision", revision] }
diff --git a/Sources/SplashGUI/Views/RootView.swift b/Sources/SplashGUI/Views/RootView.swift
index ae5044b..9444469 100644
--- a/Sources/SplashGUI/Views/RootView.swift
+++ b/Sources/SplashGUI/Views/RootView.swift
@@ -142,7 +142,11 @@ struct RootView: View {
let m = model.effectiveModel ?? model.effectiveModelID
// The port the server is actually on, not the (possibly edited) toolbar field.
if let launched = model.launchedRunConfig {
- return "Ready · \(m) on 127.0.0.1:" + String(launched.port)
+ // A LAN bind still answers loopback; show the LAN address because that's the
+ // one worth reading here, falling back to loopback while none is leased.
+ let host = launched.lanAccess
+ ? (MachineInfo.lanIPv4Address ?? "127.0.0.1") : "127.0.0.1"
+ return "Ready · \(m) on " + host + ":" + String(launched.port)
}
return "Ready · \(m)"
case .stopping: return "Stopping…"
diff --git a/Sources/SplashGUI/Views/RunTab.swift b/Sources/SplashGUI/Views/RunTab.swift
index 54f0e5e..e5de77c 100644
--- a/Sources/SplashGUI/Views/RunTab.swift
+++ b/Sources/SplashGUI/Views/RunTab.swift
@@ -198,6 +198,20 @@ struct RunTab: View {
}
Spacer()
}
+ Toggle("Serve on LAN", isOn: $model.config.run.lanAccess)
+ .help("Let other machines on your network connect: the server binds every network interface instead of this Mac only. Restart to apply. The API has no key — anyone on the network can use the model and the chat page. macOS may ask you to allow incoming connections for the Splash engine. This Mac keeps connecting over 127.0.0.1 either way.")
+ if model.config.run.lanAccess {
+ HStack(spacing: 6) {
+ Text("Other machines connect to")
+ .font(.caption)
+ .foregroundStyle(.secondary)
+ Text("http://" + (MachineInfo.lanIPv4Address ?? "no leased address") + ":"
+ + String(model.config.run.port) + "/v1")
+ .font(.system(.caption, design: .monospaced))
+ .textSelection(.enabled)
+ Spacer()
+ }
+ }
}
}
diff --git a/Sources/SplashGUI/Views/StatusWidgets.swift b/Sources/SplashGUI/Views/StatusWidgets.swift
index 25d3bcc..39c69d3 100644
--- a/Sources/SplashGUI/Views/StatusWidgets.swift
+++ b/Sources/SplashGUI/Views/StatusWidgets.swift
@@ -48,9 +48,9 @@ struct ServerToolbarControls: View {
StageChipsRow(flexibleWidth: false)
.fixedSize(horizontal: true, vertical: false)
HStack(spacing: 6) {
- Text("http://127.0.0.1:")
+ Text("http://" + endpointHost + ":")
.font(.system(.caption, design: .monospaced))
- .help("The endpoint other services connect to. OpenAI-compatible API under /v1, Anthropic under /v1/messages.")
+ .help("The endpoint other services connect to. OpenAI-compatible API under /v1, Anthropic under /v1/messages. With “Serve on LAN” on (Run tab) this shows this Mac's LAN address so you can copy it for other machines; 0.0.0.0 means the toggle is on but no network is leased yet.")
// String ports: Text interpolation of an Int applies locale number formatting,
// which grouped the port as "8,095".
TextField("", value: $model.config.run.port, format: .number.grouping(.never))
@@ -86,7 +86,16 @@ struct ServerToolbarControls: View {
}
}
- private var endpoint: String { "http://127.0.0.1:" + String(model.config.run.port) }
+ // The toolbar host follows the (possibly edited) toggle, the way the port field follows
+ // the edited port: the LAN address once "Serve on LAN" is on, loopback otherwise.
+ private var endpointHost: String {
+ if model.config.run.lanAccess {
+ return MachineInfo.lanIPv4Address ?? "0.0.0.0"
+ }
+ return "127.0.0.1"
+ }
+
+ private var endpoint: String { "http://" + endpointHost + ":" + String(model.config.run.port) }
// One slot, switched in place: the engine install / model load progress while getting to
// ready, the KV context gauge once ready, and the plain server state with an empty gauge
diff --git a/scripts/profile-test/main.swift b/scripts/profile-test/main.swift
index b014f87..b282cf2 100644
--- a/scripts/profile-test/main.swift
+++ b/scripts/profile-test/main.swift
@@ -131,6 +131,34 @@ func runTests() {
off.maxCacheDisk = "auto"
check("auto leaves the SSD quota to the engine", !SplashServer.buildArguments(for: off).contains("--max-cache-disk"))
+ // F2: LAN serving. --host goes to the engine only when the toggle is on, and a config
+ // written before the toggle existed must decode it defaulted, not throw (the Codable trap).
+ check("loopback default: no --host on the command line",
+ !SplashServer.buildArguments(for: RunConfig()).contains("--host"))
+ var lan = RunConfig()
+ lan.lanAccess = true
+ let lanArgs = SplashServer.buildArguments(for: lan)
+ check("LAN on: --host 0.0.0.0 reaches the engine",
+ lanArgs.firstIndex(of: "--host").map { $0 + 1 < lanArgs.count && lanArgs[$0 + 1] == "0.0.0.0" } == true,
+ lanArgs.joined(separator: " "))
+ let noLan = #"{"run":{"port":8123,"modelID":"someone/Model:x"}}"#
+ if let nd = noLan.data(using: .utf8),
+ let ncfg = try? JSONDecoder().decode(AppConfig.self, from: nd) {
+ check("lanAccess absent decodes false without losing the config",
+ ncfg.run.lanAccess == false && ncfg.run.port == 8123
+ && ncfg.run.modelID == "someone/Model:x")
+ } else {
+ check("lanAccess absent decodes false without losing the config", false, "decoder threw")
+ }
+ var lcfg = AppConfig()
+ lcfg.run.lanAccess = true
+ if let ld = try? JSONEncoder().encode(lcfg),
+ let lback = try? JSONDecoder().decode(AppConfig.self, from: ld) {
+ check("lanAccess round-trips through a save", lback.run.lanAccess == true)
+ } else {
+ check("lanAccess round-trips through a save", false, "encode/decode threw")
+ }
+
// I: the Auto switch resolves the four covered fields at launch.
let prof = AutoProfile(maxMemoryBytes: 40_000_000_000, contextTokens: 131_072, kvFormat: "int8")
var arun = RunConfig() // shipped default: Auto on
Add Serve on LAN toggle: bind 0.0.0.0, show the LAN address in endpoint displays
Run tab toggle (RunConfig.lanAccess, default off) appends --host 0.0.0.0 to the serve line; off leaves the engine's 127.0.0.1 default. The engine accepts IP-address Host headers without --allowed-host, so one flag suffices; no API key by design (manual toggle, trusted LAN). Toolbar endpoint label, copy button and the footer show MachineInfo.lanIPv4Address (getifaddrs, en0 first, skips link-local) while LAN is on; the Run tab prints the copyable /v1 URL. Loopback keeps working, so probes, adopt, the chat button and the Provider tab's client configs are unchanged. Harness 88 -> 92 checks (F2 section).
1f43bbfca6ce56731d678d456977755468d2daf6
cjosie <administrator@josie-c.com> · 2026-11-02T19:03 ·
browse files at this commit
parents:
115bd55