Browse Source

Improve the web page layout

master
Lyndsay Roger 9 years ago
parent
commit
ef21eaed33
  1. 23
      http.go
  2. 12
      main.go
  3. 10
      seeder.go

23
http.go

@ -440,8 +440,10 @@ func summaryHandler(w http.ResponseWriter, r *http.Request) {
} }
writeHeader(w, r) writeHeader(w, r)
// loop through each of the seeders // loop through each of the seeder name from a slice so they are always returned in
for _, s := range config.seeders { // the same order then get a pointer to the seeder struct
for _, n := range config.order {
s := config.seeders[n]
hc.Name = s.name hc.Name = s.name
// fill the structs so they can be displayed via the template // fill the structs so they can be displayed via the template
@ -505,16 +507,23 @@ func summaryHandler(w http.ResponseWriter, r *http.Request) {
// writeHeader will output the standard header // writeHeader will output the standard header
func writeHeader(w http.ResponseWriter, r *http.Request) { func writeHeader(w http.ResponseWriter, r *http.Request) {
// we are using basic and simple html here. No fancy graphics or css // we are using basic and simple html here. No fancy graphics or css
h := ` h1 := `
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head><title>dnsseeder</title></head><body> <html><head><title>dnsseeder</title></head><body>
<center> <center>
<a href="/summary">Summary</a> <a href="/summary">Summary</a>
</center>
<hr>
<br>
` `
fmt.Fprintf(w, h) fmt.Fprintf(w, h1)
// read the seeder name
n := r.FormValue("s")
if n != "" {
s := getSeederByName(n)
if s != nil {
fmt.Fprintf(w, "<br><b>Seeder: %s</b>", html.EscapeString(s.name))
}
}
fmt.Fprintf(w, "</center><hr><br>")
} }
// writeFooter will output the standard footer // writeFooter will output the standard footer

12
main.go

@ -37,6 +37,7 @@ type configData struct {
stats bool // stats cmdline option stats bool // stats cmdline option
seeders map[string]*dnsseeder // holds a pointer to all the current seeders seeders map[string]*dnsseeder // holds a pointer to all the current seeders
smtx sync.RWMutex // protect the seeders map smtx sync.RWMutex // protect the seeders map
order []string // the order of loading the netfiles so we can display in this order
dns map[string][]dns.RR // holds details of all the currently served dns records dns map[string][]dns.RR // holds details of all the currently served dns records
dnsmtx sync.RWMutex // protect the dns map dnsmtx sync.RWMutex // protect the dns map
dnsUnknown uint64 // the number of dns requests for we are not configured to handle dnsUnknown uint64 // the number of dns requests for we are not configured to handle
@ -77,6 +78,7 @@ func main() {
config.seeders = make(map[string]*dnsseeder) config.seeders = make(map[string]*dnsseeder)
config.dns = make(map[string][]dns.RR) config.dns = make(map[string][]dns.RR)
config.order = []string{}
for _, nwFile := range netwFiles { for _, nwFile := range netwFiles {
nnw, err := loadNetwork(nwFile) nnw, err := loadNetwork(nwFile)
@ -87,6 +89,7 @@ func main() {
if nnw != nil { if nnw != nil {
// FIXME - lock this // FIXME - lock this
config.seeders[nnw.name] = nnw config.seeders[nnw.name] = nnw
config.order = append(config.order, nnw.name)
} }
} }
@ -214,15 +217,6 @@ func updateDNSCounts(name, qtype string) {
} }
} }
func getSeederByName(name string) *dnsseeder {
for _, s := range config.seeders {
if s.name == name {
return s
}
}
return nil
}
/* /*
*/ */

10
seeder.go

@ -390,6 +390,16 @@ func (s *dnsseeder) isFull() bool {
return false return false
} }
// getSeederByName returns a pointer to the seeder based on its name or nil if not found
func getSeederByName(name string) *dnsseeder {
for _, s := range config.seeders {
if s.name == name {
return s
}
}
return nil
}
/* /*
*/ */

Loading…
Cancel
Save