1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-15 15:53:55 +00:00

Updated proxy detection algorithm on Linux.

This commit is contained in:
Bryan Roe
2020-08-27 13:14:11 -07:00
parent f98f976eba
commit b484cf9815
3 changed files with 128 additions and 59 deletions

View File

@@ -1,4 +1,50 @@
/*
Copyright 2019 - 2020 Intel Corporation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
function linux_getMountPoints()
{
var child = require('child_process').execFile('/bin/sh', ['sh']);
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
child.stdin.write("mount | tr '\\n' '`' | awk '");
child.stdin.write('{');
child.stdin.write(' printf "{";');
child.stdin.write(' n=split($0,lines,"`");');
child.stdin.write(' for(i=1;i<n;++i)');
child.stdin.write(' {');
child.stdin.write(' x=split(lines[i], tokens, " ");');
child.stdin.write(' j=sprintf(" type %s", tokens[x-1]);');
child.stdin.write(' e=index(lines[i], j);');
child.stdin.write(' s=index(lines[i], " on ");');
child.stdin.write(' point=substr(lines[i], s+4, e-s-4);');
child.stdin.write(' printf "%s\\"%s\\":\\"%s\\"",(i!=1?",":""), point, tokens[x-1];');
child.stdin.write(' }');
child.stdin.write(' printf "}";');
child.stdin.write("}'\nexit\n");
child.waitExit();
try
{
return (JSON.parse(child.stdout.str));
}
catch (exc)
{
return ({});
}
}
function gnome_getProxySettings(uid)
{
@@ -94,7 +140,8 @@ switch(process.platform)
{
getProxySettings: gnome_getProxySettings,
getDesktopWallpaper: gnome_getDesktopWallpaper,
setDesktopWallpaper: gnome_setDesktopWallpaper
setDesktopWallpaper: gnome_setDesktopWallpaper,
mounts: linux_getMountPoints
};
Object.defineProperty(module.exports, '_location', {
value: (function ()