Unverified Commit 4009f757 authored by Ola Bini's avatar Ola Bini

Remove valid domains as a possibility here

parent db4ec5ab
......@@ -14,7 +14,6 @@ var (
xmppSharedSecret = flag.String("shared-secret", "changeme", "Shared secret for authenticating to the XMPP server")
xmppName = flag.String("name", "changeme", "Name for the XMPP component. Usually something like prekeys.example.org")
prekeyServerFingerprint = flag.String("fingerprint", "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "Fingerprint for the prekey server. This is expected to be 56 bytes expressed in hexadecimal - thus 112 digits")
validDomains = flag.String("valid-domains", "", "A list of all domains that are valid for users, separated by commas. An empty list is equal to no restriction.")
)
func isFingerprint(name string) bool {
......
......@@ -2,33 +2,11 @@ package main
import (
"fmt"
"strings"
xco "github.com/sheenobu/go-xco"
)
func contains(a []string, x string) bool {
for _, n := range a {
if x == n {
return true
}
}
return false
}
func validDomain(d string) bool {
if *validDomains == "" {
return true
}
ds := strings.Split(*validDomains, ",")
return contains(ds, d)
}
func messageHandler(c *xco.Component, m *xco.Message) error {
if !validDomain(m.Header.From.DomainPart) {
fmt.Printf("Attempt to add data from unauthorized domain: %v@%v\n", m.Header.From.LocalPart, m.Header.From.DomainPart)
return nil
}
res, e := getPrekeyResponseFromRealServer(fmt.Sprintf("%s@%s", m.Header.From.LocalPart, m.Header.From.DomainPart), []byte(m.Body))
if e != nil {
fmt.Printf("encountered error when communicating with the raw server: %v\n", e)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment