2022-08-01 18:01:37 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								package   domainnameshop 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import   ( 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 "encoding/json" 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 "fmt" 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-20 19:21:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 "github.com/StackExchange/dnscontrol/v4/providers" 
  
						 
					
						
							
								
									
										
										
										
											2022-08-01 18:01:37 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/ * * 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-20 07:51:25 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Domainnameshop   Provider 
  
						 
					
						
							
								
									
										
										
										
											2022-08-01 18:01:37 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Info   required   in   ' creds . json ' : 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 -   token 		 API   Token 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 -   secret 	 API   Secret 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								* / 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								type   domainNameShopProvider   struct   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 Token    string   // The API token 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 Secret   string   // The API secret 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var   features   =   providers . DocumentationNotes { 
  
						 
					
						
							
								
									
										
										
										
											2022-08-20 20:42:16 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 providers . CanAutoDNSSEC :            providers . Cannot ( ) ,                                       // Maybe there is support for it 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 providers . CanGetZones :              providers . Unimplemented ( ) ,                                //
  
						 
					
						
							
								
									
										
										
										
											2022-08-20 07:51:25 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 providers . CanUseAlias :              providers . Unimplemented ( "Needs custom implementation" ) ,   // Can possibly be implemented, needs further research 
  
						 
					
						
							
								
									
										
										
										
											2022-08-01 18:01:37 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									 providers . CanUseCAA :                providers . Can ( ) , 
  
						 
					
						
							
								
									
										
										
										
											2023-03-16 19:04:20 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 providers . CanUseDS :                 providers . Unimplemented ( ) ,   // Seems to support but needs to be implemented 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 providers . CanUseDSForChildren :      providers . Unimplemented ( ) ,   // Seems to support but needs to be implemented 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 providers . CanUseLOC :                providers . Cannot ( ) , 
  
						 
					
						
							
								
									
										
										
										
											2022-08-20 20:42:16 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 providers . CanUseNAPTR :              providers . Cannot ( "According to Domainnameshop this will probably never be supported" ) ,   // Does not seem to support it 
  
						 
					
						
							
								
									
										
										
										
											2022-08-20 07:51:25 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 providers . CanUsePTR :                providers . Cannot ( "According to Domainnameshop this will probably never be supported" ) ,   // Seems to support but needs to be implemented 
  
						 
					
						
							
								
									
										
										
										
											2022-08-20 20:42:16 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 providers . CanUseSOA :                providers . Cannot ( ) ,                                                                      // Does not seem to support it 
  
						 
					
						
							
								
									
										
										
										
											2022-08-01 18:01:37 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									 providers . CanUseSRV :                providers . Can ( ) , 
  
						 
					
						
							
								
									
										
										
										
											2022-08-20 20:42:16 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 providers . CanUseSSHFP :              providers . Cannot ( "Might be supported in the future" ) ,                                     // Does not seem to support it 
  
						 
					
						
							
								
									
										
										
										
											2022-08-20 07:51:25 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 providers . CanUseTLSA :               providers . Unimplemented ( "Has support but no documentation. Needs to be investigated." ) ,   // Seems to support but needs to be implemented 
  
						 
					
						
							
								
									
										
										
										
											2022-08-20 20:42:16 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 providers . DocCreateDomains :         providers . Unimplemented ( ) ,                                                                // Not tested 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 providers . DocDualHost :              providers . Unimplemented ( ) ,                                                                // Not tested 
  
						 
					
						
							
								
									
										
										
										
											2022-08-01 18:01:37 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									 providers . DocOfficiallySupported :   providers . Cannot ( ) , 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Register with the dnscontrol system. 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// This establishes the name (all caps), and the function to call to initialize it. 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func   init ( )   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 fns   :=   providers . DspFuncs { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 Initializer :     newDomainNameShopProvider , 
  
						 
					
						
							
								
									
										
										
										
											2022-08-11 17:24:47 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										 RecordAuditor :   AuditRecords , 
  
						 
					
						
							
								
									
										
										
										
											2022-08-01 18:01:37 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									 } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 providers . RegisterDomainServiceProviderType ( "DOMAINNAMESHOP" ,   fns ,   features ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-20 07:51:25 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// newDomainNameShopProvider creates a Domainnameshop specific DNS provider. 
  
						 
					
						
							
								
									
										
										
										
											2022-08-01 18:01:37 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								func   newDomainNameShopProvider ( conf   map [ string ] string ,   metadata   json . RawMessage )   ( providers . DNSServiceProvider ,   error )   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 if   conf [ "token" ]   ==   ""   { 
  
						 
					
						
							
								
									
										
										
										
											2022-08-20 07:51:25 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										 return   nil ,   fmt . Errorf ( "no Domainnameshop token provided" ) 
  
						 
					
						
							
								
									
										
										
										
											2022-08-01 18:01:37 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									 }   else   if   conf [ "secret" ]   ==   ""   { 
  
						 
					
						
							
								
									
										
										
										
											2022-08-20 07:51:25 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										 return   nil ,   fmt . Errorf ( "no Domainnameshop secret provided" ) 
  
						 
					
						
							
								
									
										
										
										
											2022-08-01 18:01:37 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									 } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 api   :=   & domainNameShopProvider { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 Token :    conf [ "token" ] , 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 Secret :   conf [ "secret" ] , 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 // Consider testing if creds work 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 return   api ,   nil 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								type   domainResponse   struct   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 ID            int        ` json:"id" ` 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 Domain        string     ` json:"domain" ` 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 Nameservers   [ ] string   ` json:"nameservers" ` 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// The Actual fields are the values in the right format according to what is needed for RecordConfig. 
  
						 
					
						
							
								
									
										
										
										
											2022-08-14 20:49:57 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								//
  
						 
					
						
							
								
									
										
										
										
											2022-08-20 07:51:25 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								//	While the values without Actual are the values directly as received from the Domainnameshop API. 
  
						 
					
						
							
								
									
										
										
										
											2022-08-14 20:49:57 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								//	This is done to make it easier to use the values at later points. 
  
						 
					
						
							
								
									
										
										
										
											2022-08-01 18:01:37 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								type   domainNameShopRecord   struct   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 ID               int      ` json:"id" ` 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 Host             string   ` json:"host" ` 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 TTL              uint16   ` json:"ttl,omitempty" ` 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 Type             string   ` json:"type" ` 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 Data             string   ` json:"data" ` 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 Priority         string   ` json:"priority,omitempty" ` 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 ActualPriority   uint16 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 Weight           string   ` json:"weight,omitempty" ` 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 ActualWeight     uint16 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 Port             string   ` json:"port,omitempty" ` 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 ActualPort       uint16 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 CAATag           string   ` json:"tag,omitempty" ` 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 ActualCAAFlag    string   ` json:"flags,omitempty" ` 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 CAAFlag          uint64 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 DomainID         string 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}