@@ -30,7 +30,7 @@ import (
3030 "github.com/prometheus/client_golang/prometheus/promhttp"
3131)
3232
33- var VERSION = "1.0.2 "
33+ var VERSION = "1.0.3 "
3434
3535//go:embed data/wikipedia-airlines.csv
3636var wikipediaAirlinesCsvFileContent string
@@ -42,8 +42,13 @@ func main() {
4242 file := flag .String ("base-path" , "" , "Path to the directory where aircraft.json and receiver.json are located" )
4343 lat := flag .Float64 ("lat" , 0.0 , "Custom latitude of the receiver" )
4444 lon := flag .Float64 ("lon" , 0.0 , "Custom longitude of the receiver" )
45+ host := flag .String ("host" , "0.0.0.0" , "Host to listen on (default: 0.0.0.0)" )
4546 port := flag .Int ("port" , 8080 , "Port to listen on (default: 8080)" )
4647 verbose := flag .Bool ("verbose" , false , "Enable verbose output" )
48+ distanceCalc := flag .Bool ("distance-calc" , true , "Enable distance calculation to aircraft" )
49+ airlineLabel := flag .Bool ("airline-label" , true , "Enable airline labelling" )
50+ exposeFiles := flag .Bool ("expose-files" , true , "Expose original aircraft.json and receiver.json files" )
51+ rollingMapSize := flag .Int ("rolling-map-size" , 1000 , "Default size of the rolling map for caching" )
4752 flag .Parse ()
4853 log .Printf ("Dump1090Prom - A bridge between the dump1090 JSON data and prometheus – Version %s" , VERSION )
4954 source := findMetricSource (url , file )
@@ -54,6 +59,19 @@ func main() {
5459 log .Printf ("Verbose: %t" , * verbose )
5560 CONFIG .IsVerbose = * verbose
5661 }
62+ if distanceCalc != nil {
63+ CONFIG .IsDistanceCalculationEnabled = * distanceCalc
64+ }
65+ if airlineLabel != nil {
66+ CONFIG .IsAirlineLabellingEnabled = * airlineLabel
67+ }
68+ if exposeFiles != nil {
69+ CONFIG .IsExposingOriginalFilesEnabled = * exposeFiles
70+ }
71+ if rollingMapSize != nil {
72+ CONFIG .RollingMapDefaultSize = * rollingMapSize
73+ }
74+ initRollingMaps ()
5775 receiverData , err := source .fetchReceiverMetrics ()
5876 if err != nil {
5977 log .Printf ("Cannot open receiver.json: %v" , err )
@@ -81,6 +99,9 @@ func main() {
8199 if port != nil {
82100 CONFIG .Port = * port
83101 }
102+ if host != nil {
103+ CONFIG .Host = * host
104+ }
84105
85106 // Read airline data
86107 data , err := readAirlinesData (wikipediaAirlinesCsvFileContent )
@@ -114,7 +135,7 @@ func main() {
114135 }
115136 }
116137
117- log .Printf ("Starting server on port % d\n " , CONFIG .Port )
138+ log .Printf ("Starting server on %s:% d\n " , CONFIG . Host , CONFIG .Port )
118139
119140 if CONFIG .IsExposingOriginalFilesEnabled {
120141 http .HandleFunc ("/aircraft.json" , func (w http.ResponseWriter , r * http.Request ) {
@@ -131,9 +152,9 @@ func main() {
131152 }
132153
133154 http .Handle ("/metrics" , promhttp .Handler ())
134- err = http .ListenAndServe (fmt .Sprintf (":%d" , CONFIG .Port ), nil )
155+ err = http .ListenAndServe (fmt .Sprintf ("%s :%d" , CONFIG . Host , CONFIG .Port ), nil )
135156 if err != nil {
136- log .Fatalf ("failed to start server on port % d: %v" , CONFIG .Port , err )
157+ log .Fatalf ("failed to start server on %s:% d: %v" , CONFIG . Host , CONFIG .Port , err )
137158 }
138159}
139160
0 commit comments