Skip to content

Commit

Permalink
Add support for showing anycast addresses in the UI
Browse files Browse the repository at this point in the history
  • Loading branch information
dhaavi committed May 28, 2024
1 parent 1381556 commit dc1b9f9
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 2 deletions.
Binary file added assets/data/img/flags/__.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions desktop/angular/docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ mnt="$( cd ../.. && pwd )"
docker run \
-ti \
--rm \
-v $mnt:/portmaster-ui \
-w /portmaster-ui/modules/portmaster \
-v $mnt:/portmaster \
-w /portmaster/desktop/angular \
-p 8081:8080 \
node:latest \
npm start -- --host 0.0.0.0 --port 8080
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ export class MapRendererComponent implements OnInit, AfterViewInit, OnDestroy {
data.forEach((country: any) => {
this.countryNames[country.properties.iso_a2] = country.properties.name
})
// Add special country values.
this.countryNames["__"] = "Anycast"

this.worldGroup.selectAll()
.data<GeoPermissibleObjects>(data)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ export class ConnectionLocationPipe implements PipeTransform {
return '';
}
if (!!conn.country) {
if (conn.country === "__") {
return "Anycast"
}
return conn.country;
}

Expand Down
12 changes: 12 additions & 0 deletions service/intel/geoip/country_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ func (l *Location) AddCountryInfo() {
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.
info, ok := countries[l.Country.Code]
if !ok {
Expand Down Expand Up @@ -83,6 +91,10 @@ func init() {
}

var countries = map[string]CountryInfo{
"__": {
Name: "Anycast",
Center: Coordinates{AccuracyRadius: earthCircumferenceInKm},
},
"MN": {
Name: "Mongolia",
Continent: ContinentInfo{Region: "AS-E"},
Expand Down
5 changes: 5 additions & 0 deletions service/intel/geoip/country_info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ func TestCountryInfo(t *testing.T) {
t.Parallel()

for key, country := range countries {
// Skip special anycast country.
if key == "__" {
continue
}

if key != country.Code {
t.Errorf("%s has a wrong country code of %q", key, country.Code)
}
Expand Down

0 comments on commit dc1b9f9

Please sign in to comment.