Skip to content
This repository has been archived by the owner on Apr 16, 2020. It is now read-only.

Commit

Permalink
Update for Xcode 10
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuhaow committed Sep 18, 2018
1 parent 0ef88c0 commit e621175
Show file tree
Hide file tree
Showing 32 changed files with 97 additions and 84 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
All notable changes to this project will be documented in this file.
I will do my best to guarantee that this project adheres to [Semantic Versioning](http://semver.org/) after 1.0.0, but please do read change log before updating.

## 0.13.0

### Fixed
- Build on Xcode 10

## 0.12.7

### Fixed
Expand Down
8 changes: 4 additions & 4 deletions Cartfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
github "robbiehanson/CocoaAsyncSocket" ~> 7.6.2
github "CocoaLumberjack/CocoaLumberjack" ~> 3.2.1
github "lexrus/MMDB-Swift" "0.2.8"
github "robbiehanson/CocoaAsyncSocket" ~> 7.6.3
github "CocoaLumberjack/CocoaLumberjack" ~> 3.4.2
github "lexrus/MMDB-Swift" "0.2.9"
github "zhuhaow/Sodium-framework" "v1.0.10.1"
github "zhuhaow/YamlSwift" "master"
github "behrang/YamlSwift" "3.4.3"
github "zhuhaow/tun2socks" ~> 0.6.0
github "zhuhaow/Resolver" ~> 0.1.3
4 changes: 2 additions & 2 deletions Cartfile.private
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github "Quick/Quick" "v1.1.0"
github "Quick/Nimble" "v7.0.1"
github "Quick/Quick" "v1.3.1"
github "Quick/Nimble" "v7.3.0"
12 changes: 6 additions & 6 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
github "CocoaLumberjack/CocoaLumberjack" "3.4.0"
github "Quick/Nimble" "v7.0.1"
github "Quick/Quick" "v1.1.0"
github "lexrus/MMDB-Swift" "0.2.7"
github "robbiehanson/CocoaAsyncSocket" "7.6.2"
github "CocoaLumberjack/CocoaLumberjack" "3.4.2"
github "Quick/Nimble" "v7.3.0"
github "Quick/Quick" "v1.3.1"
github "behrang/YamlSwift" "3.4.3"
github "lexrus/MMDB-Swift" "0.2.9"
github "robbiehanson/CocoaAsyncSocket" "7.6.3"
github "zhuhaow/Resolver" "0.1.3"
github "zhuhaow/Sodium-framework" "v1.0.10.1"
github "zhuhaow/YamlSwift" "3e880fee0e68653f8304392cf0a9b7fc4b376a38"
github "zhuhaow/tun2socks" "0.6.1"
38 changes: 19 additions & 19 deletions NEKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1227,24 +1227,24 @@
TargetAttributes = {
362347121D7D44E700A047DE = {
CreatedOnToolsVersion = 7.3.1;
LastSwiftMigration = 0810;
LastSwiftMigration = 1000;
};
362347211D7D458E00A047DE = {
CreatedOnToolsVersion = 7.3.1;
LastSwiftMigration = 0900;
LastSwiftMigration = "";
};
36463A2F1CDCD5EB0040579C = {
CreatedOnToolsVersion = 7.3;
LastSwiftMigration = 0810;
LastSwiftMigration = 1000;
ProvisioningStyle = Automatic;
};
36A719971D5EEB4900DC35F5 = {
CreatedOnToolsVersion = 7.3.1;
LastSwiftMigration = 0810;
LastSwiftMigration = 1000;
};
36C48D4C1CF88DED0071804F = {
CreatedOnToolsVersion = 7.3.1;
LastSwiftMigration = 0900;
LastSwiftMigration = "";
ProvisioningStyle = Automatic;
};
};
Expand Down Expand Up @@ -1693,7 +1693,7 @@
PRODUCT_BUNDLE_IDENTIFIER = me.zhuhaow.NEKit.Test;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand All @@ -1711,7 +1711,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = me.zhuhaow.NEKit.Test;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand All @@ -1732,8 +1732,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand All @@ -1753,8 +1752,7 @@
PRODUCT_BUNDLE_IDENTIFIER = me.zhuhaow.NEKit.Test;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
VALIDATE_PRODUCT = YES;
};
name = Release;
Expand Down Expand Up @@ -1916,7 +1914,8 @@
PRODUCT_NAME = "$(PROJECT_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand Down Expand Up @@ -1944,7 +1943,8 @@
PRODUCT_BUNDLE_IDENTIFIER = me.zhuhaow.NEKit;
PRODUCT_NAME = "$(PROJECT_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand All @@ -1963,7 +1963,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = me.zhuhaow.osx.NEKitDemo;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand All @@ -1982,7 +1983,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = me.zhuhaow.osx.NEKitDemo;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand Down Expand Up @@ -2015,8 +2017,7 @@
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand Down Expand Up @@ -2046,8 +2047,7 @@
PRODUCT_NAME = "$(PROJECT_NAME)";
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
Expand Down
3 changes: 2 additions & 1 deletion src/Crypto/CryptoHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ public struct CryptoHelper {

public static func getIV(_ methodType: CryptoAlgorithm) -> Data {
var IV = Data(count: getIVLength(methodType))
let c = IV.count
_ = IV.withUnsafeMutableBytes {
SecRandomCopyBytes(kSecRandomDefault, IV.count, $0)
SecRandomCopyBytes(kSecRandomDefault, c, $0)
}
return IV
}
Expand Down
2 changes: 1 addition & 1 deletion src/Crypto/Libsodium.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Sodium

open class Libsodium {
/// This must be accessed at least once before Libsodium is used.
open static let initialized: Bool = {
public static let initialized: Bool = {
// this is loaded lasily and also thread-safe
_ = sodium_init()
return true
Expand Down
12 changes: 7 additions & 5 deletions src/Crypto/SodiumStreamCrypto.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ open class SodiumStreamCrypto: StreamCryptoProtocol {
case chacha20, salsa20
}

open let key: Data
open let iv: Data
open let algorithm: Alogrithm
public let key: Data
public let iv: Data
public let algorithm: Alogrithm

var counter = 0

Expand Down Expand Up @@ -38,19 +38,21 @@ open class SodiumStreamCrypto: StreamCryptoProtocol {

switch algorithm {
case .chacha20:
let c = UInt64(outputData.count)
_ = outputData.withUnsafeMutableBytes { outputPtr in
iv.withUnsafeBytes { ivPtr in
key.withUnsafeBytes { keyPtr in
crypto_stream_chacha20_xor_ic(outputPtr, outputPtr, UInt64(outputData.count), ivPtr, UInt64(counter/blockSize), keyPtr)
crypto_stream_chacha20_xor_ic(outputPtr, outputPtr, c, ivPtr, UInt64(counter/blockSize), keyPtr)
}
}
}

case .salsa20:
let c = UInt64(outputData.count)
_ = outputData.withUnsafeMutableBytes { outputPtr in
iv.withUnsafeBytes { ivPtr in
key.withUnsafeBytes { keyPtr in
crypto_stream_salsa20_xor_ic(outputPtr, outputPtr, UInt64(outputData.count), ivPtr, UInt64(counter/blockSize), keyPtr)
crypto_stream_salsa20_xor_ic(outputPtr, outputPtr, c, ivPtr, UInt64(counter/blockSize), keyPtr)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Event/ObserverFactory.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Foundation

open class ObserverFactory {
open static var currentFactory: ObserverFactory?
public static var currentFactory: ObserverFactory?

public init() {}

Expand Down
4 changes: 2 additions & 2 deletions src/GeoIP/GeoIP.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import Foundation
import MMDB

open class GeoIP {
open static let database = MMDB()!
public static let database = MMDB()!

open static func LookUp(_ ipAddress: String) -> MMDBCountry? {
public static func LookUp(_ ipAddress: String) -> MMDBCountry? {
return GeoIP.database.lookup(ipAddress)
}
}
16 changes: 8 additions & 8 deletions src/IPStack/DNS/DNSMessage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,9 @@ open class DNSMessage {
}

open class DNSQuery {
open let name: String
open let type: DNSType
open let klass: DNSClass
public let name: String
public let type: DNSType
public let klass: DNSClass
let nameBytesLength: Int

init(name: String, type: DNSType = .a, klass: DNSClass = .internet) {
Expand Down Expand Up @@ -267,12 +267,12 @@ open class DNSQuery {
}

open class DNSResource {
open let name: String
open let type: DNSType
open let klass: DNSClass
open let TTL: UInt32
public let name: String
public let type: DNSType
public let klass: DNSClass
public let TTL: UInt32
let dataLength: UInt16
open let data: Data
public let data: Data

let nameBytesLength: Int

Expand Down
2 changes: 1 addition & 1 deletion src/IPStack/DNS/DNSResolver.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Foundation

public protocol DNSResolverProtocol: class {
weak var delegate: DNSResolverDelegate? { get set }
var delegate: DNSResolverDelegate? { get set }
func resolve(session: DNSSession)
func stop()
}
Expand Down
2 changes: 1 addition & 1 deletion src/IPStack/DNS/DNSServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ open class DNSServer: DNSResolverDelegate, IPStackProtocol {
/// Current DNS server.
///
/// - warning: There is at most one DNS server running at the same time. If a DNS server is registered to `TUNInterface` then it must also be set here.
open static var currentServer: DNSServer?
public static var currentServer: DNSServer?

/// The address of DNS server.
let serverAddress: IPAddress
Expand Down
2 changes: 1 addition & 1 deletion src/IPStack/DNS/DNSSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Foundation
import CocoaLumberjackSwift

open class DNSSession {
open let requestMessage: DNSMessage
public let requestMessage: DNSMessage
var requestIPPacket: IPPacket?
open var realIP: IPAddress?
open var fakeIP: IPAddress?
Expand Down
16 changes: 8 additions & 8 deletions src/IPStack/Packet/IPPacket.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ open class IPPacket {
- returns: The version of the packet. Returns `nil` if failed to parse the packet.
*/
open static func peekIPVersion(_ data: Data) -> IPVersion? {
public static func peekIPVersion(_ data: Data) -> IPVersion? {
guard data.count >= 20 else {
return nil
}
Expand All @@ -36,7 +36,7 @@ open class IPPacket {
- returns: The protocol of the packet. Returns `nil` if failed to parse the packet.
*/
open static func peekProtocol(_ data: Data) -> TransportProtocol? {
public static func peekProtocol(_ data: Data) -> TransportProtocol? {
guard data.count >= 20 else {
return nil
}
Expand All @@ -51,7 +51,7 @@ open class IPPacket {
- returns: The source IP address of the packet. Returns `nil` if failed to parse the packet.
*/
open static func peekSourceAddress(_ data: Data) -> IPAddress? {
public static func peekSourceAddress(_ data: Data) -> IPAddress? {
guard data.count >= 20 else {
return nil
}
Expand All @@ -66,7 +66,7 @@ open class IPPacket {
- returns: The destination IP address of the packet. Returns `nil` if failed to parse the packet.
*/
open static func peekDestinationAddress(_ data: Data) -> IPAddress? {
public static func peekDestinationAddress(_ data: Data) -> IPAddress? {
guard data.count >= 20 else {
return nil
}
Expand All @@ -83,7 +83,7 @@ open class IPPacket {
- note: Only TCP and UDP packet has port field.
*/
open static func peekSourcePort(_ data: Data) -> Port? {
public static func peekSourcePort(_ data: Data) -> Port? {
guard let proto = peekProtocol(data) else {
return nil
}
Expand Down Expand Up @@ -111,7 +111,7 @@ open class IPPacket {
- note: Only TCP and UDP packet has port field.
*/
open static func peekDestinationPort(_ data: Data) -> Port? {
public static func peekDestinationPort(_ data: Data) -> Port? {
guard let proto = peekProtocol(data) else {
return nil
}
Expand Down Expand Up @@ -242,7 +242,7 @@ open class IPPacket {
}
self.protocolParser = parser
default:
DDLogError("Can not parse packet header of type \(transportProtocol) yet")
DDLogError("Can not parse packet header of type \(String(describing: transportProtocol)) yet")
return nil
}
}
Expand All @@ -261,7 +261,7 @@ open class IPPacket {
}

func buildPacket() {
packetData = NSMutableData(length: Int(headerLength) + protocolParser.bytesLength) as Data!
packetData = NSMutableData(length: Int(headerLength) + protocolParser.bytesLength) as Data?

// set header
setPayloadWithUInt8(headerLength / 4 + version.rawValue << 4, at: 0)
Expand Down
2 changes: 1 addition & 1 deletion src/IPStack/TCPStack.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import CocoaLumberjackSwift
/// This class wraps around tun2socks to build a TCP only IP stack.
open class TCPStack: TSIPStackDelegate, IPStackProtocol {
/// The `TCPStack` singleton instance.
open static var stack: TCPStack {
public static var stack: TCPStack {
TSIPStack.stack.delegate = _stack
TSIPStack.stack.processQueue = QueueFactory.getQueue()
return _stack
Expand Down
2 changes: 1 addition & 1 deletion src/ProxyServer/GCDHTTPProxyServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public final class GCDHTTPProxyServer: GCDProxyServer {
- parameter socket: The accepted socket.
*/
override open func handleNewGCDSocket(_ socket: GCDTCPSocket) {
override public func handleNewGCDSocket(_ socket: GCDTCPSocket) {
let proxySocket = HTTPProxySocket(socket: socket)
didAcceptNewSocket(proxySocket)
}
Expand Down
Loading

0 comments on commit e621175

Please sign in to comment.