File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed
Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ import (
2222
2323 "github.com/avct/uasurfer"
2424 "github.com/google/uuid"
25+ "golang.org/x/net/publicsuffix"
2526 . "gomodules.xyz/email-providers"
2627 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2728)
@@ -73,6 +74,13 @@ func (form LicenseForm) Validate() error {
7374 if agree , _ := strconv .ParseBool (form .Tos ); ! agree {
7475 return fmt .Errorf ("user must agree to terms and services" )
7576 }
77+ if apex , err := publicsuffix .EffectiveTLDPlusOne (Domain (form .Email )); err != nil {
78+ return err
79+ } else {
80+ if err := DomainWithMXRecord (apex ); err != nil {
81+ return err
82+ }
83+ }
7684 return nil
7785}
7886
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ limitations under the License.
1717package server
1818
1919import (
20+ "errors"
2021 "fmt"
2122 "net"
2223 "net/http"
@@ -29,6 +30,17 @@ import (
2930 "k8s.io/klog/v2"
3031)
3132
33+ func DomainWithMXRecord (domain string ) error {
34+ records , err := net .LookupMX (domain )
35+ if err != nil {
36+ return err
37+ }
38+ if len (records ) == 0 {
39+ return errors .New ("no MX records" )
40+ }
41+ return nil
42+ }
43+
3244func IsEnterpriseProduct (product string ) bool {
3345 return strings .HasSuffix (strings .ToLower (product ), "-enterprise" )
3446}
You can’t perform that action at this time.
0 commit comments