Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@
DEVELOPMENT_TEAM = W5364U7YZB;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES;
FRAMEWORK_SEARCH_PATHS = ../../build/Build;
FRAMEWORK_SEARCH_PATHS = "../../build/Build/**";
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = HelloFromTailscale/Info.plist;
INFOPLIST_KEY_NSHumanReadableCopyright = "";
Expand Down Expand Up @@ -407,7 +407,7 @@
DEVELOPMENT_TEAM = W5364U7YZB;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES;
FRAMEWORK_SEARCH_PATHS = ../../build/Build;
FRAMEWORK_SEARCH_PATHS = "../../build/Build/**";
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = HelloFromTailscale/Info.plist;
INFOPLIST_KEY_NSHumanReadableCopyright = "";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "2620"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES"
buildArchitectures = "Automatic">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "C2525FF02D7A70B700BD3CCA"
BuildableName = "HelloFromTailscale.app"
BlueprintName = "HelloFromTailscale"
ReferencedContainer = "container:TailscaleKitHello.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "C2525FF02D7A70B700BD3CCA"
BuildableName = "HelloFromTailscale.app"
BlueprintName = "HelloFromTailscale"
ReferencedContainer = "container:TailscaleKitHello.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "C2525FF02D7A70B700BD3CCA"
BuildableName = "HelloFromTailscale.app"
BlueprintName = "HelloFromTailscale"
ReferencedContainer = "container:TailscaleKitHello.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
2 changes: 1 addition & 1 deletion swift/TailscaleKit/LocalAPI/MessageProcessor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public class MessageProcessor: @unchecked Sendable {
await consumer.notify(notify)
}
} catch {
logger?.log("Failed to decode message: \(String(data: line, encoding: .utf8) ?? "nil")")
logger?.log("Failed to decode message: \(error.localizedDescription)")
}
}
}
Expand Down
19 changes: 6 additions & 13 deletions swift/TailscaleKit/LocalAPI/Types.swift
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ public struct IpnState: Sendable {
public var Addrs: [String]?
public var CurAddr: String?
public var Relay: String?
public var PeerRelay: String?
public var Online: Bool
public var ExitNode: Bool
public var ExitNodeOption: Bool
Expand Down Expand Up @@ -296,7 +297,7 @@ public struct IpnState: Sendable {
public var MagicDNSEnabled: Bool
}

struct PingResult: Codable, Sendable {
struct PingResult: Codable, Sendable {
public var IP: IP.Addr
public var Err: String
public var LatencySeconds: TimeInterval
Expand All @@ -308,7 +309,6 @@ public struct Netmap: Sendable {
public var SelfNode: Tailcfg.Node
public var NodeKey: Key.NodePublic
public var Peers: [Tailcfg.Node]?
public var Expiry: Time.Time
public var Domain: String
public var UserProfiles: [String: Tailcfg.UserProfile] // Keys are tailcfg.UserIDs thet get stringified
public var DNS: Tailcfg.DNSConfig?
Expand All @@ -321,18 +321,10 @@ public struct Netmap: Sendable {
return UserProfiles[String(id)]
}

public func isExpired() -> Bool {
if let expiryDate = Expiry.iso8601Date() {
return (expiryDate as NSDate).earlierDate(Date()) == expiryDate
}
return false
}

public static func == (lhs: Netmap.NetworkMap, rhs: Netmap.NetworkMap) -> Bool {
lhs.SelfNode == rhs.SelfNode &&
lhs.NodeKey == rhs.NodeKey &&
lhs.Peers == rhs.Peers &&
lhs.Expiry == rhs.Expiry &&
lhs.Domain == rhs.Domain &&
lhs.UserProfiles == rhs.UserProfiles &&
lhs.DNS == rhs.DNS
Expand Down Expand Up @@ -362,8 +354,7 @@ public struct Tailcfg: Sendable {
public var User: Tailcfg.UserID
public var Sharer: Tailcfg.UserID?
public var Key: Key.NodePublic
public var KeyExpiry: Time.Time
public var Machine: Tailcfg.MachineKey
public var KeyExpiry: Time.Time?
public var Addresses: [IP.Prefix]?
public var AllowedIPs: [IP.Prefix]?
public var Hostinfo: Hostinfo
Expand Down Expand Up @@ -408,7 +399,7 @@ public struct Tailcfg: Sendable {
return false
}

if let expiryDate = KeyExpiry.iso8601Date() {
if let expiryDate = KeyExpiry?.iso8601Date() {
return (expiryDate as NSDate).earlierDate(Date()) == expiryDate && !KeyDoesNotExpire
}

Expand Down Expand Up @@ -452,6 +443,7 @@ public struct Tailcfg: Sendable {
public struct NetworkProfile: Codable, Equatable, Sendable {
public var MagicDNSName: String?
public var DomainName: String?
public var DisplayName: String?
}

public struct DNSRecord: Codable, Sendable, Equatable {
Expand Down Expand Up @@ -504,3 +496,4 @@ struct GoError: Codable, Sendable, LocalizedError {
return Error
}
}

20 changes: 10 additions & 10 deletions swift/TailscaleKit/URLSession+Tailscale.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
import UIKit
#endif

import Network

public extension URLSessionConfiguration {

/// Adds the a connectionProxyDictionary to a URLSessionConfiguration to
/// Adds the a ProxyConfiguration to a URLSessionConfiguration to
/// proxy all requests through the given TailscaleNode.
///
/// This can also be use to make requests to LocalAPI. See LocalAPIClient
Expand All @@ -19,17 +21,15 @@ public extension URLSessionConfiguration {
throw TailscaleError.invalidProxyAddress
}

let endpoint = NWEndpoint.hostPort(host: NWEndpoint.Host(ip),
port: NWEndpoint.Port(rawValue: UInt16(port))!)

let sessionProxyConfig = ProxyConfiguration(socksv5Proxy: endpoint)
sessionProxyConfig.applyCredential(username: "tsnet", password:
proxyConfig.proxyCredential)

let config: [CFString: Any] = [
kCFProxyTypeKey: kCFProxyTypeSOCKS,
kCFProxyUsernameKey: "tsnet",
kCFProxyPasswordKey: proxyConfig.proxyCredential,
kCFProxyHostNameKey: ip,
kCFProxyPortNumberKey: port
]
self.proxyConfigurations = [sessionProxyConfig]

self.connectionProxyDictionary = config

return proxyConfig
}

Expand Down