mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2024-12-23 16:50:18 +01:00
Factored out some common stuff to separate file.
This commit is contained in:
parent
3e0e909a69
commit
33a53c11da
@ -10,32 +10,12 @@ import (
|
||||
"log"
|
||||
"net"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"bitbucket.org/s_l_teichmann/mtsatellite/common"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
)
|
||||
|
||||
func ipsFromHosts(hosts string) ([]net.IP, error) {
|
||||
|
||||
ips := []net.IP{}
|
||||
|
||||
if len(hosts) == 0 { // Empty list: allow all hosts.
|
||||
return ips, nil
|
||||
}
|
||||
|
||||
for _, host := range strings.Split(hosts, ";") {
|
||||
if hips, err := net.LookupIP(host); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
ips = append(ips, hips...)
|
||||
}
|
||||
}
|
||||
|
||||
return ips, nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
var (
|
||||
webPort int
|
||||
|
36
cmd/mtwebmapper/misc.go
Normal file
36
cmd/mtwebmapper/misc.go
Normal file
@ -0,0 +1,36 @@
|
||||
// Copyright 2014 by Sascha L. Teichmann
|
||||
// Use of this source code is governed by the MIT license
|
||||
// that can be found in the LICENSE file.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"net"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func ipsFromHosts(hosts string) ([]net.IP, error) {
|
||||
|
||||
ips := []net.IP{}
|
||||
|
||||
if len(hosts) == 0 { // Empty list: allow all hosts.
|
||||
return ips, nil
|
||||
}
|
||||
|
||||
for _, host := range strings.Split(hosts, ";") {
|
||||
if hips, err := net.LookupIP(host); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
ips = append(ips, hips...)
|
||||
}
|
||||
}
|
||||
|
||||
return ips, nil
|
||||
}
|
||||
|
||||
func min(a, b int) int {
|
||||
if a < b {
|
||||
return a
|
||||
}
|
||||
return b
|
||||
}
|
@ -205,13 +205,6 @@ func (tu *tileUpdater) doUpdates() {
|
||||
}
|
||||
}
|
||||
|
||||
func min(a, b int) int {
|
||||
if a < b {
|
||||
return a
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func updatePyramidTiles(level int, baseDir string, jobs chan xzm, done *sync.WaitGroup) {
|
||||
defer done.Done()
|
||||
scratch := image.NewRGBA(image.Rect(0, 0, 256, 256))
|
||||
|
Loading…
Reference in New Issue
Block a user