Comment: | Improve names of several properties |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
bc67e98833c29b4bdd1bbffbc0e88a1d |
User & Date: | js on 2020-05-06 00:32:10 |
Other Links: | manifest | tags |
2020-05-06
| ||
20:25 | Fix Wii build check-in: addbd546c5 user: js tags: trunk | |
00:32 | Improve names of several properties check-in: bc67e98833 user: js tags: trunk | |
2020-05-05
| ||
01:14 | Add OFSCTPSocket check-in: 4592b16fab user: js tags: trunk | |
Modified src/OFDNSResolver.m from [dbbe2fd8c5] to [5d30f91158].
︙ | ︙ | |||
758 759 760 761 762 763 764 | if (_IPv6Socket == nil) { of_socket_address_t address = of_socket_address_parse_ip(@"::", 0); _IPv6Socket = [[OFUDPSocket alloc] init]; [_IPv6Socket of_bindToAddress: &address extraType: SOCK_DNS]; | | | | 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 | if (_IPv6Socket == nil) { of_socket_address_t address = of_socket_address_parse_ip(@"::", 0); _IPv6Socket = [[OFUDPSocket alloc] init]; [_IPv6Socket of_bindToAddress: &address extraType: SOCK_DNS]; _IPv6Socket.canBlock = false; _IPv6Socket.delegate = self; } sock = _IPv6Socket; break; #endif case OF_SOCKET_ADDRESS_FAMILY_IPV4: if (_IPv4Socket == nil) { of_socket_address_t address = of_socket_address_parse_ip(@"0.0.0.0", 0); _IPv4Socket = [[OFUDPSocket alloc] init]; [_IPv4Socket of_bindToAddress: &address extraType: SOCK_DNS]; _IPv4Socket.canBlock = false; _IPv4Socket.delegate = self; } sock = _IPv4Socket; break; default: @throw [OFInvalidArgumentException exception]; |
︙ | ︙ |
Modified src/OFDatagramSocket.h from [c9598f3c24] to [cb9e65f15c].
︙ | ︙ | |||
108 109 110 111 112 113 114 | * than one thread at the same time is not thread-safe, even if copy * was called to create one "instance" for every thread! */ @interface OFDatagramSocket: OFObject <OFCopying, OFReadyForReadingObserving, OFReadyForWritingObserving> { of_socket_t _socket; | | | | | | | | | 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | * than one thread at the same time is not thread-safe, even if copy * was called to create one "instance" for every thread! */ @interface OFDatagramSocket: OFObject <OFCopying, OFReadyForReadingObserving, OFReadyForWritingObserving> { of_socket_t _socket; bool _canBlock; #ifdef OF_WII bool _canSendToBroadcastAddresses; #endif id <OFDatagramSocketDelegate> _Nullable _delegate; OF_RESERVE_IVARS(4) } /*! * @brief Whether the socket can block. * * By default, a socket can block. */ @property (nonatomic) bool canBlock; /*! * @brief Whether the socket can send to broadcast addresses. */ @property (nonatomic) bool canSendToBroadcastAddresses; /*! * @brief The delegate for asynchronous operations on the socket. * * @note The delegate is retained for as long as asynchronous operations are * still ongoing. */ |
︙ | ︙ |
Modified src/OFDatagramSocket.m from [08aed9e1e3] to [4cd95b929d].
︙ | ︙ | |||
65 66 67 68 69 70 71 | @try { if (self.class == [OFDatagramSocket class]) { [self doesNotRecognizeSelector: _cmd]; abort(); } _socket = INVALID_SOCKET; | | | 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | @try { if (self.class == [OFDatagramSocket class]) { [self doesNotRecognizeSelector: _cmd]; abort(); } _socket = INVALID_SOCKET; _canBlock = true; } @catch (id e) { [self release]; @throw e; } return self; } |
︙ | ︙ | |||
87 88 89 90 91 92 93 | } - (id)copy { return [self retain]; } | | | | | | | | | | | | | | 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | } - (id)copy { return [self retain]; } - (bool)canBlock { return _canBlock; } - (void)setCanBlock: (bool)canBlock { #if defined(HAVE_FCNTL) int flags = fcntl(_socket, F_GETFL, 0); if (flags == -1) @throw [OFSetOptionFailedException exceptionWithObject: self errNo: errno]; if (canBlock) flags &= ~O_NONBLOCK; else flags |= O_NONBLOCK; if (fcntl(_socket, F_SETFL, flags) == -1) @throw [OFSetOptionFailedException exceptionWithObject: self errNo: errno]; _canBlock = canBlock; #elif defined(OF_WINDOWS) u_long v = canBlock; if (ioctlsocket(_socket, FIONBIO, &v) == SOCKET_ERROR) @throw [OFSetOptionFailedException exceptionWithObject: self errNo: of_socket_errno()]; _canBlock = canBlock; #else OF_UNRECOGNIZED_SELECTOR #endif } - (void)setCanSendToBroadcastAddresses: (bool)canSendToBroadcastAddresses { int v = canSendToBroadcastAddresses; if (setsockopt(_socket, SOL_SOCKET, SO_BROADCAST, (char *)&v, (socklen_t)sizeof(v)) != 0) @throw [OFSetOptionFailedException exceptionWithObject: self errNo: of_socket_errno()]; #ifdef OF_WII _canSendToBroadcastAddresses = allowed; #endif } - (bool)canSendToBroadcastAddresses { #ifndef OF_WII int v; socklen_t len = sizeof(v); if (getsockopt(_socket, SOL_SOCKET, SO_BROADCAST, (char *)&v, &len) != 0 || len != sizeof(v)) @throw [OFGetOptionFailedException exceptionWithObject: self errNo: of_socket_errno()]; return v; #else return _canSendToBroadcastAddresses; #endif } - (size_t)receiveIntoBuffer: (void *)buffer length: (size_t)length sender: (of_socket_address_t *)sender { |
︙ | ︙ |
Modified src/OFHTTPClient.h from [1c7acee4b8] to [a28aee5e52].
︙ | ︙ | |||
143 144 145 146 147 148 149 | OF_SUBCLASSING_RESTRICTED @interface OFHTTPClient: OFObject { #ifdef OF_HTTPCLIENT_M @public #endif OFObject <OFHTTPClientDelegate> *_Nullable _delegate; | | | | | 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | OF_SUBCLASSING_RESTRICTED @interface OFHTTPClient: OFObject { #ifdef OF_HTTPCLIENT_M @public #endif OFObject <OFHTTPClientDelegate> *_Nullable _delegate; bool _allowsInsecureRedirects, _inProgress; OFTCPSocket *_Nullable _socket; OFURL *_Nullable _lastURL; bool _lastWasHEAD; OFHTTPResponse *_Nullable _lastResponse; } /*! * @brief The delegate of the HTTP request. */ @property OF_NULLABLE_PROPERTY (assign, nonatomic) OFObject <OFHTTPClientDelegate> *delegate; /*! * @brief Whether the HTTP client allows redirects from HTTPS to HTTP. */ @property (nonatomic) bool allowsInsecureRedirects; /*! * @brief Creates a new OFHTTPClient. * * @return A new, autoreleased OFHTTPClient */ + (instancetype)client; |
︙ | ︙ |
Modified src/OFHTTPClient.m from [8b55b3abfe] to [7d20d55912].
︙ | ︙ | |||
349 350 351 352 353 354 355 | if ([newURLScheme caseInsensitiveCompare: @"http"] != OF_ORDERED_SAME && [newURLScheme caseInsensitiveCompare: @"https"] != OF_ORDERED_SAME) follow = false; | | | 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 | if ([newURLScheme caseInsensitiveCompare: @"http"] != OF_ORDERED_SAME && [newURLScheme caseInsensitiveCompare: @"https"] != OF_ORDERED_SAME) follow = false; if (!_client->_allowsInsecureRedirects && [URL.scheme caseInsensitiveCompare: @"https"] == OF_ORDERED_SAME && [newURLScheme caseInsensitiveCompare: @"http"] == OF_ORDERED_SAME) follow = false; if (follow && [_client->_delegate respondsToSelector: @selector( |
︙ | ︙ | |||
1196 1197 1198 1199 1200 1201 1202 | else return defaultShouldFollow(request.method, statusCode); } @end @implementation OFHTTPClient @synthesize delegate = _delegate; | | | 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 | else return defaultShouldFollow(request.method, statusCode); } @end @implementation OFHTTPClient @synthesize delegate = _delegate; @synthesize allowsInsecureRedirects = _allowsInsecureRedirects; + (instancetype)client { return [[[self alloc] init] autorelease]; } - (void)dealloc |
︙ | ︙ |
Modified src/OFIPSocketAsyncConnector.m from [bca137df6a] to [6a448fb9d2].
︙ | ︙ | |||
65 66 67 68 69 70 71 | [super dealloc]; } - (void)didConnect { if (_exception == nil) | | | 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | [super dealloc]; } - (void)didConnect { if (_exception == nil) [_socket setCanBlock: true]; #ifdef OF_HAVE_BLOCKS if (_block != NULL) { if ([_socket isKindOfClass: [OFTCPSocket class]]) ((of_tcp_socket_async_connect_block_t)_block)( _exception); # ifdef OF_HAVE_SCTP |
︙ | ︙ | |||
176 177 178 179 180 181 182 | * Additionally, on Wii, there is no getsockopt(), so it would not be * possible to get the error (or success) after connecting anyway. * * So for now, connecting is blocking on Wii and 3DS. * * FIXME: Use a different thread as a work around. */ | | | | 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | * Additionally, on Wii, there is no getsockopt(), so it would not be * possible to get the error (or success) after connecting anyway. * * So for now, connecting is blocking on Wii and 3DS. * * FIXME: Use a different thread as a work around. */ [_socket setCanBlock: true]; #else [_socket setCanBlock: false]; #endif if (![_socket of_connectSocketToAddress: &address errNo: &errNo]) { #if !defined(OF_NINTENDO_3DS) && !defined(OF_WII) if (errNo == EINPROGRESS) { [OFRunLoop of_addAsyncConnectForSocket: _socket |
︙ | ︙ | |||
211 212 213 214 215 216 217 | return; #if !defined(OF_NINTENDO_3DS) && !defined(OF_WII) } #endif } #if defined(OF_NINTENDO_3DS) || defined(OF_WII) | | | 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | return; #if !defined(OF_NINTENDO_3DS) && !defined(OF_WII) } #endif } #if defined(OF_NINTENDO_3DS) || defined(OF_WII) [_socket setCanBlock: false]; #endif [self didConnect]; } - (void)resolver: (OFDNSResolver *)resolver didResolveHost: (OFString *)host |
︙ | ︙ |
Modified src/OFIPXSocket.m from [f311d46952] to [06e0564b9c].
︙ | ︙ | |||
59 60 61 62 63 64 65 | SOCK_DGRAM | SOCK_CLOEXEC, protocol)) == INVALID_SOCKET) @throw [OFBindFailedException exceptionWithPort: port packetType: packetType socket: self errNo: of_socket_errno()]; | | | 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | SOCK_DGRAM | SOCK_CLOEXEC, protocol)) == INVALID_SOCKET) @throw [OFBindFailedException exceptionWithPort: port packetType: packetType socket: self errNo: of_socket_errno()]; _canBlock = true; #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL_H) && defined(FD_CLOEXEC) if ((flags = fcntl(_socket, F_GETFD, 0)) != -1) fcntl(_socket, F_SETFD, flags | FD_CLOEXEC); #endif if (bind(_socket, &address.sockaddr.sockaddr, address.length) != 0) { |
︙ | ︙ |
Modified src/OFSCTPSocket.h from [1a4def476d] to [946c9ca590].
︙ | ︙ | |||
70 71 72 73 74 75 76 | */ @interface OFSCTPSocket: OFSequencedPacketSocket { OF_RESERVE_IVARS(4) } /*! | > | | | 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | */ @interface OFSCTPSocket: OFSequencedPacketSocket { OF_RESERVE_IVARS(4) } /*! * @brief Whether sending packets can be delayed. Setting this to NO sets * SCTP_NODELAY on the socket. */ @property (nonatomic) bool canDelaySendingPackets; /*! * @brief The delegate for asynchronous operations on the socket. * * @note The delegate is retained for as long as asynchronous operations are * still ongoing. */ |
︙ | ︙ |
Modified src/OFSCTPSocket.m from [e60922f38a] to [f509519c08].
︙ | ︙ | |||
241 242 243 244 245 246 247 | SOCK_STREAM | SOCK_CLOEXEC, IPPROTO_SCTP)) == INVALID_SOCKET) @throw [OFBindFailedException exceptionWithHost: host port: port socket: self errNo: of_socket_errno()]; | | | 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 | SOCK_STREAM | SOCK_CLOEXEC, IPPROTO_SCTP)) == INVALID_SOCKET) @throw [OFBindFailedException exceptionWithHost: host port: port socket: self errNo: of_socket_errno()]; _canBlock = true; #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL) && defined(FD_CLOEXEC) if ((flags = fcntl(_socket, F_GETFD, 0)) != -1) fcntl(_socket, F_SETFD, flags | FD_CLOEXEC); #endif setsockopt(_socket, SOL_SOCKET, SO_REUSEADDR, |
︙ | ︙ | |||
301 302 303 304 305 306 307 | @throw [OFBindFailedException exceptionWithHost: host port: port socket: self errNo: EAFNOSUPPORT]; } } | | | | | | 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 | @throw [OFBindFailedException exceptionWithHost: host port: port socket: self errNo: EAFNOSUPPORT]; } } - (void)setCanDelaySendingPackets: (bool)canDelaySendingPackets { int v = !canDelaySendingPackets; if (setsockopt(_socket, IPPROTO_SCTP, SCTP_NODELAY, (char *)&v, (socklen_t)sizeof(v)) != 0) @throw [OFSetOptionFailedException exceptionWithObject: self errNo: of_socket_errno()]; } - (bool)canDelaySendingPackets { int v; socklen_t len = sizeof(v); if (getsockopt(_socket, IPPROTO_SCTP, SCTP_NODELAY, (char *)&v, &len) != 0 || len != sizeof(v)) @throw [OFGetOptionFailedException exceptionWithObject: self errNo: of_socket_errno()]; return !v; } @end |
Modified src/OFSPXSocket.m from [d20cbb636c] to [9940cead8b].
︙ | ︙ | |||
113 114 115 116 117 118 119 | if (![_socket of_createSocketForAddress: &address errNo: &errNo]) { exception = [self of_connectionFailedExceptionForErrNo: errNo]; goto inform_delegate; } | | | 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | if (![_socket of_createSocketForAddress: &address errNo: &errNo]) { exception = [self of_connectionFailedExceptionForErrNo: errNo]; goto inform_delegate; } _socket.canBlock = false; if (![_socket of_connectSocketToAddress: &address errNo: &errNo]) { if (errNo == EINPROGRESS) { [OFRunLoop of_addAsyncConnectForSocket: _socket mode: runLoopMode delegate: self]; |
︙ | ︙ | |||
142 143 144 145 146 147 148 | - (void)of_socketDidConnect: (id)sock exception: (id)exception { id <OFSPXSocketDelegate> delegate = ((OFSPXSocket *)sock).delegate; if (exception == nil) | | | 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | - (void)of_socketDidConnect: (id)sock exception: (id)exception { id <OFSPXSocketDelegate> delegate = ((OFSPXSocket *)sock).delegate; if (exception == nil) ((OFSPXSocket *)sock).canBlock = true; #ifdef OF_HAVE_BLOCKS if (_block != NULL) _block(exception); else { #endif if ([delegate respondsToSelector: |
︙ | ︙ | |||
333 334 335 336 337 338 339 | SOCK_SEQPACKET | SOCK_CLOEXEC, NSPROTO_SPX)) == INVALID_SOCKET) @throw [OFBindFailedException exceptionWithPort: port packetType: SPX_PACKET_TYPE socket: self errNo: of_socket_errno()]; | | | 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 | SOCK_SEQPACKET | SOCK_CLOEXEC, NSPROTO_SPX)) == INVALID_SOCKET) @throw [OFBindFailedException exceptionWithPort: port packetType: SPX_PACKET_TYPE socket: self errNo: of_socket_errno()]; _canBlock = true; #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL_H) && defined(FD_CLOEXEC) if ((flags = fcntl(_socket, F_GETFD, 0)) != -1) fcntl(_socket, F_SETFD, flags | FD_CLOEXEC); #endif if (bind(_socket, &address.sockaddr.sockaddr, address.length) != 0) { |
︙ | ︙ |
Modified src/OFSPXStreamSocket.m from [65dc3f6ee6] to [cb1a9316c7].
︙ | ︙ | |||
116 117 118 119 120 121 122 | if (![_socket of_createSocketForAddress: &address errNo: &errNo]) { exception = [self of_connectionFailedExceptionForErrNo: errNo]; goto inform_delegate; } | | | 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | if (![_socket of_createSocketForAddress: &address errNo: &errNo]) { exception = [self of_connectionFailedExceptionForErrNo: errNo]; goto inform_delegate; } _socket.canBlock = false; if (![_socket of_connectSocketToAddress: &address errNo: &errNo]) { if (errNo == EINPROGRESS) { [OFRunLoop of_addAsyncConnectForSocket: _socket mode: runLoopMode delegate: self]; |
︙ | ︙ | |||
146 147 148 149 150 151 152 | - (void)of_socketDidConnect: (id)sock exception: (id)exception { id <OFSPXStreamSocketDelegate> delegate = ((OFSPXStreamSocket *)sock).delegate; if (exception == nil) | | | 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | - (void)of_socketDidConnect: (id)sock exception: (id)exception { id <OFSPXStreamSocketDelegate> delegate = ((OFSPXStreamSocket *)sock).delegate; if (exception == nil) ((OFSPXStreamSocket *)sock).canBlock = true; #ifdef OF_HAVE_BLOCKS if (_block != NULL) _block(exception); else { #endif if ([delegate respondsToSelector: |
︙ | ︙ | |||
337 338 339 340 341 342 343 | SOCK_STREAM | SOCK_CLOEXEC, NSPROTO_SPX)) == INVALID_SOCKET) @throw [OFBindFailedException exceptionWithPort: port packetType: SPX_PACKET_TYPE socket: self errNo: of_socket_errno()]; | | | 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 | SOCK_STREAM | SOCK_CLOEXEC, NSPROTO_SPX)) == INVALID_SOCKET) @throw [OFBindFailedException exceptionWithPort: port packetType: SPX_PACKET_TYPE socket: self errNo: of_socket_errno()]; _canBlock = true; #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL_H) && defined(FD_CLOEXEC) if ((flags = fcntl(_socket, F_GETFD, 0)) != -1) fcntl(_socket, F_SETFD, flags | FD_CLOEXEC); #endif if (bind(_socket, &address.sockaddr.sockaddr, address.length) != 0) { |
︙ | ︙ |
Modified src/OFSequencedPacketSocket.h from [5d1d2d056e] to [92ebbc1deb].
︙ | ︙ | |||
126 127 128 129 130 131 132 | * than one thread at the same time is not thread-safe, even if copy * was called to create one "instance" for every thread! */ @interface OFSequencedPacketSocket: OFObject <OFCopying, OFReadyForReadingObserving, OFReadyForWritingObserving> { of_socket_t _socket; | | | | | | 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | * than one thread at the same time is not thread-safe, even if copy * was called to create one "instance" for every thread! */ @interface OFSequencedPacketSocket: OFObject <OFCopying, OFReadyForReadingObserving, OFReadyForWritingObserving> { of_socket_t _socket; bool _canBlock, _listening; of_socket_address_t _remoteAddress; id _Nullable _delegate; OF_RESERVE_IVARS(4) } /*! * @brief Whether the socket can block. * * By default, a socket can block. */ @property (nonatomic) bool canBlock; /*! * @brief Whether the socket is a listening socket. */ @property (readonly, nonatomic, getter=isListening) bool listening; /*! |
︙ | ︙ |
Modified src/OFSequencedPacketSocket.m from [02e9d8a16c] to [395d4dcdd4].
︙ | ︙ | |||
68 69 70 71 72 73 74 | @try { if (self.class == [OFSequencedPacketSocket class]) { [self doesNotRecognizeSelector: _cmd]; abort(); } _socket = INVALID_SOCKET; | | | 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | @try { if (self.class == [OFSequencedPacketSocket class]) { [self doesNotRecognizeSelector: _cmd]; abort(); } _socket = INVALID_SOCKET; _canBlock = true; } @catch (id e) { [self release]; @throw e; } return self; } |
︙ | ︙ | |||
104 105 106 107 108 109 110 | #endif - (id)copy { return [self retain]; } | | | | | | | | | 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | #endif - (id)copy { return [self retain]; } - (bool)canBlock { return _canBlock; } - (void)setCanBlock: (bool)canBlock { #if defined(HAVE_FCNTL) int flags = fcntl(_socket, F_GETFL, 0); if (flags == -1) @throw [OFSetOptionFailedException exceptionWithObject: self errNo: errno]; if (canBlock) flags &= ~O_NONBLOCK; else flags |= O_NONBLOCK; if (fcntl(_socket, F_SETFL, flags) == -1) @throw [OFSetOptionFailedException exceptionWithObject: self errNo: errno]; _canBlock = canBlock; #elif defined(OF_WINDOWS) u_long v = canBlock; if (ioctlsocket(_socket, FIONBIO, &v) == SOCKET_ERROR) @throw [OFSetOptionFailedException exceptionWithObject: self errNo: of_socket_errno()]; _canBlock = canBlock; #else OF_UNRECOGNIZED_SELECTOR #endif } - (size_t)receiveIntoBuffer: (void *)buffer length: (size_t)length |
︙ | ︙ |
Modified src/OFStream.h from [849d120fde] to [cac7e1c78f].
︙ | ︙ | |||
186 187 188 189 190 191 192 | * the methods that do the actual work. OFStream uses those for all other * methods and does all the caching and other stuff for you. If you * override these methods without the `lowlevel` prefix, you *will* break * caching and get broken results! */ @interface OFStream: OFObject <OFCopying> { | | | | | | | | 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | * the methods that do the actual work. OFStream uses those for all other * methods and does all the caching and other stuff for you. If you * override these methods without the `lowlevel` prefix, you *will* break * caching and get broken results! */ @interface OFStream: OFObject <OFCopying> { bool _canBlock; id _Nullable _delegate; #ifndef OF_SEEKABLE_STREAM_M @private #endif char *_Nullable _readBuffer, *_Nullable _readBufferMemory; char *_Nullable _writeBuffer; size_t _readBufferLength, _writeBufferLength; bool _buffersWrites, _waitingForDelimiter; OF_RESERVE_IVARS(4) } /*! * @brief Whether the end of the stream has been reached. */ @property (readonly, nonatomic, getter=isAtEndOfStream) bool atEndOfStream; /*! * @brief Whether writes are buffered. */ @property (nonatomic, nonatomic) bool buffersWrites; /*! * @brief Whether data is present in the internal read buffer. */ @property (readonly, nonatomic) bool hasDataInReadBuffer; /*! * @brief Whether the stream can block. * * By default, a stream can block. * On Win32, setting this currently only works for sockets! */ @property (nonatomic) bool canBlock; /*! * @brief The delegate for asynchronous operations on the stream. * * @note The delegate is retained for as long as asynchronous operations are * still ongoing. */ |
︙ | ︙ |
Modified src/OFStream.m from [c63329fd4a] to [dd10e2b21b].
︙ | ︙ | |||
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | #import "OFWriteFailedException.h" #import "of_asprintf.h" #define MIN_READ_SIZE 512 @implementation OFStream @synthesize of_waitingForDelimiter = _waitingForDelimiter, delegate = _delegate; #if defined(SIGPIPE) && defined(SIG_IGN) + (void)initialize { if (self == [OFStream class]) signal(SIGPIPE, SIG_IGN); } #endif - (instancetype)init { self = [super init]; @try { if (self.class == [OFStream class]) { [self doesNotRecognizeSelector: _cmd]; abort(); } | > | | 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | #import "OFWriteFailedException.h" #import "of_asprintf.h" #define MIN_READ_SIZE 512 @implementation OFStream @synthesize buffersWrites = _buffersWrites; @synthesize of_waitingForDelimiter = _waitingForDelimiter, delegate = _delegate; #if defined(SIGPIPE) && defined(SIG_IGN) + (void)initialize { if (self == [OFStream class]) signal(SIGPIPE, SIG_IGN); } #endif - (instancetype)init { self = [super init]; @try { if (self.class == [OFStream class]) { [self doesNotRecognizeSelector: _cmd]; abort(); } _canBlock = true; } @catch (id e) { [self release]; @throw e; } return self; } |
︙ | ︙ | |||
1124 1125 1126 1127 1128 1129 1130 | - (OFString *)tryReadTillDelimiter: (OFString *)delimiter { return [self tryReadTillDelimiter: delimiter encoding: OF_STRING_ENCODING_UTF_8]; } | < < < < < < < < < < | | | 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 | - (OFString *)tryReadTillDelimiter: (OFString *)delimiter { return [self tryReadTillDelimiter: delimiter encoding: OF_STRING_ENCODING_UTF_8]; } - (void)flushWriteBuffer { if (_writeBuffer == NULL) return; [self lowlevelWriteBuffer: _writeBuffer length: _writeBufferLength]; [self freeMemory: _writeBuffer]; _writeBuffer = NULL; _writeBufferLength = 0; } - (size_t)writeBuffer: (const void *)buffer length: (size_t)length { if (!_buffersWrites) { size_t bytesWritten = [self lowlevelWriteBuffer: buffer length: length]; if (_canBlock && bytesWritten < length) @throw [OFWriteFailedException exceptionWithObject: self requestedLength: length bytesWritten: bytesWritten errNo: 0]; return bytesWritten; |
︙ | ︙ | |||
1796 1797 1798 1799 1800 1801 1802 | } - (bool)hasDataInReadBuffer { return (_readBufferLength > 0); } | | | | | | 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 | } - (bool)hasDataInReadBuffer { return (_readBufferLength > 0); } - (bool)canBlock { return _canBlock; } - (void)setCanBlock: (bool)canBlock { #if defined(HAVE_FCNTL) && !defined(OF_AMIGAOS) bool readImplemented = false, writeImplemented = false; @try { int readFlags; readFlags = fcntl(((id <OFReadyForReadingObserving>)self) .fileDescriptorForReading, F_GETFL, 0); readImplemented = true; if (readFlags == -1) @throw [OFSetOptionFailedException exceptionWithObject: self errNo: errno]; if (canBlock) readFlags &= ~O_NONBLOCK; else readFlags |= O_NONBLOCK; if (fcntl(((id <OFReadyForReadingObserving>)self) .fileDescriptorForReading, F_SETFL, readFlags) == -1) @throw [OFSetOptionFailedException |
︙ | ︙ | |||
1845 1846 1847 1848 1849 1850 1851 | writeImplemented = true; if (writeFlags == -1) @throw [OFSetOptionFailedException exceptionWithObject: self errNo: errno]; | | | | 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 | writeImplemented = true; if (writeFlags == -1) @throw [OFSetOptionFailedException exceptionWithObject: self errNo: errno]; if (canBlock) writeFlags &= ~O_NONBLOCK; else writeFlags |= O_NONBLOCK; if (fcntl(((id <OFReadyForWritingObserving>)self) .fileDescriptorForWriting, F_SETFL, writeFlags) == -1) @throw [OFSetOptionFailedException exceptionWithObject: self errNo: errno]; } @catch (OFNotImplementedException *e) { } if (!readImplemented && !writeImplemented) @throw [OFNotImplementedException exceptionWithSelector: _cmd object: self]; _canBlock = canBlock; #else OF_UNRECOGNIZED_SELECTOR #endif } - (int)fileDescriptorForReading { |
︙ | ︙ | |||
1912 1913 1914 1915 1916 1917 1918 | [self freeMemory: _readBufferMemory]; _readBuffer = _readBufferMemory = NULL; _readBufferLength = 0; [self freeMemory: _writeBuffer]; _writeBuffer = NULL; _writeBufferLength = 0; | | | 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 | [self freeMemory: _readBufferMemory]; _readBuffer = _readBufferMemory = NULL; _readBufferLength = 0; [self freeMemory: _writeBuffer]; _writeBuffer = NULL; _writeBufferLength = 0; _buffersWrites = false; _waitingForDelimiter = false; } @end |
Modified src/OFStreamSocket.m from [1b3aa72b95] to [2df2daa037].
︙ | ︙ | |||
158 159 160 161 162 163 164 | errNo: of_socket_errno()]; #endif return (size_t)bytesWritten; } #if defined(OF_WINDOWS) || defined(OF_AMIGAOS) | | | | | | 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | errNo: of_socket_errno()]; #endif return (size_t)bytesWritten; } #if defined(OF_WINDOWS) || defined(OF_AMIGAOS) - (void)setCanBlock: (bool)canBlock { # ifdef OF_WINDOWS u_long v = canBlock; # else char v = canBlock; # endif if (ioctlsocket(_socket, FIONBIO, &v) == SOCKET_ERROR) @throw [OFSetOptionFailedException exceptionWithObject: self errNo: of_socket_errno()]; _canBlock = canBlock; } #endif - (int)fileDescriptorForReading { #ifndef OF_WINDOWS return _socket; |
︙ | ︙ |
Modified src/OFTCPSocket.h from [8293d08642] to [cedf99692f].
︙ | ︙ | |||
80 81 82 83 84 85 86 | #ifdef OF_HAVE_CLASS_PROPERTIES @property (class, nullable, copy, nonatomic) OFString *SOCKS5Host; @property (class, nonatomic) uint16_t SOCKS5Port; #endif #if !defined(OF_WII) && !defined(OF_NINTENDO_3DS) /*! | | | | > | | 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | #ifdef OF_HAVE_CLASS_PROPERTIES @property (class, nullable, copy, nonatomic) OFString *SOCKS5Host; @property (class, nonatomic) uint16_t SOCKS5Port; #endif #if !defined(OF_WII) && !defined(OF_NINTENDO_3DS) /*! * @brief Whether the socket sends keep alives for the connection. * * @warning This is not available on the Wii or Nintendo 3DS! */ @property (nonatomic) bool sendsKeepAlives; #endif #ifndef OF_WII /*! * @brief Whether sending segments can be delayed. Setting this to NO sets * TCP_NODELAY on the socket. * * @warning This is not available on the Wii! */ @property (nonatomic) bool canDelaySendingSegments; #endif /*! * @brief The host to use as a SOCKS5 proxy. */ @property OF_NULLABLE_PROPERTY (copy, nonatomic) OFString *SOCKS5Host; |
︙ | ︙ |
Modified src/OFTCPSocket.m from [243bdb7d8b] to [dc32b6d4c9].
︙ | ︙ | |||
328 329 330 331 332 333 334 | SOCK_STREAM | SOCK_CLOEXEC, 0)) == INVALID_SOCKET) @throw [OFBindFailedException exceptionWithHost: host port: port socket: self errNo: of_socket_errno()]; | | | 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 | SOCK_STREAM | SOCK_CLOEXEC, 0)) == INVALID_SOCKET) @throw [OFBindFailedException exceptionWithHost: host port: port socket: self errNo: of_socket_errno()]; _canBlock = true; #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL) && defined(FD_CLOEXEC) if ((flags = fcntl(_socket, F_GETFD, 0)) != -1) fcntl(_socket, F_SETFD, flags | FD_CLOEXEC); #endif setsockopt(_socket, SOL_SOCKET, SO_REUSEADDR, |
︙ | ︙ | |||
434 435 436 437 438 439 440 | port: port socket: self errNo: EADDRNOTAVAIL]; #endif } #if !defined(OF_WII) && !defined(OF_NINTENDO_3DS) | | | | | | | | | 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 | port: port socket: self errNo: EADDRNOTAVAIL]; #endif } #if !defined(OF_WII) && !defined(OF_NINTENDO_3DS) - (void)setSendsKeepAlives: (bool)sendsKeepAlives { int v = sendsKeepAlives; if (setsockopt(_socket, SOL_SOCKET, SO_KEEPALIVE, (char *)&v, (socklen_t)sizeof(v)) != 0) @throw [OFSetOptionFailedException exceptionWithObject: self errNo: of_socket_errno()]; } - (bool)sendsKeepAlives { int v; socklen_t len = sizeof(v); if (getsockopt(_socket, SOL_SOCKET, SO_KEEPALIVE, (char *)&v, &len) != 0 || len != sizeof(v)) @throw [OFGetOptionFailedException exceptionWithObject: self errNo: of_socket_errno()]; return v; } #endif #ifndef OF_WII - (void)setCanDelaySendingSegments: (bool)canDelaySendingSegments { int v = !canDelaySendingSegments; if (setsockopt(_socket, IPPROTO_TCP, TCP_NODELAY, (char *)&v, (socklen_t)sizeof(v)) != 0) @throw [OFSetOptionFailedException exceptionWithObject: self errNo: of_socket_errno()]; } - (bool)canDelaySendingSegments { int v; socklen_t len = sizeof(v); if (getsockopt(_socket, IPPROTO_TCP, TCP_NODELAY, (char *)&v, &len) != 0 || len != sizeof(v)) @throw [OFGetOptionFailedException exceptionWithObject: self errNo: of_socket_errno()]; return !v; } #endif - (void)close { #ifdef OF_WII _port = 0; #endif [super close]; } @end |
Modified src/OFTCPSocketSOCKS5Connector.m from [de0e24bef7] to [a4bbcb1257].
︙ | ︙ | |||
71 72 73 74 75 76 77 | [_request release]; [super dealloc]; } - (void)didConnect { | < < < | 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | [_request release]; [super dealloc]; } - (void)didConnect { _socket.delegate = _delegate; #ifdef OF_HAVE_BLOCKS if (_block != NULL) _block(_exception); else { #endif |
︙ | ︙ |
Modified src/OFTLSSocket.h from [c867497861] to [ba822d3148].
︙ | ︙ | |||
77 78 79 80 81 82 83 | * @warning You have to ensure that this is in secure memory protected from * swapping! This is also the reason why this is not an OFString. */ @property OF_NULLABLE_PROPERTY (assign, nonatomic) const char *privateKeyPassphrase; /*! | | | < | 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | * @warning You have to ensure that this is in secure memory protected from * swapping! This is also the reason why this is not an OFString. */ @property OF_NULLABLE_PROPERTY (assign, nonatomic) const char *privateKeyPassphrase; /*! * @brief Whether certificates are verified. * * The default is enabled. */ @property (nonatomic) bool verifiesCertificates; /*! * @brief Initializes the TLS socket with the specified TCP socket as its * underlying socket. * * @param socket The TCP socket to use as underlying socket */ |
︙ | ︙ |
Modified src/OFTarArchive.m from [9fc8cae7a2] to [74012ab28d].
︙ | ︙ | |||
494 495 496 497 498 499 500 | if (_toWrite > 0) @throw [OFTruncatedDataException exception]; remainder = 512 - _entry.size % 512; if (remainder != 512) { | | | | | 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 | if (_toWrite > 0) @throw [OFTruncatedDataException exception]; remainder = 512 - _entry.size % 512; if (remainder != 512) { bool didBufferWrites = _stream.buffersWrites; _stream.buffersWrites = true; while (remainder--) [_stream writeInt8: 0]; [_stream flushWriteBuffer]; _stream.buffersWrites = didBufferWrites; } [_stream release]; _stream = nil; [super close]; } |
︙ | ︙ |
Modified src/OFUDPSocket.m from [2b709ddc80] to [851b1788ef].
︙ | ︙ | |||
54 55 56 57 58 59 60 | @throw [OFBindFailedException exceptionWithHost: host port: port socket: self errNo: of_socket_errno()]; } | | | 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | @throw [OFBindFailedException exceptionWithHost: host port: port socket: self errNo: of_socket_errno()]; } _canBlock = true; #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL) && defined(FD_CLOEXEC) /* {} needed to avoid warning with Clang 10 if next #if is false. */ if ((flags = fcntl(_socket, F_GETFD, 0)) != -1) { fcntl(_socket, F_SETFD, flags | FD_CLOEXEC); } #endif |
︙ | ︙ |
Modified utils/ofhttp/OFHTTP.m from [37d96aee35] to [da5c2f66e5].
︙ | ︙ | |||
554 555 556 557 558 559 560 | @"%[prog]: Cannot use -o / --output when more than one URL " @"has been specified!", @"prog", [OFApplication programName])]; [OFApplication terminateWithStatus: 1]; } if (_insecure) | | | | | 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 | @"%[prog]: Cannot use -o / --output when more than one URL " @"has been specified!", @"prog", [OFApplication programName])]; [OFApplication terminateWithStatus: 1]; } if (_insecure) _HTTPClient.allowsInsecureRedirects = true; [self performSelector: @selector(downloadNextURL) afterDelay: 0]; } - (void)client: (OFHTTPClient *)client didCreateSocket: (OFTCPSocket *)sock request: (OFHTTPRequest *)request { if (_insecure && [sock respondsToSelector: @selector(setVerifiesCertificates:)]) ((id <OFTLSSocket>)sock).verifiesCertificates = false; } - (void)client: (OFHTTPClient *)client wantsRequestBody: (OFStream *)body request: (OFHTTPRequest *)request { /* TODO: Do asynchronously and print status */ |
︙ | ︙ |