From 371f28658d4930ae6ee55fd815ceacb7178b50db Mon Sep 17 00:00:00 2001 From: Jens Zeilund Date: Mon, 30 Oct 2023 19:44:34 +0100 Subject: [PATCH] feat: add support to serve on specific interfaces (#95) --- main.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 3197baa..c003812 100644 --- a/main.go +++ b/main.go @@ -62,6 +62,7 @@ var cli struct { Serve struct { Path string `arg:"" help:"Local path or bucket prefix"` + Interface string `default:"0.0.0.0"` Port int `default:8080` Cors string `help:"Value of HTTP CORS header."` CacheSize int `default:64 help:"Size of cache in Megabytes."` @@ -119,8 +120,8 @@ func main() { logger.Printf("served %s in %s", r.URL.Path, time.Since(start)) }) - logger.Printf("Serving %s %s on port %d with Access-Control-Allow-Origin: %s\n", cli.Serve.Bucket, cli.Serve.Path, cli.Serve.Port, cli.Serve.Cors) - logger.Fatal(http.ListenAndServe(":"+strconv.Itoa(cli.Serve.Port), nil)) + logger.Printf("Serving %s %s on port %d and interface %s with Access-Control-Allow-Origin: %s\n", cli.Serve.Bucket, cli.Serve.Path, cli.Serve.Port, cli.Serve.Interface, cli.Serve.Cors) + logger.Fatal(http.ListenAndServe(cli.Serve.Interface+":"+strconv.Itoa(cli.Serve.Port), nil)) case "extract ": err := pmtiles.Extract(logger, cli.Extract.Bucket, cli.Extract.Input, cli.Extract.Maxzoom, cli.Extract.Region, cli.Extract.Bbox, cli.Extract.Output, cli.Extract.DownloadThreads, cli.Extract.Overfetch, cli.Extract.DryRun) if err != nil {