mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-05 03:53:44 +02:00
map fix
This commit is contained in:
parent
b6047899a8
commit
a3ec5846df
2 changed files with 14 additions and 34 deletions
|
@ -24,29 +24,6 @@
|
||||||
" <body>\n" \
|
" <body>\n" \
|
||||||
" <div id=\"map\"></div>\n" \
|
" <div id=\"map\"></div>\n" \
|
||||||
" <script>\n" \
|
" <script>\n" \
|
||||||
" var target = document.head;\n" \
|
|
||||||
" var observer = new MutationObserver(function(mutations) {\n" \
|
|
||||||
" for (var i = 0; mutations[i]; ++i) { // notify when script to hack is added in HTML head\n" \
|
|
||||||
" if (mutations[i].addedNodes[0].nodeName == \"SCRIPT\" && mutations[i].addedNodes[0].src.match(/\\/AuthenticationService.Authenticate?/g)) {\n" \
|
|
||||||
" var str = mutations[i].addedNodes[0].src.match(/[?&]callback=.*[&$]/g);\n" \
|
|
||||||
" if (str) {\n" \
|
|
||||||
" if (str[0][str[0].length - 1] == '&') {\n" \
|
|
||||||
" str = str[0].substring(10, str[0].length - 1);\n" \
|
|
||||||
" } else {\n" \
|
|
||||||
" str = str[0].substring(10);\n" \
|
|
||||||
" }\n" \
|
|
||||||
" var split = str.split(\".\");\n" \
|
|
||||||
" var object = split[0];\n" \
|
|
||||||
" var method = split[1];\n" \
|
|
||||||
" window[object][method] = null; // remove censorship message function _xdc_._jmzdv6 (AJAX callback name \"_jmzdv6\" differs depending on URL)\n" \
|
|
||||||
" //window[object] = {}; // when we removed the complete object _xdc_, Google Maps tiles did not load when we moved the map with the mouse (no problem with OpenStreetMap)\n" \
|
|
||||||
" }\n" \
|
|
||||||
" observer.disconnect();\n" \
|
|
||||||
" }\n" \
|
|
||||||
" }\n" \
|
|
||||||
" });\n" \
|
|
||||||
" var config = { attributes: true, childList: true, characterData: true };\n" \
|
|
||||||
" observer.observe(target, config);\n" \
|
|
||||||
" function initMap() {\n" \
|
" function initMap() {\n" \
|
||||||
" var map = new google.maps.Map(document.getElementById('map'), {\n" \
|
" var map = new google.maps.Map(document.getElementById('map'), {\n" \
|
||||||
" zoom: 3\n" \
|
" zoom: 3\n" \
|
||||||
|
@ -68,7 +45,7 @@
|
||||||
" <script src=\"https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/markerclusterer.js\">\n" \
|
" <script src=\"https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/markerclusterer.js\">\n" \
|
||||||
" </script>\n" \
|
" </script>\n" \
|
||||||
" <script async defer\n" \
|
" <script async defer\n" \
|
||||||
" src=\"https://maps.googleapis.com/maps/api/js?callback=initMap\">\n" \
|
" src=\"https://maps.googleapis.com/maps/api/js?key=%s&callback=initMap\">\n" \
|
||||||
" </script>\n" \
|
" </script>\n" \
|
||||||
" </body>\n" \
|
" </body>\n" \
|
||||||
"</html>"
|
"</html>"
|
||||||
|
|
|
@ -179,14 +179,15 @@ struct ForwardingStats
|
||||||
Meter bps;
|
Meter bps;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int64_t s_startTime; // Time service was started
|
static int64_t s_startTime; // Time service was started
|
||||||
static std::vector<int> s_ports; // Ports to bind for UDP traffic
|
static std::vector<int> s_ports; // Ports to bind for UDP traffic
|
||||||
static int s_relayMaxHops = 0; // Max relay hops
|
static int s_relayMaxHops = 0; // Max relay hops
|
||||||
static Identity s_self; // My identity (including secret)
|
static Identity s_self; // My identity (including secret)
|
||||||
static std::atomic_bool s_run; // Remains true until shutdown is ordered
|
static std::atomic_bool s_run; // Remains true until shutdown is ordered
|
||||||
static json s_config; // JSON config file contents
|
static json s_config; // JSON config file contents
|
||||||
static std::string s_statsRoot; // Root to write stats, peers, etc.
|
static std::string s_statsRoot; // Root to write stats, peers, etc.
|
||||||
static std::atomic_bool s_geoInit; // True if geoIP data is initialized
|
static std::atomic_bool s_geoInit; // True if geoIP data is initialized
|
||||||
|
static std::string s_googleMapsAPIKey; // Google maps API key for GeoIP /map feature
|
||||||
|
|
||||||
static Meter s_inputRate;
|
static Meter s_inputRate;
|
||||||
static Meter s_outputRate;
|
static Meter s_outputRate;
|
||||||
|
@ -816,6 +817,7 @@ int main(int argc,char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
s_googleMapsAPIKey = s_config["googleMapsAPIKey"];
|
||||||
std::string geoIpPath = s_config["geoIp"];
|
std::string geoIpPath = s_config["geoIp"];
|
||||||
if (geoIpPath.length() > 0) {
|
if (geoIpPath.length() > 0) {
|
||||||
FILE *gf = fopen(geoIpPath.c_str(),"rb");
|
FILE *gf = fopen(geoIpPath.c_str(),"rb");
|
||||||
|
@ -1004,7 +1006,7 @@ int main(int argc,char **argv)
|
||||||
});
|
});
|
||||||
|
|
||||||
apiServ.Get("/map",[](const httplib::Request &req,httplib::Response &res) {
|
apiServ.Get("/map",[](const httplib::Request &req,httplib::Response &res) {
|
||||||
char tmp[128];
|
char tmp[4096];
|
||||||
if (!s_geoInit) {
|
if (!s_geoInit) {
|
||||||
res.set_content("Not enabled or GeoIP CSV file not finished reading.","text/plain");
|
res.set_content("Not enabled or GeoIP CSV file not finished reading.","text/plain");
|
||||||
return;
|
return;
|
||||||
|
@ -1069,7 +1071,8 @@ int main(int argc,char **argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
o << ZT_GEOIP_HTML_TAIL;
|
OSUtils::ztsnprintf(tmp,sizeof(tmp),ZT_GEOIP_HTML_TAIL,s_googleMapsAPIKey.c_str());
|
||||||
|
o << tmp;
|
||||||
res.set_content(o.str(),"text/html");
|
res.set_content(o.str(),"text/html");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue