1
0
Fork 0
mirror of https://github.com/Eggbertx/gochan.git synced 2025-08-17 10:56:24 -07:00

Fix new cookie domain for when you use a port number, and fix getRemoteAddr, which has been broken for a while lol.

This commit is contained in:
Darren VanBuren 2017-08-01 03:05:29 -07:00
parent 9503f989ca
commit cac77437b0
3 changed files with 8 additions and 1 deletions

View file

@ -7,6 +7,7 @@ import (
"net/http"
"os"
"path"
"regexp"
"strconv"
"time"
@ -123,6 +124,9 @@ func createSession(key string, username string, password string, request *http.R
//returns 0 for successful, 1 for password mismatch, and 2 for other
domain := request.Host
chopPortNumRegex := regexp.MustCompile("(.+|\\w+):(\\d+)$")
domain = chopPortNumRegex.Split(domain, -1)[0]
if !validReferrer(*request) {
mod_log.Print("Rejected login from possible spambot @ : " + request.RemoteAddr)
return 2

View file

@ -649,6 +649,9 @@ func makePost(w http.ResponseWriter, r *http.Request, data interface{}) {
var errortext string
domain := r.Host
chopPortNumRegex := regexp.MustCompile("(.+|\\w+):(\\d+)$")
domain = chopPortNumRegex.Split(domain, -1)[0]
var post PostTable
post.IName = "post"
post.ParentID, _ = strconv.Atoi(request.FormValue("threadid"))

View file

@ -177,7 +177,7 @@ func getRealIP(r *http.Request) (ip string) {
if r.Header.Get("X-Forwarded-For") != "" {
ip = r.Header.Get("X-Forwarded-For")
} else {
ip = r.Host
ip = r.RemoteAddr
}
}
return