diff --git a/README.md b/README.md index d87ee76..cd705c1 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ -![Version](https://img.shields.io/badge/version-0.8.3-orange.svg) +![Version](https://img.shields.io/badge/version-0.8.4-orange.svg) ![Maintained YES](https://img.shields.io/badge/Maintained%3F-yes-green.svg) ![Ask Me Anything !](https://img.shields.io/badge/Ask%20me-anything-1abc9c.svg) # ![logo](https://github.com/jolav/codetabs/blob/master/www/_public/icons/ct/ct64r.png?raw=true) **ONLINE TOOLS ([codetabs.com](https://codetabs.com))** -**version 0.8.3** +**version 0.8.4** 1. [Count LOC (lines of code) online from github/gitlab repos or zipped uploaded folder](#count-loc-online) 2. [CORS proxy](#cors-proxy) diff --git a/_utils/stats.go b/_utils/stats.go index 6c08264..50de2c9 100644 --- a/_utils/stats.go +++ b/_utils/stats.go @@ -26,7 +26,6 @@ func AddHit(w http.ResponseWriter, r *http.Request, service, mode string, } } } - askingFor := strings.Trim(fmt.Sprint(r.URL), string(r.URL.Path)) if mode == "production" { @@ -38,6 +37,41 @@ func AddHit(w http.ResponseWriter, r *http.Request, service, mode string, } } +// AddBanned ... +func AddBanned(w http.ResponseWriter, r *http.Request, service, mode string, + hLog *log.Logger) { + ip := GetIP(r) + sv := strings.ToUpper(service) + host := r.Header.Get("Host") + if host == "" { + host = r.Header.Get("Origin") + if host == "" { + host = r.Header.Get("Referer") + if host == "" { + host = "???" + } + } + } + askingFor := strings.Trim(fmt.Sprint(r.URL), string(r.URL.Path)) + + if mode == "production" { + hLog.Println(ip, sv, host, askingFor) + } else { + log.Println(ip, sv, host, askingFor) + } +} + +// CreateCustomBansLogFile ... +func NewBanFile(f string) *log.Logger { + infoLog, err := os.OpenFile(f, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0644) + if err != nil { + log.Fatalf("ERROR opening Ban log file %s\n", err) + } + bannedLog := log.New(infoLog, "BANNED: ", log.Ldate|log.Ltime) + //hitsLog := log.New(infoLog, "HIT :\t", log.Ldate|log.Ltime) + return bannedLog +} + // CreateCustomHitsLogFile ... func NewHitsFile(f string) *log.Logger { infoLog, err := os.OpenFile(f, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0644) diff --git a/main.go b/main.go index 54ff58f..c3ed233 100644 --- a/main.go +++ b/main.go @@ -26,7 +26,7 @@ import ( "github.com/jolav/codetabs/weather" ) -var version = "0.8.3" +var version = "0.8.4" var when = "undefined" type Conf struct { @@ -34,9 +34,11 @@ type Conf struct { Port int ErrorsLogFile string HitsLogFile string + BannedLogFile string DevHosts []string Services []string hitsLog *log.Logger + bannedLog *log.Logger } func main() { @@ -68,6 +70,10 @@ func main() { } defer mylog.Close() + // Custom Ban Log File + c.BannedLogFile = usernow.HomeDir + c.BannedLogFile + c.bannedLog = u.NewBanFile(c.BannedLogFile) + // Custom Hits Log File c.HitsLogFile = usernow.HomeDir + c.HitsLogFile c.hitsLog = u.NewHitsFile(c.HitsLogFile) @@ -86,6 +92,7 @@ func main() { mux.HandleFunc("/v1/video2gif/", mw(video2gif.Router, "video2gif", c)) mux.HandleFunc("/v1/stars/", mw(stars.Router, "stars", c)) mux.HandleFunc("/v1/proxy/", mw(proxy.Router, "proxy", c)) + mux.HandleFunc("/v1/tmp/", mw(proxy.Router, "proxy", c)) mux.HandleFunc("/v1/loc/", mw(loc.Router, "loc", c)) mux.HandleFunc("/", u.BadRequest) @@ -104,14 +111,14 @@ func main() { func mw(next http.HandlerFunc, service string, c Conf) http.HandlerFunc { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - go u.AddHit(w, r, service, c.Mode, c.hitsLog) if service == "proxy" { if isBanned(r) { http.Error(w, "Unauthorized", http.StatusUnauthorized) + go u.AddBanned(w, r, service, c.Mode, c.bannedLog) return } } - + go u.AddHit(w, r, service, c.Mode, c.hitsLog) next.ServeHTTP(w, r) }) } diff --git a/proxy/proxy.go b/proxy/proxy.go index 0bd082a..0fac474 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -71,6 +71,11 @@ func (p *proxy) doProxyRequest(w http.ResponseWriter, r *http.Request) { if strings.Contains(contentType, "application/xml") { u.SendXMLToClient(w, data, 200) + return + } + + if strings.Contains(contentType, "text/") { + w.Header().Add("Content-type", "text/plain") } reader := bufio.NewReader(resp.Body) diff --git a/www/_error/404.css b/www/_error/404.css index 62938c1..fb3011f 100644 --- a/www/_error/404.css +++ b/www/_error/404.css @@ -88,7 +88,7 @@ a.link:hover { /* TITLE */ .titleBox { - font-family: "Titillium Web", "arial", sans-serif; + font-family: "arial", sans-serif; padding: 0px; font-size: 2.5em; text-align: center; @@ -98,4 +98,4 @@ a.link:hover { .titleBox img { vertical-align: middle; padding: 0px 15px 8px 0px; -} \ No newline at end of file +} diff --git a/www/_error/404.html b/www/_error/404.html index 6cefafd..f6e1049 100644 --- a/www/_error/404.html +++ b/www/_error/404.html @@ -46,12 +46,6 @@

- - - - - - - \ No newline at end of file + diff --git a/www/_error/429.html b/www/_error/429.html index b6139fd..ca07704 100644 --- a/www/_error/429.html +++ b/www/_error/429.html @@ -46,12 +46,6 @@

- - - - - - - \ No newline at end of file + diff --git a/www/_public/fonts/TitilliumWeb.ttf b/www/_public/fonts/TitilliumWeb.ttf new file mode 100644 index 0000000..e0e2dc8 Binary files /dev/null and b/www/_public/fonts/TitilliumWeb.ttf differ diff --git a/www/_public/fonts/Varela.ttf b/www/_public/fonts/Varela.ttf new file mode 100644 index 0000000..c890d5e Binary files /dev/null and b/www/_public/fonts/Varela.ttf differ diff --git a/www/_public/templates/analyticstracking.html b/www/_public/templates/analyticstracking.html deleted file mode 100644 index 0f1a112..0000000 --- a/www/_public/templates/analyticstracking.html +++ /dev/null @@ -1,14 +0,0 @@ - - - \ No newline at end of file diff --git a/www/_public/templates/cookieLaw.html b/www/_public/templates/cookieLaw.html deleted file mode 100644 index 7bd59b0..0000000 --- a/www/_public/templates/cookieLaw.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/www/_public/templates/footer.html b/www/_public/templates/footer.html index 83b46d6..924ec0c 100644 --- a/www/_public/templates/footer.html +++ b/www/_public/templates/footer.html @@ -34,6 +34,20 @@ text-align: center; } + @font-face { + font-family: 'Varela'; + font-style: normal; + font-weight: 400; + src: url('_public/fonts/Varela.ttf'); + } + + @font-face { + font-family: 'Titillium'; + font-style: normal; + font-weight: 400; + src: url('_public/fonts/TitilliumWeb.ttf'); + } +
+ + diff --git a/www/_public/templates/footerIP.html b/www/_public/templates/footerIP.html index 2f46023..6995cb4 100644 --- a/www/_public/templates/footerIP.html +++ b/www/_public/templates/footerIP.html @@ -34,6 +34,20 @@ text-align: center; }*/ + @font-face { + font-family: 'Varela'; + font-style: normal; + font-weight: 400; + src: url('_public/fonts/Varela.ttf'); + } + + @font-face { + font-family: 'Titillium'; + font-style: normal; + font-weight: 400; + src: url('_public/fonts/TitilliumWeb.ttf'); + } + @@ -49,14 +63,15 @@
You can submit your questions, feedbacks, and feature requests opening a issue on github or - - emailing us - + + 0f67664f6c606b6a7b6e6d7c216c6062Of989968bbc95bb968a888c9caf968080 + +
Jolav - © 2023 - + © - View on GitHub @@ -64,3 +79,38 @@
+ + + diff --git a/www/_public/templates/footerLoc.html b/www/_public/templates/footerLoc.html index 69e7dc7..5af7cca 100644 --- a/www/_public/templates/footerLoc.html +++ b/www/_public/templates/footerLoc.html @@ -34,6 +34,20 @@ text-align: center; } + @font-face { + font-family: 'Varela'; + font-style: normal; + font-weight: 400; + src: url('_public/fonts/Varela.ttf'); + } + + @font-face { + font-family: 'Titillium'; + font-style: normal; + font-weight: 400; + src: url('_public/fonts/TitilliumWeb.ttf'); + } +
+ + diff --git a/www/_public/templates/version.html b/www/_public/templates/version.html index a37255e..478728c 100644 --- a/www/_public/templates/version.html +++ b/www/_public/templates/version.html @@ -2,7 +2,7 @@

API doc - (version 0.8.3) + (version 0.8.4)

diff --git a/www/alexa/alexa-ranking.html b/www/alexa/alexa-ranking.html index 9fa6194..4ff5875 100644 --- a/www/alexa/alexa-ranking.html +++ b/www/alexa/alexa-ranking.html @@ -93,19 +93,9 @@

- - - - - - - - - - - \ No newline at end of file + diff --git a/www/cors-proxy/cors-proxy.html b/www/cors-proxy/cors-proxy.html index a80c14e..ad332bb 100644 --- a/www/cors-proxy/cors-proxy.html +++ b/www/cors-proxy/cors-proxy.html @@ -26,6 +26,18 @@

+
+

+ +
+

+ PLEASE READ THE NEWS ABOUT CORS-PROXY +

+
+
+

+
+
Description @@ -97,14 +109,6 @@

- - - - - - - - diff --git a/www/count-loc/count-loc-online.html b/www/count-loc/count-loc-online.html index 1bc9849..a8503e3 100644 --- a/www/count-loc/count-loc-online.html +++ b/www/count-loc/count-loc-online.html @@ -186,12 +186,6 @@

- - - - - - @@ -199,8 +193,6 @@

- - diff --git a/www/github-stars/github-star-history.html b/www/github-stars/github-star-history.html index 133f302..94ed964 100644 --- a/www/github-stars/github-star-history.html +++ b/www/github-stars/github-star-history.html @@ -100,20 +100,12 @@

- - - - - - - - diff --git a/www/http-headers/headers.html b/www/http-headers/headers.html index 33d052f..2137dda 100644 --- a/www/http-headers/headers.html +++ b/www/http-headers/headers.html @@ -112,18 +112,9 @@

- - - - - - - - - - \ No newline at end of file + diff --git a/www/index.html b/www/index.html index 09bc67b..4efefb6 100644 --- a/www/index.html +++ b/www/index.html @@ -70,6 +70,20 @@

+ + +
@@ -174,20 +196,6 @@

- -
@@ -196,13 +204,7 @@

- - - - - - diff --git a/www/ip-geolocation/ip-geolocation.html b/www/ip-geolocation/ip-geolocation.html index 5b66b16..6b7ef16 100644 --- a/www/ip-geolocation/ip-geolocation.html +++ b/www/ip-geolocation/ip-geolocation.html @@ -166,18 +166,9 @@

- - - - - - - - - diff --git a/www/video2gif/video-to-gif.html b/www/video2gif/video-to-gif.html index 1779197..2206951 100644 --- a/www/video2gif/video-to-gif.html +++ b/www/video2gif/video-to-gif.html @@ -115,17 +115,9 @@

- - - - - - - - diff --git a/www/weather/weather.html b/www/weather/weather.html index 3ba923f..5e18a35 100644 --- a/www/weather/weather.html +++ b/www/weather/weather.html @@ -134,14 +134,6 @@

- - - - - - - - - \ No newline at end of file +