Project

General

Profile

« Previous | Next » 

Revision 23adb26d

Added by Renato Botelho over 8 years ago

Break some long lines, no functional changes

View differences:

src/etc/inc/services.inc
2548 2548
		}
2549 2549

  
2550 2550
		$wanipv6 = get_interface_ipv6($if);
2551
		$cacheFile = "{$g['conf_path']}/dyndns_{$dnsupdate['interface']}_rfc2136_" . escapeshellarg($dnsupdate['host']) . "_{$dnsupdate['server']}.cache";
2551
		$cacheFile = $g['conf_path'] .
2552
		    "/dyndns_{$dnsupdate['interface']}_rfc2136_" .
2553
		    escapeshellarg($dnsupdate['host']) .
2554
		    "_{$dnsupdate['server']}.cache";
2552 2555
		$cacheFilev6 = $cacheFile . ".ipv6";
2553 2556
		$currentTime = time();
2554 2557

  
......
2568 2571
			$hostname .= ".";
2569 2572
		}
2570 2573

  
2571
		/* write private key file
2572
		   this is dumb - public and private keys are the same for HMAC-MD5,
2573
		   but nsupdate insists on having both */
2574
		$fd = fopen("{$g['varetc_path']}/K{$i}{$keyname}+157+00000.private", "w");
2574
		/*
2575
		 * write private key file
2576
		 * this is dumb - public and private keys are the same for
2577
		 * HMAC-MD5, but nsupdate insists on having both
2578
		 */
2579
		$fd = fopen($g['varetc_path'] .
2580
		    "/K{$i}{$keyname}+157+00000.private", "w");
2575 2581
		$privkey = <<<EOD
2576 2582
Private-key-format: v1.2
2577 2583
Algorithm: 157 (HMAC)
......
2593 2599
			$proto = 2;
2594 2600
		}
2595 2601

  
2596
		$fd = fopen("{$g['varetc_path']}/K{$i}{$keyname}+157+00000.key", "w");
2597
		fwrite($fd, "{$keyname} IN KEY {$flags} {$proto} 157 {$dnsupdate['keydata']}\n");
2602
		$fd = fopen($g['varetc_path'] .
2603
		    "/K{$i}{$keyname}+157+00000.key", "w");
2604
		fwrite($fd, "{$keyname} IN KEY {$flags} {$proto} 157 " .
2605
		    "{$dnsupdate['keydata']}\n");
2598 2606
		fclose($fd);
2599 2607

  
2600 2608
		/* generate update instructions */
......
2604 2612
		}
2605 2613

  
2606 2614
		if (file_exists($cacheFile)) {
2607
			list($cachedipv4, $cacheTimev4) = explode("|", file_get_contents($cacheFile));
2615
			list($cachedipv4, $cacheTimev4) = explode("|",
2616
			    file_get_contents($cacheFile));
2608 2617
		}
2609 2618
		if (file_exists($cacheFilev6)) {
2610
			list($cachedipv6, $cacheTimev6) = explode("|", file_get_contents($cacheFilev6));
2619
			list($cachedipv6, $cacheTimev6) = explode("|",
2620
			    file_get_contents($cacheFilev6));
2611 2621
		}
2612 2622

  
2613 2623
		// 25 Days
......
2616 2626

  
2617 2627
		/* Update IPv4 if we have it. */
2618 2628
		if (is_ipaddrv4($wanip) && $dnsupdate['recordtype'] != "AAAA") {
2619
			if (($wanip != $cachedipv4) || (($currentTime - $cacheTimev4) > $maxCacheAgeSecs) || $forced) {
2620
				$upinst .= "update delete {$dnsupdate['host']}. A\n";
2621
				$upinst .= "update add {$dnsupdate['host']}. {$dnsupdate['ttl']} A {$wanip}\n";
2629
			if (($wanip != $cachedipv4) || $forced ||
2630
			    (($currentTime - $cacheTimev4) > $maxCacheAgeSecs)) {
2631
				$upinst .= "update delete " .
2632
				    "{$dnsupdate['host']}. A\n";
2633
				$upinst .= "update add {$dnsupdate['host']}. " .
2634
				    "{$dnsupdate['ttl']} A {$wanip}\n";
2622 2635
				$need_update = true;
2623 2636
			} else {
2624
				log_error(sprintf(gettext("phpDynDNS: Not updating %s A record because the IP address has not changed."), $dnsupdate['host']));
2637
				log_error(sprintf(gettext(
2638
				    "phpDynDNS: Not updating %s A record because the IP address has not changed."),
2639
				    $dnsupdate['host']));
2625 2640
			}
2626 2641
		} else {
2627 2642
			@unlink($cacheFile);
......
2630 2645

  
2631 2646
		/* Update IPv6 if we have it. */
2632 2647
		if (is_ipaddrv6($wanipv6) && $dnsupdate['recordtype'] != "A") {
2633
			if (($wanipv6 != $cachedipv6) || (($currentTime - $cacheTimev6) > $maxCacheAgeSecs) || $forced) {
2634
				$upinst .= "update delete {$dnsupdate['host']}. AAAA\n";
2635
				$upinst .= "update add {$dnsupdate['host']}. {$dnsupdate['ttl']} AAAA {$wanipv6}\n";
2648
			if (($wanipv6 != $cachedipv6) || $forced ||
2649
			    (($currentTime - $cacheTimev6) > $maxCacheAgeSecs)) {
2650
				$upinst .= "update delete " .
2651
				    "{$dnsupdate['host']}. AAAA\n";
2652
				$upinst .= "update add {$dnsupdate['host']}. " .
2653
				    "{$dnsupdate['ttl']} AAAA {$wanipv6}\n";
2636 2654
				$need_update = true;
2637 2655
			} else {
2638
				log_error(sprintf(gettext("phpDynDNS: Not updating %s AAAA record because the IPv6 address has not changed."), $dnsupdate['host']));
2656
				log_error(sprintf(gettext(
2657
				    "phpDynDNS: Not updating %s AAAA record because the IPv6 address has not changed."),
2658
				    $dnsupdate['host']));
2639 2659
			}
2640 2660
		} else {
2641 2661
			@unlink($cacheFilev6);
......
2648 2668
			continue;
2649 2669
		}
2650 2670

  
2651
		@file_put_contents("{$g['varetc_path']}/nsupdatecmds{$i}", $upinst);
2671
		@file_put_contents("{$g['varetc_path']}/nsupdatecmds{$i}",
2672
		    $upinst);
2652 2673
		unset($upinst);
2653 2674
		/* invoke nsupdate */
2654
		$cmd = "/usr/local/bin/nsupdate -k {$g['varetc_path']}/K{$i}{$keyname}+157+00000.key";
2675
		$cmd = "/usr/local/bin/nsupdate -k " .
2676
		    "{$g['varetc_path']}/K{$i}{$keyname}+157+00000.key";
2677

  
2655 2678
		if (isset($dnsupdate['usetcp'])) {
2656 2679
			$cmd .= " -v";
2657 2680
		}
2681

  
2658 2682
		$cmd .= " {$g['varetc_path']}/nsupdatecmds{$i}";
2683

  
2659 2684
		if (mwexec($cmd) == 0) {
2660 2685
			if (!empty($cacheFile)) {
2661
				@file_put_contents($cacheFile, "{$wanip}|{$currentTime}");
2662
				log_error(sprintf(gettext('phpDynDNS: updating cache file %1$s: %2$s'), $cacheFile, $wanip));
2663
				$notify_text .= sprintf(gettext('DynDNS updated IP Address (A) for %1$s on %2$s (%3$s) to %4$s'), $dnsupdate['host'], convert_real_interface_to_friendly_descr($if), $if, $wanip) . "\n";
2686
				@file_put_contents($cacheFile,
2687
				    "{$wanip}|{$currentTime}");
2688
				log_error(sprintf(gettext(
2689
				    'phpDynDNS: updating cache file %1$s: %2$s'),
2690
				    $cacheFile, $wanip));
2691
				$notify_text .= sprintf(gettext(
2692
				    'DynDNS updated IP Address (A) for %1$s on %2$s (%3$s) to %4$s'),
2693
				    $dnsupdate['host'],
2694
				    convert_real_interface_to_friendly_descr($if),
2695
				    $if, $wanip) . "\n";
2664 2696
			}
2665 2697
			if (!empty($cacheFilev6)) {
2666
				@file_put_contents($cacheFilev6, "{$wanipv6}|{$currentTime}");
2667
				log_error(sprintf(gettext('phpDynDNS: updating cache file %1$s: %2$s'), $cacheFilev6, $wanipv6));
2668
				$notify_text .= sprintf(gettext('DynDNS updated IPv6 Address (AAAA) for %1$s on %2$s (%3$s) to %4$s'), $dnsupdate['host'], convert_real_interface_to_friendly_descr($if), $if, $wanipv6) . "\n";
2698
				@file_put_contents($cacheFilev6,
2699
				    "{$wanipv6}|{$currentTime}");
2700
				log_error(sprintf(gettext(
2701
				    'phpDynDNS: updating cache file %1$s: %2$s'),
2702
				    $cacheFilev6, $wanipv6));
2703
				$notify_text .= sprintf(gettext(
2704
				    'DynDNS updated IPv6 Address (AAAA) for %1$s on %2$s (%3$s) to %4$s'),
2705
				    $dnsupdate['host'],
2706
				    convert_real_interface_to_friendly_descr($if),
2707
				    $if, $wanipv6) . "\n";
2669 2708
			}
2670 2709
		} else {
2671 2710
			if (!empty($cacheFile)) {
2672
				log_error(sprintf(gettext('phpDynDNS: ERROR while updating IP Address (A) for %1$s (%2$s)'), $dnsupdate['host'], $wanip));
2711
				log_error(sprintf(gettext(
2712
				    'phpDynDNS: ERROR while updating IP Address (A) for %1$s (%2$s)'),
2713
				    $dnsupdate['host'], $wanip));
2673 2714
			}
2674 2715
			if (!empty($cacheFilev6)) {
2675
				log_error(sprintf(gettext('phpDynDNS: ERROR while updating IP Address (AAAA) for %1$s (%2$s)'), $dnsupdate['host'], $wanipv6));
2716
				log_error(sprintf(gettext(
2717
				    'phpDynDNS: ERROR while updating IP Address (AAAA) for %1$s (%2$s)'),
2718
				    $dnsupdate['host'], $wanipv6));
2676 2719
			}
2677 2720
		}
2678 2721
		unset($cmd);

Also available in: Unified diff