mirror of
https://github.com/Eggbertx/gochan.git
synced 2025-08-05 04:36:24 -07:00
show real IP of poster, display any and all warnings during build
This commit is contained in:
parent
938e13caba
commit
4e267bbce0
5 changed files with 18 additions and 3 deletions
Binary file not shown.
Binary file not shown.
|
@ -581,7 +581,8 @@ func makePost(w http.ResponseWriter, r *http.Request, data interface{}) {
|
||||||
http.SetCookie(writer, &http.Cookie{Name: "password", Value: request.FormValue("postpassword"), Path: "/", Domain: config.SiteDomain, RawExpires: getSpecificSQLDateTime(time.Now().Add(time.Duration(31536000))),MaxAge: 31536000})
|
http.SetCookie(writer, &http.Cookie{Name: "password", Value: request.FormValue("postpassword"), Path: "/", Domain: config.SiteDomain, RawExpires: getSpecificSQLDateTime(time.Now().Add(time.Duration(31536000))),MaxAge: 31536000})
|
||||||
//http.SetCookie(writer, &http.Cookie{Name: "password", Value: request.FormValue("postpassword"), Path: "/", Domain: config.Domain, RawExpires: getSpecificSQLDateTime(time.Now().Add(time.Duration(31536000))),MaxAge: 31536000})
|
//http.SetCookie(writer, &http.Cookie{Name: "password", Value: request.FormValue("postpassword"), Path: "/", Domain: config.Domain, RawExpires: getSpecificSQLDateTime(time.Now().Add(time.Duration(31536000))),MaxAge: 31536000})
|
||||||
|
|
||||||
post.IP = request.RemoteAddr
|
// post.IP = request.RemoteAddr
|
||||||
|
post.IP = getRealIP(&request)
|
||||||
post.Timestamp = time.Now()
|
post.Timestamp = time.Now()
|
||||||
post.PosterAuthority = getStaffRank()
|
post.PosterAuthority = getStaffRank()
|
||||||
post.Bumped = time.Now()
|
post.Bumped = time.Now()
|
||||||
|
@ -710,7 +711,7 @@ func makePost(w http.ResponseWriter, r *http.Request, data interface{}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(isbanned) > 0 {
|
if len(isbanned) > 0 {
|
||||||
post.IP = request.RemoteAddr
|
|
||||||
wrapped := &Wrapper{IName: "bans",Data: isbanned}
|
wrapped := &Wrapper{IName: "bans",Data: isbanned}
|
||||||
|
|
||||||
var banpage_buffer bytes.Buffer
|
var banpage_buffer bytes.Buffer
|
||||||
|
|
|
@ -162,6 +162,20 @@ func initServer() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getRealIP(request *http.Request) (ip string) {
|
||||||
|
// HTTP_CF_CONNECTING_IP > X-Forwarded-For > RemoteAddr
|
||||||
|
if request.Header.Get("HTTP_CF_CONNECTING_IP") != "" {
|
||||||
|
ip = request.Header.Get("HTTP_CF_CONNECTING_IP")
|
||||||
|
} else {
|
||||||
|
if request.Header.Get("X-Forwarded-For") != "" {
|
||||||
|
ip = request.Header.Get("X-Forwarded-For")
|
||||||
|
} else {
|
||||||
|
ip = request.RemoteAddr
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func validReferrer(request http.Request) (valid bool) {
|
func validReferrer(request http.Request) (valid bool) {
|
||||||
if request.Referer() == "" || request.Referer()[7:len(config.SiteDomain)+7] != config.SiteDomain {
|
if request.Referer() == "" || request.Referer()[7:len(config.SiteDomain)+7] != config.SiteDomain {
|
||||||
// if request.Referer() == "" || request.Referer()[7:len(config.Domain)+7] != config.Domain {
|
// if request.Referer() == "" || request.Referer()[7:len(config.Domain)+7] != config.Domain {
|
||||||
|
|
|
@ -14,7 +14,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
// #cgo LDFLAGS: -lcrypt
|
// #cgo LDFLAGS: -lcrypt -Wall
|
||||||
// #define _GNU_SOURCE
|
// #define _GNU_SOURCE
|
||||||
// #include <crypt.h>
|
// #include <crypt.h>
|
||||||
// #include <stdlib.h>
|
// #include <stdlib.h>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue