Compare commits

...

11 Commits

7 changed files with 56 additions and 9 deletions

View File

@ -72,6 +72,10 @@ extern NSString *const SRHTTPResponseErrorKey;
// Optional array of cookies (NSHTTPCookie objects) to apply to the connections
@property (nonatomic, readwrite) NSArray * requestCookies;
// Optional proxy configuration dictionary (kCFStreamPropertyHTTPProxy format).
// Set before calling -open. Example: Proxyman at 127.0.0.1:9090.
@property (nonatomic, strong) NSDictionary *proxyDictionary;
// This returns the negotiated protocol.
// It will be nil until after the handshake completes.
@property (nonatomic, readonly, copy) NSString *protocol;

View File

@ -619,7 +619,16 @@ static __strong NSData *CRLFCRLF;
_inputStream.delegate = self;
_outputStream.delegate = self;
if (self.proxyDictionary) {
CFReadStreamSetProperty((__bridge CFReadStreamRef)_inputStream,
kCFStreamPropertyHTTPProxy,
(__bridge CFDictionaryRef)self.proxyDictionary);
CFWriteStreamSetProperty((__bridge CFWriteStreamRef)_outputStream,
kCFStreamPropertyHTTPProxy,
(__bridge CFDictionaryRef)self.proxyDictionary);
}
[self setupNetworkServiceType:_urlRequest.networkServiceType];
}

View File

@ -38,6 +38,8 @@
#include <memory>
#include "../../../../../DesktopEditor/graphics/BaseThread.h"
#define _LOGGER_SOCKETS
namespace NSNetwork
{
namespace NSWebSocket
@ -124,6 +126,10 @@ namespace NSNetwork
}
//webSocket.connect(url, queryDst, sio::string_message::create(sAuth));
#ifdef _LOGGER_SOCKETS
m_socket->set_proxy_basic_auth("http://127.0.0.1:9090", "", "");
#endif
m_connecting_in_process = true;
m_socket->connect(m_base->url, queryDst, objAuth);

View File

@ -42,6 +42,8 @@
#include <memory>
#include "../../../../../DesktopEditor/graphics/BaseThread.h"
#define _LOGGER_SOCKETS
namespace NSNetwork
{
namespace NSWebSocket
@ -113,6 +115,10 @@ namespace NSNetwork
}
//webSocket.connect(url, queryDst, sio_no_tls::string_message::create(sAuth));
#ifdef _LOGGER_SOCKETS
m_socket->set_proxy_basic_auth("http://127.0.0.1:9090", "", "");
#endif
m_connecting_in_process = true;
m_socket->connect(m_base->url, queryDst, objAuth);

View File

@ -48,7 +48,7 @@
}
- (void)open
{
{
if (m_url && m_url.length)
{
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:m_url]];
@ -58,6 +58,19 @@
protocols:nil
allowsUntrustedSSLCertificates:YES];
self.socket.delegate = self;
#ifdef _LOGGER_SOCKETS
self.socket.proxyDictionary = @{
(NSString *)kCFNetworkProxiesHTTPEnable: @YES,
(NSString *)kCFNetworkProxiesHTTPProxy: @"127.0.0.1",
(NSString *)kCFNetworkProxiesHTTPPort: @9090,
(NSString *)kCFNetworkProxiesHTTPSEnable: @YES,
(NSString *)kCFNetworkProxiesHTTPSProxy: @"127.0.0.1",
(NSString *)kCFNetworkProxiesHTTPSPort: @9090
};
NSLog(@"[SocketRocket] Proxyman proxy enabled: 127.0.0.1:9090");
#endif
[self.socket open];
}
}
@ -65,7 +78,7 @@
- (void)send:(NSString*)message
{
#if _LOGGER_SOCKETS
#ifdef _LOGGER_SOCKETS
NSLog(@"------------------- SEND TO SOCKET -------------------");
NSLog(@"%@", message);
@ -101,7 +114,7 @@
- (void)webSocket:(SRWebSocket *)webSocket didReceiveMessage:(id)message
{
#if _LOGGER_SOCKETS
#ifdef _LOGGER_SOCKETS
NSLog(@"------------------- SOCKET RECEIVE MESSAGE -------------------");
NSLog(@"%@", message);
@ -119,7 +132,7 @@
{
m_listener->onOpen();
#if _LOGGER_SOCKETS
#ifdef _LOGGER_SOCKETS
NSLog(@"------------------- SOCKET OPEN -------------------");
NSLog(@"URL : %@", webSocket.url);
@ -134,7 +147,7 @@
{
m_listener->onError(error.localizedDescription.stdstring);
#if _LOGGER_SOCKETS
#ifdef _LOGGER_SOCKETS
NSLog(@"---------------------------------------------------------");
NSLog(@"------------------- SOCKET ERROR : %@ ------------", error);
@ -147,7 +160,7 @@
{
m_listener->onClose(code, reason.stdstring);
#if _LOGGER_SOCKETS
#ifdef _LOGGER_SOCKETS
NSLog(@"---------------------------------------------------------");
NSLog(@"------------------- SOCKET CLOSE : %@ -----------", reason);
@ -158,7 +171,7 @@
- (void)webSocket:(SRWebSocket *)webSocket didReceivePong:(NSData *)pongPayload
{
#if _LOGGER_SOCKETS
#ifdef _LOGGER_SOCKETS
NSString *str = [[NSString alloc] initWithData:pongPayload encoding:NSUTF8StringEncoding];

View File

@ -478,6 +478,15 @@ core_android {
!core_android_no_unistd {
DEFINES += HAVE_UNISTD_H HAVE_FCNTL_H
}
core_release {
QMAKE_CFLAGS += -g0
QMAKE_CXXFLAGS += -g0
QMAKE_LFLAGS += -Wl,-s
QMAKE_CFLAGS -= -fno-limit-debug-info
QMAKE_CXXFLAGS -= -fno-limit-debug-info
}
}
core_debug {

View File

@ -267,7 +267,7 @@ namespace SimpleTypes
std::wstring CGuid::ToString (bool braces) const
{
std::wstringstream sstream;
sstream << boost::wformat( L"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x" ) % m_oGUID.a % m_oGUID.b % m_oGUID.c % m_oGUID.d % m_oGUID.e % m_oGUID.f % m_oGUID.g % m_oGUID.h % m_oGUID.i % m_oGUID.j % m_oGUID.k;
sstream << boost::wformat( L"%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X" ) % m_oGUID.a % m_oGUID.b % m_oGUID.c % m_oGUID.d % m_oGUID.e % m_oGUID.f % m_oGUID.g % m_oGUID.h % m_oGUID.i % m_oGUID.j % m_oGUID.k;
std::wstring res = (braces ? L"{" : L"") + sstream.str() + (braces ? L"}" : L"");
return res;
}