Factored out some common stuff to separate file.

This commit is contained in:
Sascha L. Teichmann 2015-03-02 13:14:29 +01:00
parent 3e0e909a69
commit 33a53c11da
3 changed files with 36 additions and 27 deletions

View File

@ -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
View 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
}

View File

@ -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))