From 04c32f2a199970e54daa663f7371fd71545c48bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Netth=C3=B6fel?= Date: Wed, 15 Mar 2017 09:31:23 +0100 Subject: [PATCH] Initial import from github enterprise --- GCXMulticastDNSKit.podspec | 12 + GCXMulticastDNSKit.xcodeproj/project.pbxproj | 453 ++++++++++++++++++ .../contents.xcworkspacedata | 7 + .../xcschemes/GCXMulticastDNSKit.xcscheme | 99 ++++ GCXMulticastDNSKit/Discovery.swift | 315 ++++++++++++ .../DiscoveryConfiguration.swift | 29 ++ GCXMulticastDNSKit/GCXMulticastDNSKit.h | 29 ++ GCXMulticastDNSKit/Info.plist | 24 + .../GCXDiscoveryObjectiveCIntegration.m | 52 ++ .../GCXDiscoveryTests.swift | 133 +++++ GCXMulticastDNSKitTests/Info.plist | 22 + LICENSE.txt | 202 ++++++++ README.md | 67 +++ 13 files changed, 1444 insertions(+) create mode 100644 GCXMulticastDNSKit.podspec create mode 100644 GCXMulticastDNSKit.xcodeproj/project.pbxproj create mode 100644 GCXMulticastDNSKit.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 GCXMulticastDNSKit.xcodeproj/xcshareddata/xcschemes/GCXMulticastDNSKit.xcscheme create mode 100644 GCXMulticastDNSKit/Discovery.swift create mode 100644 GCXMulticastDNSKit/DiscoveryConfiguration.swift create mode 100644 GCXMulticastDNSKit/GCXMulticastDNSKit.h create mode 100644 GCXMulticastDNSKit/Info.plist create mode 100644 GCXMulticastDNSKitTests/GCXDiscoveryObjectiveCIntegration.m create mode 100644 GCXMulticastDNSKitTests/GCXDiscoveryTests.swift create mode 100644 GCXMulticastDNSKitTests/Info.plist create mode 100644 LICENSE.txt create mode 100644 README.md diff --git a/GCXMulticastDNSKit.podspec b/GCXMulticastDNSKit.podspec new file mode 100644 index 0000000..98d8ee4 --- /dev/null +++ b/GCXMulticastDNSKit.podspec @@ -0,0 +1,12 @@ +Pod::Spec.new do |spec| + spec.name = "GCXMulticastDNSKit" + spec.version = "1.0.1" + spec.summary = "mDNS discovery framework for iOS." + spec.homepage = "https://www.grandcentrix.net" + spec.license = { :type => 'Apache License, Version 2.0', :file => 'LICENSE.txt' } + spec.authors = { "Christian Netthöfel" => 'christian.netthoefel@grandcentrix.net' } + spec.social_media_url = "http://twitter.com/grandcentrix" + spec.platform = :ios, "9.0" + spec.source = { git: "https://github.com/grandcentrix/GCXMulticastDNSKit.git", tag: "v#{spec.version}"} + spec.source_files = "GCXMulticastDNSKit/**/*.{swift}" +end diff --git a/GCXMulticastDNSKit.xcodeproj/project.pbxproj b/GCXMulticastDNSKit.xcodeproj/project.pbxproj new file mode 100644 index 0000000..6aaad5d --- /dev/null +++ b/GCXMulticastDNSKit.xcodeproj/project.pbxproj @@ -0,0 +1,453 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 68B792891E69620900A482A8 /* GCXDiscoveryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68B792881E69620900A482A8 /* GCXDiscoveryTests.swift */; }; + 68B7928D1E697BC300A482A8 /* GCXDiscoveryObjectiveCIntegration.m in Sources */ = {isa = PBXBuildFile; fileRef = 68B7928C1E697BC300A482A8 /* GCXDiscoveryObjectiveCIntegration.m */; }; + 68FF3C211E24DDDF00A482A8 /* GCXMulticastDNSKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 68FF3C171E24DDDF00A482A8 /* GCXMulticastDNSKit.framework */; }; + 68FF3C281E24DDDF00A482A8 /* GCXMulticastDNSKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 68FF3C1A1E24DDDF00A482A8 /* GCXMulticastDNSKit.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 68FF3C4C1E24E6A700A482A8 /* Discovery.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68FF3C4B1E24E6A700A482A8 /* Discovery.swift */; }; + 68FF3C4E1E24E6D400A482A8 /* DiscoveryConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68FF3C4D1E24E6D400A482A8 /* DiscoveryConfiguration.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 68FF3C221E24DDDF00A482A8 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 68FF3C0E1E24DDDF00A482A8 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 68FF3C161E24DDDF00A482A8; + remoteInfo = GCXMulticastDNSKit; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + 68B792881E69620900A482A8 /* GCXDiscoveryTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GCXDiscoveryTests.swift; sourceTree = ""; }; + 68B7928C1E697BC300A482A8 /* GCXDiscoveryObjectiveCIntegration.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GCXDiscoveryObjectiveCIntegration.m; sourceTree = ""; }; + 68FF3C171E24DDDF00A482A8 /* GCXMulticastDNSKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = GCXMulticastDNSKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 68FF3C1A1E24DDDF00A482A8 /* GCXMulticastDNSKit.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GCXMulticastDNSKit.h; sourceTree = ""; }; + 68FF3C1B1E24DDDF00A482A8 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 68FF3C201E24DDDF00A482A8 /* GCXMulticastDNSKitTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = GCXMulticastDNSKitTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 68FF3C271E24DDDF00A482A8 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 68FF3C4B1E24E6A700A482A8 /* Discovery.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Discovery.swift; sourceTree = ""; }; + 68FF3C4D1E24E6D400A482A8 /* DiscoveryConfiguration.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiscoveryConfiguration.swift; sourceTree = ""; }; + 68FF3C7B1E2621C100A482A8 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = SOURCE_ROOT; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 68FF3C131E24DDDF00A482A8 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 68FF3C1D1E24DDDF00A482A8 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 68FF3C211E24DDDF00A482A8 /* GCXMulticastDNSKit.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 68B792871E6961D000A482A8 /* Unit Tests */ = { + isa = PBXGroup; + children = ( + 68B792881E69620900A482A8 /* GCXDiscoveryTests.swift */, + ); + name = "Unit Tests"; + sourceTree = ""; + }; + 68B7928A1E697B6400A482A8 /* Framework integration */ = { + isa = PBXGroup; + children = ( + 68B7928C1E697BC300A482A8 /* GCXDiscoveryObjectiveCIntegration.m */, + ); + name = "Framework integration"; + sourceTree = ""; + }; + 68FF3C0D1E24DDDF00A482A8 = { + isa = PBXGroup; + children = ( + 68FF3C191E24DDDF00A482A8 /* GCXMulticastDNSKit */, + 68FF3C241E24DDDF00A482A8 /* GCXMulticastDNSKitTests */, + 68FF3C181E24DDDF00A482A8 /* Products */, + ); + sourceTree = ""; + }; + 68FF3C181E24DDDF00A482A8 /* Products */ = { + isa = PBXGroup; + children = ( + 68FF3C171E24DDDF00A482A8 /* GCXMulticastDNSKit.framework */, + 68FF3C201E24DDDF00A482A8 /* GCXMulticastDNSKitTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + 68FF3C191E24DDDF00A482A8 /* GCXMulticastDNSKit */ = { + isa = PBXGroup; + children = ( + 68FF3C7B1E2621C100A482A8 /* README.md */, + 68FF3C1A1E24DDDF00A482A8 /* GCXMulticastDNSKit.h */, + 68FF3C1B1E24DDDF00A482A8 /* Info.plist */, + 68FF3C4B1E24E6A700A482A8 /* Discovery.swift */, + 68FF3C4D1E24E6D400A482A8 /* DiscoveryConfiguration.swift */, + ); + path = GCXMulticastDNSKit; + sourceTree = ""; + }; + 68FF3C241E24DDDF00A482A8 /* GCXMulticastDNSKitTests */ = { + isa = PBXGroup; + children = ( + 68B7928A1E697B6400A482A8 /* Framework integration */, + 68B792871E6961D000A482A8 /* Unit Tests */, + 68FF3C271E24DDDF00A482A8 /* Info.plist */, + ); + path = GCXMulticastDNSKitTests; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + 68FF3C141E24DDDF00A482A8 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 68FF3C281E24DDDF00A482A8 /* GCXMulticastDNSKit.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + 68FF3C161E24DDDF00A482A8 /* GCXMulticastDNSKit */ = { + isa = PBXNativeTarget; + buildConfigurationList = 68FF3C2B1E24DDDF00A482A8 /* Build configuration list for PBXNativeTarget "GCXMulticastDNSKit" */; + buildPhases = ( + 68FF3C121E24DDDF00A482A8 /* Sources */, + 68FF3C131E24DDDF00A482A8 /* Frameworks */, + 68FF3C141E24DDDF00A482A8 /* Headers */, + 68FF3C151E24DDDF00A482A8 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = GCXMulticastDNSKit; + productName = GCXMulticastDNSKit; + productReference = 68FF3C171E24DDDF00A482A8 /* GCXMulticastDNSKit.framework */; + productType = "com.apple.product-type.framework"; + }; + 68FF3C1F1E24DDDF00A482A8 /* GCXMulticastDNSKitTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 68FF3C2E1E24DDDF00A482A8 /* Build configuration list for PBXNativeTarget "GCXMulticastDNSKitTests" */; + buildPhases = ( + 68FF3C1C1E24DDDF00A482A8 /* Sources */, + 68FF3C1D1E24DDDF00A482A8 /* Frameworks */, + 68FF3C1E1E24DDDF00A482A8 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 68FF3C231E24DDDF00A482A8 /* PBXTargetDependency */, + ); + name = GCXMulticastDNSKitTests; + productName = GCXMulticastDNSKitTests; + productReference = 68FF3C201E24DDDF00A482A8 /* GCXMulticastDNSKitTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 68FF3C0E1E24DDDF00A482A8 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0820; + LastUpgradeCheck = 0820; + ORGANIZATIONNAME = "grandcentrix GmbH"; + TargetAttributes = { + 68FF3C161E24DDDF00A482A8 = { + CreatedOnToolsVersion = 8.2.1; + LastSwiftMigration = 0820; + ProvisioningStyle = Automatic; + }; + 68FF3C1F1E24DDDF00A482A8 = { + CreatedOnToolsVersion = 8.2.1; + LastSwiftMigration = 0820; + ProvisioningStyle = Automatic; + }; + }; + }; + buildConfigurationList = 68FF3C111E24DDDF00A482A8 /* Build configuration list for PBXProject "GCXMulticastDNSKit" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 68FF3C0D1E24DDDF00A482A8; + productRefGroup = 68FF3C181E24DDDF00A482A8 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 68FF3C161E24DDDF00A482A8 /* GCXMulticastDNSKit */, + 68FF3C1F1E24DDDF00A482A8 /* GCXMulticastDNSKitTests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 68FF3C151E24DDDF00A482A8 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 68FF3C1E1E24DDDF00A482A8 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 68FF3C121E24DDDF00A482A8 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 68FF3C4E1E24E6D400A482A8 /* DiscoveryConfiguration.swift in Sources */, + 68FF3C4C1E24E6A700A482A8 /* Discovery.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 68FF3C1C1E24DDDF00A482A8 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 68B7928D1E697BC300A482A8 /* GCXDiscoveryObjectiveCIntegration.m in Sources */, + 68B792891E69620900A482A8 /* GCXDiscoveryTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 68FF3C231E24DDDF00A482A8 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 68FF3C161E24DDDF00A482A8 /* GCXMulticastDNSKit */; + targetProxy = 68FF3C221E24DDDF00A482A8 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin XCBuildConfiguration section */ + 68FF3C291E24DDDF00A482A8 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 10.2; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Debug; + }; + 68FF3C2A1E24DDDF00A482A8 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 10.2; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; + 68FF3C2C1E24DDDF00A482A8 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_IDENTITY = ""; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + INFOPLIST_FILE = GCXMulticastDNSKit/Info.plist; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = net.grandcentrix.GCXMulticastDNSKit; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 3.0; + }; + name = Debug; + }; + 68FF3C2D1E24DDDF00A482A8 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_IDENTITY = ""; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + INFOPLIST_FILE = GCXMulticastDNSKit/Info.plist; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = net.grandcentrix.GCXMulticastDNSKit; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + SWIFT_VERSION = 3.0; + }; + name = Release; + }; + 68FF3C2F1E24DDDF00A482A8 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + CLANG_ENABLE_MODULES = YES; + INFOPLIST_FILE = GCXMulticastDNSKitTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = net.grandcentrix.GCXMulticastDNSKitTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 3.0; + }; + name = Debug; + }; + 68FF3C301E24DDDF00A482A8 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + CLANG_ENABLE_MODULES = YES; + INFOPLIST_FILE = GCXMulticastDNSKitTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = net.grandcentrix.GCXMulticastDNSKitTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 68FF3C111E24DDDF00A482A8 /* Build configuration list for PBXProject "GCXMulticastDNSKit" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 68FF3C291E24DDDF00A482A8 /* Debug */, + 68FF3C2A1E24DDDF00A482A8 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 68FF3C2B1E24DDDF00A482A8 /* Build configuration list for PBXNativeTarget "GCXMulticastDNSKit" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 68FF3C2C1E24DDDF00A482A8 /* Debug */, + 68FF3C2D1E24DDDF00A482A8 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 68FF3C2E1E24DDDF00A482A8 /* Build configuration list for PBXNativeTarget "GCXMulticastDNSKitTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 68FF3C2F1E24DDDF00A482A8 /* Debug */, + 68FF3C301E24DDDF00A482A8 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 68FF3C0E1E24DDDF00A482A8 /* Project object */; +} diff --git a/GCXMulticastDNSKit.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/GCXMulticastDNSKit.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..9bd72b9 --- /dev/null +++ b/GCXMulticastDNSKit.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/GCXMulticastDNSKit.xcodeproj/xcshareddata/xcschemes/GCXMulticastDNSKit.xcscheme b/GCXMulticastDNSKit.xcodeproj/xcshareddata/xcschemes/GCXMulticastDNSKit.xcscheme new file mode 100644 index 0000000..81c6ddd --- /dev/null +++ b/GCXMulticastDNSKit.xcodeproj/xcshareddata/xcschemes/GCXMulticastDNSKit.xcscheme @@ -0,0 +1,99 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/GCXMulticastDNSKit/Discovery.swift b/GCXMulticastDNSKit/Discovery.swift new file mode 100644 index 0000000..f3ad691 --- /dev/null +++ b/GCXMulticastDNSKit/Discovery.swift @@ -0,0 +1,315 @@ +// +// Discovery.swift +// GCXMulticastDNSKit +// +// Copyright 2017 grandcentrix GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import Foundation + +public typealias DiscoveryDiscoverHandler = (DiscoveryService) -> Void +public typealias DiscoveryFailHandler = (DiscoveryConfiguration, DiscoveryError) -> Void +public typealias DiscoveryServiceRemovedHandler = (DiscoveryService) -> Void + + +/// a private class that encapsulates all information for a specific service discovery +private class DiscoveryItem { + + /// the configuration used for this discovery + var configuration: DiscoveryConfiguration + + /// the net service browser used to discover this service + var netServiceBrowser = NetServiceBrowser() + + /// the found net services + var netServices: Set = Set() + + + /// designated initializer, must be initialized with a configuration + /// + /// - Parameter configuration: the configuration + init(with configuration: DiscoveryConfiguration) { + self.configuration = configuration + } + + + /// checks if a service instance is valid for this discovery configuration + /// + /// - Parameter netService: the net service to check + /// - Returns: true if the net service matches the configuration's spec, else false + func isValidForService(netService: NetService) -> Bool { + guard let serviceNamePrefix = configuration.serviceNamePrefix else { + // when no service name prefix is specified, all services are valid + return true + } + return netService.name.hasPrefix(serviceNamePrefix) + } +} + + +/// a structure to enapsulate the result of a service discovery, this is returned +@objc(GCXDiscoveryService) public class DiscoveryService: NSObject { + + /// the configuration used to search + public let configuration: DiscoveryConfiguration + + /// the found service + public let netService: NetService + + init(configuration: DiscoveryConfiguration, netService: NetService) { + self.configuration = configuration + self.netService = netService + super.init() + } +} + + +/// the errors that can occur whilst searching for services +/// +/// - unknown: a unknown error +/// - browsingFailure: failed to browse +/// - resolvingTimeout: timeout while resolving +/// - resolvingFailure: a general failure while resolving +@objc(GCXDiscoveryError) public enum DiscoveryError: Int, Error { + case unknown + case browsingFailure + case resolvingTimeout + case resolvingFailure +} + + +/// the protocol used for the delegate +@objc(GCXDiscoveryDelegate) public protocol DiscoveryDelegate { + + /// called when a service has been discovered and resolved. Can be called multiple times for a + /// search when more than one matching service is found. Is only called while in search mode. + /// + /// - Parameter service: the found service + func discoveryDidDiscover(service: DiscoveryService) + + + /// called when the discovery for a configuration fails. Can be called multiple times for a + /// search when more than one matching service is present and some of them fail to resolve. + /// Is only called while in search mode. + /// + /// - Parameters: + /// - configuration: the configuration + /// - error: the reason for the fail + func discoveryDidFail(configuration: DiscoveryConfiguration, error: DiscoveryError) + + + /// called when a service disappers, can be called multiple times. Is only called while in search mode. + /// + /// - Parameter service: the service that disappeared + func discoveryDidDisappear(service: DiscoveryService) +} + +// MARK: - public interface + + +/// the class to use to discover service on the network. Initialize a new instance with an array of +/// configurations and start the search. +@objc(GCXDiscovery) public class Discovery: NSObject { + + + /// the default search domain, empty string means .local. + /// Should be sufficient for 99% of the use cases + fileprivate let defaultMDNSDomain = "" + + /// the timeout for resolving a service + fileprivate var serviceResolveTimeout: TimeInterval + + /// the configurations used for the search + fileprivate var configurations: [DiscoveryConfiguration] + + /// the local models to manage the search + fileprivate var items: [DiscoveryItem]? + + /// the delegate + public var delegate: DiscoveryDelegate? + + + /// the completion closures + fileprivate var discoverHandler: DiscoveryDiscoverHandler? + fileprivate var failHandler: DiscoveryFailHandler? + fileprivate var serviceRemovedHandler: DiscoveryServiceRemovedHandler? + + /// the designated initializer. creates a new discovery for the specified configurations + /// + /// - Parameters: + /// - configurations: an array of GCXDiscoveryConfiguration instance. Must contain at least one config or the init will fail + /// - delegate: the delegate + public init?(with configurations: [DiscoveryConfiguration], + delegate: DiscoveryDelegate, + serviceResolveTimeout: TimeInterval = 10) { + guard configurations.count > 0 else { + return nil + } + + self.configurations = configurations + self.delegate = delegate + self.serviceResolveTimeout = serviceResolveTimeout + } + + public init?(with configurations: [DiscoveryConfiguration], + discoverHandler: DiscoveryDiscoverHandler?, + failHandler: DiscoveryFailHandler?, + serviceRemovedHandler: DiscoveryServiceRemovedHandler?, + serviceResolveTimeout: TimeInterval = 10) { + guard configurations.count > 0 else { + return nil + } + + self.configurations = configurations + self.discoverHandler = discoverHandler + self.failHandler = failHandler + self.serviceRemovedHandler = serviceRemovedHandler + self.serviceResolveTimeout = serviceResolveTimeout + } + + /// starts the discovery process + public func startDiscovery() { + stopDiscovery() + initializeItems() + } + + /// stops the discovery process + public func stopDiscovery() { + stopSearchingAndResolving() + } +} + +// MARK: - private methods +extension Discovery { + + /// creates the models from the configurations and starts the search for the services + fileprivate func initializeItems() { + items = configurations.map { + let item = DiscoveryItem( with: $0) + item.netServiceBrowser.delegate = self + item.netServiceBrowser.searchForServices(ofType: item.configuration.serviceType, inDomain: defaultMDNSDomain) + return item + } + } + + /// stops all search and resolve operations + fileprivate func stopSearchingAndResolving() { + let _ = items?.map { + $0.netServiceBrowser.stop() + let _ = $0.netServices.map { $0.stop() } + } + + items = nil + } + + /// lookup for an item from a net service + fileprivate func item(service: NetService) -> DiscoveryItem? { + guard let item = items?.filter({ (discoveryItem) -> Bool in + return discoveryItem.netServices.contains(service) + }).first else { + return nil + } + + return item + } + + /// lookup for an item from a net service browser + fileprivate func item(serviceBrowser: NetServiceBrowser) -> DiscoveryItem? { + guard let item = items?.filter({ (discoveryItem) -> Bool in + return discoveryItem.netServiceBrowser == serviceBrowser + }).first else { + return nil + } + + return item + } +} + +// MARK: - Delegate notifiction helpers +extension Discovery { + fileprivate func notifyDiscoveryDidDiscover(service: DiscoveryService) { + DispatchQueue.main.async { [weak self] () -> Void in + self?.delegate?.discoveryDidDiscover(service: service) + self?.discoverHandler?(service) + } + } + + fileprivate func notifyDiscoveryDidFail(configuration: DiscoveryConfiguration, error: DiscoveryError) { + DispatchQueue.main.async { [weak self] () -> Void in + self?.delegate?.discoveryDidFail(configuration: configuration, error: error) + self?.failHandler?(configuration, error) + } + } + + fileprivate func notifyDiscoveryServiceDidDisappear(service: DiscoveryService) { + DispatchQueue.main.async { [weak self] () -> Void in + self?.delegate?.discoveryDidDisappear(service: service) + self?.serviceRemovedHandler?(service) + } + } +} + +// MARK: - NetServiceBrowserDelegate +extension Discovery: NetServiceBrowserDelegate { + + public func netServiceBrowser(_ browser: NetServiceBrowser, didFind service: NetService, moreComing: Bool) { + guard let item = item(serviceBrowser: browser) else { + return + } + + if item.isValidForService(netService: service) { + item.netServices.insert(service) + service.delegate = self + service.resolve(withTimeout: serviceResolveTimeout) + } + } + + public func netServiceBrowser(_ browser: NetServiceBrowser, didNotSearch errorDict: [String : NSNumber]) { + guard let item = item(serviceBrowser: browser) else { + return + } + + notifyDiscoveryDidFail(configuration: item.configuration, error: .browsingFailure) + } + + public func netServiceBrowser(_ browser: NetServiceBrowser, didRemove service: NetService, moreComing: Bool) { + guard let item = item(service: service) else { + return + } + + item.netServices.remove(service) + + notifyDiscoveryServiceDidDisappear(service: DiscoveryService(configuration: item.configuration, netService: service)) + } +} + +// MARK: - NetServiceDelegate +extension Discovery: NetServiceDelegate { + + public func netServiceDidResolveAddress(_ sender: NetService) { + guard let item = item(service: sender) else { + return + } + + notifyDiscoveryDidDiscover(service: DiscoveryService(configuration: item.configuration, netService: sender)) + } + + public func netService(_ sender: NetService, didNotResolve errorDict: [String : NSNumber]) { + guard let item = item(service: sender) else { + return + } + + notifyDiscoveryDidFail(configuration: item.configuration, error: .resolvingFailure) + } +} diff --git a/GCXMulticastDNSKit/DiscoveryConfiguration.swift b/GCXMulticastDNSKit/DiscoveryConfiguration.swift new file mode 100644 index 0000000..691b70e --- /dev/null +++ b/GCXMulticastDNSKit/DiscoveryConfiguration.swift @@ -0,0 +1,29 @@ +// +// DiscoveryConfiguration.swift +// GCXMulticastDNSKit +// +// Copyright 2017 grandcentrix GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import Foundation + +@objc(GCXDiscoveryConfiguration) public class DiscoveryConfiguration: NSObject { + public let serviceType: String + public var serviceNamePrefix: String? + + public init(serviceType: String, serviceNamePrefix: String?) { + self.serviceType = serviceType + self.serviceNamePrefix = serviceNamePrefix + } +} diff --git a/GCXMulticastDNSKit/GCXMulticastDNSKit.h b/GCXMulticastDNSKit/GCXMulticastDNSKit.h new file mode 100644 index 0000000..ede23f4 --- /dev/null +++ b/GCXMulticastDNSKit/GCXMulticastDNSKit.h @@ -0,0 +1,29 @@ +// +// GCXMulticastDNSKit.h +// GCXMulticastDNSKit +// +// Copyright 2017 grandcentrix GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#import + +//! Project version number for GCXMulticastDNSKit. +FOUNDATION_EXPORT double GCXMulticastDNSKitVersionNumber; + +//! Project version string for GCXMulticastDNSKit. +FOUNDATION_EXPORT const unsigned char GCXMulticastDNSKitVersionString[]; + +// In this header, you should import all the public headers of your framework using statements like #import + + diff --git a/GCXMulticastDNSKit/Info.plist b/GCXMulticastDNSKit/Info.plist new file mode 100644 index 0000000..fbe1e6b --- /dev/null +++ b/GCXMulticastDNSKit/Info.plist @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleVersion + $(CURRENT_PROJECT_VERSION) + NSPrincipalClass + + + diff --git a/GCXMulticastDNSKitTests/GCXDiscoveryObjectiveCIntegration.m b/GCXMulticastDNSKitTests/GCXDiscoveryObjectiveCIntegration.m new file mode 100644 index 0000000..1b4bfae --- /dev/null +++ b/GCXMulticastDNSKitTests/GCXDiscoveryObjectiveCIntegration.m @@ -0,0 +1,52 @@ +// +// GCXDiscoveryObjectiveCIntegration.m +// GCXMulticastDNSKit +// +// Copyright 2017 grandcentrix GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#import + +@import GCXMulticastDNSKit; + +@interface GCXDiscoveryObjectiveCIntegration : XCTestCase + +@end + +@implementation GCXDiscoveryObjectiveCIntegration + + + +- (void)testIntegration { + GCXDiscoveryConfiguration *configuration = [[GCXDiscoveryConfiguration alloc] initWithServiceType:@"testService" serviceNamePrefix:nil]; + + NSArray *configs = @[ configuration ]; + GCXDiscovery *discovery = [[GCXDiscovery alloc]initWith:configs delegate:self serviceResolveTimeout:10]; + XCTAssertNotNil(discovery); +} + + + +#pragma mark - GCXDiscoveryDelegate + +- (void)discoveryDidDiscoverWithService:(GCXDiscoveryService * _Nonnull)service { +} + +- (void)discoveryDidFailWithConfiguration:(GCXDiscoveryConfiguration * _Nonnull)configuration error:(enum GCXDiscoveryError)error { +} + +- (void)discoveryDidDisappearWithService:(GCXDiscoveryService * _Nonnull)service { +} + +@end diff --git a/GCXMulticastDNSKitTests/GCXDiscoveryTests.swift b/GCXMulticastDNSKitTests/GCXDiscoveryTests.swift new file mode 100644 index 0000000..ebf6616 --- /dev/null +++ b/GCXMulticastDNSKitTests/GCXDiscoveryTests.swift @@ -0,0 +1,133 @@ +// +// GCXDiscoveryTests.swift +// GCXMulticastDNSKit +// +// Copyright 2017 grandcentrix GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import XCTest +@testable import GCXMulticastDNSKit + + +class GCXDiscoveryTests: XCTestCase { + + var service: NetService? + var didDiscoverExpectation: XCTestExpectation? + + var discovery: Discovery? + + override func tearDown() { + service?.stop() + discovery?.stopDiscovery() + discovery = nil + } + + func testThatInitialzationWithEmptyConfigurationReturnsNil() { + let disovery = Discovery(with: [], delegate: self) + XCTAssertNil(disovery) + } + + func testThatInitialzationWithValidConfigurationReturnsObject() { + let configuration = DiscoveryConfiguration(serviceType: "testService", serviceNamePrefix: nil) + let disovery = Discovery(with: [configuration], delegate: self) + XCTAssertNotNil(disovery) + } + + func testThatInitialzationForClosuresWithEmptyConfigurationReturnsNil() { + let disovery = Discovery(with: [], discoverHandler: nil, failHandler: nil, serviceRemovedHandler: nil) + XCTAssertNil(disovery) + } + + func testThatInitialzationForClosuresWithValidConfigurationReturnsObject() { + let configuration = DiscoveryConfiguration(serviceType: "testService", serviceNamePrefix: nil) + let disovery = Discovery(with: [configuration], discoverHandler: nil, failHandler: nil, serviceRemovedHandler: nil) + XCTAssertNotNil(disovery) + } + + func testThatDiscoveryIsStoppedBeforeStartingANewDiscovery() { + let discoveryConfiguration = DiscoveryConfiguration(serviceType: "serviceType", serviceNamePrefix: nil) + + class DiscoveryMock : Discovery { + var expectation: XCTestExpectation? + + override func stopDiscovery() { + expectation?.fulfill() + super.stopDiscovery() + } + } + guard let discovery = DiscoveryMock(with: [ discoveryConfiguration], delegate: self) else { + XCTAssertTrue(false, "Could not initialize discovery") + return + } + + discovery.expectation = self.expectation(description: "stopDiscovery is called before starting") + discovery.startDiscovery() + waitForExpectations(timeout: 0, handler: nil) + } + + + func testThatAPublishedServiceIsDiscoveredUsingDelegate() { + service = NetService(domain: "", type: "_http._tcp", name: "GCXDNSKitTest", port: 10000 ) + service?.publish() + + let discoveryConfiguration = DiscoveryConfiguration(serviceType: "_http._tcp", serviceNamePrefix: "GCXDNSKitTest") + + guard let discovery = Discovery(with: [ discoveryConfiguration], delegate: self) else { + XCTAssertTrue(false, "Could not initialize discovery") + return + } + + self.discovery = discovery + didDiscoverExpectation = self.expectation(description: "disovery did discover service") + discovery.startDiscovery() + waitForExpectations(timeout: 10, handler: nil) + } + + func testThatAPublishedServiceIsDiscoveredUsingClosures() { + service = NetService(domain: "", type: "_http._tcp", name: "GCXDNSKitTest", port: 10000 ) + service?.publish() + + didDiscoverExpectation = self.expectation(description: "disovery did discover service") + + let discoveryConfiguration = DiscoveryConfiguration(serviceType: "_http._tcp", serviceNamePrefix: "GCXDNSKitTest") + guard let discovery = Discovery(with: [ discoveryConfiguration ], discoverHandler: { [unowned self] (service) in + self.didDiscoverExpectation?.fulfill() + }, failHandler: nil, serviceRemovedHandler: nil) else { + XCTAssertTrue(false, "Could not initialize discovery") + return + } + + self.discovery = discovery + discovery.startDiscovery() + waitForExpectations(timeout: 10, handler: nil) + } + + + + +} + +extension GCXDiscoveryTests: DiscoveryDelegate{ + + func discoveryDidDiscover(service: DiscoveryService) { + didDiscoverExpectation?.fulfill() + } + + func discoveryDidDisappear(service: DiscoveryService) { + } + + func discoveryDidFail(configuration: DiscoveryConfiguration, error: DiscoveryError) { + + } +} diff --git a/GCXMulticastDNSKitTests/Info.plist b/GCXMulticastDNSKitTests/Info.plist new file mode 100644 index 0000000..6c6c23c --- /dev/null +++ b/GCXMulticastDNSKitTests/Info.plist @@ -0,0 +1,22 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + + diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..3d1ec59 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2017 grandcentrix GmbH + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/README.md b/README.md new file mode 100644 index 0000000..3db9dbb --- /dev/null +++ b/README.md @@ -0,0 +1,67 @@ +# GCXMulticastDNSKit + [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) ![Release](https://img.shields.io/github/release/grandcentrix/GCXMulticastDNSKit.svg) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) [![Cocoapods compatible](https://img.shields.io/cocoapods/v/GCXMulticastDNSKit.svg)](https://cocoapods.org/) + + +Multicast DNS framework for iOS + +## Abtract + +GCXMulticastDNSKit is a framework that can be used to discover network services that are announced on the local network. It is a wrapper for the network services provided by Apple. + +## Introduction + +mDNS is a service to resolve hostnames on a local network without the use of a central domain name server. Instead a resolving host simply sends a DNS query to a local multicast address and the host with that name responds with a multicast message with its IP address. Multicast DNS is also used in combination with DNS based service discovery where a host that provides a network service can announce its service to the local network. Those services can then be discovered using multicast messages + +See: [1] [Multicast DNS](https://en.wikipedia.org/wiki/Multicast_DNS) + [2] [Zeroconf Service discovery](https://en.wikipedia.org/wiki/Zero-configuration_networking#Service_discovery) + +This framework currenlty provides functionality to discover services on the local network based on their service type and service name. + +## Installation + +### Cocoapods + +```ruby +use_frameworks! + +pod 'GCXMulticastDNSKit', :git => 'https://github.com/grandcentrix/GCXMulticastDNSKit.git', :tag => '1.0.1' + +``` + +### Carthage + +```ruby +git "https://github.com/grandcentrix/GCXMulticastDNSKit.git" ~> 1.0.1 + +``` + +## Usage + +To use this framework we assume that you know the service type of the services (for example `_ptp._tcp` is valid service type for PTP/IP services, another example would be `_http._tcp`). Because there can be more than one service that provides functionality you can also specify an optional prefix for service name that must match. For the example below we are looking for PTP compatible cameras from Vendor A. Those announce themselves with a PTP service type and a services name of `Vendor A (#serialnr)`. We want to find all VendorA cameras on the local network so we use `_ptp._tcp` as service type and `Vendor A` as service name prefix: + +```swift +let configurations = [ DiscoveryConfiguration(serviceType: "_ptp._tcp", + serviceNamePrefix: "Vendor A") ] + +discovery = Discovery(withConfigurations:configurations, delegate: self) +discovery?.startDiscovery() + +``` + +## License + +``` +Copyright 2017 grandcentrix GmbH + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +```