BIRDLG_BGPMAP_INFO 選項 (#44)
* BIRDLG_BGPMAP_INFO update the paramater description fix for bgpmap_test singleline and multiline * Static file instead of jsdelivr; favicon.ico Co-authored-by: testscript <testscript@example.com>
This commit is contained in:
parent
58847759b3
commit
af5b653326
@ -85,6 +85,7 @@ Usage: all configuration is done via commandline parameters or environment varia
|
|||||||
| --proxy-port | BIRDLG_PROXY_PORT | port bird-lgproxy is running on (default 8000) |
|
| --proxy-port | BIRDLG_PROXY_PORT | port bird-lgproxy is running on (default 8000) |
|
||||||
| --whois | BIRDLG_WHOIS | whois server for queries (default "whois.verisign-grs.com") |
|
| --whois | BIRDLG_WHOIS | whois server for queries (default "whois.verisign-grs.com") |
|
||||||
| --dns-interface | BIRDLG_DNS_INTERFACE | dns zone to query ASN information (default "asn.cymru.com") |
|
| --dns-interface | BIRDLG_DNS_INTERFACE | dns zone to query ASN information (default "asn.cymru.com") |
|
||||||
|
| --bgpmap-info | BIRDLG_BGPMAP_INFO | the infos displayed in bgpmap, separated by comma, start with `:` means allow multiline (default "asn,as-name,ASName,descr") |
|
||||||
| --title-brand | BIRDLG_TITLE_BRAND | prefix of page titles in browser tabs (default "Bird-lg Go") |
|
| --title-brand | BIRDLG_TITLE_BRAND | prefix of page titles in browser tabs (default "Bird-lg Go") |
|
||||||
| --navbar-brand | BIRDLG_NAVBAR_BRAND | brand to show in the navigation bar (default "Bird-lg Go") |
|
| --navbar-brand | BIRDLG_NAVBAR_BRAND | brand to show in the navigation bar (default "Bird-lg Go") |
|
||||||
| --navbar-brand-url | BIRDLG_NAVBAR_BRAND_URL | the url of the brand to show in the navigation bar (default "/") |
|
| --navbar-brand-url | BIRDLG_NAVBAR_BRAND_URL | the url of the brand to show in the navigation bar (default "/") |
|
||||||
|
BIN
frontend/assets/favicon.ico
Normal file
BIN
frontend/assets/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 32 KiB |
7
frontend/assets/static/jsdelivr/npm/bootstrap@4.5.1/dist/css/bootstrap.min.css
vendored
Normal file
7
frontend/assets/static/jsdelivr/npm/bootstrap@4.5.1/dist/css/bootstrap.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
7
frontend/assets/static/jsdelivr/npm/bootstrap@4.5.1/dist/js/bootstrap.min.js
vendored
Normal file
7
frontend/assets/static/jsdelivr/npm/bootstrap@4.5.1/dist/js/bootstrap.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
2
frontend/assets/static/jsdelivr/npm/jquery@3.5.1/dist/jquery.min.js
vendored
Normal file
2
frontend/assets/static/jsdelivr/npm/jquery@3.5.1/dist/jquery.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
8
frontend/assets/static/jsdelivr/npm/viz.js@2.1.2/viz.min.js
vendored
Normal file
8
frontend/assets/static/jsdelivr/npm/viz.js@2.1.2/viz.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -2,8 +2,8 @@
|
|||||||
<div id="bgpmap">
|
<div id="bgpmap">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/viz.js@2.1.2/viz.min.js" crossorigin="anonymous"></script>
|
<script src="/static/jsdelivr/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="/static/jsdelivr/npm/viz.js@2.1.2/lite.render.js" crossorigin="anonymous"></script>
|
||||||
<script>
|
<script>
|
||||||
var viz = new Viz();
|
var viz = new Viz();
|
||||||
viz.renderSVGElement(`{{ .Result }}`)
|
viz.renderSVGElement(`{{ .Result }}`)
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en-US">
|
<html lang="en-US">
|
||||||
<head>
|
<head>
|
||||||
|
<link rel="icon" href="/favicon.ico" type="image/x-icon" />
|
||||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
|
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
|
||||||
<meta name="renderer" content="webkit">
|
<meta name="renderer" content="webkit">
|
||||||
<title>{{ html .Title }}</title>
|
<title>{{ html .Title }}</title>
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.1/dist/css/bootstrap.min.css" integrity="sha256-VoFZSlmyTXsegReQCNmbXrS4hBBUl/cexZvPmPWoJsY=" crossorigin="anonymous">
|
<link rel="stylesheet" href="/static/jsdelivr/npm/bootstrap@4.5.1/dist/css/bootstrap.min.css" integrity="sha256-VoFZSlmyTXsegReQCNmbXrS4hBBUl/cexZvPmPWoJsY=" crossorigin="anonymous">
|
||||||
<meta name="robots" content="noindex, nofollow">
|
<meta name="robots" content="noindex, nofollow">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@ -73,8 +74,8 @@
|
|||||||
{{ .Content }}
|
{{ .Content }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
|
<script src="/static/jsdelivr/npm/jquery@3.5.1/dist/jquery.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.1/dist/js/bootstrap.min.js" integrity="sha256-0IiaoZCI++9oAAvmCb5Y0r93XkuhvJpRalZLffQXLok=" crossorigin="anonymous"></script>
|
<script src="/static/jsdelivr/npm/bootstrap@4.5.1/dist/js/bootstrap.min.js" integrity="sha256-0IiaoZCI++9oAAvmCb5Y0r93XkuhvJpRalZLffQXLok=" crossorigin="anonymous"></script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
function goto() {
|
function goto() {
|
||||||
|
@ -23,23 +23,46 @@ func getASNRepresentation(asn string) string {
|
|||||||
|
|
||||||
if setting.whoisServer != "" {
|
if setting.whoisServer != "" {
|
||||||
// get ASN representation using WHOIS
|
// get ASN representation using WHOIS
|
||||||
|
if setting.bgpmapInfo == "" {
|
||||||
|
setting.bgpmapInfo = "asn,as-name,ASName,descr"
|
||||||
|
}
|
||||||
records := whois(fmt.Sprintf("AS%s", asn))
|
records := whois(fmt.Sprintf("AS%s", asn))
|
||||||
if records != "" {
|
if records != "" {
|
||||||
recordsSplit := strings.Split(records, "\n")
|
recordsSplit := strings.Split(records, "\n")
|
||||||
result := ""
|
var result []string
|
||||||
for _, line := range recordsSplit {
|
for _, title := range strings.Split(setting.bgpmapInfo, ",") {
|
||||||
if strings.Contains(line, "as-name:") || strings.Contains(line, "ASName:") {
|
if title == "asn" {
|
||||||
result = result + strings.TrimSpace(strings.SplitN(line, ":", 2)[1])
|
result = append(result, "AS"+asn)
|
||||||
} else if strings.Contains(line, "descr:") {
|
|
||||||
result = result + "\\n" + strings.TrimSpace(strings.SplitN(line, ":", 2)[1])
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if result != "" {
|
for _, title := range strings.Split(setting.bgpmapInfo, ",") {
|
||||||
return fmt.Sprintf("AS%s\\n%s", asn, result)
|
allow_multiline := false
|
||||||
|
if title[0] == ':' && len(title) >= 2 {
|
||||||
|
title = title[1:]
|
||||||
|
allow_multiline = true
|
||||||
|
}
|
||||||
|
for _, line := range recordsSplit {
|
||||||
|
if len(line) == 0 || line[0] == '%' || !strings.Contains(line, ":") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
linearr := strings.SplitN(line, ":", 2)
|
||||||
|
line_title := linearr[0]
|
||||||
|
content := strings.TrimSpace(linearr[1])
|
||||||
|
if line_title != title {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
result = append(result, content)
|
||||||
|
if !allow_multiline {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(result) > 0 {
|
||||||
|
return fmt.Sprintf("%s", strings.Join(result, "\n"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return fmt.Sprintf("AS%s", asn)
|
return fmt.Sprintf("AS%s", asn)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ type settingType struct {
|
|||||||
navBarBrandURL string
|
navBarBrandURL string
|
||||||
navBarAllServer string
|
navBarAllServer string
|
||||||
navBarAllURL string
|
navBarAllURL string
|
||||||
|
bgpmapInfo string
|
||||||
telegramBotName string
|
telegramBotName string
|
||||||
protocolFilter []string
|
protocolFilter []string
|
||||||
}
|
}
|
||||||
@ -39,6 +40,7 @@ func main() {
|
|||||||
navBarBrandURL: "/",
|
navBarBrandURL: "/",
|
||||||
navBarAllServer: "All Servers",
|
navBarAllServer: "All Servers",
|
||||||
navBarAllURL: "all",
|
navBarAllURL: "all",
|
||||||
|
bgpmapInfo: "asn,as-name,ASName,descr",
|
||||||
telegramBotName: "",
|
telegramBotName: "",
|
||||||
protocolFilter: []string{},
|
protocolFilter: []string{},
|
||||||
}
|
}
|
||||||
@ -83,6 +85,9 @@ func main() {
|
|||||||
if env := os.Getenv("BIRDLG_NAVBAR_ALL_URL"); env != "" {
|
if env := os.Getenv("BIRDLG_NAVBAR_ALL_URL"); env != "" {
|
||||||
settingDefault.navBarAllURL = env
|
settingDefault.navBarAllURL = env
|
||||||
}
|
}
|
||||||
|
if env := os.Getenv("BIRDLG_BGPMAP_INFO"); env != "" {
|
||||||
|
settingDefault.bgpmapInfo = env
|
||||||
|
}
|
||||||
if env := os.Getenv("BIRDLG_TELEGRAM_BOT_NAME"); env != "" {
|
if env := os.Getenv("BIRDLG_TELEGRAM_BOT_NAME"); env != "" {
|
||||||
settingDefault.telegramBotName = env
|
settingDefault.telegramBotName = env
|
||||||
}
|
}
|
||||||
@ -99,9 +104,10 @@ func main() {
|
|||||||
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")
|
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")
|
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")
|
navBarBrandURLPtr := flag.String("navbar-brand-url", settingDefault.navBarBrandURL, "the url of the brand to show in the navigation bar")
|
||||||
navBarAllServerPtr := flag.String("navbar-all-servers", settingDefault.navBarAllServer, "brand to show in the navigation bar")
|
navBarAllServerPtr := flag.String("navbar-all-servers", settingDefault.navBarAllServer, "the text of \"All servers\" button in the navigation bar")
|
||||||
navBarAllURL := flag.String("navbar-all-url", settingDefault.navBarAllURL, "brand to show in the navigation bar")
|
navBarAllURL := flag.String("navbar-all-url", settingDefault.navBarAllURL, "the URL of \"All servers\" button")
|
||||||
|
bgpmapInfo := flag.String("bgpmap-info", settingDefault.bgpmapInfo, "the infos displayed in bgpmap, separated by comma, start with \":\" means allow multiline")
|
||||||
telegramBotNamePtr := flag.String("telegram-bot-name", settingDefault.telegramBotName, "telegram bot name (used to filter @bot commands)")
|
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, ","),
|
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")
|
"protocol types to show in summary tables (comma separated list); defaults to all if not set")
|
||||||
@ -148,6 +154,7 @@ func main() {
|
|||||||
*navBarBrandURLPtr,
|
*navBarBrandURLPtr,
|
||||||
*navBarAllServerPtr,
|
*navBarAllServerPtr,
|
||||||
*navBarAllURL,
|
*navBarAllURL,
|
||||||
|
*bgpmapInfo,
|
||||||
*telegramBotNamePtr,
|
*telegramBotNamePtr,
|
||||||
protocolFilter,
|
protocolFilter,
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user