Private
Public Access
1
0

Add port number option

This commit is contained in:
James Magahern
2021-06-14 21:40:55 -07:00
parent 3c99b647d2
commit f64ffcb8cc

View File

@@ -17,6 +17,7 @@ void printUsage()
fprintf(stderr, "\t-s \t Use SSL (requires -c option)\n"); fprintf(stderr, "\t-s \t Use SSL (requires -c option)\n");
fprintf(stderr, "\t-c \t SSL certificate path encoded as pkcs12\n"); fprintf(stderr, "\t-c \t SSL certificate path encoded as pkcs12\n");
fprintf(stderr, "\t-a \t Optional access control file\n"); fprintf(stderr, "\t-a \t Optional access control file\n");
fprintf(stderr, "\t-p \t Specify port number (default: 5738)\n");
} }
BOOL acquireCredentials(bool encrypted, const char *accessFile, NSString **out_username, NSString **out_password) BOOL acquireCredentials(bool encrypted, const char *accessFile, NSString **out_username, NSString **out_password)
@@ -104,11 +105,12 @@ int main(int argc, char *const argv[]) {
BOOL usesSSL = NO; BOOL usesSSL = NO;
BOOL showHelp = NO; BOOL showHelp = NO;
BOOL usesAccessControl = NO; BOOL usesAccessControl = NO;
long portNumber = -1;
const char *certPath = NULL; const char *certPath = NULL;
const char *accessFilePath = NULL; const char *accessFilePath = NULL;
int c = -1; int c = -1;
while ( (c = getopt(argc, argv, "hsc:a:")) != -1 ) { while ( (c = getopt(argc, argv, "hsc:a:p:")) != -1 ) {
switch (c) { switch (c) {
case 's': case 's':
usesSSL = YES; usesSSL = YES;
@@ -120,6 +122,9 @@ int main(int argc, char *const argv[]) {
usesAccessControl = YES; usesAccessControl = YES;
accessFilePath = optarg; accessFilePath = optarg;
break; break;
case 'p':
portNumber = strtol(optarg, NULL, 10);
break;
case 'h': case 'h':
showHelp = YES; showHelp = YES;
break; break;
@@ -181,6 +186,10 @@ int main(int argc, char *const argv[]) {
bridge.sslCertPath = [NSString stringWithCString:certPath encoding:NSASCIIStringEncoding]; bridge.sslCertPath = [NSString stringWithCString:certPath encoding:NSASCIIStringEncoding];
} }
if (portNumber > 0) {
bridge.port = portNumber;
}
[bridge connect]; [bridge connect];
BOOL running = YES; BOOL running = YES;