-
Notifications
You must be signed in to change notification settings - Fork 128
Dev for: Support IPv6 in PSWebSocketServer #50 #53
base: develop
Are you sure you want to change the base?
Conversation
…oth. E.g., nil (4+6), "0.0.0.0"(4+6), "::"(4+6), 127.0.0.1"(4), "::1"(6), "192.168.1.10"(4) etc.
@afbytes thanks for this, I'm away on Holiday until August 1st, I'll check this when I get back! |
@@ -48,6 +48,9 @@ @interface PSWebSocketServerConnection : NSObject | |||
@end | |||
@implementation PSWebSocketServerConnection | |||
|
|||
// private member variable | |||
bool _isV6Address = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should have curly braces around it; otherwise it isn't an instance/member variable, it's a global variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, it should be declared in PSWebSocketServer, not PSWebSocketServerConnection.
And you can't initialize an instance variable in its declaration, so the = false
needs to be deleted.
From zwopple#53 with minor fixes For couchbase/couchbase-lite-ios#1238
} | ||
addr.sin_port = htons(port); | ||
_addrData = [NSData dataWithBytes:&addr length:sizeof(addr)]; | ||
_isV6Address = isV6Address; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is wrong: If isV6Address is false but isAnyAddress is true, then _addrData
will contain an IPv6 address, so the CFSocketCreate call below needs to pass PF_INET6
.
I fixed this by removing this line and adding _isV6Address = YES
at the end of the IPv6 branch above (after line 151 in this patch.)
Support specifying the web socket server to listen on IPv4, IPv6 or both. E.g., nil (4+6), "0.0.0.0"(4+6), "::"(4+6), 127.0.0.1"(4), "::1"(6), "192.168.1.10"(4) etc.