一些小改動 (#42)
* 1. remove ":" at the start of port assignement. 2. use BIRDLG_PROXY_PORT at proxy. 3. add custom URL to brand * goto / if only one server * add BIRDLG_TRACEROUTE_BIN
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
<body>
|
||||
|
||||
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
||||
<a class="navbar-brand" href="/">{{ .Brand }}</a>
|
||||
<a class="navbar-brand" href="{{ .BrandURL }}">{{ .Brand }}</a>
|
||||
<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>
|
||||
</button>
|
||||
@@ -28,13 +28,24 @@
|
||||
{{ end }}
|
||||
<ul class="navbar-nav mr-auto">
|
||||
<li class="nav-item">
|
||||
{{ if eq .AllServersURLCustom "all" }}
|
||||
<a class="nav-link{{ if .AllServersLinkActive }} active{{ end }}"
|
||||
href="/{{ $option }}/{{ .AllServersURL }}/{{ $target }}"> All Servers </a>
|
||||
href="/{{ $option }}/{{ .AllServersURL }}/{{ $target }}"> {{ .AllServerTitle }} </a>
|
||||
{{ else }}
|
||||
<a class="nav-link active"
|
||||
href="{{ .AllServersURLCustom }}"> {{ .AllServerTitle }} </a>
|
||||
{{ end }}
|
||||
</li>
|
||||
{{ $length := len .ServersEscaped }}
|
||||
{{ range $k, $v := .ServersEscaped }}
|
||||
<li class="nav-item">
|
||||
{{ if gt $length 1 }}
|
||||
<a class="nav-link{{ if eq $server $v }} active{{ end }}"
|
||||
href="/{{ $option }}/{{ $v }}/{{ $target }}">{{ html (index $.ServersDisplay $k) }}</a>
|
||||
{{ else }}
|
||||
<a class="nav-link{{ if eq $server $v }} active{{ end }}"
|
||||
href="/">{{ html (index $.ServersDisplay $k) }}</a>
|
||||
{{ end }}
|
||||
</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
|
||||
@@ -18,6 +18,9 @@ type settingType struct {
|
||||
netSpecificMode string
|
||||
titleBrand string
|
||||
navBarBrand string
|
||||
navBarBrandURL string
|
||||
navBarAllServer string
|
||||
navBarAllURL string
|
||||
telegramBotName string
|
||||
protocolFilter []string
|
||||
}
|
||||
@@ -29,10 +32,13 @@ func main() {
|
||||
servers: []string{""},
|
||||
proxyPort: 8000,
|
||||
whoisServer: "whois.verisign-grs.com",
|
||||
listen: ":5000",
|
||||
listen: "5000",
|
||||
dnsInterface: "asn.cymru.com",
|
||||
titleBrand: "Bird-lg Go",
|
||||
navBarBrand: "Bird-lg Go",
|
||||
navBarBrandURL: "/",
|
||||
navBarAllServer: "All Servers",
|
||||
navBarAllURL: "all",
|
||||
telegramBotName: "",
|
||||
protocolFilter: []string{},
|
||||
}
|
||||
@@ -68,6 +74,15 @@ func main() {
|
||||
if env := os.Getenv("BIRDLG_NAVBAR_BRAND"); env != "" {
|
||||
settingDefault.navBarBrand = env
|
||||
}
|
||||
if env := os.Getenv("BIRDLG_NAVBAR_BRAND_URL"); env != "" {
|
||||
settingDefault.navBarBrandURL = env
|
||||
}
|
||||
if env := os.Getenv("BIRDLG_NAVBAR_ALL_SERVERS"); env != "" {
|
||||
settingDefault.navBarAllServer = env
|
||||
}
|
||||
if env := os.Getenv("BIRDLG_NAVBAR_ALL_URL"); env != "" {
|
||||
settingDefault.navBarAllURL = env
|
||||
}
|
||||
if env := os.Getenv("BIRDLG_TELEGRAM_BOT_NAME"); env != "" {
|
||||
settingDefault.telegramBotName = env
|
||||
}
|
||||
@@ -84,6 +99,9 @@ func main() {
|
||||
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")
|
||||
navBarBrandURLPtr := flag.String("navbar-brand-url", settingDefault.navBarBrandURL, "brand to show in the navigation bar")
|
||||
navBarAllServerPtr := flag.String("navbar-all-servers", settingDefault.navBarAllServer, "brand to show in the navigation bar")
|
||||
navBarAllURL := flag.String("navbar-all-url", settingDefault.navBarAllURL, "brand to show in the navigation bar")
|
||||
telegramBotNamePtr := flag.String("telegram-bot-name", settingDefault.telegramBotName, "telegram bot name (used to filter @bot commands)")
|
||||
protocolFilterPtr := flag.String("protocol-filter", strings.Join(settingDefault.protocolFilter, ","),
|
||||
"protocol types to show in summary tables (comma separated list); defaults to all if not set")
|
||||
@@ -93,6 +111,11 @@ func main() {
|
||||
panic("no server set")
|
||||
}
|
||||
|
||||
if !strings.Contains(*listenPtr, ":") {
|
||||
listenHost := ":" + (*listenPtr)
|
||||
listenPtr = &listenHost
|
||||
}
|
||||
|
||||
servers := strings.Split(*serversPtr, ",")
|
||||
serversDisplay := strings.Split(*serversPtr, ",")
|
||||
|
||||
@@ -122,6 +145,9 @@ func main() {
|
||||
strings.ToLower(*netSpecificModePtr),
|
||||
*titleBrandPtr,
|
||||
*navBarBrandPtr,
|
||||
*navBarBrandURLPtr,
|
||||
*navBarAllServerPtr,
|
||||
*navBarAllURL,
|
||||
*telegramBotNamePtr,
|
||||
protocolFilter,
|
||||
}
|
||||
|
||||
@@ -67,6 +67,8 @@ func renderPageTemplate(w http.ResponseWriter, r *http.Request, title string, co
|
||||
ServersDisplay: setting.serversDisplay,
|
||||
AllServersLinkActive: strings.ToLower(split[1]) == strings.ToLower(strings.Join(setting.servers, "+")),
|
||||
AllServersURL: url.PathEscape(strings.Join(setting.servers, "+")),
|
||||
AllServerTitle: setting.navBarAllServer,
|
||||
AllServersURLCustom: setting.navBarAllURL,
|
||||
IsWhois: isWhois,
|
||||
WhoisTarget: whoisTarget,
|
||||
|
||||
@@ -75,6 +77,7 @@ func renderPageTemplate(w http.ResponseWriter, r *http.Request, title string, co
|
||||
URLCommand: split[2],
|
||||
Title: setting.titleBrand + title,
|
||||
Brand: setting.navBarBrand,
|
||||
BrandURL: setting.navBarBrandURL,
|
||||
Content: content,
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,9 @@ type TemplatePage struct {
|
||||
|
||||
// Parameters related to current request
|
||||
AllServersLinkActive bool
|
||||
AllServerTitle string
|
||||
AllServersURL string
|
||||
AllServersURLCustom string
|
||||
|
||||
// Whois specific handling (for its unique URL)
|
||||
IsWhois bool
|
||||
@@ -35,9 +37,10 @@ type TemplatePage struct {
|
||||
URLCommand string
|
||||
|
||||
// Generated content to be displayed
|
||||
Title string
|
||||
Brand string
|
||||
Content string
|
||||
Title string
|
||||
Brand string
|
||||
BrandURL string
|
||||
Content string
|
||||
}
|
||||
|
||||
// summary
|
||||
|
||||
Reference in New Issue
Block a user