text stringlengths 9 39.2M | dir stringlengths 25 226 | lang stringclasses 163
values | created_date timestamp[s] | updated_date timestamp[s] | repo_name stringclasses 751
values | repo_full_name stringclasses 752
values | star int64 1.01k 183k | len_tokens int64 1 18.5M |
|---|---|---|---|---|---|---|---|---|
```unknown
github "CocoaLumberjack/CocoaLumberjack" "3.6.0"
github "Quick/Nimble" "v8.0.5"
github "Quick/Quick" "v2.2.0"
github "behrang/YamlSwift" "3.4.3"
github "lexrus/MMDB-Swift" "0.5.0"
github "robbiehanson/CocoaAsyncSocket" "7.6.3"
github "zhuhaow/Resolver" "0.2.0"
github "zhuhaow/Sodium-framework" "v1.0.10.1"
gi... | /content/code_sandbox/Cartfile.resolved | unknown | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 156 |
```yaml
engines:
fixme:
enabled: true
tailor:
enabled: true
ratings:
paths:
- "**.swift"
exclude_paths:
- "NEKit.xcodeproj/"
- "README.md"
``` | /content/code_sandbox/.codeclimate.yml | yaml | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 50 |
```swift
import Foundation
let verbose = true
// MARK: - Exception Handling
let handler: @convention(c) (NSException) -> Void = {
exception in
print("FATAL EXCEPTION: \(exception)")
exit(1)
}
NSSetUncaughtExceptionHandler(handler)
// MARK: - Task Utilities
func runShellCommand(command: String) -> String?... | /content/code_sandbox/GenerateCommonCryptoModule.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 956 |
```unknown
github "robbiehanson/CocoaAsyncSocket" ~> 7.6.3
github "CocoaLumberjack/CocoaLumberjack" ~> 3.5.2
github "lexrus/MMDB-Swift" "0.5.0"
github "zhuhaow/Sodium-framework" "v1.0.10.1"
github "behrang/YamlSwift" "3.4.3"
github "zhuhaow/tun2socks" ~> 0.7.0
github "zhuhaow/Resolver" ~> 0.2.0
``` | /content/code_sandbox/Cartfile | unknown | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 131 |
```unknown
github "Quick/Quick" "v2.2.0"
github "Quick/Nimble" "v8.0.5"
``` | /content/code_sandbox/Cartfile.private | unknown | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 30 |
```yaml
disabled_rules:
- line_length
- type_name
- variable_name
- cyclomatic_complexity
- nesting
excluded:
- Carthage
- tun2socks
- test
``` | /content/code_sandbox/.swiftlint.yml | yaml | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 45 |
```xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "path_to_url">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_... | /content/code_sandbox/NEKitTests-iOS/Info.plist | xml | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 228 |
```swift
import Cocoa
import NEKit
import CocoaLumberjackSwift
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
@IBOutlet weak var window: NSWindow!
var httpProxy: GCDHTTPProxyServer?
var socks5Proxy: GCDSOCKS5ProxyServer?
func applicationDidFinishLaunching(_ aNotification: Not... | /content/code_sandbox/NEKitDemo/AppDelegate.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 309 |
```xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "path_to_url">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIconFile</key>
<string></string>
<... | /content/code_sandbox/NEKitDemo/Info.plist | xml | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 305 |
```yaml
output: "."
source_directory: ../
author: Zhuhao Wang
readme: ../README.md
github_url: path_to_url
min_acl: internal
module: NEKit
theme: fullwidth
custom_categories:
- name: Proxy Server
children:
- ProxyServer
- GCDProxyServer
- GCDSOCKS5ProxyServer
- GCDHTTPProxyServer
- n... | /content/code_sandbox/.jazzy.yaml | yaml | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 772 |
```objective-c
#import <UIKit/UIKit.h>
//! Project version number for NEKit-iOS.
FOUNDATION_EXPORT double NEKit_iOS;
//! Project version string for NEKit_iOS.
FOUNDATION_EXPORT const unsigned char NEKit_iOSVersionString[];
// In this header, you should import all the public headers of your framework using statements... | /content/code_sandbox/NEKit-iOS/NEKit-iOS.h | objective-c | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 76 |
```xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "path_to_url">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_... | /content/code_sandbox/NEKit-iOS/Info.plist | xml | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 248 |
```swift
import Quick
import Nimble
@testable import NEKit
class IPRangeSpec: QuickSpec {
override func spec() {
let cidrWrongSamples = [
("127.0.0.132", IPRangeError.invalidCIDRFormat),
("13.1242.1241.1/3", IPRangeError.invalidCIDRFormat),
("123.122.33.21/35", IPRangeEr... | /content/code_sandbox/test/Utils/IPRangeSpec.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 905 |
```swift
import Quick
import Nimble
@testable import NEKit
class IPAddressSpec: QuickSpec {
override func spec() {
it("can init from IPv4 string") {
let ip = IPAddress(fromString: "127.0.0.1")
expect(ip).toNot(beNil())
expect(ip?.family) == .IPv4
}
... | /content/code_sandbox/test/Utils/IPAddressSpec.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 324 |
```swift
import Quick
import Nimble
@testable import NEKit
class HTTPURLSpec: QuickSpec {
override func spec() {
let testCases: [(String, Bool, String?, String?, Int?, String)] = [
("path_to_url", true, "http", "google.com", nil, "ncr"),
("path_to_url", true, "http", "google.com", n... | /content/code_sandbox/test/Utils/HTTPURLSpec.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 477 |
```objective-c
#import <Cocoa/Cocoa.h>
//! Project version number for NEKit.
FOUNDATION_EXPORT double NEKitVersionNumber;
//! Project version string for NEKit.
FOUNDATION_EXPORT const unsigned char NEKitVersionString[];
// In this header, you should import all the public headers of your framework using statements li... | /content/code_sandbox/NEKit-macOS/NEKit.h | objective-c | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 70 |
```xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "path_to_url">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_... | /content/code_sandbox/NEKit-macOS/Info.plist | xml | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 248 |
```xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6233" systemVersion="14A329f" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
... | /content/code_sandbox/NEKitDemo/Base.lproj/MainMenu.xib | xml | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 7,892 |
```unknown
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:NEKit.xcodeproj">
</FileRef>
</Workspace>
``` | /content/code_sandbox/NEKit.xcodeproj/project.xcworkspace/contents.xcworkspacedata | unknown | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 51 |
```xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "path_to_url">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
``` | /content/code_sandbox/NEKit.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist | xml | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 72 |
```unknown
{
"DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey" : "E7F16E682DEFAA475C57A9EB4974749FA6202939",
your_sha256_hashKey" : {
},
"DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey" : {
"B97EEED760BDEDB08668E142659F81205FA7D2F5" : 0,
"3DD768C8AB2D6A2647C9EF99992D3CC5820E77C4" :... | /content/code_sandbox/NEKit.xcodeproj/project.xcworkspace/xcshareddata/NEKit.xcscmblueprint | unknown | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 1,008 |
```unknown
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1130"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning ... | /content/code_sandbox/NEKit.xcodeproj/xcshareddata/xcschemes/NEKit-macOS.xcscheme | unknown | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 869 |
```unknown
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1130"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning ... | /content/code_sandbox/NEKit.xcodeproj/xcshareddata/xcschemes/NEKit-iOS.xcscheme | unknown | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 829 |
```unknown
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1130"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning ... | /content/code_sandbox/NEKit.xcodeproj/xcshareddata/xcschemes/NEKitDemo.xcscheme | unknown | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 752 |
```xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "path_to_url">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_... | /content/code_sandbox/NEKitTest-macOS/Info.plist | xml | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 228 |
```swift
import Foundation
open class ResponseGeneratorFactory {
static var HTTPProxyResponseGenerator: ResponseGenerator.Type?
static var SOCKS5ProxyResponseGenerator: ResponseGenerator.Type?
}
``` | /content/code_sandbox/src/ResponseGeneratorFactory.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 37 |
```swift
import Foundation
open class ResponseGenerator {
public let session: ConnectSession
public init(withSession session: ConnectSession) {
self.session = session
}
open func generateResponse() -> Data {
return Data()
}
}
``` | /content/code_sandbox/src/ResponseGenerator.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 53 |
```swift
import Foundation
import Resolver
struct GlobalIntializer {
private static let _initialized: Bool = {
Resolver.queue = QueueFactory.getQueue()
return true
}()
static func initalize() {
_ = _initialized
}
}
``` | /content/code_sandbox/src/GlobalIntializer.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 55 |
```swift
import Foundation
public struct Opt {
public static var MAXNWTCPSocketReadDataSize = 128 * 1024
// This is only used in finding the end of HTTP header (as of now). There is no limit on the length of http header, but Apache set it to 8KB
public static var MAXNWTCPScanLength = 8912
public stat... | /content/code_sandbox/src/Opt.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 184 |
```swift
import Foundation
public struct Utils {
public struct HTTPData {
public static let DoubleCRLF = "\r\n\r\n".data(using: String.Encoding.utf8)!
public static let CRLF = "\r\n".data(using: String.Encoding.utf8)!
public static let ConnectSuccessResponse = "HTTP/1.1 200 Connection Estab... | /content/code_sandbox/src/Utils.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 902 |
```swift
import Foundation
import CocoaLumberjackSwift
/**
The pool is build to hold fake ips.
- note: It is NOT thread-safe.
*/
public final class IPPool {
let family: IPAddress.Family
let range: IPRange
var currentEnd: IPAddress
var pool: [IPAddress] = []
public init(range: IPRange) {
... | /content/code_sandbox/src/Utils/IPPool.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 219 |
```swift
import Foundation
public enum IPInterval {
case IPv4(UInt32), IPv6(UInt128)
}
``` | /content/code_sandbox/src/Utils/IPInterval.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 22 |
```swift
import Foundation
open class Checksum {
public static func computeChecksum(_ data: Data, from start: Int = 0, to end: Int? = nil, withPseudoHeaderChecksum initChecksum: UInt32 = 0) -> UInt16 {
return toChecksum(computeChecksumUnfold(data, from: start, to: end, withPseudoHeaderChecksum: initChecks... | /content/code_sandbox/src/Utils/Checksum.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 390 |
```swift
import Foundation
// This is just a simple wrapper of `Data`.
// Theoratically, it may be better to use a ring buffer for what is needed for this project.
// But this buffer should be much more space efficient.
struct Buffer {
private var buffer: Data
private var offset = 0
var left: Int {
... | /content/code_sandbox/src/Utils/Buffer.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 444 |
```swift
import Foundation
public class IPAddress: CustomStringConvertible, Comparable {
public enum Family {
case IPv4, IPv6
}
public enum Address: Equatable {
case IPv4(in_addr), IPv6(in6_addr)
public var asUInt128: UInt128 {
switch self {
case .IPv4(let ... | /content/code_sandbox/src/Utils/IPAddress.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 1,712 |
```swift
//
// BinaryDataScanner.swift
// Murphy
//
// Created by Dave Peck on 7/20/14.
//
import Foundation
/*
Toying with tools to help read binary formats.
I've seen lots of approaches in swift that create
an intermediate object per-read (usually another NSData)
but even if these are lightweight under the hood... | /content/code_sandbox/src/Utils/BinaryDataScanner.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 476 |
```swift
import Foundation
/// Represents the port number of IP protocol.
public struct Port: CustomStringConvertible, ExpressibleByIntegerLiteral {
public typealias IntegerLiteralType = UInt16
fileprivate var inport: UInt16
/**
Initialize a new instance with the port number in network byte order.
... | /content/code_sandbox/src/Utils/Port.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 456 |
```swift
import Foundation
public enum IPMask {
case IPv4(UInt32), IPv6(UInt128)
func mask(baseIP: IPAddress) -> (IPAddress, IPAddress)? {
switch (self, baseIP.address) {
case (.IPv4(var m), .IPv4(let addr)):
guard m <= 32 else {
return nil
}
... | /content/code_sandbox/src/Utils/IPMask.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 387 |
```swift
import Foundation
public enum IPRangeError: Error {
case invalidCIDRFormat, invalidRangeFormat, invalidRange, invalidFormat, addressIncompatible, noRange, intervalInvalid, invalidMask
}
public class IPRange {
public let startIP: IPAddress
// including, so we can include 255.255.255.255 in range.
... | /content/code_sandbox/src/Utils/IPRange.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 812 |
```swift
import Foundation
public class HTTPURL {
public let scheme: String?
public let host: String?
public let port: Int?
// public let path: String
public let relativePath: String
// swiftlint:disable:next force_try
static let urlreg = try! NSRegularExpression(pattern: "^(?:(?:(https... | /content/code_sandbox/src/Utils/HTTPURL.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 365 |
```swift
import Foundation
open class StreamScanner {
var receivedData: NSMutableData = NSMutableData()
let pattern: Data
let maximumLength: Int
var finished = false
var currentLength: Int {
return receivedData.length
}
public init(pattern: Data, maximumLength: Int) {
self... | /content/code_sandbox/src/Utils/StreamScanner.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 358 |
```swift
import Foundation
class HTTPStreamScanner {
enum ReadAction {
case readHeader, readContent(Int), stop
}
enum Result {
case header(HTTPHeader), content(Data)
}
enum HTTPStreamScannerError: Error {
case contentIsTooLong, scannerIsStopped, unsupportedStreamTy... | /content/code_sandbox/src/Utils/HTTPStreamScanner.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 454 |
```swift
import Foundation
/**
* The helper wrapping up an HTTP basic authentication credential.
*/
public struct HTTPAuthentication {
/// The username of the credential.
public let username: String
/// The password of the credential.
public let password: String
/**
Initailize the credent... | /content/code_sandbox/src/Utils/HTTPAuthentication.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 255 |
```swift
//
// UInt128.swift
//
// An implementation of a 128-bit unsigned integer data type not
// relying on any outside libraries apart from Swift's standard
// library. It also seeks to implement the entirety of the
// UnsignedInteger protocol as well as standard functions supported
// by Swift's native unsigned in... | /content/code_sandbox/src/Utils/UInt128.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 6,962 |
```swift
import Foundation
/// This is just a wrapper as a work around since there is no way to change a passed-in value in a block.
open class Box<T> {
/// The underlying value.
open var value: T
/**
Init the `Box`.
- parameter value: The variable to be wrapped in.
*/
init(_ value: T)... | /content/code_sandbox/src/Utils/Atomic.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 426 |
```swift
import Foundation
class QueueFactory {
private static let queueKey = DispatchSpecificKey<String>()
static let queue: DispatchQueue = {
let q = DispatchQueue(label: "NEKit.ProcessingQueue")
q.setSpecific(key: QueueFactory.queueKey, value: "NEKit.ProcessingQueue")
return q
}... | /content/code_sandbox/src/Tunnel/QueueFactory.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 175 |
```swift
import Foundation
import Resolver
protocol TunnelDelegate : class {
func tunnelDidClose(_ tunnel: Tunnel)
}
/// The tunnel forwards data between local and remote.
public class Tunnel: NSObject, SocketDelegate {
/// The status of `Tunnel`.
public enum TunnelStatus: CustomStringConvertible {
... | /content/code_sandbox/src/Tunnel/Tunnel.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 1,616 |
```swift
import Foundation
import tun2socks
import CocoaLumberjackSwift
/// This class wraps around tun2socks to build a TCP only IP stack.
open class TCPStack: TSIPStackDelegate, IPStackProtocol {
/// The `TCPStack` singleton instance.
public static var stack: TCPStack {
TSIPStack.stack.delegate = _st... | /content/code_sandbox/src/IPStack/TCPStack.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 606 |
```swift
import Foundation
import NetworkExtension
/// TUN interface provide a scheme to register a set of IP Stacks (implementing `IPStackProtocol`) to process IP packets from a virtual TUN interface.
open class TUNInterface {
fileprivate weak var packetFlow: NEPacketTunnelFlow?
fileprivate var stacks: [IPSta... | /content/code_sandbox/src/IPStack/TUNInterface.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 514 |
```swift
import Foundation
/// The protocol defines an IP stack.
public protocol IPStackProtocol: class {
/**
Input a packet into the stack.
- parameter packet: The IP packet.
- parameter version: The version of the IP packet, i.e., AF_INET, AF_INET6.
- returns: If the stack takes in this pa... | /content/code_sandbox/src/IPStack/IPStackProtocol.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 238 |
```swift
import Foundation
import CocoaLumberjackSwift
public class Router {
var IPv4NATRoutes: [Port: (IPv4Address, Port)] = [:]
let interfaceIP: IPv4Address
let fakeSourceIP: IPv4Address
let proxyServerIP: IPv4Address
let proxyServerPort: Port
// let IPv6NATRoutes: [UInt16] = []
publi... | /content/code_sandbox/src/IPStack/Router.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 692 |
```swift
import Foundation
struct ConnectInfo {
let sourceAddress: IPAddress
let sourcePort: Port
let destinationAddress: IPAddress
let destinationPort: Port
}
extension ConnectInfo: Hashable {}
func == (left: ConnectInfo, right: ConnectInfo) -> Bool {
return left.destinationAddress == right.dest... | /content/code_sandbox/src/IPStack/UDPDirectStack.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 1,071 |
```swift
import Foundation
class TCPMutablePacket: IPMutablePacket {
var sourcePort: Port {
get {
return Port(bytesInNetworkOrder: payload.bytes.advancedBy(IPHeaderLength))
}
set {
setPort(sourcePort, newPort: newValue, at: 0)
}
}
var destinationPort... | /content/code_sandbox/src/IPStack/Packet/TCPMutablePacket.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 270 |
```swift
import Foundation
import CocoaLumberjackSwift
public enum IPVersion: UInt8 {
case iPv4 = 4, iPv6 = 6
}
public enum TransportProtocol: UInt8 {
case icmp = 1, tcp = 6, udp = 17
}
/// The class to process and build IP packet.
///
/// - note: Only IPv4 is supported as of now.
open class IPPacket {
/... | /content/code_sandbox/src/IPStack/Packet/IPPacket.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 2,563 |
```swift
import Foundation
protocol TransportProtocolParserProtocol {
var packetData: Data! { get set }
var offset: Int { get set }
var bytesLength: Int { get }
var payload: Data! { get set }
func buildSegment(_ pseudoHeaderChecksum: UInt32)
}
/// Parser to process UDP packet and build packet.... | /content/code_sandbox/src/IPStack/Packet/PacketProtocolParser.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 521 |
```swift
import Foundation
enum ChangeType {
case Address, Port
}
public class IPMutablePacket {
// Support only IPv4 for now
let version: IPVersion
let proto: TransportType
let IPHeaderLength: Int
var sourceAddress: IPv4Address {
get {
return IPv4Address(fromBytesInNetwor... | /content/code_sandbox/src/IPStack/Packet/IPMutablePacket.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 731 |
```swift
import Foundation
import CocoaLumberjackSwift
open class DNSSession {
public let requestMessage: DNSMessage
var requestIPPacket: IPPacket?
open var realIP: IPAddress?
open var fakeIP: IPAddress?
open var realResponseMessage: DNSMessage?
var realResponseIPPacket: IPPacket?
open var ... | /content/code_sandbox/src/IPStack/DNS/DNSSession.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 353 |
```swift
import Foundation
public protocol DNSResolverProtocol: class {
var delegate: DNSResolverDelegate? { get set }
func resolve(session: DNSSession)
func stop()
}
public protocol DNSResolverDelegate: class {
func didReceive(rawResponse: Data)
}
open class UDPDNSResolver: DNSResolverProtocol, NWUD... | /content/code_sandbox/src/IPStack/DNS/DNSResolver.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 212 |
```swift
import Foundation
import CocoaLumberjackSwift
open class DNSMessage {
// var sourceAddress: IPv4Address?
// var sourcePort: Port?
// var destinationAddress: IPv4Address?
// var destinationPort: Port?
open var transactionID: UInt16 = 0
open var messageType: DNSMessageType = ... | /content/code_sandbox/src/IPStack/DNS/DNSMessage.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 3,041 |
```swift
import Foundation
import NetworkExtension
import CocoaLumberjackSwift
/// A DNS server designed as an `IPStackProtocol` implementation which works with TUN interface.
///
/// This class is thread-safe.
open class DNSServer: DNSResolverDelegate, IPStackProtocol {
/// Current DNS server.
///
/// - w... | /content/code_sandbox/src/IPStack/DNS/DNSServer.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 1,967 |
```swift
import Foundation
public enum DNSType: UInt16 {
// swiftlint:disable:next type_name
case invalid = 0, a, ns, md, mf, cname, soa, mb, mg, mr, null, wks, ptr, hinfo, minfo, mx, txt, rp, afsdb, x25, isdn, rt, nsap, nsapptr, sig, key, px, gpos, aaaa, loc, nxt, eid, nimloc, srv, atma, naptr, kx, cert, a6, ... | /content/code_sandbox/src/IPStack/DNS/DNSEnums.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 236 |
```swift
import Foundation
import MMDB
open class GeoIP {
// Back in the days, MMDB ships a bundled GeoLite2 database. However, that has changed
// due to license change of the database. Now developers must initialize it by themselves.
// In order to maintain the API compatibility while expose the issue AS... | /content/code_sandbox/src/GeoIP/GeoIP.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 141 |
```swift
import Foundation
import CocoaAsyncSocket
/// The TCP socket build upon `GCDAsyncSocket`.
///
/// - warning: This class is not thread-safe.
open class GCDTCPSocket: NSObject, GCDAsyncSocketDelegate, RawTCPSocketProtocol {
fileprivate let socket: GCDAsyncSocket
fileprivate var enableTLS: Bool = false
... | /content/code_sandbox/src/RawSocket/GCDTCPSocket.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 1,841 |
```unknown
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
360F392C1DD2068E002BED59 /* Resolver.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 360F392B1DD2068E002BED59 /* Resolver.framework */; };
360F392D1DD206A3002BED59 /* Reso... | /content/code_sandbox/NEKit.xcodeproj/project.pbxproj | unknown | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 49,954 |
```swift
import Foundation
import NetworkExtension
import CocoaLumberjackSwift
/// The delegate protocol of `NWUDPSocket`.
public protocol NWUDPSocketDelegate: class {
/**
Socket did receive data from remote.
- parameter data: The data.
- parameter from: The socket the data is read from.
... | /content/code_sandbox/src/RawSocket/NWUDPSocket.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 979 |
```swift
import Foundation
import NetworkExtension
import CocoaLumberjackSwift
/// The TCP socket build upon `NWTCPConnection`.
///
/// - warning: This class is not thread-safe.
public class NWTCPSocket: NSObject, RawTCPSocketProtocol {
private var connection: NWTCPConnection?
private var writePending = false... | /content/code_sandbox/src/RawSocket/NWTCPSocket.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 2,054 |
```swift
import Foundation
import tun2socks
/// The TCP socket build upon `TSTCPSocket`.
///
/// - warning: This class is not thread-safe.
public class TUNTCPSocket: RawTCPSocketProtocol, TSTCPSocketDelegate {
fileprivate let tsSocket: TSTCPSocket
fileprivate var reading = false
fileprivate var pendingRead... | /content/code_sandbox/src/RawSocket/TUNTCPSocket.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 1,625 |
```swift
import Foundation
import NetworkExtension
/**
Represents the type of the socket.
- NW: The socket based on `NWTCPConnection`.
- GCD: The socket based on `GCDAsyncSocket`.
*/
public enum SocketBaseType {
case nw, gcd
}
/// Factory to create `RawTCPSocket` based on configuration.
open class RawSocket... | /content/code_sandbox/src/RawSocket/RawSocketFactory.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 272 |
```swift
import Foundation
import Yaml
public enum ConfigurationParserError: Error {
case invalidYamlFile, noRuleDefined, ruleTypeMissing, unknownRuleType, ruleParsingError(errorInfo: String), noAdapterDefined, adapterIDMissing, adapterTypeMissing, adapterTypeUnknown, adapterParsingError(errorInfo: String)
}
/// ... | /content/code_sandbox/src/Config/Configuration.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 305 |
```swift
import Foundation
/// The raw socket protocol which represents a TCP socket.
///
/// Any concrete implementation does not need to be thread-safe.
///
/// - warning: It is expected that the instance is accessed on the specific queue only.
public protocol RawTCPSocketProtocol : class {
/// The `RawTCPSocket... | /content/code_sandbox/src/RawSocket/RawTCPSocketProtocol.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 913 |
```swift
import Foundation
import Yaml
struct AdapterFactoryParser {
// swiftlint:disable:next cyclomatic_complexity
static func parseAdapterFactoryManager(_ config: Yaml) throws -> AdapterFactoryManager {
var factoryDict: [String: AdapterFactory] = [:]
factoryDict["direct"] = DirectAdapterFact... | /content/code_sandbox/src/Config/AdapterFactoryParser.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 1,744 |
```swift
import Foundation
import Yaml
struct RuleParser {
static func parseRuleManager(_ config: Yaml, adapterFactoryManager: AdapterFactoryManager) throws -> RuleManager {
guard let ruleConfigs = config.array else {
throw ConfigurationParserError.noRuleDefined
}
var rules: [R... | /content/code_sandbox/src/Config/RuleParser.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 1,264 |
```swift
import Foundation
/**
The current connection status of the socket.
- Invalid: The socket is just created but never connects.
- Connecting: The socket is connecting.
- Established: The connection is established.
- Disconnecting: The socket is disconnecting.
- Closed: The socket is clos... | /content/code_sandbox/src/Socket/SocketProtocol.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 927 |
```swift
import Foundation
/// The socket which encapsulates the logic to handle connection to proxies.
open class ProxySocket: NSObject, SocketProtocol, RawTCPSocketDelegate {
/// Received `ConnectSession`.
public var session: ConnectSession?
public var observer: Observer<ProxySocketEvent>?
private ... | /content/code_sandbox/src/Socket/ProxySocket/ProxySocket.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 1,051 |
```swift
import Foundation
public class SOCKS5ProxySocket: ProxySocket {
enum SOCKS5ProxyReadStatus: CustomStringConvertible {
case invalid,
readingVersionIdentifierAndNumberOfMethods,
readingMethods,
readingConnectHeader,
readingIPv4Address,
readingDomainLength,
... | /content/code_sandbox/src/Socket/ProxySocket/SOCKS5ProxySocket.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 1,693 |
```swift
import Foundation
/// This class just forwards data directly.
/// - note: It is designed to work with tun2socks only.
public class DirectProxySocket: ProxySocket {
enum DirectProxyReadStatus: CustomStringConvertible {
case invalid,
forwarding,
stopped
var description: Str... | /content/code_sandbox/src/Socket/ProxySocket/DirectProxySocket.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 681 |
```swift
import Foundation
public class HTTPProxySocket: ProxySocket {
enum HTTPProxyReadStatus: CustomStringConvertible {
case invalid,
readingFirstHeader,
pendingFirstHeader,
readingHeader,
readingContent,
stopped
var description: String {
... | /content/code_sandbox/src/Socket/ProxySocket/HTTPProxySocket.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 1,281 |
```swift
import Foundation
/// This adapter connects to remote host through a HTTP proxy with SSL.
public class SecureHTTPAdapter: HTTPAdapter {
override public init(serverHost: String, serverPort: Int, auth: HTTPAuthentication?) {
super.init(serverHost: serverHost, serverPort: serverPort, auth: auth)
... | /content/code_sandbox/src/Socket/AdapterSocket/SecureHTTPAdapter.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 74 |
```swift
import Foundation
public class RejectAdapter: AdapterSocket {
public let delay: Int
public init(delay: Int) {
self.delay = delay
}
override public func openSocketWith(session: ConnectSession) {
super.openSocketWith(session: session)
QueueFactory.getQueue().asyncAfter... | /content/code_sandbox/src/Socket/AdapterSocket/RejectAdapter.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 274 |
```swift
import Foundation
/// This adpater selects the fastest proxy automatically from a set of proxies.
public class SpeedAdapter: AdapterSocket, SocketDelegate {
public var adapters: [(AdapterSocket, Int)]!
var connectingCount = 0
var pendingCount = 0
fileprivate var _shouldConnect: Bool = true
... | /content/code_sandbox/src/Socket/AdapterSocket/SpeedAdapter.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 731 |
```swift
import Foundation
public enum HTTPAdapterError: Error, CustomStringConvertible {
case invalidURL, serailizationFailure
public var description: String {
switch self {
case .invalidURL:
return "Invalid url when connecting through proxy"
case .serailizationFailure:
... | /content/code_sandbox/src/Socket/AdapterSocket/HTTPAdapter.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 797 |
```swift
import Foundation
public class SOCKS5Adapter: AdapterSocket {
enum SOCKS5AdapterStatus {
case invalid,
connecting,
readingMethodResponse,
readingResponseFirstPart,
readingResponseSecondPart,
forwarding
}
public let serverHost: String
public let s... | /content/code_sandbox/src/Socket/AdapterSocket/SOCKS5Adapter.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 826 |
```swift
import Foundation
/// This adapter connects to remote directly.
public class DirectAdapter: AdapterSocket {
/// If this is set to `false`, then the IP address will be resolved by system.
var resolveHost = false
/**
Connect to remote according to the `ConnectSession`.
- parameter sessio... | /content/code_sandbox/src/Socket/AdapterSocket/DirectAdapter.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 331 |
```swift
import Foundation
open class AdapterSocket: NSObject, SocketProtocol, RawTCPSocketDelegate {
open var session: ConnectSession!
open var observer: Observer<AdapterSocketEvent>?
open override var description: String {
return "<\(typeName) host:\(session.host) port:\(session.port))>"
... | /content/code_sandbox/src/Socket/AdapterSocket/AdapterSocket.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 924 |
```swift
import Foundation
extension ShadowsocksAdapter {
public class CryptoStreamProcessor {
public class Factory {
let password: String
let algorithm: CryptoAlgorithm
let key: Data
public init(password: String, algorithm: CryptoAlgorithm) {
... | /content/code_sandbox/src/Socket/AdapterSocket/Shadowsocks/CryptoStreamProcessor.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 927 |
```swift
import Foundation
import CommonCrypto
/// This adapter connects to remote through Shadowsocks proxy.
public class ShadowsocksAdapter: AdapterSocket {
enum ShadowsocksAdapterStatus {
case invalid,
connecting,
connected,
forwarding,
stopped
}
enum EncryptMeth... | /content/code_sandbox/src/Socket/AdapterSocket/Shadowsocks/ShadowsocksAdapter.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 755 |
```swift
import Foundation
extension ShadowsocksAdapter {
public struct StreamObfuscater {
public class Factory {
public init() {}
public func build(for session: ConnectSession) -> StreamObfuscaterBase {
return StreamObfuscaterBase(for: session)
}
... | /content/code_sandbox/src/Socket/AdapterSocket/Shadowsocks/StreamObfuscater.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 1,321 |
```swift
import Foundation
/// Factory building adapter with proxy server host and port.
open class ServerAdapterFactory: AdapterFactory {
let serverHost: String
let serverPort: Int
public init(serverHost: String, serverPort: Int) {
self.serverHost = serverHost
self.serverPort = serverPort... | /content/code_sandbox/src/Socket/AdapterSocket/Factory/ServerAdapterFactory.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 70 |
```swift
import Foundation
/// Factory building Shadowsocks adapter.
open class ShadowsocksAdapterFactory: ServerAdapterFactory {
let protocolObfuscaterFactory: ShadowsocksAdapter.ProtocolObfuscater.Factory
let cryptorFactory: ShadowsocksAdapter.CryptoStreamProcessor.Factory
let streamObfuscaterFactory: Sh... | /content/code_sandbox/src/Socket/AdapterSocket/Factory/ShadowsocksAdapterFactory.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 305 |
```swift
import Foundation
/// Factory building SOCKS5 adapter.
open class SOCKS5AdapterFactory: ServerAdapterFactory {
override public init(serverHost: String, serverPort: Int) {
super.init(serverHost: serverHost, serverPort: serverPort)
}
/**
Get a SOCKS5 adapter.
- parameter session:... | /content/code_sandbox/src/Socket/AdapterSocket/Factory/SOCKS5AdapterFactory.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 136 |
```swift
import Foundation
/// This is a very simple wrapper of a dict of type `[String: AdapterFactory]`.
///
/// Use it as a normal dict.
public class AdapterFactoryManager {
private var factoryDict: [String: AdapterFactory]
public subscript(index: String) -> AdapterFactory? {
get {
if i... | /content/code_sandbox/src/Socket/AdapterSocket/Factory/AdapterFactoryManager.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 145 |
```swift
import Foundation
/// Factory building speed adapter.
open class SpeedAdapterFactory: AdapterFactory {
open var adapterFactories: [(AdapterFactory, Int)]!
public override init() {}
/**
Get a speed adapter.
- parameter session: The connect session.
- returns: The built adapter.
... | /content/code_sandbox/src/Socket/AdapterSocket/Factory/SpeedAdapterFactory.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 157 |
```swift
import Foundation
/// Factory building HTTP adapter.
open class HTTPAdapterFactory: HTTPAuthenticationAdapterFactory {
required public init(serverHost: String, serverPort: Int, auth: HTTPAuthentication?) {
super.init(serverHost: serverHost, serverPort: serverPort, auth: auth)
}
/**
G... | /content/code_sandbox/src/Socket/AdapterSocket/Factory/HTTPAdapterFactory.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 142 |
```swift
import Foundation
/// Factory building server adapter which requires authentication.
open class HTTPAuthenticationAdapterFactory: ServerAdapterFactory {
let auth: HTTPAuthentication?
required public init(serverHost: String, serverPort: Int, auth: HTTPAuthentication?) {
self.auth = auth
... | /content/code_sandbox/src/Socket/AdapterSocket/Factory/AuthenticationServerAdapterFactory.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 73 |
```swift
import Foundation
/// The base class of adapter factory.
open class AdapterFactory {
public init() {}
/**
Build an adapter.
- parameter session: The connect session.
- returns: The built adapter.
*/
open func getAdapterFor(session: ConnectSession) -> AdapterSocket {
... | /content/code_sandbox/src/Socket/AdapterSocket/Factory/AdapterFactory.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 167 |
```swift
import Foundation
open class RejectAdapterFactory: AdapterFactory {
public let delay: Int
public init(delay: Int = Opt.RejectAdapterDefaultDelay) {
self.delay = delay
}
override open func getAdapterFor(session: ConnectSession) -> AdapterSocket {
return RejectAdapter(delay: de... | /content/code_sandbox/src/Socket/AdapterSocket/Factory/RejectAdapterFactory.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 69 |
```swift
import Foundation
extension ShadowsocksAdapter {
public struct ProtocolObfuscater {
public class Factory {
public init() {}
public func build() -> ProtocolObfuscaterBase {
return ProtocolObfuscaterBase()
}
}
public class Protoco... | /content/code_sandbox/src/Socket/AdapterSocket/Shadowsocks/ProtocolObfuscater.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 3,733 |
```swift
import Foundation
/// Factory building secured HTTP (HTTP with SSL) adapter.
open class SecureHTTPAdapterFactory: HTTPAdapterFactory {
required public init(serverHost: String, serverPort: Int, auth: HTTPAuthentication?) {
super.init(serverHost: serverHost, serverPort: serverPort, auth: auth)
}... | /content/code_sandbox/src/Socket/AdapterSocket/Factory/SecureHTTPAdapterFactory.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 150 |
```swift
import Foundation
public protocol StreamCryptoProtocol {
func update(_ data: inout Data)
}
``` | /content/code_sandbox/src/Crypto/StreamCryptoProtocol.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 20 |
```swift
import Foundation
import CommonCrypto
public struct HMAC {
public static func final(value: String, algorithm: HashAlgorithm, key: Data) -> Data {
let data = value.data(using: String.Encoding.utf8)!
return final(value: data, algorithm: algorithm, key: key)
}
public static func fin... | /content/code_sandbox/src/Crypto/HMAC.swift | swift | 2016-05-07T13:03:07 | 2024-07-25T11:16:48 | NEKit | zhuhaow/NEKit | 2,835 | 260 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.