mirror of
				https://github.com/superseriousbusiness/gotosocial.git
				synced 2025-10-29 19:02:26 -05:00 
			
		
		
		
	[chore] Validate/set account domain (#619)
* add miekg/dns dependency * set/validate accountDomain
This commit is contained in:
		
					parent
					
						
							
								dfdc473cef
							
						
					
				
			
			
				commit
				
					
						cf5c6d724d
					
				
			
		
					 304 changed files with 34218 additions and 1 deletions
				
			
		|  | @ -23,6 +23,7 @@ import ( | |||
| 	"fmt" | ||||
| 	"strings" | ||||
| 
 | ||||
| 	"github.com/miekg/dns" | ||||
| 	"github.com/sirupsen/logrus" | ||||
| ) | ||||
| 
 | ||||
|  | @ -31,10 +32,23 @@ func Validate() error { | |||
| 	errs := []error{} | ||||
| 
 | ||||
| 	// host | ||||
| 	if GetHost() == "" { | ||||
| 	host := GetHost() | ||||
| 	if host == "" { | ||||
| 		errs = append(errs, fmt.Errorf("%s must be set", HostFlag())) | ||||
| 	} | ||||
| 
 | ||||
| 	// accountDomain; only check if host was set, otherwise there's no point | ||||
| 	if host != "" { | ||||
| 		switch ad := GetAccountDomain(); ad { | ||||
| 		case "": | ||||
| 			SetAccountDomain(GetHost()) | ||||
| 		default: | ||||
| 			if !dns.IsSubDomain(ad, host) { | ||||
| 				errs = append(errs, fmt.Errorf("%s was %s and %s was %s, but %s is not a valid subdomain of %s", HostFlag(), host, AccountDomainFlag(), ad, host, ad)) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	// protocol | ||||
| 	switch proto := GetProtocol(); proto { | ||||
| 	case "https": | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue