Project

General

Profile

« Previous | Next » 

Revision e33068b7

Added by Marcos M 6 months ago

Generate the UUID using the external interface MAC

Use the configured external interface to generate the UUID and serial for
miniupnpd.conf. Additionally, resort to using a random MAC on failure.

View differences:

src/usr/local/pkg/miniupnpd.inc
33 33
		fclose($handle);
34 34
	}
35 35

  
36
	function upnp_uuid() {
37
		/* md5 hash of wan mac */
38
		$uuid = md5(get_interface_mac(get_real_interface("wan")));
36
	function upnp_uuid($interface) {
37
		$mac = get_interface_mac($interface);
38
		if (empty($mac)) {
39
			$mac = generate_random_mac_address();
40
		}
41
		/* md5 hash of external inteface mac */
42
		$uuid = md5($mac);
39 43
		/* put uuid in correct format 8-4-4-4-12 */
40 44
		return substr($uuid, 0, 8) . '-' . substr($uuid, 9, 4) . '-' . substr($uuid, 13, 4) . '-' . substr($uuid, 17, 4) . '-' . substr($uuid, 21, 12);
41 45
	}
......
248 252
				}
249 253

  
250 254
				/* set uuid and serial */
251
				$config_text .= "uuid=".upnp_uuid()."\n";
252
				$config_text .= "serial=".strtoupper(substr(upnp_uuid(), 0, 8))."\n";
255
				$uuid = upnp_uuid($ext_ifname);
256
				$config_text .= "uuid={$uuid}\n";
257
				$config_text .= "serial=".strtoupper(substr($uuid, 0, 8))."\n";
253 258

  
254 259
				/* set model number */
255 260
				if (!empty($upnp_config['modelnumber'])){

Also available in: Unified diff