-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Mac OS X proxies #16
Comments
PList parser: <?php namespace parse;
use util\cmd\Console;
use util\profiling\Timer;
$timer= Timer::measure(function() use($argv) {
$parser= xml_parser_create();
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
xml_parse_into_struct($parser, file_get_contents($argv[1]), $elements);
xml_parser_free($parser);
$result= [];
$key= null;
foreach ($elements as $tag) {
if ('open' === $tag['type'] && 'dict' === $tag['tag']) {
$key ? $path.= '/'.$key : $path= '';
} else if ('complete' === $tag['type']) {
if ('key' === $tag['tag']) {
$key= $tag['value'];
} else if (!isset($tag['value'])) {
$result[$path.'/'.$key]= null; // Empty values
} else if ('string' === $tag['tag']) {
$result[$path.'/'.$key][]= $tag['value'];
} else if ('integer' === $tag['tag']) {
$result[$path.'/'.$key][]= (int)$tag['value'];
} else if ('true' === $tag['tag']) {
$result[$path.'/'.$key][]= true;
} else if ('false' === $tag['tag']) {
$result[$path.'/'.$key][]= false;
}
} else if ('close' === $tag['type'] && 'dict' === $tag['tag']) {
$path= substr($path, 0, strrpos($path, '/'));
}
}
Console::writeLine($result);
});
Console::writeLinef('Took %.3f seconds', $timer->elapsedTime()); Result for above:
|
Theory: // I'm uncertain about this, how do we now which one is active?
$service= $plist[$plist['/CurrentSet'].'/Network/Global/IPv4/ServiceOder'][0];
// Probable
$network= $plist[$plist['/CurrentSet'].'/Network/Service/'.$service.'/__LINK__'][0];
if ($plist[$network.'/Proxies/HTTPEnable'][0]) {
return new HttpProxy(
$plist[$network.'/Proxies/HTTPProxy'][0],
$plist[$network.'/Proxies/HTTPPort'][0],
$plist[$network.'/Proxies/ExceptionsList']
);
} else {
return HttpProxy::NONE;
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
From /Library/Preferences/SystemConfiguration/preferences.plist
The text was updated successfully, but these errors were encountered: