6 Commits

Author SHA1 Message Date
Pierre-Olivier Latour
c6d118f4ec Merge pull request #487 from gezihuzi/dev_bonjour_extent
Bonjour service support custom txt data
2020-08-17 06:45:49 -07:00
Pierre-Olivier Latour
0da9ee6afe Merge pull request #497 from trapper-/master
Replace deprecated MobileCoreServices with CoreServices
2020-08-17 06:44:20 -07:00
Regan
6c93927e12 Replace deprecated MobileCoreServices with CoreServices 2020-07-22 12:32:16 +08:00
gezihuzi
f4cf591e50 replace MobileCoreServices to CoreServices 2020-05-29 15:39:20 +08:00
gezihuzi
5c737549fc Merge remote-tracking branch 'origin/master' into dev_bonjour_extent 2020-03-30 10:00:39 +08:00
gezihuzi
2d8dc8775d Support setting txtData 2019-12-14 23:02:23 +08:00
5 changed files with 42 additions and 11 deletions

View File

@@ -26,9 +26,9 @@ Pod::Spec.new do |s|
cs.private_header_files = "GCDWebServer/Core/GCDWebServerPrivate.h"
cs.requires_arc = true
cs.ios.library = 'z'
cs.ios.frameworks = 'MobileCoreServices', 'CFNetwork'
cs.ios.frameworks = 'CoreServices', 'CFNetwork'
cs.tvos.library = 'z'
cs.tvos.frameworks = 'MobileCoreServices', 'CFNetwork'
cs.tvos.frameworks = 'CoreServices', 'CFNetwork'
cs.osx.library = 'z'
cs.osx.framework = 'SystemConfiguration'
end

View File

@@ -96,7 +96,7 @@
CEE28D501AE0098600F4023C /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E2BE851018E79DAF0061360B /* SystemConfiguration.framework */; };
CEE28D511AE0098C00F4023C /* CoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E208D1B2167BB17E00500836 /* CoreServices.framework */; };
CEE28D521AE00A7A00F4023C /* GCDWebServers.h in Headers */ = {isa = PBXBuildFile; fileRef = CEE28CF31AE0051F00F4023C /* GCDWebServers.h */; settings = {ATTRIBUTES = (Public, ); }; };
CEE28D571AE00AFE00F4023C /* MobileCoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E221129C1690B7BA0048D2B2 /* MobileCoreServices.framework */; };
CEE28D571AE00AFE00F4023C /* CoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E221129C1690B7BA0048D2B2 /* CoreServices.framework */; };
CEE28D591AE00AFE00F4023C /* CFNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E22112981690B7AA0048D2B2 /* CFNetwork.framework */; };
CEE28D6A1AE1ABAA00F4023C /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CEE28D691AE1ABAA00F4023C /* UIKit.framework */; };
E208D149167B76B700500836 /* CFNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E208D148167B76B700500836 /* CFNetwork.framework */; };
@@ -161,7 +161,7 @@
E2DDD1B71BE6951A002CE867 /* CFNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E2DDD1B61BE6951A002CE867 /* CFNetwork.framework */; };
E2DDD1BA1BE69545002CE867 /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = E2DDD1B91BE69545002CE867 /* libz.tbd */; };
E2DDD1BC1BE69551002CE867 /* libxml2.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = E2DDD1BB1BE69551002CE867 /* libxml2.tbd */; };
E2DDD1BE1BE6956F002CE867 /* MobileCoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E2DDD1BD1BE6956F002CE867 /* MobileCoreServices.framework */; };
E2DDD1BE1BE6956F002CE867 /* CoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E2DDD1BD1BE6956F002CE867 /* CoreServices.framework */; };
E2DDD1C01BE69576002CE867 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E2DDD1BF1BE69576002CE867 /* UIKit.framework */; };
E2DDD1CE1BE698A8002CE867 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2DDD1CD1BE698A8002CE867 /* AppDelegate.swift */; };
E2DDD1D11BE698A8002CE867 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2DDD1D01BE698A8002CE867 /* ViewController.swift */; };
@@ -293,7 +293,7 @@
E208D1B2167BB17E00500836 /* CoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreServices.framework; path = System/Library/Frameworks/CoreServices.framework; sourceTree = SDKROOT; };
E221128E1690B6470048D2B2 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
E22112981690B7AA0048D2B2 /* CFNetwork.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CFNetwork.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/System/Library/Frameworks/CFNetwork.framework; sourceTree = DEVELOPER_DIR; };
E221129C1690B7BA0048D2B2 /* MobileCoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MobileCoreServices.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/System/Library/Frameworks/MobileCoreServices.framework; sourceTree = DEVELOPER_DIR; };
E221129C1690B7BA0048D2B2 /* CoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreServices.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/System/Library/Frameworks/CoreServices.framework; sourceTree = DEVELOPER_DIR; };
E24039251BA09207000B7089 /* Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
E24039311BA092B7000B7089 /* Tests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Tests.m; sourceTree = "<group>"; };
E24A3C4021E2940600C58878 /* module.modulemap */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.module-map"; path = module.modulemap; sourceTree = "<group>"; };
@@ -335,7 +335,7 @@
E2DDD1B61BE6951A002CE867 /* CFNetwork.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CFNetwork.framework; path = Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS9.0.sdk/System/Library/Frameworks/CFNetwork.framework; sourceTree = DEVELOPER_DIR; };
E2DDD1B91BE69545002CE867 /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS9.0.sdk/usr/lib/libz.tbd; sourceTree = DEVELOPER_DIR; };
E2DDD1BB1BE69551002CE867 /* libxml2.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libxml2.tbd; path = Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS9.0.sdk/usr/lib/libxml2.tbd; sourceTree = DEVELOPER_DIR; };
E2DDD1BD1BE6956F002CE867 /* MobileCoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MobileCoreServices.framework; path = Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS9.0.sdk/System/Library/Frameworks/MobileCoreServices.framework; sourceTree = DEVELOPER_DIR; };
E2DDD1BD1BE6956F002CE867 /* CoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreServices.framework; path = Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS9.0.sdk/System/Library/Frameworks/CoreServices.framework; sourceTree = DEVELOPER_DIR; };
E2DDD1BF1BE69576002CE867 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS9.0.sdk/System/Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; };
E2DDD1C71BE698A8002CE867 /* GCDWebServer.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = GCDWebServer.app; sourceTree = BUILT_PRODUCTS_DIR; };
E2DDD1CD1BE698A8002CE867 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
@@ -387,7 +387,7 @@
buildActionMask = 2147483647;
files = (
CEE28D6A1AE1ABAA00F4023C /* UIKit.framework in Frameworks */,
CEE28D571AE00AFE00F4023C /* MobileCoreServices.framework in Frameworks */,
CEE28D571AE00AFE00F4023C /* CoreServices.framework in Frameworks */,
CEE28D591AE00AFE00F4023C /* CFNetwork.framework in Frameworks */,
E2DDD2251BE6A0AE002CE867 /* libxml2.tbd in Frameworks */,
E2DDD2271BE6A0B4002CE867 /* libz.tbd in Frameworks */,
@@ -407,7 +407,7 @@
buildActionMask = 2147483647;
files = (
E2DDD1C01BE69576002CE867 /* UIKit.framework in Frameworks */,
E2DDD1BE1BE6956F002CE867 /* MobileCoreServices.framework in Frameworks */,
E2DDD1BE1BE6956F002CE867 /* CoreServices.framework in Frameworks */,
E2DDD1B71BE6951A002CE867 /* CFNetwork.framework in Frameworks */,
E2DDD1BC1BE69551002CE867 /* libxml2.tbd in Frameworks */,
E2DDD1BA1BE69545002CE867 /* libz.tbd in Frameworks */,
@@ -490,7 +490,7 @@
isa = PBXGroup;
children = (
CEE28D691AE1ABAA00F4023C /* UIKit.framework */,
E221129C1690B7BA0048D2B2 /* MobileCoreServices.framework */,
E221129C1690B7BA0048D2B2 /* CoreServices.framework */,
E22112981690B7AA0048D2B2 /* CFNetwork.framework */,
E2DDD2241BE6A0AE002CE867 /* libxml2.tbd */,
E2DDD2261BE6A0B4002CE867 /* libz.tbd */,
@@ -593,7 +593,7 @@
isa = PBXGroup;
children = (
E2DDD1BF1BE69576002CE867 /* UIKit.framework */,
E2DDD1BD1BE6956F002CE867 /* MobileCoreServices.framework */,
E2DDD1BD1BE6956F002CE867 /* CoreServices.framework */,
E2DDD1B61BE6951A002CE867 /* CFNetwork.framework */,
E2DDD1BB1BE69551002CE867 /* libxml2.tbd */,
E2DDD1B91BE69545002CE867 /* libz.tbd */,

View File

@@ -92,6 +92,13 @@ extern NSString* const GCDWebServerOption_Port;
*/
extern NSString* const GCDWebServerOption_BonjourName;
/**
* The Bonjour TXT Data used by the GCDWebServer (NSDictionary<NSString, NSString>).
*
* The default value is nil.
*/
extern NSString* const GCDWebServerOption_BonjourTXTData;
/**
* The Bonjour service type used by the GCDWebServer (NSString).
*

View File

@@ -53,6 +53,7 @@
NSString* const GCDWebServerOption_Port = @"Port";
NSString* const GCDWebServerOption_BonjourName = @"BonjourName";
NSString* const GCDWebServerOption_BonjourType = @"BonjourType";
NSString* const GCDWebServerOption_BonjourTXTData = @"BonjourTXTData";
NSString* const GCDWebServerOption_RequestNATPortMapping = @"RequestNATPortMapping";
NSString* const GCDWebServerOption_BindToLocalhost = @"BindToLocalhost";
NSString* const GCDWebServerOption_MaxPendingConnections = @"MaxPendingConnections";
@@ -590,6 +591,29 @@ static inline NSString* _EncodeBase64(NSString* string) {
CFNetServiceSetClient(_registrationService, _NetServiceRegisterCallBack, &context);
CFNetServiceScheduleWithRunLoop(_registrationService, CFRunLoopGetMain(), kCFRunLoopCommonModes);
CFStreamError streamError = {0};
NSDictionary* txtDataDictionary = _GetOption(_options, GCDWebServerOption_BonjourTXTData, nil);
if (txtDataDictionary != nil) {
NSUInteger count = txtDataDictionary.count;
CFStringRef keys[count];
CFStringRef values[count];
NSUInteger index = 0;
for (NSString *key in txtDataDictionary) {
NSString *value = txtDataDictionary[key];
keys[index] = (__bridge CFStringRef)(key);
values[index] = (__bridge CFStringRef)(value);
index ++;
}
CFDictionaryRef txtDictionary = CFDictionaryCreate(CFAllocatorGetDefault(), (void *)keys, (void *)values, count, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
if (txtDictionary != NULL) {
CFDataRef txtData = CFNetServiceCreateTXTDataWithDictionary(nil, txtDictionary);
Boolean setTXTDataResult = CFNetServiceSetTXTData(_registrationService, txtData);
if (!setTXTDataResult) {
GWS_LOG_ERROR(@"Failed setting TXTData");
}
}
}
CFNetServiceRegisterWithOptions(_registrationService, 0, &streamError);
_resolutionService = CFNetServiceCreateCopy(kCFAllocatorDefault, _registrationService);

View File

@@ -31,7 +31,7 @@
#import <TargetConditionals.h>
#if TARGET_OS_IPHONE
#import <MobileCoreServices/MobileCoreServices.h>
#import <CoreServices/CoreServices.h>
#else
#import <SystemConfiguration/SystemConfiguration.h>
#endif