]> git.ipfire.org Git - thirdparty/wireguard-apple.git/commitdiff
WireGuardKit: Set public access level for shared structs
authorAndrej Mihajlov <and@mullvad.net>
Thu, 5 Nov 2020 11:23:06 +0000 (12:23 +0100)
committerAndrej Mihajlov <and@mullvad.net>
Wed, 2 Dec 2020 10:08:08 +0000 (11:08 +0100)
Signed-off-by: Andrej Mihajlov <and@mullvad.net>
WireGuardKit/Sources/WireGuardKit/DNSServer.swift
WireGuardKit/Sources/WireGuardKit/Endpoint.swift
WireGuardKit/Sources/WireGuardKit/IPAddressRange.swift
WireGuardKit/Sources/WireGuardKit/InterfaceConfiguration.swift
WireGuardKit/Sources/WireGuardKit/PeerConfiguration.swift
WireGuardKit/Sources/WireGuardKit/TunnelConfiguration.swift

index 0d03577fa1780b80bae5def30ff437a050d7d0e1..b1a2401e5f5f59b83693897e166b3fd013791b91 100644 (file)
@@ -4,26 +4,26 @@
 import Foundation
 import Network
 
-struct DNSServer {
-    let address: IPAddress
+public struct DNSServer {
+    public let address: IPAddress
 
-    init(address: IPAddress) {
+    public init(address: IPAddress) {
         self.address = address
     }
 }
 
 extension DNSServer: Equatable {
-    static func == (lhs: DNSServer, rhs: DNSServer) -> Bool {
+    public static func == (lhs: DNSServer, rhs: DNSServer) -> Bool {
         return lhs.address.rawValue == rhs.address.rawValue
     }
 }
 
 extension DNSServer {
-    var stringRepresentation: String {
+    public var stringRepresentation: String {
         return "\(address)"
     }
 
-    init?(from addressString: String) {
+    public init?(from addressString: String) {
         if let addr = IPv4Address(addressString) {
             address = addr
         } else if let addr = IPv6Address(addressString) {
index dad59617f53c0ded3114a18f2831f7fb72f62768..07529e38f9c8a7b7e1cb478a7af9f54c19076d85 100644 (file)
@@ -4,31 +4,31 @@
 import Foundation
 import Network
 
-struct Endpoint {
-    let host: NWEndpoint.Host
-    let port: NWEndpoint.Port
+public struct Endpoint {
+    public let host: NWEndpoint.Host
+    public let port: NWEndpoint.Port
 
-    init(host: NWEndpoint.Host, port: NWEndpoint.Port) {
+    public init(host: NWEndpoint.Host, port: NWEndpoint.Port) {
         self.host = host
         self.port = port
     }
 }
 
 extension Endpoint: Equatable {
-    static func == (lhs: Endpoint, rhs: Endpoint) -> Bool {
+    public static func == (lhs: Endpoint, rhs: Endpoint) -> Bool {
         return lhs.host == rhs.host && lhs.port == rhs.port
     }
 }
 
 extension Endpoint: Hashable {
-    func hash(into hasher: inout Hasher) {
+    public func hash(into hasher: inout Hasher) {
         hasher.combine(host)
         hasher.combine(port)
     }
 }
 
 extension Endpoint {
-    var stringRepresentation: String {
+    public var stringRepresentation: String {
         switch host {
         case .name(let hostname, _):
             return "\(hostname):\(port)"
@@ -41,7 +41,7 @@ extension Endpoint {
         }
     }
 
-    init?(from string: String) {
+    public init?(from string: String) {
         // Separation of host and port is based on 'parse_endpoint' function in
         // https://git.zx2c4.com/wireguard-tools/tree/src/config.c
         guard !string.isEmpty else { return nil }
@@ -72,7 +72,7 @@ extension Endpoint {
 }
 
 extension Endpoint {
-    func hasHostAsIPAddress() -> Bool {
+    public func hasHostAsIPAddress() -> Bool {
         switch host {
         case .name:
             return false
@@ -85,7 +85,7 @@ extension Endpoint {
         }
     }
 
-    func hostname() -> String? {
+    public func hostname() -> String? {
         switch host {
         case .name(let hostname, _):
             return hostname
index d38686c1407a455d39cdfebd2f8c9ab73bc85c67..c65ff1df4dfa85c131bc9cafe1be444e66c67479 100644 (file)
@@ -4,9 +4,9 @@
 import Foundation
 import Network
 
-struct IPAddressRange {
-    let address: IPAddress
-    var networkPrefixLength: UInt8
+public struct IPAddressRange {
+    public let address: IPAddress
+    public let networkPrefixLength: UInt8
 
     init(address: IPAddress, networkPrefixLength: UInt8) {
         self.address = address
@@ -15,24 +15,24 @@ struct IPAddressRange {
 }
 
 extension IPAddressRange: Equatable {
-    static func == (lhs: IPAddressRange, rhs: IPAddressRange) -> Bool {
+    public static func == (lhs: IPAddressRange, rhs: IPAddressRange) -> Bool {
         return lhs.address.rawValue == rhs.address.rawValue && lhs.networkPrefixLength == rhs.networkPrefixLength
     }
 }
 
 extension IPAddressRange: Hashable {
-    func hash(into hasher: inout Hasher) {
+    public func hash(into hasher: inout Hasher) {
         hasher.combine(address.rawValue)
         hasher.combine(networkPrefixLength)
     }
 }
 
 extension IPAddressRange {
-    var stringRepresentation: String {
+    public var stringRepresentation: String {
         return "\(address)/\(networkPrefixLength)"
     }
 
-    init?(from string: String) {
+    public init?(from string: String) {
         guard let parsed = IPAddressRange.parseAddressString(string) else { return nil }
         address = parsed.0
         networkPrefixLength = parsed.1
index d80ed895f39503ce499cc6c72774db4ee011175d..16a904626a7c9440ca15c9a6768dd1a73f7afec6 100644 (file)
@@ -4,14 +4,14 @@
 import Foundation
 import Network
 
-struct InterfaceConfiguration {
-    var privateKey: Data
-    var addresses = [IPAddressRange]()
-    var listenPort: UInt16?
-    var mtu: UInt16?
-    var dns = [DNSServer]()
+public struct InterfaceConfiguration {
+    public var privateKey: Data
+    public var addresses = [IPAddressRange]()
+    public var listenPort: UInt16?
+    public var mtu: UInt16?
+    public var dns = [DNSServer]()
 
-    init(privateKey: Data) {
+    public init(privateKey: Data) {
         if privateKey.count != TunnelConfiguration.keyLength {
             fatalError("Invalid private key")
         }
@@ -20,7 +20,7 @@ struct InterfaceConfiguration {
 }
 
 extension InterfaceConfiguration: Equatable {
-    static func == (lhs: InterfaceConfiguration, rhs: InterfaceConfiguration) -> Bool {
+    public static func == (lhs: InterfaceConfiguration, rhs: InterfaceConfiguration) -> Bool {
         let lhsAddresses = lhs.addresses.filter { $0.address is IPv4Address } + lhs.addresses.filter { $0.address is IPv6Address }
         let rhsAddresses = rhs.addresses.filter { $0.address is IPv4Address } + rhs.addresses.filter { $0.address is IPv6Address }
 
index 7fd3f87e856e0226889f56829f3ca3dccf688859..4d92dc6fcaf6b084efede3029e591a159be27b0a 100644 (file)
@@ -3,9 +3,9 @@
 
 import Foundation
 
-struct PeerConfiguration {
-    var publicKey: Data
-    var preSharedKey: Data? {
+public struct PeerConfiguration {
+    public var publicKey: Data
+    public var preSharedKey: Data? {
         didSet(value) {
             if let value = value {
                 if value.count != TunnelConfiguration.keyLength {
@@ -14,14 +14,14 @@ struct PeerConfiguration {
             }
         }
     }
-    var allowedIPs = [IPAddressRange]()
-    var endpoint: Endpoint?
-    var persistentKeepAlive: UInt16?
-    var rxBytes: UInt64?
-    var txBytes: UInt64?
-    var lastHandshakeTime: Date?
+    public var allowedIPs = [IPAddressRange]()
+    public var endpoint: Endpoint?
+    public var persistentKeepAlive: UInt16?
+    public var rxBytes: UInt64?
+    public var txBytes: UInt64?
+    public var lastHandshakeTime: Date?
 
-    init(publicKey: Data) {
+    public init(publicKey: Data) {
         self.publicKey = publicKey
         if publicKey.count != TunnelConfiguration.keyLength {
             fatalError("Invalid public key")
@@ -30,7 +30,7 @@ struct PeerConfiguration {
 }
 
 extension PeerConfiguration: Equatable {
-    static func == (lhs: PeerConfiguration, rhs: PeerConfiguration) -> Bool {
+    public static func == (lhs: PeerConfiguration, rhs: PeerConfiguration) -> Bool {
         return lhs.publicKey == rhs.publicKey &&
             lhs.preSharedKey == rhs.preSharedKey &&
             Set(lhs.allowedIPs) == Set(rhs.allowedIPs) &&
@@ -40,7 +40,7 @@ extension PeerConfiguration: Equatable {
 }
 
 extension PeerConfiguration: Hashable {
-    func hash(into hasher: inout Hasher) {
+    public func hash(into hasher: inout Hasher) {
         hasher.combine(publicKey)
         hasher.combine(preSharedKey)
         hasher.combine(Set(allowedIPs))
index 5a8f7df5af50b2bd0096d3888bf145c3bdedd150..b1ca442404dae8f2e18dbaec3d11465aa1b9d68d 100644 (file)
@@ -3,14 +3,14 @@
 
 import Foundation
 
-final class TunnelConfiguration {
-    var name: String?
-    var interface: InterfaceConfiguration
-    let peers: [PeerConfiguration]
+public final class TunnelConfiguration {
+    public var name: String?
+    public var interface: InterfaceConfiguration
+    public let peers: [PeerConfiguration]
 
-    static let keyLength = 32
+    public static let keyLength = 32
 
-    init(name: String?, interface: InterfaceConfiguration, peers: [PeerConfiguration]) {
+    public init(name: String?, interface: InterfaceConfiguration, peers: [PeerConfiguration]) {
         self.interface = interface
         self.peers = peers
         self.name = name
@@ -24,7 +24,7 @@ final class TunnelConfiguration {
 }
 
 extension TunnelConfiguration: Equatable {
-    static func == (lhs: TunnelConfiguration, rhs: TunnelConfiguration) -> Bool {
+    public static func == (lhs: TunnelConfiguration, rhs: TunnelConfiguration) -> Bool {
         return lhs.name == rhs.name &&
             lhs.interface == rhs.interface &&
             Set(lhs.peers) == Set(rhs.peers)