Skip to content

Commit

Permalink
api_addr/admin_addr
Browse files Browse the repository at this point in the history
  • Loading branch information
kdudkov committed May 24, 2022
1 parent f9906f6 commit f128cd1
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 35 deletions.
4 changes: 3 additions & 1 deletion cmd/goatak_server/http_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ func NewHttp(app *App, adminAddress string, apiAddress string) *HttpServer {
renderer: renderer,
}

srv.listeners["admin api calls"] = getAdminApi(app, adminAddress, renderer)
if adminAddress != "" {
srv.listeners["admin api calls"] = getAdminApi(app, adminAddress, renderer)
}
srv.listeners["marti api calls"] = getMartiApi(app, apiAddress)
//srv.listeners["tls api calls"] = getTlsApi(app, ":8446")

Expand Down
41 changes: 19 additions & 22 deletions cmd/goatak_server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ var (
)

type AppConfig struct {
tcpPort int
udpPort int
webPort int
apiPort int
sslPort int
tcpPort int
udpPort int
adminAddr string
apiAddr string
sslPort int

logging bool
ca *x509.CertPool
Expand Down Expand Up @@ -103,10 +103,7 @@ func (app *App) Run() {
}()
}

NewHttp(app,
fmt.Sprintf(":%d", app.config.webPort),
fmt.Sprintf(":%d", app.config.apiPort),
).Start()
NewHttp(app, app.config.adminAddr, app.config.apiAddr).Start()

go app.EventProcessor()
go app.cleaner()
Expand Down Expand Up @@ -422,15 +419,15 @@ func main() {

viper.SetConfigFile(*conf)

viper.SetDefault("web_port", 8080)
viper.SetDefault("tcp_port", 8999)
viper.SetDefault("udp_port", 8999)
viper.SetDefault("ssl_port", 8089)
viper.SetDefault("api_port", 8889)
viper.SetDefault("admin_addr", ":8080")
viper.SetDefault("api_addr", ":8889")

viper.SetDefault("me.lat", 35.462939)
viper.SetDefault("me.lon", -97.537283)
viper.SetDefault("me.zoom", 5)
viper.SetDefault("me.lat", 59.8396)
viper.SetDefault("me.lon", 31.0213)
viper.SetDefault("me.zoom", 10)

err := viper.ReadInConfig()
if err != nil {
Expand All @@ -456,14 +453,14 @@ func main() {
}

config := &AppConfig{
tcpPort: viper.GetInt("tcp_port"),
udpPort: viper.GetInt("udp_port"),
webPort: viper.GetInt("web_port"),
apiPort: viper.GetInt("api_port"),
sslPort: viper.GetInt("ssl_port"),
logging: *logging,
ca: ca,
cert: cert,
tcpPort: viper.GetInt("tcp_port"),
udpPort: viper.GetInt("udp_port"),
adminAddr: viper.GetString("admin_addr"),
apiAddr: viper.GetString("api_addr"),
sslPort: viper.GetInt("ssl_port"),
logging: *logging,
ca: ca,
cert: cert,
}

app := NewApp(config, logger.Sugar())
Expand Down
4 changes: 3 additions & 1 deletion goatak_server.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
---
web_port: 8080
admin_addr: ":8080"
api_addr: ":8889"
tcp_port: 8999
udp_port: 8999
ssl_port: 8089

me:
lat: 35.462939
lon: -97.537283
Expand Down
11 changes: 7 additions & 4 deletions model/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,14 @@ func getSIDC(fn string) string {

tokens := strings.Split(fn, "-")

if len(tokens) < 3 {
return ""
sidc := "S" + tokens[1]

if len(tokens) > 2 {
sidc += tokens[2] + "P"
} else {
sidc += "-P"
}

sidc := "S" + tokens[1] + tokens[2] + "P"
if len(tokens) > 3 {
for _, c := range tokens[3:] {
if len(c) > 1 {
Expand All @@ -182,7 +185,7 @@ func getSIDC(fn string) string {
}
}

if len(sidc) < 10 {
if len(sidc) < 12 {
sidc += strings.Repeat("-", 10-len(sidc))
}
return strings.ToUpper(sidc)
Expand Down
10 changes: 3 additions & 7 deletions staticfiles/static/js/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ let app = new Vue({
attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
maxZoom: 19
});
let topoAttribution = 'Kartendaten: &copy; <a href="https://openstreetmap.org/copyright">OpenStreetMap</a>-Mitwirkende, <a href="http://viewfinderpanoramas.org">SRTM</a> | Kartendarstellung: &copy; <a href="https://opentopomap.org">OpenTopoMap</a>';
let opentopo = L.tileLayer('https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png', {
let topoAttribution = 'Map data: &copy; <a href="https://openstreetmap.org/copyright">OpenStreetMap</a> contributors, <a href="http://viewfinderpanoramas.org">SRTM</a> | Map style: &copy; <a href="https://opentopomap.org">OpenTopoMap</a>, <a href="https://opentopomap.ru">OpenTopoMap.ru</a> (<a href="https://creativecommons.org/licenses/by-sa/3.0/">CC-BY-SA</a>)';
let opentopo = L.tileLayer('https://tile-{s}.opentopomap.ru/{z}/{x}/{y}.png', {
attribution: topoAttribution,
maxZoom: 17
});
Expand All @@ -102,17 +102,13 @@ let app = new Vue({
let sputnik = L.tileLayer('https://{s}.tilessputnik.ru/{z}/{x}/{y}.png', {
maxZoom: 20
});
let ggc = L.tileLayer('https://a.tiles.nakarte.me/ggc250/{z}/{y}/{x}', {
maxZoom: 15
});
osm.addTo(this.map);
opentopo.addTo(this.map);

L.control.scale({metric: true}).addTo(this.map);
L.control.layers({
"OSM": osm,
"Telesputnik": sputnik,
"OpenTopoMap": opentopo,
"GGC-250": ggc,
"Google sat": google
}, null, {hideSingleBase: true}).addTo(this.map);

Expand Down

0 comments on commit f128cd1

Please sign in to comment.