mirror of https://github.com/tp4a/teleport
macOS助手也支持在https访问web界面时与页面正常通讯了(需要注册根证书)。
parent
ac0a55f78d
commit
93a1b8259c
|
@ -179,7 +179,7 @@ int AppDelegate_select_app (void *_self) {
|
||||||
[mySelectPanel setAllowsMultipleSelection:NO];
|
[mySelectPanel setAllowsMultipleSelection:NO];
|
||||||
[mySelectPanel setResolvesAliases:YES];
|
[mySelectPanel setResolvesAliases:YES];
|
||||||
|
|
||||||
if([mySelectPanel runModal] == NSOKButton) {
|
if([mySelectPanel runModal] == NSModalResponseOK) {
|
||||||
NSURL *ret = [mySelectPanel URL];
|
NSURL *ret = [mySelectPanel URL];
|
||||||
NSLog(@"%@", ret.absoluteString);
|
NSLog(@"%@", ret.absoluteString);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,7 @@
|
||||||
#ifndef __TS_CONST_H__
|
#ifndef __TS_CONST_H__
|
||||||
#define __TS_CONST_H__
|
#define __TS_CONST_H__
|
||||||
|
|
||||||
//#define TS_WEB_URL L"https://www.tp4a.com/"
|
|
||||||
//#define TS_TRAY_MSG L"Teleport助手正常工作中"
|
|
||||||
|
|
||||||
#define TS_HTTP_RPC_PORT 50022
|
#define TS_HTTP_RPC_PORT 50022
|
||||||
//#define TS_HTTP_RPC_HOST "127.0.0.1"
|
#define TS_HTTPS_RPC_PORT 50023
|
||||||
#define TS_HTTP_RPC_HOST "localhost"
|
|
||||||
|
|
||||||
#endif // __TS_CONST_H__
|
#endif // __TS_CONST_H__
|
||||||
|
|
|
@ -18,33 +18,44 @@
|
||||||
#define RDP_CLIENT_FREERDP
|
#define RDP_CLIENT_FREERDP
|
||||||
|
|
||||||
TsHttpRpc g_http_interface;
|
TsHttpRpc g_http_interface;
|
||||||
|
TsHttpRpc g_https_interface;
|
||||||
|
|
||||||
void* g_app = NULL;
|
void* g_app = NULL;
|
||||||
|
|
||||||
int http_rpc_start(void* app) {
|
int http_rpc_start(void* app) {
|
||||||
g_app = app;
|
g_app = app;
|
||||||
|
|
||||||
// if(!g_env.init())
|
EXLOGW("======================================================\n");
|
||||||
// return;
|
|
||||||
|
|
||||||
if (!g_http_interface.init(TS_HTTP_RPC_HOST, TS_HTTP_RPC_PORT))
|
if (!g_http_interface.init_http())
|
||||||
{
|
{
|
||||||
EXLOGE("[ERROR] can not start HTTP-RPC listener, maybe port %d is already in use.\n", TS_HTTP_RPC_PORT);
|
EXLOGE("[ERROR] can not start HTTP-RPC listener, maybe port %d is already in use.\n", TS_HTTP_RPC_PORT);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXLOGW("======================================================\n");
|
EXLOGW("[rpc] TeleportAssist-HTTP-RPC ready on localhost:%d\n", TS_HTTP_RPC_PORT);
|
||||||
EXLOGW("[rpc] TeleportAssist-HTTP-RPC ready on %s:%d\n", TS_HTTP_RPC_HOST, TS_HTTP_RPC_PORT);
|
|
||||||
|
|
||||||
if(!g_http_interface.start())
|
if(!g_http_interface.start())
|
||||||
return -2;
|
return -2;
|
||||||
|
|
||||||
|
if (!g_https_interface.init_https())
|
||||||
|
{
|
||||||
|
EXLOGE("[ERROR] can not start HTTPS-RPC listener, maybe port %d is already in use.\n", TS_HTTPS_RPC_PORT);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
EXLOGW("[rpc] TeleportAssist-HTTPS-RPC ready on localhost:%d\n", TS_HTTPS_RPC_PORT);
|
||||||
|
|
||||||
|
if(!g_https_interface.start())
|
||||||
|
return -2;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void http_rpc_stop(void)
|
void http_rpc_stop(void)
|
||||||
{
|
{
|
||||||
g_http_interface.stop();
|
g_http_interface.stop();
|
||||||
|
g_https_interface.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
#define HEXTOI(x) (isdigit(x) ? x - '0' : x - 'W')
|
#define HEXTOI(x) (isdigit(x) ? x - '0' : x - 'W')
|
||||||
|
@ -95,26 +106,60 @@ TsHttpRpc::~TsHttpRpc()
|
||||||
mg_mgr_free(&m_mg_mgr);
|
mg_mgr_free(&m_mg_mgr);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TsHttpRpc::init(const char* ip, int port)
|
bool TsHttpRpc::init_http()
|
||||||
{
|
{
|
||||||
struct mg_connection* nc = NULL;
|
|
||||||
|
|
||||||
char addr[128] = { 0 };
|
char addr[128] = { 0 };
|
||||||
if (0 == strcmp(ip, "127.0.0.1") || 0 == strcmp(ip, "localhost"))
|
ex_strformat(addr, 128, "tcp://localhost:%d", TS_HTTP_RPC_PORT);
|
||||||
ex_strformat(addr, 128, "tcp://127.0.0.1:%d", port);
|
|
||||||
else
|
|
||||||
ex_strformat(addr, 128, "tcp://%s:%d", ip, port);
|
|
||||||
|
|
||||||
|
struct mg_connection* nc = NULL;
|
||||||
nc = mg_bind(&m_mg_mgr, addr, _mg_event_handler);
|
nc = mg_bind(&m_mg_mgr, addr, _mg_event_handler);
|
||||||
if (nc == NULL)
|
if (nc == NULL) {
|
||||||
{
|
EXLOGE("[rpc] TsHttpRpc::init_http() localhost:%d\n", TS_HTTP_RPC_PORT);
|
||||||
EXLOGE("[rpc] TsHttpRpc::init %s:%d\n", ip, port);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
nc->user_data = this;
|
nc->user_data = this;
|
||||||
|
|
||||||
mg_set_protocol_http_websocket(nc);
|
mg_set_protocol_http_websocket(nc);
|
||||||
|
|
||||||
|
return _on_init();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TsHttpRpc::init_https()
|
||||||
|
{
|
||||||
|
ex_wstr file_ssl_cert = g_env.m_res_path;
|
||||||
|
ex_path_join(file_ssl_cert, false, L"localhost.pem", NULL);
|
||||||
|
ex_wstr file_ssl_key = g_env.m_res_path;
|
||||||
|
ex_path_join(file_ssl_key, false, L"localhost.key", NULL);
|
||||||
|
ex_astr _ssl_cert;
|
||||||
|
ex_wstr2astr(file_ssl_cert, _ssl_cert);
|
||||||
|
ex_astr _ssl_key;
|
||||||
|
ex_wstr2astr(file_ssl_key, _ssl_key);
|
||||||
|
|
||||||
|
const char *err = NULL;
|
||||||
|
struct mg_bind_opts bind_opts;
|
||||||
|
memset(&bind_opts, 0, sizeof(bind_opts));
|
||||||
|
bind_opts.ssl_cert = _ssl_cert.c_str();
|
||||||
|
bind_opts.ssl_key = _ssl_key.c_str();
|
||||||
|
bind_opts.error_string = &err;
|
||||||
|
|
||||||
|
char addr[128] = { 0 };
|
||||||
|
ex_strformat(addr, 128, "tcp://localhost:%d", TS_HTTPS_RPC_PORT);
|
||||||
|
|
||||||
|
struct mg_connection* nc = NULL;
|
||||||
|
nc = mg_bind_opt(&m_mg_mgr, addr, _mg_event_handler, bind_opts);
|
||||||
|
if (nc == NULL) {
|
||||||
|
EXLOGE("[rpc] TsHttpRpc::init_https() localhost:%d\n", TS_HTTPS_RPC_PORT);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
nc->user_data = this;
|
||||||
|
|
||||||
|
mg_set_protocol_http_websocket(nc);
|
||||||
|
|
||||||
|
return _on_init();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TsHttpRpc::_on_init() {
|
||||||
m_content_type_map[".js"] = "application/javascript";
|
m_content_type_map[".js"] = "application/javascript";
|
||||||
m_content_type_map[".png"] = "image/png";
|
m_content_type_map[".png"] = "image/png";
|
||||||
m_content_type_map[".jpeg"] = "image/jpeg";
|
m_content_type_map[".jpeg"] = "image/jpeg";
|
||||||
|
|
|
@ -59,7 +59,8 @@ public:
|
||||||
TsHttpRpc();
|
TsHttpRpc();
|
||||||
~TsHttpRpc();
|
~TsHttpRpc();
|
||||||
|
|
||||||
bool init(const char* ip, int port);
|
bool init_http();
|
||||||
|
bool init_https();
|
||||||
|
|
||||||
ex_astr get_content_type(ex_astr file_suffix)
|
ex_astr get_content_type(ex_astr file_suffix)
|
||||||
{
|
{
|
||||||
|
@ -79,6 +80,8 @@ protected:
|
||||||
// void _set_stop_flag(void);
|
// void _set_stop_flag(void);
|
||||||
// void _on_stop();
|
// void _on_stop();
|
||||||
|
|
||||||
|
bool _on_init();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int _parse_request(struct http_message* req, ex_astr& func_cmd, ex_astr& func_args);
|
int _parse_request(struct http_message* req, ex_astr& func_cmd, ex_astr& func_args);
|
||||||
void _process_js_request(const ex_astr& func_cmd, const ex_astr& func_args, ex_astr& buf);
|
void _process_js_request(const ex_astr& func_cmd, const ex_astr& func_args, ex_astr& buf);
|
||||||
|
|
|
@ -37,6 +37,8 @@
|
||||||
7AA2CD541F6AB9F10074C92B /* json_writer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7AA2CD501F6AB9F10074C92B /* json_writer.cpp */; };
|
7AA2CD541F6AB9F10074C92B /* json_writer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7AA2CD501F6AB9F10074C92B /* json_writer.cpp */; };
|
||||||
7AA2CD571F6ABA2E0074C92B /* mongoose.c in Sources */ = {isa = PBXBuildFile; fileRef = 7AA2CD561F6ABA2E0074C92B /* mongoose.c */; };
|
7AA2CD571F6ABA2E0074C92B /* mongoose.c in Sources */ = {isa = PBXBuildFile; fileRef = 7AA2CD561F6ABA2E0074C92B /* mongoose.c */; };
|
||||||
7AA2CD591F6AC0DA0074C92B /* site in Resources */ = {isa = PBXBuildFile; fileRef = 7AA2CD581F6AC0DA0074C92B /* site */; };
|
7AA2CD591F6AC0DA0074C92B /* site in Resources */ = {isa = PBXBuildFile; fileRef = 7AA2CD581F6AC0DA0074C92B /* site */; };
|
||||||
|
7AF9BF272199E3DE00BE5DBC /* libssl.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7AF9BF1F2199E31A00BE5DBC /* libssl.a */; };
|
||||||
|
7AF9BF292199E3DF00BE5DBC /* libcrypto.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7AF9BF282199E3DF00BE5DBC /* libcrypto.a */; };
|
||||||
A1B7B9DD1DB53ED200809327 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = A1B7B9DF1DB53ED200809327 /* Localizable.strings */; };
|
A1B7B9DD1DB53ED200809327 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = A1B7B9DF1DB53ED200809327 /* Localizable.strings */; };
|
||||||
A1D700071A5DCE8D003563E4 /* AboutWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = A1D700061A5DCE8D003563E4 /* AboutWindowController.m */; };
|
A1D700071A5DCE8D003563E4 /* AboutWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = A1D700061A5DCE8D003563E4 /* AboutWindowController.m */; };
|
||||||
C149EBFE15D5214600B1F558 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C149EBFD15D5214600B1F558 /* Cocoa.framework */; };
|
C149EBFE15D5214600B1F558 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C149EBFD15D5214600B1F558 /* Cocoa.framework */; };
|
||||||
|
@ -76,7 +78,6 @@
|
||||||
7A27E4A61F6A899B004FDE5D /* ts_const.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ts_const.h; sourceTree = "<group>"; };
|
7A27E4A61F6A899B004FDE5D /* ts_const.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ts_const.h; sourceTree = "<group>"; };
|
||||||
7A27E4A71F6A8EEC004FDE5D /* ts_env.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ts_env.cpp; sourceTree = "<group>"; };
|
7A27E4A71F6A8EEC004FDE5D /* ts_env.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ts_env.cpp; sourceTree = "<group>"; };
|
||||||
7A27E4A81F6A8EEC004FDE5D /* ts_env.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ts_env.h; sourceTree = "<group>"; };
|
7A27E4A81F6A8EEC004FDE5D /* ts_env.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ts_env.h; sourceTree = "<group>"; };
|
||||||
7A2EC2C1219863A3009CFA85 /* tp_assist.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = tp_assist.entitlements; sourceTree = "<group>"; };
|
|
||||||
7A40FFE21F7B2A4500F11697 /* AppDelegate-C-Interface.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "AppDelegate-C-Interface.h"; sourceTree = "<group>"; };
|
7A40FFE21F7B2A4500F11697 /* AppDelegate-C-Interface.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "AppDelegate-C-Interface.h"; sourceTree = "<group>"; };
|
||||||
7A7C6C8F21973C24006869D9 /* StatusIconAlt@3X.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "StatusIconAlt@3X.png"; sourceTree = "<group>"; };
|
7A7C6C8F21973C24006869D9 /* StatusIconAlt@3X.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "StatusIconAlt@3X.png"; sourceTree = "<group>"; };
|
||||||
7A7C6C9021973C24006869D9 /* StatusIcon@3X.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "StatusIcon@3X.png"; sourceTree = "<group>"; };
|
7A7C6C9021973C24006869D9 /* StatusIcon@3X.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "StatusIcon@3X.png"; sourceTree = "<group>"; };
|
||||||
|
@ -106,6 +107,11 @@
|
||||||
7AA2CD501F6AB9F10074C92B /* json_writer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = json_writer.cpp; path = ../../../../external/jsoncpp/src/lib_json/json_writer.cpp; sourceTree = "<group>"; };
|
7AA2CD501F6AB9F10074C92B /* json_writer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = json_writer.cpp; path = ../../../../external/jsoncpp/src/lib_json/json_writer.cpp; sourceTree = "<group>"; };
|
||||||
7AA2CD561F6ABA2E0074C92B /* mongoose.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = mongoose.c; path = ../../../../external/mongoose/mongoose.c; sourceTree = "<group>"; };
|
7AA2CD561F6ABA2E0074C92B /* mongoose.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = mongoose.c; path = ../../../../external/mongoose/mongoose.c; sourceTree = "<group>"; };
|
||||||
7AA2CD581F6AC0DA0074C92B /* site */ = {isa = PBXFileReference; lastKnownFileType = folder; path = site; sourceTree = "<group>"; };
|
7AA2CD581F6AC0DA0074C92B /* site */ = {isa = PBXFileReference; lastKnownFileType = folder; path = site; sourceTree = "<group>"; };
|
||||||
|
7AF9BF1F2199E31A00BE5DBC /* libssl.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libssl.a; path = ../../external/macos/release/lib/libssl.a; sourceTree = "<group>"; };
|
||||||
|
7AF9BF212199E32B00BE5DBC /* libmbedx509.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libmbedx509.a; path = ../../external/macos/release/lib/libmbedx509.a; sourceTree = "<group>"; };
|
||||||
|
7AF9BF222199E32B00BE5DBC /* libmbedtls.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libmbedtls.a; path = ../../external/macos/release/lib/libmbedtls.a; sourceTree = "<group>"; };
|
||||||
|
7AF9BF232199E32B00BE5DBC /* libmbedcrypto.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libmbedcrypto.a; path = ../../external/macos/release/lib/libmbedcrypto.a; sourceTree = "<group>"; };
|
||||||
|
7AF9BF282199E3DF00BE5DBC /* libcrypto.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libcrypto.a; path = ../../external/macos/release/lib/libcrypto.a; sourceTree = "<group>"; };
|
||||||
A1B7B9D31DB5361700809327 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = "<group>"; };
|
A1B7B9D31DB5361700809327 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = "<group>"; };
|
||||||
A1B7B9DE1DB53ED200809327 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
|
A1B7B9DE1DB53ED200809327 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
A1B7B9E01DB53ED700809327 /* Base */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = Base; path = Base.lproj/Localizable.strings; sourceTree = "<group>"; };
|
A1B7B9E01DB53ED700809327 /* Base */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = Base; path = Base.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
|
@ -137,6 +143,8 @@
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
C149EBFE15D5214600B1F558 /* Cocoa.framework in Frameworks */,
|
C149EBFE15D5214600B1F558 /* Cocoa.framework in Frameworks */,
|
||||||
|
7AF9BF292199E3DF00BE5DBC /* libcrypto.a in Frameworks */,
|
||||||
|
7AF9BF272199E3DE00BE5DBC /* libssl.a in Frameworks */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
@ -239,6 +247,13 @@
|
||||||
path = csrc;
|
path = csrc;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
|
7AF9BF1E2199E0DD00BE5DBC /* mbedtls */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
);
|
||||||
|
name = mbedtls;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
A12D9BE61BCF2C72004F52A6 /* apple-scpt */ = {
|
A12D9BE61BCF2C72004F52A6 /* apple-scpt */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
@ -251,7 +266,6 @@
|
||||||
C149EBEE15D5214600B1F558 = {
|
C149EBEE15D5214600B1F558 = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
7A2EC2C1219863A3009CFA85 /* tp_assist.entitlements */,
|
|
||||||
7A1818951F8242E900F3C882 /* apple-scripts */,
|
7A1818951F8242E900F3C882 /* apple-scripts */,
|
||||||
7AA2CD581F6AC0DA0074C92B /* site */,
|
7AA2CD581F6AC0DA0074C92B /* site */,
|
||||||
C149EBFC15D5214600B1F558 /* Frameworks */,
|
C149EBFC15D5214600B1F558 /* Frameworks */,
|
||||||
|
@ -271,6 +285,11 @@
|
||||||
C149EBFC15D5214600B1F558 /* Frameworks */ = {
|
C149EBFC15D5214600B1F558 /* Frameworks */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
7AF9BF282199E3DF00BE5DBC /* libcrypto.a */,
|
||||||
|
7AF9BF232199E32B00BE5DBC /* libmbedcrypto.a */,
|
||||||
|
7AF9BF222199E32B00BE5DBC /* libmbedtls.a */,
|
||||||
|
7AF9BF212199E32B00BE5DBC /* libmbedx509.a */,
|
||||||
|
7AF9BF1F2199E31A00BE5DBC /* libssl.a */,
|
||||||
C149EBFD15D5214600B1F558 /* Cocoa.framework */,
|
C149EBFD15D5214600B1F558 /* Cocoa.framework */,
|
||||||
C149EBFF15D5214600B1F558 /* Other Frameworks */,
|
C149EBFF15D5214600B1F558 /* Other Frameworks */,
|
||||||
);
|
);
|
||||||
|
@ -290,6 +309,7 @@
|
||||||
C149EC0315D5214600B1F558 /* src */ = {
|
C149EC0315D5214600B1F558 /* src */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
7AF9BF1E2199E0DD00BE5DBC /* mbedtls */,
|
||||||
7A45423D2196E32800FEB5B4 /* cfg */,
|
7A45423D2196E32800FEB5B4 /* cfg */,
|
||||||
7AD3E8741F6A7CC600D2EB48 /* csrc */,
|
7AD3E8741F6A7CC600D2EB48 /* csrc */,
|
||||||
A12D9BE61BCF2C72004F52A6 /* apple-scpt */,
|
A12D9BE61BCF2C72004F52A6 /* apple-scpt */,
|
||||||
|
@ -589,8 +609,20 @@
|
||||||
COMBINE_HIDPI_IMAGES = YES;
|
COMBINE_HIDPI_IMAGES = YES;
|
||||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||||
GCC_PREFIX_HEADER = "src/tp_assist-Prefix.pch";
|
GCC_PREFIX_HEADER = "src/tp_assist-Prefix.pch";
|
||||||
|
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||||
|
"DEBUG=1",
|
||||||
|
MG_ENABLE_SSL,
|
||||||
|
);
|
||||||
|
HEADER_SEARCH_PATHS = (
|
||||||
|
../../common/teleport,
|
||||||
|
../../common/libex/include,
|
||||||
|
../../external/mongoose,
|
||||||
|
../../external/jsoncpp/include,
|
||||||
|
../../external/macos/release/include,
|
||||||
|
);
|
||||||
INFOPLIST_FILE = "src/tp_assist-Info.plist";
|
INFOPLIST_FILE = "src/tp_assist-Info.plist";
|
||||||
MACOSX_DEPLOYMENT_TARGET = 10.10;
|
LIBRARY_SEARCH_PATHS = ../../external/macos/release/lib;
|
||||||
|
MACOSX_DEPLOYMENT_TARGET = 10.13;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = "teleport.${PRODUCT_NAME:rfc1034identifier}";
|
PRODUCT_BUNDLE_IDENTIFIER = "teleport.${PRODUCT_NAME:rfc1034identifier}";
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
VALID_ARCHS = x86_64;
|
VALID_ARCHS = x86_64;
|
||||||
|
@ -605,8 +637,17 @@
|
||||||
COMBINE_HIDPI_IMAGES = YES;
|
COMBINE_HIDPI_IMAGES = YES;
|
||||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||||
GCC_PREFIX_HEADER = "src/tp_assist-Prefix.pch";
|
GCC_PREFIX_HEADER = "src/tp_assist-Prefix.pch";
|
||||||
|
GCC_PREPROCESSOR_DEFINITIONS = MG_ENABLE_SSL;
|
||||||
|
HEADER_SEARCH_PATHS = (
|
||||||
|
../../common/teleport,
|
||||||
|
../../common/libex/include,
|
||||||
|
../../external/mongoose,
|
||||||
|
../../external/jsoncpp/include,
|
||||||
|
../../external/macos/release/include,
|
||||||
|
);
|
||||||
INFOPLIST_FILE = "src/tp_assist-Info.plist";
|
INFOPLIST_FILE = "src/tp_assist-Info.plist";
|
||||||
MACOSX_DEPLOYMENT_TARGET = 10.10;
|
LIBRARY_SEARCH_PATHS = ../../external/macos/release/lib;
|
||||||
|
MACOSX_DEPLOYMENT_TARGET = 10.13;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = "teleport.${PRODUCT_NAME:rfc1034identifier}";
|
PRODUCT_BUNDLE_IDENTIFIER = "teleport.${PRODUCT_NAME:rfc1034identifier}";
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
VALID_ARCHS = x86_64;
|
VALID_ARCHS = x86_64;
|
||||||
|
|
|
@ -96,7 +96,7 @@ INT_PTR CALLBACK eomDlgMainProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARA
|
||||||
|
|
||||||
case IDM_OPEN_CONFIG:
|
case IDM_OPEN_CONFIG:
|
||||||
{
|
{
|
||||||
ShellExecute(nullptr, _T("open"), _T("http://127.0.0.1:50022/config"), nullptr, nullptr, SW_SHOW);
|
ShellExecute(nullptr, _T("open"), _T("http://localhost:50022/config"), nullptr, nullptr, SW_SHOW);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var g_url_base = 'http://127.0.0.1:50022';
|
var g_url_base = 'http://localhost:50022';
|
||||||
|
|
||||||
var g_cfg = null;
|
var g_cfg = null;
|
||||||
|
|
||||||
|
|
|
@ -129,7 +129,7 @@ void http_rpc_main_loop(bool is_https) {
|
||||||
}
|
}
|
||||||
|
|
||||||
EXLOGW("======================================================\n");
|
EXLOGW("======================================================\n");
|
||||||
EXLOGW("[rpc] TeleportAssist-HTTPS-RPC ready on 127.0.0.1:%d\n", TS_HTTPS_RPC_PORT);
|
EXLOGW("[rpc] TeleportAssist-HTTPS-RPC ready on localhost:%d\n", TS_HTTPS_RPC_PORT);
|
||||||
|
|
||||||
g_https_interface.run();
|
g_https_interface.run();
|
||||||
|
|
||||||
|
@ -141,7 +141,7 @@ void http_rpc_main_loop(bool is_https) {
|
||||||
}
|
}
|
||||||
|
|
||||||
EXLOGW("======================================================\n");
|
EXLOGW("======================================================\n");
|
||||||
EXLOGW("[rpc] TeleportAssist-HTTP-RPC ready on 127.0.0.1:%d\n", TS_HTTP_RPC_PORT);
|
EXLOGW("[rpc] TeleportAssist-HTTP-RPC ready on localhost:%d\n", TS_HTTP_RPC_PORT);
|
||||||
|
|
||||||
g_http_interface.run();
|
g_http_interface.run();
|
||||||
|
|
||||||
|
@ -221,11 +221,11 @@ bool TsHttpRpc::init_http() {
|
||||||
struct mg_connection* nc = nullptr;
|
struct mg_connection* nc = nullptr;
|
||||||
|
|
||||||
char addr[128] = { 0 };
|
char addr[128] = { 0 };
|
||||||
ex_strformat(addr, 128, "tcp://127.0.0.1:%d", TS_HTTP_RPC_PORT);
|
ex_strformat(addr, 128, "tcp://localhost:%d", TS_HTTP_RPC_PORT);
|
||||||
|
|
||||||
nc = mg_bind(&m_mg_mgr, addr, _mg_event_handler);
|
nc = mg_bind(&m_mg_mgr, addr, _mg_event_handler);
|
||||||
if (!nc) {
|
if (!nc) {
|
||||||
EXLOGE("[rpc] TsHttpRpc::init 127.0.0.1:%d\n", TS_HTTP_RPC_PORT);
|
EXLOGE("[rpc] TsHttpRpc::init localhost:%d\n", TS_HTTP_RPC_PORT);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
nc->user_data = this;
|
nc->user_data = this;
|
||||||
|
@ -254,13 +254,13 @@ bool TsHttpRpc::init_https() {
|
||||||
|
|
||||||
|
|
||||||
char addr[128] = { 0 };
|
char addr[128] = { 0 };
|
||||||
ex_strformat(addr, 128, "tcp://127.0.0.1:%d", TS_HTTPS_RPC_PORT);
|
ex_strformat(addr, 128, "tcp://localhost:%d", TS_HTTPS_RPC_PORT);
|
||||||
//ex_strformat(addr, 128, "%d", TS_HTTPS_RPC_PORT);
|
//ex_strformat(addr, 128, "%d", TS_HTTPS_RPC_PORT);
|
||||||
|
|
||||||
struct mg_connection* nc = nullptr;
|
struct mg_connection* nc = nullptr;
|
||||||
nc = mg_bind_opt(&m_mg_mgr, addr, _mg_event_handler, bind_opts);
|
nc = mg_bind_opt(&m_mg_mgr, addr, _mg_event_handler, bind_opts);
|
||||||
if (!nc) {
|
if (!nc) {
|
||||||
EXLOGE("[rpc] TsHttpRpc::init 127.0.0.1:%d\n", TS_HTTPS_RPC_PORT);
|
EXLOGE("[rpc] TsHttpRpc::init localhost:%d\n", TS_HTTPS_RPC_PORT);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
nc->user_data = this;
|
nc->user_data = this;
|
||||||
|
|
|
@ -17,14 +17,14 @@
|
||||||
//=================================================================
|
//=================================================================
|
||||||
接口使用说明:
|
接口使用说明:
|
||||||
|
|
||||||
本程序启动后,监听 127.0.0.1:50022,接收http请求,请求格式要求如下:
|
本程序启动后,监听 localhost:50022,接收http请求,请求格式要求如下:
|
||||||
|
|
||||||
GET 方式
|
GET 方式
|
||||||
http://127.0.0.1:50022/method/json_param
|
http://localhost:50022/method/json_param
|
||||||
其中json_param是使用url_encode进行编码后的json格式字符串
|
其中json_param是使用url_encode进行编码后的json格式字符串
|
||||||
|
|
||||||
POST 方式
|
POST 方式
|
||||||
http://127.0.0.1:50022/method
|
http://localhost:50022/method
|
||||||
post的数据区域是json_param
|
post的数据区域是json_param
|
||||||
|
|
||||||
其中,URI分为三个部分:
|
其中,URI分为三个部分:
|
||||||
|
|
Loading…
Reference in New Issue