Skip to content

Commit

Permalink
rename POSTKey to URLKey
Browse files Browse the repository at this point in the history
  • Loading branch information
aerth committed Jun 16, 2016
1 parent 98fba0c commit 8596769
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
17 changes: 10 additions & 7 deletions routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,16 @@ func route(cwd string, staticDir string) (r *mux.Router) {
r.Methods("GET").Path("/static/{dir}/{whatever}.mp3").Handler(s)
r.Methods("GET").Path("/static/{dir}/{whatever}.m3u").Handler(s)
r.Methods("GET").Path("/static/{dir}/{whatever}.md").Handler(s)
r.Methods("GET").Path("/files/{whatever}.tgz").Handler(sf)
r.Methods("GET").Path("/files/{whatever}.txz").Handler(sf)
r.Methods("GET").Path("/files/{whatever}.txt").Handler(sf)
r.Methods("GET").Path("/files/{whatever}.tar").Handler(sf)
r.Methods("GET").Path("/files/{whatever}.zip").Handler(sf)
r.Methods("GET").Path("/files/{whatever}.tar.gz").Handler(sf)
r.Methods("GET").Path("/files/{whatever}.tar.bz2").Handler(sf)
r.Methods("GET").Path("/files/").Handler(sf)
/*
r.Methods("GET").Path("/files/{whatever}.tgz").Handler(ss)
r.Methods("GET").Path("/files/{whatever}.txz").Handler(ss)
r.Methods("GET").Path("/files/{whatever}.txt").Handler(ss)
r.Methods("GET").Path("/files/{whatever}.tar").Handler(ss)
r.Methods("GET").Path("/files/{whatever}.zip").Handler(ss)
r.Methods("GET").Path("/files/{whatever}.tar.gz").Handler(ss)
r.Methods("GET").Path("/files/{whatever}.tar.bz2").Handler(ss)
*/
if *customExtension != "" {
r.Methods("GET").Path("/files/{whatever}." + *customExtension).Handler(sf)
}
Expand Down
8 changes: 5 additions & 3 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ import (

func homeHandler(w http.ResponseWriter, r *http.Request) {
hitcounter = hitcounter + 1
cosgo.Visitors = hitcounter
if !*quiet {
log.Printf("Visitor: %s %s %s %s", r.UserAgent(), r.RemoteAddr, r.Host, r.RequestURI)
log.Printf("Visitor #%v: %s %s %s %s", cosgo.Visitors, r.UserAgent(), r.RemoteAddr, r.Host, r.RequestURI)
}

query, err := url.ParseQuery(r.URL.RawQuery)
Expand Down Expand Up @@ -135,9 +136,9 @@ func verifyKey(r *http.Request) bool {
userkey = strings.TrimRight(userkey, "/send")
// Check URL Key
if *debug {
log.Printf("\nComparing... \n\t" + userkey + "\n\t" + cosgo.PostKey)
log.Printf("\nComparing... \n\t" + userkey + "\n\t" + cosgo.URLKey)
}
if userkey != cosgo.PostKey {
if userkey != cosgo.URLKey {
log.Println("Key Mismatch. ", r.UserAgent(), r.RemoteAddr, r.RequestURI+"\n")
return false
}
Expand Down Expand Up @@ -219,6 +220,7 @@ func srvSuccess(r *http.Request, rw http.ResponseWriter, status int) {
// serverSingle just shows one file.
func serveSingle(pattern string, filename string) {
http.HandleFunc(pattern, func(w http.ResponseWriter, r *http.Request) {
log.Printf("Serving %s: %s at %s", pattern, r.UserAgent(), r.RemoteAddr)
http.ServeContent(w, r, filename, time.Now(), nil)
})
}

0 comments on commit 8596769

Please sign in to comment.