aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorFChannel <>2021-07-01 14:01:52 -0700
committerFChannel <>2021-07-01 14:01:52 -0700
commita122d62f78e5f1fd66efc28994809d720a2841ab (patch)
treec3a8592d4753adbb6ef9ac26f97d4ba9f8f3a0b5 /main.go
parentdbe79ecbb5bb0645093780380cc241f6cd8d1a20 (diff)
flushed out version of tripcode with secure trips and instancesalt added to config
Diffstat (limited to 'main.go')
-rw-r--r--main.go59
1 files changed, 24 insertions, 35 deletions
diff --git a/main.go b/main.go
index 972e69e..9dac9e2 100644
--- a/main.go
+++ b/main.go
@@ -1,25 +1,27 @@
package main
-import "fmt"
-import "strings"
-import "strconv"
-import "net/http"
-import "net/url"
-import "database/sql"
-import _ "github.com/lib/pq"
-import "math/rand"
-import "html/template"
-import "time"
-import "regexp"
-import "os/exec"
-import "bytes"
-import "encoding/json"
-import "io/ioutil"
-import "mime/multipart"
-import "os"
-import "bufio"
-import "io"
-import "github.com/gofrs/uuid"
+import (
+ "fmt"
+ "strings"
+ "strconv"
+ "net/http"
+ "net/url"
+ "database/sql"
+ _ "github.com/lib/pq"
+ "math/rand"
+ "html/template"
+ "time"
+ "regexp"
+ "os/exec"
+ "bytes"
+ "encoding/json"
+ "io/ioutil"
+ "mime/multipart"
+ "os"
+ "bufio"
+ "io"
+ "github.com/gofrs/uuid"
+)
var Port = ":" + GetConfigValue("instanceport")
var TP = GetConfigValue("instancetp")
@@ -39,6 +41,8 @@ var TorProxy = GetConfigValue("torproxy") //127.0.0.1:9050
var PublicIndexing = strings.ToLower(GetConfigValue("publicindex"))
+var Salt = GetConfigValue("instancesalt")
+
var activitystreams = "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\""
func main() {
@@ -1211,21 +1215,6 @@ func CreateTripCode(input string) string {
return code[0]
}
-func CreateNameTripCode(r *http.Request, db *sql.DB) (string, string) {
- input := r.FormValue("name")
- re := regexp.MustCompile("#.+")
- chunck := re.FindString(input)
- ce := regexp.MustCompile(`(?i)#Admin`)
- admin := ce.MatchString(chunck)
- board, modcred := GetPasswordFromSession(r)
- if(admin && HasAuth(db, modcred, board)) {
- return re.ReplaceAllString(input, ""), "#Admin"
- } else if(chunck != "") {
- hash := CreateTripCode(chunck)
- return re.ReplaceAllString(input, ""), "!" + hash[42:50]
- }
- return input, ""
-}
func GetActorFromPath(db *sql.DB, location string, prefix string) Actor {
pattern := fmt.Sprintf("%s([^/\n]+)(/.+)?", prefix)