Skip to content

Commit bd869b6

Browse files
author
dsward2
committed
This commit adds support for simultaneous http and https connections for the LocalRadio web server and the Icecast server.
Currently, the app built with these changes will not work on older operating systems, e.g., Mac OS X 10.11, due to a compatibility issue with icecast and /usr/lib/libcurl.dylib. This problem will be researched.
1 parent 54765db commit bd869b6

File tree

17 files changed

+388
-82
lines changed

17 files changed

+388
-82
lines changed

IcecastSource/IcecastSource/main.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ - (void)runIcecastSource
199199
{
200200
if (readyToSend == YES)
201201
{
202-
usleep(1000);
202+
usleep(5000);
203203
}
204204
}
205205
else

LocalRadio.xcodeproj/project.pbxproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@
145145
0EA9CD5021228D93005B792B /* libao.4.dylib in Copy Libraries */ = {isa = PBXBuildFile; fileRef = 0EA9CD4F21228BDC005B792B /* libao.4.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
146146
0EB0470821C596C9000285EB /* TLSManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 0EB0470721C596C9000285EB /* TLSManager.m */; };
147147
0EB0470921C59C3E000285EB /* DDKeychain_LocalRadio.m in Sources */ = {isa = PBXBuildFile; fileRef = 0E1F694721BEFF2900A1F356 /* DDKeychain_LocalRadio.m */; };
148+
0EB0470C21C7469F000285EB /* HTTPSWebServerController.m in Sources */ = {isa = PBXBuildFile; fileRef = 0EB0470B21C7469F000285EB /* HTTPSWebServerController.m */; };
149+
0EB0470F21C75661000285EB /* HTTPSWebServerConnection.m in Sources */ = {isa = PBXBuildFile; fileRef = 0EB0470E21C75661000285EB /* HTTPSWebServerConnection.m */; };
148150
0EB5B0EF1F690813008DBE9A /* BUILD.md in Sources */ = {isa = PBXBuildFile; fileRef = 0EB5B0EE1F690813008DBE9A /* BUILD.md */; };
149151
0EB5B0F11F6915D3008DBE9A /* CREDITS.md in Sources */ = {isa = PBXBuildFile; fileRef = 0EB5B0F01F6915D3008DBE9A /* CREDITS.md */; };
150152
0EB5B0F51F6B89D5008DBE9A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0EB5B0F41F6B89D5008DBE9A /* Assets.xcassets */; };
@@ -1651,6 +1653,10 @@
16511653
0EA9CD4F21228BDC005B792B /* libao.4.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libao.4.dylib; sourceTree = "<group>"; };
16521654
0EB0470621C596C9000285EB /* TLSManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TLSManager.h; sourceTree = "<group>"; };
16531655
0EB0470721C596C9000285EB /* TLSManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TLSManager.m; sourceTree = "<group>"; };
1656+
0EB0470A21C7469F000285EB /* HTTPSWebServerController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HTTPSWebServerController.h; sourceTree = "<group>"; };
1657+
0EB0470B21C7469F000285EB /* HTTPSWebServerController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HTTPSWebServerController.m; sourceTree = "<group>"; };
1658+
0EB0470D21C75661000285EB /* HTTPSWebServerConnection.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HTTPSWebServerConnection.h; sourceTree = "<group>"; };
1659+
0EB0470E21C75661000285EB /* HTTPSWebServerConnection.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HTTPSWebServerConnection.m; sourceTree = "<group>"; };
16541660
0EB5B0EE1F690813008DBE9A /* BUILD.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = BUILD.md; sourceTree = "<group>"; };
16551661
0EB5B0F01F6915D3008DBE9A /* CREDITS.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = CREDITS.md; sourceTree = "<group>"; };
16561662
0EB5B0F41F6B89D5008DBE9A /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = Documents/Images/AppIcon/Assets.xcassets; sourceTree = SOURCE_ROOT; };
@@ -3612,8 +3618,12 @@
36123618
0EB0470721C596C9000285EB /* TLSManager.m */,
36133619
0E84C9711ED8DA650065864B /* HTTPWebServerConnection.h */,
36143620
0E84C9721ED8DA650065864B /* HTTPWebServerConnection.m */,
3621+
0EB0470D21C75661000285EB /* HTTPSWebServerConnection.h */,
3622+
0EB0470E21C75661000285EB /* HTTPSWebServerConnection.m */,
36153623
0E4ED1AB1EAB823B00D2157B /* HTTPWebServerController.h */,
36163624
0E4ED1AC1EAB823B00D2157B /* HTTPWebServerController.m */,
3625+
0EB0470A21C7469F000285EB /* HTTPSWebServerController.h */,
3626+
0EB0470B21C7469F000285EB /* HTTPSWebServerController.m */,
36173627
0E28BE691F2B6A47005999FB /* UDPStatusListenerController.h */,
36183628
0E28BE6A1F2B6A47005999FB /* UDPStatusListenerController.m */,
36193629
0E28BE901F2C0DFA005999FB /* UDPStatusListener.h */,
@@ -7460,11 +7470,13 @@
74607470
0E4ECFC31EAB633B00D2157B /* main.m in Sources */,
74617471
0E4ED1901EAB7E5700D2157B /* HTTPFileResponse.m in Sources */,
74627472
0E32F8E41FEBA01600492813 /* TaskItem.m in Sources */,
7473+
0EB0470F21C75661000285EB /* HTTPSWebServerConnection.m in Sources */,
74637474
0EC207671EDCE11A006899EB /* SDRController.m in Sources */,
74647475
0E0563191F1A3C0D0093B473 /* WebViewDelegate.m in Sources */,
74657476
0ED06E3B215F354800430953 /* IcecastSourceController.m in Sources */,
74667477
0E4ECFC01EAB633B00D2157B /* AppDelegate.m in Sources */,
74677478
0EB5B0F11F6915D3008DBE9A /* CREDITS.md in Sources */,
7479+
0EB0470C21C7469F000285EB /* HTTPSWebServerController.m in Sources */,
74687480
0ED07162215F9AF300430953 /* DDLog.m in Sources */,
74697481
0EA9CD4E211E70AA005B792B /* CustomTaskController.m in Sources */,
74707482
0E84C9C11ED935E00065864B /* README.md in Sources */,

LocalRadio/AppDelegate.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
@class LocalRadioAppSettings;
1313
@class HTTPWebServerController;
14+
@class HTTPSWebServerController;
1415
@class SDRController;
1516
@class IcecastController;
1617
@class IcecastSourceController;
@@ -32,12 +33,15 @@
3233

3334
//NS_ASSUME_NONNULL_BEGIN
3435

36+
@property (weak) IBOutlet NSWindow *window;
37+
3538
@property (weak) IBOutlet WebViewDelegate * webViewDelegate;
3639

3740
// These object are instantiated and inter-connected in Inteface Builder
3841
@property (strong) IBOutlet LocalRadioAppSettings * localRadioAppSettings;
3942
@property (strong) IBOutlet SQLiteController * sqliteController;
4043
@property (strong) IBOutlet HTTPWebServerController * httpWebServerController;
44+
@property (strong) IBOutlet HTTPSWebServerController * httpsWebServerController;
4145
@property (strong) IBOutlet SDRController * sdrController;
4246
@property (strong) IBOutlet IcecastController * icecastController;
4347
@property (strong) IBOutlet IcecastSourceController * icecastSourceController;
@@ -118,6 +122,7 @@
118122
@property (weak) IBOutlet NSButton * editSetDefaultsButton;
119123

120124
@property (weak) IBOutlet NSWindow * editConfigurationSheetWindow;
125+
@property (weak) IBOutlet NSWindow * generatingKeysAndCertificatesSheetWindow;
121126

122127
@property (weak) IBOutlet NSButton * showConfigurationFilesButton;
123128
@property (weak) IBOutlet NSButton * changeConfigurationButton;
@@ -148,7 +153,7 @@
148153

149154
- (void)restartServices;
150155

151-
- (NSString *)webServerControllerURLString;
156+
- (NSString *)httpWebServerControllerURLString;
152157

153158

154159
- (IBAction)openLocalRadioServerWebPage:(id)sender;
@@ -166,6 +171,7 @@
166171

167172
- (NSString *)localHostString;
168173
- (NSString *)httpWebServerPortString;
174+
- (NSString *)httpsWebServerPortString;
169175

170176
- (int) processIDForProcessName:(NSString *)processName;
171177

LocalRadio/AppDelegate.m

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#import "AppDelegate.h"
1010
#import "LocalRadioAppSettings.h"
1111
#import "HTTPWebServerController.h"
12+
#import "HTTPSWebServerController.h"
1213
#import "SQLiteController.h"
1314
#import "SDRController.h"
1415
#import "IcecastController.h"
@@ -45,7 +46,6 @@
4546

4647

4748
@interface AppDelegate ()
48-
@property (weak) IBOutlet NSWindow *window;
4949
@end
5050

5151
@implementation AppDelegate
@@ -142,7 +142,7 @@ - (void)configureServices
142142

143143
- (void)finishConfigureServices
144144
{
145-
// runs on main thread
145+
// runs on main thread for AppKit UI elements
146146
self.useWebViewAudioPlayerCheckbox.state = YES;
147147
self.listenMode = kListenModeIdle;
148148

@@ -182,10 +182,16 @@ - (void)periodicUpdateTimerFired:(NSTimer *)timer
182182

183183
- (void)startServices
184184
{
185+
[self.httpWebServerController stopHTTPServer];
186+
187+
[self.httpsWebServerController stopHTTPServer];
188+
185189
[self.icecastController startIcecastServer];
186190

187191
[self.httpWebServerController startHTTPServer];
188192

193+
[self.httpsWebServerController startHTTPServer];
194+
189195
[self.webViewDelegate loadMainPage];
190196

191197
[self updateCurrentTasksText:self];
@@ -531,7 +537,7 @@ - (NSString *)localHostIPString
531537

532538
- (NSString *)httpWebServerPortString
533539
{
534-
NSUInteger webHostPort = self.httpWebServerController.webServerPort;
540+
NSUInteger webHostPort = self.httpWebServerController.serverClassPortNumber.integerValue;
535541

536542
NSString * portString = [NSString stringWithFormat:@"%lu", (unsigned long)webHostPort];
537543

@@ -540,12 +546,37 @@ - (NSString *)httpWebServerPortString
540546

541547
// ================================================================
542548

543-
- (NSString *)webServerControllerURLString
549+
- (NSString *)httpsWebServerPortString
544550
{
545-
NSString * hostString = [self localHostString];
551+
NSUInteger webHostPort = self.httpsWebServerController.serverClassPortNumber.integerValue;
552+
553+
NSString * portString = [NSString stringWithFormat:@"%lu", (unsigned long)webHostPort];
554+
555+
return portString;
556+
}
557+
558+
// ================================================================
559+
560+
- (NSString *)httpWebServerControllerURLString
561+
{
562+
//NSString * hostString = [self localHostString];
563+
NSString * hostString = [self localHostIPString];
546564
NSString * portString = [self httpWebServerPortString];
547565
NSInteger portInteger = portString.integerValue;
548566

567+
NSString * urlString = [NSString stringWithFormat:@"http://%@:%ld", hostString, portInteger];
568+
569+
return urlString;
570+
}
571+
572+
// ================================================================
573+
574+
- (NSString *)httpsWebServerControllerURLString
575+
{
576+
NSString * hostString = [self localHostString];
577+
NSString * portString = [self httpsWebServerPortString];
578+
NSInteger portInteger = portString.integerValue;
579+
549580
NSString * urlString = [NSString stringWithFormat:@"https://%@:%ld", hostString, portInteger];
550581

551582
return urlString;
@@ -931,7 +962,7 @@ - (IBAction)updateViews:(id)sender
931962
}
932963

933964

934-
self.statusLocalRadioURLTextField.stringValue = [self webServerControllerURLString];
965+
self.statusLocalRadioURLTextField.stringValue = [self httpsWebServerControllerURLString];
935966

936967

937968
if (statusPortNumber != NULL)
@@ -990,6 +1021,9 @@ - (void)updateConfiguration
9901021
NSInteger localRadioServerHTTPPort = self.editLocalRadioHTTPServerPortTextField.integerValue;
9911022
[self.localRadioAppSettings setInteger:localRadioServerHTTPPort forKey:@"LocalRadioServerHTTPPort"];
9921023

1024+
NSInteger localRadioServerHTTPSPort = self.editLocalRadioHTTPSServerPortTextField.integerValue;
1025+
[self.localRadioAppSettings setInteger:localRadioServerHTTPSPort forKey:@"LocalRadioServerHTTPSPort"];
1026+
9931027
NSInteger icecastServerMode = 0;
9941028
[self.localRadioAppSettings setInteger:icecastServerMode forKey:@"IcecastServerMode"];
9951029

@@ -1113,7 +1147,7 @@ - (IBAction)changeConfigurationButtonAction:(id)sender
11131147

11141148
- (IBAction)openLocalRadioServerWebPage:(id)sender
11151149
{
1116-
NSString * urlString = [self webServerControllerURLString];
1150+
NSString * urlString = [self httpsWebServerControllerURLString];
11171151

11181152
if (urlString != NULL)
11191153
{

0 commit comments

Comments
 (0)