-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored config to be uniform with possibilty for local overrides.
- Loading branch information
Showing
16 changed files
with
161 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*.log | ||
go-ma-* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/spf13/pflag" | ||
"github.com/spf13/viper" | ||
) | ||
|
||
const ( | ||
defaultHttpSocket string = "0.0.0.0:5003" | ||
) | ||
|
||
func init() { | ||
|
||
// Flags - user configurations | ||
|
||
pflag.String("http_socket", defaultHttpSocket, "Address for webserver to listen on") | ||
viper.BindPFlag("http.socket", pflag.Lookup("socket")) | ||
|
||
// pflag.Int("port", defaultListenPort, "Port for service to listen on") | ||
// v.BindPFlag("port", pflag.Lookup("port")) | ||
|
||
pflag.Parse() | ||
} | ||
|
||
func getHttpSocket() string { | ||
return viper.GetString("http.socket") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,2 @@ | ||
# If you prefer the allow list template instead of the deny list, see community template: | ||
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore | ||
# | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
arm64-* | ||
|
||
# Test binary, built with `go test -c` | ||
*.test | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
|
||
# Dependency directories (remove the comment below to include it) | ||
# vendor/ | ||
|
||
# Go workspace file | ||
go.work | ||
go-* | ||
.env | ||
go-ma-relay* | ||
.vscode | ||
.env | ||
*.log | ||
go-ma* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,28 @@ | ||
package main | ||
|
||
import ( | ||
"flag" | ||
|
||
"go.deanishe.net/env" | ||
"github.com/spf13/pflag" | ||
"github.com/spf13/viper" | ||
) | ||
|
||
const ( | ||
defaultListenPort string = "4001" // 0 = random | ||
defaultHttpAddr string = "0.0.0.0" | ||
defaultHttpPort string = "4000" | ||
) | ||
|
||
var ( | ||
httpSocket string | ||
|
||
httpAddr string = env.Get("GO_MA_RELAY_HTTP_ADDR", defaultHttpAddr) | ||
httpPort string = env.Get("GO_MA_RELAY_HTTP_PORT", defaultHttpPort) | ||
listenPort string = env.Get("GO_MA_RELAY_LISTEN_PORT", defaultListenPort) | ||
// defaultListenPort int = 4001 // 0 = random | ||
defaultHttpSocket string = "0.0.0.0:4000" | ||
) | ||
|
||
func init() { | ||
|
||
// Flags - user configurations | ||
|
||
flag.StringVar(&httpAddr, "httpAddr", httpAddr, "Address to listen on") | ||
flag.StringVar(&httpPort, "httpPort", httpPort, "Listen port for webserver") | ||
|
||
flag.StringVar(&listenPort, "listenPort", listenPort, "Port to listen on for peers") | ||
|
||
flag.Parse() | ||
pflag.String("http_socket", defaultHttpSocket, "Address for webserver to listen on") | ||
viper.BindPFlag("http.socket", pflag.Lookup("socket")) | ||
|
||
// Assemble vars for http server | ||
httpSocket = httpAddr + ":" + httpPort | ||
} | ||
|
||
func GetListenPort() string { | ||
return listenPort | ||
} | ||
|
||
func GetHttpSocket() string { | ||
return httpSocket | ||
} | ||
// pflag.Int("port", defaultListenPort, "Port for service to listen on") | ||
// v.BindPFlag("port", pflag.Lookup("port")) | ||
|
||
func GetHttpAddr() string { | ||
return httpAddr | ||
pflag.Parse() | ||
} | ||
|
||
func GetHttpPort() string { | ||
return httpPort | ||
func getHttpSocket() string { | ||
return viper.GetString("http.socket") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
package main | ||
|
||
const ( | ||
NAME = "go-ma-relay" | ||
VERSION = "1.0.6" | ||
NAME = "go-ma-relay" | ||
VERSION = "1.0.6" | ||
ENV_PREFIX = "GO_MA_RELAY" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.