mirror of
https://github.com/safing/portmaster
synced 2025-04-21 19:39:09 +00:00
Add support for showing anycast addresses in the UI
This commit is contained in:
parent
1381556e93
commit
dc1b9f98f2
6 changed files with 24 additions and 2 deletions
assets/data/img/flags
desktop/angular
service/intel/geoip
BIN
assets/data/img/flags/__.png
Normal file
BIN
assets/data/img/flags/__.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 461 B |
|
@ -11,8 +11,8 @@ mnt="$( cd ../.. && pwd )"
|
||||||
docker run \
|
docker run \
|
||||||
-ti \
|
-ti \
|
||||||
--rm \
|
--rm \
|
||||||
-v $mnt:/portmaster-ui \
|
-v $mnt:/portmaster \
|
||||||
-w /portmaster-ui/modules/portmaster \
|
-w /portmaster/desktop/angular \
|
||||||
-p 8081:8080 \
|
-p 8081:8080 \
|
||||||
node:latest \
|
node:latest \
|
||||||
npm start -- --host 0.0.0.0 --port 8080
|
npm start -- --host 0.0.0.0 --port 8080
|
||||||
|
|
|
@ -195,6 +195,8 @@ export class MapRendererComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||||
data.forEach((country: any) => {
|
data.forEach((country: any) => {
|
||||||
this.countryNames[country.properties.iso_a2] = country.properties.name
|
this.countryNames[country.properties.iso_a2] = country.properties.name
|
||||||
})
|
})
|
||||||
|
// Add special country values.
|
||||||
|
this.countryNames["__"] = "Anycast"
|
||||||
|
|
||||||
this.worldGroup.selectAll()
|
this.worldGroup.selectAll()
|
||||||
.data<GeoPermissibleObjects>(data)
|
.data<GeoPermissibleObjects>(data)
|
||||||
|
|
|
@ -11,6 +11,9 @@ export class ConnectionLocationPipe implements PipeTransform {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
if (!!conn.country) {
|
if (!!conn.country) {
|
||||||
|
if (conn.country === "__") {
|
||||||
|
return "Anycast"
|
||||||
|
}
|
||||||
return conn.country;
|
return conn.country;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,14 @@ func (l *Location) AddCountryInfo() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check for anycast.
|
||||||
|
if l.IsAnycast {
|
||||||
|
// Reset data for anycast.
|
||||||
|
l.Country.Code = "__"
|
||||||
|
l.Coordinates.Latitude = 0
|
||||||
|
l.Coordinates.Longitude = 0
|
||||||
|
}
|
||||||
|
|
||||||
// Get country info.
|
// Get country info.
|
||||||
info, ok := countries[l.Country.Code]
|
info, ok := countries[l.Country.Code]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
@ -83,6 +91,10 @@ func init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
var countries = map[string]CountryInfo{
|
var countries = map[string]CountryInfo{
|
||||||
|
"__": {
|
||||||
|
Name: "Anycast",
|
||||||
|
Center: Coordinates{AccuracyRadius: earthCircumferenceInKm},
|
||||||
|
},
|
||||||
"MN": {
|
"MN": {
|
||||||
Name: "Mongolia",
|
Name: "Mongolia",
|
||||||
Continent: ContinentInfo{Region: "AS-E"},
|
Continent: ContinentInfo{Region: "AS-E"},
|
||||||
|
|
|
@ -9,6 +9,11 @@ func TestCountryInfo(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
for key, country := range countries {
|
for key, country := range countries {
|
||||||
|
// Skip special anycast country.
|
||||||
|
if key == "__" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
if key != country.Code {
|
if key != country.Code {
|
||||||
t.Errorf("%s has a wrong country code of %q", key, country.Code)
|
t.Errorf("%s has a wrong country code of %q", key, country.Code)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue