Project

General

Profile

« Previous | Next » 

Revision af41271b

Added by Jason McCormick over 8 years ago

move back to r53.class for license continuity

(cherry picked from commit 16b163661b1d1a5bcc9a24ce023f7a06c5fb420e)

View differences:

src/etc/inc/dyndns.class
678 678
					}
679 679
					curl_setopt($ch, CURLOPT_URL, $server .$port . '?system=dyndns&hostname=' . $this->_dnsHost . '&myip=' . $this->_dnsIP . '&wildcard='.$this->_dnsWildcard . '&mx=' . $this->_dnsMX . '&backmx=NO');
680 680
					break;
681
				case 'route53':
682
					/* http://docs.aws.amazon.com/Route53/latest/APIReference/Welcome.html */
683
					/* AWS3 Signature generation inspired by Dan Myers http://sourceforge.net/projects/php-r53/ */
684
					$reqdate = gmdate('D, d M Y H:i:s e');
685
					$httphead[] = array();
686
					$httphead[] = sprintf("Date: %s", $reqdate);
687
					/* to avoid having user to know their AWS Region, for now use V3 */
688
					$httphead[] = sprintf(
689
							"X-Amzn-Authorization: AWS3-HTTPS AWSAccessKeyId=%s,Algorithm=HMACSHA256,SignedHeaders=date,Signature=%s",
690
							$this->_dnsUser,
691
							base64_encode(hash_hmac("sha256", $reqdate, $this->_dnsPass, true))
692
					);					
693
					$apiurl = sprintf("https://route53.amazonaws.com/2013-04-01/hostedzone/%s/rrset", $this->_dnsZoneID);
694
					$xmlreq .= "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
695
					$xmlreq .= "<ChangeResourceRecordSetsRequest xmlns=\"https://route53.amazonaws.com/doc/2013-04-01/\">";
696
					$xmlreq .= "<ChangeBatch><Changes><Change>";
697
					$xmlreq .= "<Action>UPSERT</Action>";
698
					$xmlreq .= "<ResourceRecordSet>";
699
					$xmlreq .= sprintf("<Name>%s</Name>", $this->_dnsHost);
700
					$xmlreq .= "<Type>A</Type>";
701
					$xmlreq .= sprintf("<TTL>%d</TTL>", $this->_dnsTTL);
702
					$xmlreq .= sprintf("<ResourceRecords><ResourceRecord><Value>%s</Value></ResourceRecord></ResourceRecords>",
703
								$this->_dnsIP);
704
					$xmlreq .= "</ResourceRecordSet>";
705
					$xmlreq .= "</Change></Changes></ChangeBatch>";
706
					$xmlreq .= "</ChangeResourceRecordSetsRequest>";
707
					
708
					$httphead[] = "Content-Type: text/plain";
709
					$httphead[] = sprintf("Content-Length: %d", strlen($xmlreq));
710
					
681
				case 'route53':		
682
					require_once("r53.class");
683
					$r53 = new Route53($this->_dnsUser, $this->_dnsPass);
684
					$apiurl = $r53->getApiUrl($this->_dnsZoneID);
685
					$xmlreq = $r53->getRequestBody($this->_dnsHost, $this->_dnsIP, $this->_dnsTTL);
686
					$httphead = $r53->getHttpPostHeaders(strlen($xmlreq));
711 687
					curl_setopt($ch, CURLOPT_HTTPHEADER, $httphead);
712 688
					if($this->_dnsVerboseLog){
713 689
						log_error(sprintf("Sending reuquest to: %s", $apiurl));
714 690
						foreach($httphead as $hv){
715 691
							log_error(sprintf("Header: %s", $hv));
716 692
						}
717
						log_error(sprintf("XMLPOST:\n%s\n\n", $xmlreq));
693
						log_error(sprintf("XMLPOST: %s", $xmlreq));
718 694
					}
719 695
					curl_setopt($ch, CURLOPT_URL, $apiurl);
720 696
					curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlreq);

Also available in: Unified diff