mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-09 23:00:58 +00:00
Add local geoip
This commit is contained in:
parent
175769b53e
commit
50068b0b0f
@ -5,12 +5,12 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
AssetsBuildDate = "Sun, 22 Nov 2015 22:45:35 GMT"
|
||||
AssetsBuildDate = "Wed, 13 Apr 2016 20:30:55 GMT"
|
||||
)
|
||||
|
||||
func Assets() map[string][]byte {
|
||||
var assets = make(map[string][]byte, 1)
|
||||
|
||||
assets["index.html"], _ = base64.StdEncoding.DecodeString("H4sIAAAJbogA/7Q7e3PbNvL/+1MgbH4l1Uqk5DzakS11EufRzC9pPYk77Z3ON0ORkISYIhgStOwm/u63C4AkQFGOlTStK1HAvrAvLJbo8b1nv5+c/ev0OVmJdTI9ODjGb5KE6XLi0NQh6XIQZtnEKa7TSKxYupRDEU9FzpOE5hMnp0l4/SwU4Uk96EwPCDle0TDGB3hcUxGSaBXmBRUTpxSLwc+OObUSIhvQDyW7nDh/Df54Mjjh6ywUbJ5QhyAzmgLeq+cTGi+phZmGazpxLhndZDwXBvCGxWI1iekli+hA/ugTljLBwmRQRGFCJyN/2EEqpkWUs0wwnhrUOgDDUqx4bsMoIMFEQqdvUS+kEKEojgM1pKYTll6QVU4XEycI1uFVFKf+nHNRiDzM8EfE10E9EDzwH/iPgqgomjF/zQCqKBwCygfbiOuEFitKRS2CHFL8CPluHWbko/5ByIqy5UqMyePhMLs60sM3+ttH6yY8vDAQYlZksJYxSXlK2wgiBCMZwAtQx6Bgf9MxGY0a+oRIG8DgcPh/zeCc5zHNYXRbErGA5RIRt2lvtPhznsQ2znFQL/s4UN6Hj3MeX5MoCYti4lSrq+wZs8tqCu0YslR7r5xdjbQVTzlPCPo40D2spxEZCDIw5D2wcy5o7FTUBL0Sgwj8wqAHKGy9JEUeoeXB0u8LH6Qp40US5lSaPXwfXgUJmxfBMsRIYosFi4JDf+iPpAuA7KAvf8kWTmCQzaanCQ0LSjYhE2SzYmCS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1OxpOkIr6CBybm7stz0CBwLMvYWP6shfbMt5VsuezbQXei+83X3cBQHEGX6Wagy9YA3z/bQo+RakR0jwpwVo1Jb1OfJsQeREqYx149Js2f5Z4i0B5uWax83nyjY3sua9d1kN66pe4NV1rwMD61VzktsO/rPIv2/CPw/AAAA//8BAAD//yYmmqszMAAA")
|
||||
return assets
|
||||
}
|
||||
|
@ -103,6 +103,11 @@
|
||||
</tfoor>
|
||||
</table>
|
||||
</div>
|
||||
<hr>
|
||||
<p>
|
||||
This product includes GeoLite2 data created by MaxMind, available from
|
||||
<a href="http://www.maxmind.com">http://www.maxmind.com</a>.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
||||
@ -200,15 +205,6 @@
|
||||
|
||||
$scope.uri[relay.url] = uri;
|
||||
|
||||
initProgress("Resolving location for " + uri.hostname);
|
||||
var resolveGeoIp = $http.get('http://ipinfo.io/' + uri.hostname).then(function (response) {
|
||||
progressDone("Resolving location for " + uri.hostname);
|
||||
|
||||
$scope.geoip[relay.url] = response.data;
|
||||
});
|
||||
|
||||
promises.push(resolveGeoIp);
|
||||
|
||||
var resolveStatus = $q.defer();
|
||||
|
||||
initProgress("Getting relay status for " + uri.hostname);
|
||||
@ -249,23 +245,22 @@
|
||||
|
||||
angular.forEach($scope.relays, function(relay) {
|
||||
var scope = $rootScope.$new(true);
|
||||
var geoip = $scope.geoip[relay.url];
|
||||
var loc = relay.location.latitude + "," + relay.location.longitude;
|
||||
|
||||
// Deal with overlapping markers
|
||||
while (geoip.loc in usedLocs) {
|
||||
var locParts = geoip.loc.split(',');
|
||||
while (loc in usedLocs) {
|
||||
var locParts = loc.split(',');
|
||||
locParts = [parseFloat(locParts[0]), parseFloat(locParts[1])];
|
||||
locParts[Math.round(Math.random())] += 0.5 * (Math.random() >= 0.5 ? 1 : -1);
|
||||
geoip.loc = locParts.join(',');
|
||||
loc = locParts.join(',');
|
||||
}
|
||||
|
||||
usedLocs[geoip.loc] = true;
|
||||
usedLocs[loc] = true;
|
||||
|
||||
var locParts = geoip.loc.split(',');
|
||||
var locParts = loc.split(',');
|
||||
var position = new google.maps.LatLng(locParts[0], locParts[1]);
|
||||
|
||||
scope.status = $scope.status[relay.url];
|
||||
scope.geoip = geoip;
|
||||
scope.relay = relay;
|
||||
scope.uri = $scope.uri[relay.url];
|
||||
|
||||
|
@ -25,15 +25,23 @@ import (
|
||||
"github.com/golang/groupcache/lru"
|
||||
"github.com/juju/ratelimit"
|
||||
|
||||
"github.com/oschwald/geoip2-golang"
|
||||
|
||||
"github.com/syncthing/relaypoolsrv/auto"
|
||||
"github.com/syncthing/syncthing/lib/relay/client"
|
||||
"github.com/syncthing/syncthing/lib/sync"
|
||||
"github.com/syncthing/syncthing/lib/tlsutil"
|
||||
)
|
||||
|
||||
type location struct {
|
||||
Latitude float64 `json:"latitude"`
|
||||
Longitude float64 `json:"longitude"`
|
||||
}
|
||||
|
||||
type relay struct {
|
||||
URL string `json:"url"`
|
||||
uri *url.URL
|
||||
URL string `json:"url"`
|
||||
Location location `json:"location"`
|
||||
uri *url.URL
|
||||
}
|
||||
|
||||
func (r relay) String() string {
|
||||
@ -68,6 +76,7 @@ var (
|
||||
postLimit time.Duration
|
||||
permRelaysFile string
|
||||
ipHeader string
|
||||
geoipPath string
|
||||
|
||||
getMut sync.RWMutex = sync.NewRWMutex()
|
||||
getLRUCache *lru.Cache
|
||||
@ -96,6 +105,7 @@ func main() {
|
||||
flag.Int64Var(&postLimitBurst, "post-limit-burst", postLimitBurst, "Allowed burst post requests")
|
||||
flag.StringVar(&permRelaysFile, "perm-relays", "", "Path to list of permanent relays")
|
||||
flag.StringVar(&ipHeader, "ip-header", "", "Name of header which holds clients ip:port. Only meaningful when running behind a reverse proxy.")
|
||||
flag.StringVar(&geoipPath, "geoip", "GeoLite2-City.mmdb", "Path to GeoLite2-City database")
|
||||
|
||||
flag.Parse()
|
||||
|
||||
@ -333,6 +343,7 @@ func handlePostRequest(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
newRelay.uri = uri
|
||||
newRelay.Location = getLocation(uri.Host)
|
||||
|
||||
for _, current := range permanentRelays {
|
||||
if current.uri.Host == newRelay.uri.Host {
|
||||
@ -483,8 +494,9 @@ func loadPermanentRelays(file string) {
|
||||
}
|
||||
|
||||
permanentRelays = append(permanentRelays, relay{
|
||||
URL: line,
|
||||
uri: uri,
|
||||
URL: line,
|
||||
Location: getLocation(uri.Host),
|
||||
uri: uri,
|
||||
})
|
||||
if debug {
|
||||
log.Println("Adding permanent relay", line)
|
||||
@ -506,3 +518,26 @@ func createTestCertificate() tls.Certificate {
|
||||
|
||||
return cert
|
||||
}
|
||||
|
||||
func getLocation(host string) location {
|
||||
db, err := geoip2.Open(geoipPath)
|
||||
if err != nil {
|
||||
return location{}
|
||||
}
|
||||
defer db.Close()
|
||||
|
||||
addr, err := net.ResolveTCPAddr("tcp", host)
|
||||
if err != nil {
|
||||
return location{}
|
||||
}
|
||||
|
||||
city, err := db.City(addr.IP)
|
||||
if err != nil {
|
||||
return location{}
|
||||
}
|
||||
|
||||
return location{
|
||||
Latitude: city.Location.Latitude,
|
||||
Longitude: city.Location.Longitude,
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user