Files
archived-libtailscale/swift/Examples/TailscaleKitHello/HelloFromTailscale/HelloView.swift
Jonathan Nobels d5a3c8e8ef swift, go.mod: adding localAPI support via SOCK5
updates tailscale/tailscale#13937

This adds localAPI support into TailscaleKit.  LocalAPI can now be queried
via the SOCK5 proxy on both MacOS and iOS.   This also fixes SOCKS5
support for iOS so you can simply apply our config to a URLSession.

This pulls in most of LocalAPI - though much of it is untested, it's based
on the implementation in tailscale/corp/xcode.

Unit tests pending.

Signed-off-by: Jonathan Nobels <jonathan@tailscale.com>
2025-04-25 11:55:09 -04:00

46 lines
1.1 KiB
Swift

// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause
import SwiftUI
struct HelloView: View {
@State var viewModel : HelloViewModel
let dialer: Dialer
init(dialer: Dialer, model: HelloModel) {
self.dialer = dialer
self.viewModel = HelloViewModel(model: model)
}
var body: some View {
VStack {
Text("TailscaleKit Sample App. See README.md for setup instructions.")
.font(.title3)
.padding(20)
Spacer(minLength: 5)
Text(viewModel.stateMessage)
Text(viewModel.peerCountMessage)
Spacer(minLength: 5)
Text(viewModel.message)
.font(.title3)
Button("Phone Home") {
viewModel.runRequest(dialer)
}
}
.padding()
}
}
actor PreviewDialer: Dialer {
func phoneHome(_ setMessage: @escaping @Sendable (String) async -> Void) async {
await setMessage("Hello from Preview!")
}
}
#Preview {
let d = PreviewDialer()
HelloView(dialer: d, model: HelloModel(logger: Logger()))
}