Whitespace fixes

This commit is contained in:
Björn Busse 2017-10-02 10:54:27 +00:00
parent 9ae20db92e
commit 3b3f68c525
1 changed files with 22 additions and 22 deletions

44
main.go
View File

@ -1,16 +1,16 @@
package main
import (
"container/ring"
"fmt"
"github.com/hpcloud/tail"
"encoding/json"
"net/http"
"os"
"regexp"
"strconv"
"strings"
"time"
"container/ring"
"fmt"
"github.com/hpcloud/tail"
"encoding/json"
"net/http"
"os"
"regexp"
"strconv"
"strings"
"time"
)
func fileHandler(w http.ResponseWriter, r *http.Request, s string) {
@ -19,7 +19,7 @@ func fileHandler(w http.ResponseWriter, r *http.Request, s string) {
for _, v := range whitelist {
if !strings.Contains(v, fn) {
sendFile(w, fn, "", "Permission denied")
return
return
}
}
@ -30,7 +30,7 @@ func fileHandler(w http.ResponseWriter, r *http.Request, s string) {
if (watch == false) {
t, err := tail.TailFile(fn, tail.Config{Follow: false})
watch = true
watch = true
}
if (err == nil) {
@ -78,7 +78,7 @@ var prj = "httptail"
var version = "0.1.0"
var server_inet6 = "[fdef:c181:4234:7978:6::1]:8080"
var whitelist = map[int]string{
0: "/var/log",
0: "/var/log",
}
var logring = ring.New(1000)
@ -87,21 +87,21 @@ var watch bool = false
var m_prev = ""
func main() {
uid := os.Getuid()
t.Filename = ""
uid := os.Getuid()
t.Filename = ""
if (uid == -1) {
fmt.Println("Windows is unsupported")
if (uid == -1) {
fmt.Println("Windows is unsupported")
}
if (uid == 0) {
if (uid == 0) {
fmt.Println("Refusing to run as root")
return
}
return
}
http.HandleFunc("/tail/", makeHandler(fileHandler))
http.HandleFunc("/tail/", makeHandler(fileHandler))
fmt.Println("Serving " + prj + " " + version + " on " + server_inet6)
http.ListenAndServe(server_inet6, nil)
t.Cleanup()
t.Cleanup()
}