frontend: support rebranding
This commit is contained in:
parent
6e4bbd6410
commit
7b1dc6718d
@ -15,19 +15,21 @@ type settingType struct {
|
|||||||
listen string
|
listen string
|
||||||
dnsInterface string
|
dnsInterface string
|
||||||
netSpecificMode string
|
netSpecificMode string
|
||||||
|
titleBrand string
|
||||||
|
navBarBrand string
|
||||||
}
|
}
|
||||||
|
|
||||||
var setting settingType
|
var setting settingType
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
var settingDefault = settingType{
|
var settingDefault = settingType{
|
||||||
[]string{""},
|
servers: []string{""},
|
||||||
"",
|
proxyPort: 8000,
|
||||||
8000,
|
whoisServer: "whois.verisign-grs.com",
|
||||||
"whois.verisign-grs.com",
|
listen: ":5000",
|
||||||
":5000",
|
dnsInterface: "asn.cymru.com",
|
||||||
"asn.cymru.com",
|
titleBrand: "Bird-lg Go",
|
||||||
"",
|
navBarBrand: "Bird-lg Go",
|
||||||
}
|
}
|
||||||
|
|
||||||
if env := os.Getenv("BIRDLG_SERVERS"); env != "" {
|
if env := os.Getenv("BIRDLG_SERVERS"); env != "" {
|
||||||
@ -51,10 +53,16 @@ func main() {
|
|||||||
if env := os.Getenv("BIRDLG_DNS_INTERFACE"); env != "" {
|
if env := os.Getenv("BIRDLG_DNS_INTERFACE"); env != "" {
|
||||||
settingDefault.dnsInterface = env
|
settingDefault.dnsInterface = env
|
||||||
}
|
}
|
||||||
|
|
||||||
if env := os.Getenv("BIRDLG_NET_SPECIFIC_MODE"); env != "" {
|
if env := os.Getenv("BIRDLG_NET_SPECIFIC_MODE"); env != "" {
|
||||||
settingDefault.netSpecificMode = env
|
settingDefault.netSpecificMode = env
|
||||||
}
|
}
|
||||||
|
if env := os.Getenv("BIRDLG_TITLE_BRAND"); env != "" {
|
||||||
|
settingDefault.titleBrand = env
|
||||||
|
settingDefault.navBarBrand = env
|
||||||
|
}
|
||||||
|
if env := os.Getenv("BIRDLG_NAVBAR_BRAND"); env != "" {
|
||||||
|
settingDefault.navBarBrand = env
|
||||||
|
}
|
||||||
|
|
||||||
serversPtr := flag.String("servers", strings.Join(settingDefault.servers, ","), "server name prefixes, separated by comma")
|
serversPtr := flag.String("servers", strings.Join(settingDefault.servers, ","), "server name prefixes, separated by comma")
|
||||||
domainPtr := flag.String("domain", settingDefault.domain, "server name domain suffixes")
|
domainPtr := flag.String("domain", settingDefault.domain, "server name domain suffixes")
|
||||||
@ -63,6 +71,8 @@ func main() {
|
|||||||
listenPtr := flag.String("listen", settingDefault.listen, "address bird-lg is listening on")
|
listenPtr := flag.String("listen", settingDefault.listen, "address bird-lg is listening on")
|
||||||
dnsInterfacePtr := flag.String("dns-interface", settingDefault.dnsInterface, "dns zone to query ASN information")
|
dnsInterfacePtr := flag.String("dns-interface", settingDefault.dnsInterface, "dns zone to query ASN information")
|
||||||
netSpecificModePtr := flag.String("net-specific-mode", settingDefault.netSpecificMode, "network specific operation mode, [(none)|dn42]")
|
netSpecificModePtr := flag.String("net-specific-mode", settingDefault.netSpecificMode, "network specific operation mode, [(none)|dn42]")
|
||||||
|
titleBrandPtr := flag.String("title-brand", settingDefault.titleBrand, "prefix of page titles in browser tabs")
|
||||||
|
navBarBrandPtr := flag.String("navbar-brand", settingDefault.navBarBrand, "brand to show in the navigation bar")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
if *serversPtr == "" {
|
if *serversPtr == "" {
|
||||||
@ -79,6 +89,8 @@ func main() {
|
|||||||
*listenPtr,
|
*listenPtr,
|
||||||
*dnsInterfacePtr,
|
*dnsInterfacePtr,
|
||||||
strings.ToLower(*netSpecificModePtr),
|
strings.ToLower(*netSpecificModePtr),
|
||||||
|
*titleBrandPtr,
|
||||||
|
*navBarBrandPtr,
|
||||||
}
|
}
|
||||||
|
|
||||||
webServerStart()
|
webServerStart()
|
||||||
|
@ -50,7 +50,8 @@ func renderTemplate(w http.ResponseWriter, r *http.Request, title string, conten
|
|||||||
args.URLServer = strings.ToLower(split[2])
|
args.URLServer = strings.ToLower(split[2])
|
||||||
args.URLCommand = split[3]
|
args.URLCommand = split[3]
|
||||||
|
|
||||||
args.Title = title
|
args.Title = setting.titleBrand + title
|
||||||
|
args.Brand = setting.navBarBrand
|
||||||
args.Content = content
|
args.Content = content
|
||||||
|
|
||||||
err := tmpl.Execute(w, args)
|
err := tmpl.Execute(w, args)
|
||||||
|
@ -24,6 +24,7 @@ type tmplArguments struct {
|
|||||||
|
|
||||||
// Generated content to be displayed
|
// Generated content to be displayed
|
||||||
Title string
|
Title string
|
||||||
|
Brand string
|
||||||
Content string
|
Content string
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,7 +42,7 @@ var tmpl = template.Must(template.New("tmpl").Parse(`
|
|||||||
<body>
|
<body>
|
||||||
|
|
||||||
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
||||||
<a class="navbar-brand" href="/">Bird-lg Go</a>
|
<a class="navbar-brand" href="/">{{ .Brand }}</a>
|
||||||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
<span class="navbar-toggler-icon"></span>
|
<span class="navbar-toggler-icon"></span>
|
||||||
</button>
|
</button>
|
||||||
|
@ -15,7 +15,7 @@ func webHandlerWhois(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
renderTemplate(
|
renderTemplate(
|
||||||
w, r,
|
w, r,
|
||||||
"Bird-lg Go - whois "+html.EscapeString(target),
|
" - whois "+html.EscapeString(target),
|
||||||
"<h2>whois "+html.EscapeString(target)+"</h2>"+smartFormatter(whois(target)),
|
"<h2>whois "+html.EscapeString(target)+"</h2>"+smartFormatter(whois(target)),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -67,7 +67,7 @@ func webBackendCommunicator(endpoint string, command string) func(w http.Respons
|
|||||||
|
|
||||||
renderTemplate(
|
renderTemplate(
|
||||||
w, r,
|
w, r,
|
||||||
"Bird-lg Go - "+html.EscapeString(endpoint+" "+backendCommand),
|
" - "+html.EscapeString(endpoint+" "+backendCommand),
|
||||||
result,
|
result,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -98,7 +98,7 @@ func webHandlerBGPMap(endpoint string, command string) func(w http.ResponseWrite
|
|||||||
var responses []string = batchRequest(servers, endpoint, backendCommand)
|
var responses []string = batchRequest(servers, endpoint, backendCommand)
|
||||||
renderTemplate(
|
renderTemplate(
|
||||||
w, r,
|
w, r,
|
||||||
"Bird-lg Go - "+html.EscapeString(endpoint+" "+backendCommand),
|
" - "+html.EscapeString(endpoint+" "+backendCommand),
|
||||||
`
|
`
|
||||||
<script src="https://cdn.jsdelivr.net/npm/viz.js@2.1.2/viz.min.js" crossorigin="anonymous"></script>
|
<script src="https://cdn.jsdelivr.net/npm/viz.js@2.1.2/viz.min.js" crossorigin="anonymous"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/viz.js@2.1.2/lite.render.js" crossorigin="anonymous"></script>
|
<script src="https://cdn.jsdelivr.net/npm/viz.js@2.1.2/lite.render.js" crossorigin="anonymous"></script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user