Skip to content

Commit

Permalink
new format and auto convert
Browse files Browse the repository at this point in the history
  • Loading branch information
rikaaa0928 committed Feb 11, 2019
1 parent 2bc570b commit 98ee787
Show file tree
Hide file tree
Showing 7 changed files with 177 additions and 87 deletions.
130 changes: 73 additions & 57 deletions default.json
Original file line number Diff line number Diff line change
@@ -1,49 +1,86 @@
{
"inbound": {
"port": 0,
"listen": "0.0.0.0",
"protocol": "socks",
"settings": {
"auth": "noauth",
"udp": true,
"ip": "127.0.0.1"
},
"domainOverride": [
"http",
"tls"
"dns": {
"servers": [
""
]
},
"outbound": {
"tag": "",
"protocol": "vmess",
"routing": {
"strategy": "rules",
"settings": {
"vnext": [
"domainStrategy": "IPIfNonMatch",
"rules": [
{
"address": "",
"port": 0,
"users": [
{
"id": "",
"alterId": 0,
"security": "aes-128-gcm"
}
"type": "field",
"port": null,
"outboundTag": "direct",
"ip": [
"0.0.0.0/0"
]
}
]
}
},
"inbounds": [
{
"port": 0,
"listen": "0.0.0.0",
"protocol": "socks",
"settings": {
"auth": "noauth",
"udp": true,
"ip": "127.0.0.1"
},
"domainOverride": [
"http",
"tls"
]
},
"streamSettings": {
"network": "ws",
"security": "",
"wsSettings": {
"connectionReuse": true,
"path": ""
{
"port": 1,
"listen": "0.0.0.0",
"protocol": "http",
"settings": {
"auth": "noauth",
"udp": true,
"ip": "127.0.0.1"
},
"domainOverride": [
"http",
"tls"
]
}
],
"outbounds": [
{
"tag": "",
"protocol": "vmess",
"settings": {
"vnext": [
{
"address": "",
"port": 0,
"users": [
{
"id": "",
"alterId": 0,
"security": "aes-128-gcm"
}
]
}
]
},
"streamSettings": {
"network": "ws",
"security": "",
"wsSettings": {
"connectionReuse": true,
"path": ""
}
},
"mux": {
"enabled": true
}
},
"mux": {
"enabled": true
}
},
"outboundDetour": [
{
"protocol": "freedom",
"settings": {},
Expand All @@ -58,26 +95,5 @@
},
"tag": ""
}
],
"dns": {
"servers": [
""
]
},
"routing": {
"strategy": "rules",
"settings": {
"domainStrategy": "IPIfNonMatch",
"rules": [
{
"type": "field",
"port": null,
"outboundTag": "direct",
"ip": [
"0.0.0.0/0"
]
}
]
}
}
]
}
2 changes: 1 addition & 1 deletion main.1.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function createWindow() {
width: 800,
height: 600,
transparent: false,
frame: false,
frame: true,
minWidth: 400
})

Expand Down
17 changes: 10 additions & 7 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ app.on('before-quit', function () {
});

function createWindow() {
tray = new Tray(path.join(__dirname, 'logo.ico'))
tray = new Tray(path.join(__dirname, 'logo.ico'));

// Create the browser window.
mainWindow = new BrowserWindow({
Expand All @@ -28,14 +28,14 @@ function createWindow() {
transparent: false,
frame: false,
minWidth: 400
})
});

// and load the index.html of the app.
mainWindow.loadURL(url.format({
pathname: path.join(__dirname, 'index.html'),
protocol: 'file:',
slashes: true
}))
}));

const contextMenu = Menu.buildFromTemplate([{
label: 'Show App',
Expand All @@ -51,11 +51,14 @@ function createWindow() {
}
}
]);
tray.setToolTip('V2ray Electron')
tray.setContextMenu(contextMenu)
tray.on('double-click', () => {
mainWindow.show()
});
tray.setToolTip('V2ray Electron');
tray.setContextMenu(contextMenu);

mainWindow.on('resize', updateReply)
mainWindow.on('move', updateReply)
mainWindow.on('resize', updateReply);
mainWindow.on('move', updateReply);

function updateReply() {

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "v2ray_electron",
"productName": "v2ray electron client",
"version": "0.1.0",
"version": "0.2.0",
"main": "main.js",
"devDependencies": {
"electron": "4.0.1",
Expand Down
35 changes: 30 additions & 5 deletions renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ if (remote.process.env.PORTABLE_EXECUTABLE_DIR == undefined) {
} else {
PORTABLE_EXECUTABLE_DIR = remote.process.env.PORTABLE_EXECUTABLE_DIR
}
let guiCOnfigFilePath = path.join(PORTABLE_EXECUTABLE_DIR, 'guiConfig.json');
let guiConfig = parseConfigFile(guiCOnfigFilePath);
let guiConfigFilePath = path.join(PORTABLE_EXECUTABLE_DIR, 'guiConfig.json');
let guiConfig = parseConfigFile(guiConfigFilePath);
const tbody = $("tbody");
let runningProcess = [];
const tmp = tbody.html();
Expand Down Expand Up @@ -55,7 +55,7 @@ $("body").on("click", function () {
});

function init() {
guiConfig = parseConfigFile(guiCOnfigFilePath);
guiConfig = parseConfigFile(guiConfigFilePath);
updateList(guiConfig);
}

Expand All @@ -67,6 +67,31 @@ if (guiConfig.auto != undefined && guiConfig.auto >= 0) {
startServer(fileName, i);
}

function getPorts(conf) {
if (conf.inbound != undefined) {
return conf.inbound.listen + ":" + conf.inbound.port;
} else if (conf.inbounds != undefined) {
let str = "";
for (let i = 0; i < conf.inbounds.length; i++) {
switch (conf.inbounds[i].protocol) {
case "http":
str += "H:" + conf.inbounds[i].port + ";";
break;
case "socks":
str += "S:" + conf.inbounds[i].port + ";";
break;
default:
str += "?:" + conf.inbounds[i].port + ";";
}
}
if (str.length > 0) {
str = str.substring(0, str.length - 1);
}
return str;
}
return "undefined";
}

function updateList(obj) {
//let ftr = $("tbody tr:first");
tbody.html("");
Expand All @@ -78,7 +103,7 @@ function updateList(obj) {
tds.eq(0)[0].innerText = obj.servers[i].name;
let conf = parseConfigFile(path.join(PORTABLE_EXECUTABLE_DIR, obj.servers[i].file));
try {
tds.eq(1)[0].innerText = conf.inbound.listen + ":" + conf.inbound.port;
tds.eq(1)[0].innerText = getPorts(conf);
} catch {
tds.eq(1)[0].innerText = "undefined";
}
Expand Down Expand Up @@ -114,7 +139,7 @@ function updateList(obj) {
function deleteConfig(i) {
fs.unlinkSync(path.join(PORTABLE_EXECUTABLE_DIR, guiConfig.servers[i].file));
guiConfig.servers.splice(i, 1);
saveToFile(guiCOnfigFilePath, JSON.stringify(guiConfig, null, '\t'));
saveToFile(guiConfigFilePath, JSON.stringify(guiConfig, null, '\t'));
init();
}

Expand Down
9 changes: 4 additions & 5 deletions struct.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"error": "",
"loglevel": "warning"
},
"inbound": {
"inbounds": [{
"port": 0,
"listen": "",
"protocol": "socks",
Expand All @@ -17,8 +17,8 @@
"domainOverride": [
""
]
},
"outbound": {
}],
"outbounds": [{
"tag": "",
"protocol": "vmess",
"settings": {
Expand Down Expand Up @@ -46,7 +46,6 @@
"mux": {
"enabled": true
}
},
"inboundDetour": ["ref:root:inbound"]
}]
}
}
Loading

0 comments on commit 98ee787

Please sign in to comment.