├── dist
├── web
│ └── .gitkeep
└── electron
│ ├── static
│ └── icons
│ │ ├── icon.ico
│ │ └── icon.png
│ ├── fonts
│ ├── element-icons--fonts.ttf
│ └── element-icons--fonts.woff
│ ├── index.html
│ └── main.js
├── src
├── renderer
│ ├── assets
│ │ ├── .gitkeep
│ │ └── logo.png
│ ├── App.vue
│ ├── main.js
│ ├── components
│ │ ├── about.vue
│ │ ├── setting.vue
│ │ ├── panel.vue
│ │ └── home.vue
│ └── router
│ │ └── index.js
├── main
│ ├── index.dev.js
│ └── index.js
├── index.ejs
└── core
│ ├── startup.js
│ └── tunnel.js
├── template
└── panel.gif
├── static
└── icons
│ ├── icon.ico
│ ├── icon.png
│ └── 256x256.png
├── .gitignore
├── appveyor.yml
├── .babelrc
├── public
└── index.html
├── README.md
├── .travis.yml
├── .electron-vue
├── dev-client.js
├── webpack.main.config.js
├── build.js
├── webpack.web.config.js
├── dev-runner.js
└── webpack.renderer.config.js
├── package.json
└── LICENSE
/dist/web/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/renderer/assets/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/template/panel.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yaoing/iMC-Tunnel/HEAD/template/panel.gif
--------------------------------------------------------------------------------
/static/icons/icon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yaoing/iMC-Tunnel/HEAD/static/icons/icon.ico
--------------------------------------------------------------------------------
/static/icons/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yaoing/iMC-Tunnel/HEAD/static/icons/icon.png
--------------------------------------------------------------------------------
/static/icons/256x256.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yaoing/iMC-Tunnel/HEAD/static/icons/256x256.png
--------------------------------------------------------------------------------
/src/renderer/assets/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yaoing/iMC-Tunnel/HEAD/src/renderer/assets/logo.png
--------------------------------------------------------------------------------
/dist/electron/static/icons/icon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yaoing/iMC-Tunnel/HEAD/dist/electron/static/icons/icon.ico
--------------------------------------------------------------------------------
/dist/electron/static/icons/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yaoing/iMC-Tunnel/HEAD/dist/electron/static/icons/icon.png
--------------------------------------------------------------------------------
/dist/electron/fonts/element-icons--fonts.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yaoing/iMC-Tunnel/HEAD/dist/electron/fonts/element-icons--fonts.ttf
--------------------------------------------------------------------------------
/dist/electron/fonts/element-icons--fonts.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yaoing/iMC-Tunnel/HEAD/dist/electron/fonts/element-icons--fonts.woff
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | build/
3 | dist/electron/*
4 | dist/web/*
5 | node_modules/
6 | npm-debug.log
7 | npm-debug.log.*
8 | thumbs.db
9 | !.gitkeep
10 | .idea
11 |
--------------------------------------------------------------------------------
/dist/electron/index.html:
--------------------------------------------------------------------------------
1 |
iMC Tunnel
--------------------------------------------------------------------------------
/src/renderer/App.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
15 |
16 |
37 |
--------------------------------------------------------------------------------
/appveyor.yml:
--------------------------------------------------------------------------------
1 | version: 0.1.{build}
2 |
3 | branches:
4 | only:
5 | - master
6 |
7 | image: Visual Studio 2017
8 | platform:
9 | - x64
10 |
11 | cache:
12 | - node_modules
13 | - '%APPDATA%\npm-cache'
14 | - '%USERPROFILE%\.electron'
15 | - '%USERPROFILE%\AppData\Local\Yarn\cache'
16 |
17 | init:
18 | - git config --global core.autocrlf input
19 |
20 | install:
21 | - ps: Install-Product node 8 x64
22 | - git reset --hard HEAD
23 | - yarn
24 | - node --version
25 |
26 | build_script:
27 | - yarn build
28 |
29 | test: off
30 |
--------------------------------------------------------------------------------
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "comments": false,
3 | "env": {
4 | "main": {
5 | "presets": [
6 | ["env", {
7 | "targets": { "node": 7 }
8 | }],
9 | "stage-0"
10 | ]
11 | },
12 | "renderer": {
13 | "presets": [
14 | ["env", {
15 | "modules": false
16 | }],
17 | "stage-0"
18 | ]
19 | },
20 | "web": {
21 | "presets": [
22 | ["env", {
23 | "modules": false
24 | }],
25 | "stage-0"
26 | ]
27 | }
28 | },
29 | "plugins": ["transform-runtime"]
30 | }
31 |
--------------------------------------------------------------------------------
/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | <%= htmlWebpackPlugin.options.title %>
9 |
10 |
11 |
12 | We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/renderer/main.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import ElementUI from 'element-ui';
3 | import 'element-ui/lib/theme-chalk/index.css';
4 |
5 | import App from './App'
6 | import router from './router'
7 |
8 | import startup from "../core/startup.js";
9 |
10 | if (!process.env.IS_WEB) Vue.use(require('vue-electron'))
11 | Vue.config.productionTip = false;
12 |
13 | Vue.use(ElementUI);
14 |
15 |
16 | //initial setting
17 | if(!localStorage.getItem("settings")){
18 | localStorage.setItem("settings",JSON.stringify({
19 | bindIP:'10.10.10.146',
20 | bindPort:'8080'
21 | }))
22 | startup.enable()
23 | }
24 |
25 | /* eslint-disable no-new */
26 | new Vue({
27 | components: { App },
28 | router,
29 | template: ' '
30 | }).$mount('#app')
31 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # iMC Tunnel
2 |
3 | >一款带图形化界面的 iMC Portal(H3C)网关 连接工具
4 |
5 |
6 |
7 |
8 |
9 | #### 安装流程
10 |
11 | - 在页面右侧*Releases*中下载对应操作系统的最新版本安装程序
12 | - 用户双击安装包进行安装(杀毒软件可能拦截)
13 | -
14 | #### 支持功能
15 | - [x] 开机自动连接
16 | - [x] 断线重连
17 | - [x] 自定义网关IP及端口
18 | - [x] 多平台支持
19 |
20 | #### 存在问题
21 | - 长期显示主界面会导致内存占用率暴增
22 | - 解决方案:工具切换至后台,需要时在任务栏图标中打开,内存占用稳定在80M
23 |
24 | #### 参考项目
25 |
26 | - [electron-vue](https://github.com/SimulatedGREG/electron-vue)
27 | - [element-ui](https://github.com/ElemeFE/element)
28 | - [MC-Portal-Login](https://github.com/Besfim/iMC-Portal-Login)
29 |
--------------------------------------------------------------------------------
/src/main/index.dev.js:
--------------------------------------------------------------------------------
1 | /**
2 | * This file is used specifically and only for development. It installs
3 | * `electron-debug` & `vue-devtools`. There shouldn't be any need to
4 | * modify this file, but it can be used to extend your development
5 | * environment.
6 | */
7 |
8 | /* eslint-disable */
9 |
10 | // Install `electron-debug` with `devtron`
11 | require('electron-debug')({ showDevTools: true })
12 |
13 | // Install `vue-devtools`
14 | require('electron').app.on('ready', () => {
15 | let installExtension = require('electron-devtools-installer')
16 | installExtension.default(installExtension.VUEJS_DEVTOOLS)
17 | .then(() => {})
18 | .catch(err => {
19 | console.log('Unable to install `vue-devtools`: \n', err)
20 | })
21 | })
22 |
23 | // Require `main` process to boot app
24 | require('./index')
--------------------------------------------------------------------------------
/src/renderer/components/about.vue:
--------------------------------------------------------------------------------
1 |
2 |
13 |
14 |
15 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/src/renderer/router/index.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import Router from 'vue-router'
3 |
4 | import panel from "@/components/panel";
5 | import home from '@/components/home'
6 | import setting from "@/components/setting";
7 | import about from "@/components/about";
8 |
9 | Vue.use(Router);
10 |
11 |
12 | export default new Router({
13 | mode:'hash',
14 | routes:[
15 | {
16 | path:'/',
17 | name:'panel',
18 | component:panel,
19 | children:[
20 | {
21 | path:'home',
22 | name:'home',
23 | component:home,
24 | },
25 | {
26 | path:'setting',
27 | name:'setting',
28 | component:setting,
29 | },
30 | {
31 | path:'about',
32 | name:'about',
33 | component:about,
34 | }
35 | ]
36 | },
37 |
38 |
39 | ]
40 | })
--------------------------------------------------------------------------------
/src/index.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | iMC Tunnel
6 | <% if (htmlWebpackPlugin.options.nodeModules) { %>
7 |
8 |
11 | <% } %>
12 |
13 |
14 |
15 |
16 | <% if (!process.browser) { %>
17 |
20 | <% } %>
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/src/core/startup.js:
--------------------------------------------------------------------------------
1 | const AutoLaunch = require('auto-launch');
2 |
3 | const launcher = new AutoLaunch({
4 | name: 'iMC Tunnel',
5 | path: process.execPath,
6 | isHidden: true,
7 | mac: {
8 | useLaunchAgent: false
9 | }
10 | });
11 |
12 | function enable(){
13 | launcher.isEnabled().then(function (isEnabled){
14 | if(isEnabled)
15 | return 0
16 |
17 | launcher.enable();
18 | return 1
19 | }).catch(function(err){
20 | console.log(err)
21 | return -1
22 | });
23 | }
24 |
25 |
26 | function disable(){
27 | launcher.isEnabled().then(function (isEnabled){
28 | if(!isEnabled)
29 | return 0
30 |
31 | launcher.disable();
32 | return 1
33 | }).catch(function(err){
34 | console.log(err)
35 | return -1
36 | });
37 | }
38 |
39 | function isStartup(){
40 | return launcher.isEnabled()
41 | }
42 |
43 |
44 |
45 | export default {enable,disable,isStartup}
46 |
47 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | osx_image: xcode8.3
2 | sudo: required
3 | dist: trusty
4 | language: c
5 | matrix:
6 | include:
7 | - os: osx
8 | - os: linux
9 | env: CC=clang CXX=clang++ npm_config_clang=1
10 | compiler: clang
11 | cache:
12 | directories:
13 | - node_modules
14 | - "$HOME/.electron"
15 | - "$HOME/.cache"
16 | addons:
17 | apt:
18 | packages:
19 | - libgnome-keyring-dev
20 | - icnsutils
21 | before_install:
22 | - mkdir -p /tmp/git-lfs && curl -L https://github.com/github/git-lfs/releases/download/v1.2.1/git-lfs-$([
23 | "$TRAVIS_OS_NAME" == "linux" ] && echo "linux" || echo "darwin")-amd64-1.2.1.tar.gz
24 | | tar -xz -C /tmp/git-lfs --strip-components 1 && /tmp/git-lfs/git-lfs pull
25 | - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install --no-install-recommends -y icnsutils graphicsmagick xz-utils; fi
26 | install:
27 | - nvm install 10
28 | - curl -o- -L https://yarnpkg.com/install.sh | bash
29 | - source ~/.bashrc
30 | - npm install -g xvfb-maybe
31 | - yarn
32 | script:
33 | - yarn run build
34 | branches:
35 | only:
36 | - master
37 |
--------------------------------------------------------------------------------
/.electron-vue/dev-client.js:
--------------------------------------------------------------------------------
1 | const hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true')
2 |
3 | hotClient.subscribe(event => {
4 | /**
5 | * Reload browser when HTMLWebpackPlugin emits a new index.html
6 | *
7 | * Currently disabled until jantimon/html-webpack-plugin#680 is resolved.
8 | * https://github.com/SimulatedGREG/electron-vue/issues/437
9 | * https://github.com/jantimon/html-webpack-plugin/issues/680
10 | */
11 | // if (event.action === 'reload') {
12 | // window.location.reload()
13 | // }
14 |
15 | /**
16 | * Notify `mainWindow` when `main` process is compiling,
17 | * giving notice for an expected reload of the `electron` process
18 | */
19 | if (event.action === 'compiling') {
20 | document.body.innerHTML += `
21 |
34 |
35 |
36 | Compiling Main Process...
37 |
38 | `
39 | }
40 | })
41 |
--------------------------------------------------------------------------------
/.electron-vue/webpack.main.config.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | process.env.BABEL_ENV = 'main'
4 |
5 | const path = require('path')
6 | const { dependencies } = require('../package.json')
7 | const webpack = require('webpack')
8 |
9 | const MinifyPlugin = require("babel-minify-webpack-plugin")
10 |
11 | let mainConfig = {
12 | entry: {
13 | main: path.join(__dirname, '../src/main/index.js')
14 | },
15 | externals: [
16 | ...Object.keys(dependencies || {})
17 | ],
18 | module: {
19 | rules: [
20 | {
21 | test: /\.js$/,
22 | use: 'babel-loader',
23 | exclude: /node_modules/
24 | },
25 | {
26 | test: /\.node$/,
27 | use: 'node-loader'
28 | }
29 | ]
30 | },
31 | node: {
32 | __dirname: process.env.NODE_ENV !== 'production',
33 | __filename: process.env.NODE_ENV !== 'production'
34 | },
35 | output: {
36 | filename: '[name].js',
37 | libraryTarget: 'commonjs2',
38 | path: path.join(__dirname, '../dist/electron')
39 | },
40 | plugins: [
41 | new webpack.NoEmitOnErrorsPlugin()
42 | ],
43 | resolve: {
44 | extensions: ['.js', '.json', '.node']
45 | },
46 | target: 'electron-main'
47 | }
48 |
49 | /**
50 | * Adjust mainConfig for development settings
51 | */
52 | if (process.env.NODE_ENV !== 'production') {
53 | mainConfig.plugins.push(
54 | new webpack.DefinePlugin({
55 | '__static': `"${path.join(__dirname, '../static').replace(/\\/g, '\\\\')}"`
56 | })
57 | )
58 | }
59 |
60 | /**
61 | * Adjust mainConfig for production settings
62 | */
63 | if (process.env.NODE_ENV === 'production') {
64 | mainConfig.plugins.push(
65 | new MinifyPlugin(),
66 | new webpack.DefinePlugin({
67 | 'process.env.NODE_ENV': '"production"'
68 | })
69 | )
70 | }
71 |
72 | module.exports = mainConfig
73 |
--------------------------------------------------------------------------------
/dist/electron/main.js:
--------------------------------------------------------------------------------
1 | module.exports=function(e){function n(i){if(t[i])return t[i].exports;var r=t[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}var t={};return n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(i,r,function(n){return e[n]}.bind(null,r));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},n.p="",n(n.s=1)}([function(e){e.exports=require("electron")},function(e,n,t){"use strict";function i(){if((o=new r.BrowserWindow({frame:!1,width:560,height:330,resizable:!1,title:"iMC Tunnel",webPreferences:{webSecurity:!1,nodeIntegration:!0,defaultFontFamily:{standard:"Microsoft YaHei"}}})).loadURL(a),o.setMenu(null),"win32"===process.platform){var e=[{label:"打开面板",click:function(){o.show()}},{label:"退出",click:function(){r.app.quit()}}],n=r.nativeImage.createFromPath(__dirname+"/static/icons/icon.png");n=n.resize({width:256,height:256});var t=new r.Tray(n),i=r.Menu.buildFromTemplate(e);t.setToolTip("iMC Tunnel"),t.setContextMenu(i),t.on("click",(function(){o.setSkipTaskbar(!1),o.show()})),t.on("right-click",(function(){t.popUpContextMenu(e)}))}}t.r(n);var r=t(0);t.n(r);global.__static=t(2).join(__dirname,"/static").replace(/\\/g,"\\\\");var o=void 0,a="file://"+__dirname+"/index.html";r.app.on("ready",i),r.app.on("window-all-closed",(function(){"darwin"!==process.platform&&r.app.quit()})),r.app.on("activate",(function(){null===o&&i()})),r.ipcMain.on("minWin",(function(){return o.minimize()})),r.ipcMain.on("closeWin",(function(e){o.hide(),o.setSkipTaskbar(!0),e.preventDefault()})),r.app.makeSingleInstance((function(){o&&(o.isMinimized()&&o.restore(),o.focus(),o.show())}))&&r.app.quit(),n.default=r.app},function(e){e.exports=require("path")}]);
--------------------------------------------------------------------------------
/src/renderer/components/setting.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | 保存
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
81 |
82 |
--------------------------------------------------------------------------------
/src/main/index.js:
--------------------------------------------------------------------------------
1 | import { app, ipcMain,BrowserWindow,Tray,Menu,nativeImage} from 'electron'
2 |
3 | /**
4 | * Set `__static` path to static files in production
5 | * https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-static-assets.html
6 | */
7 | if (process.env.NODE_ENV !== 'development') {
8 | global.__static = require('path').join(__dirname, '/static').replace(/\\/g, '\\\\')
9 | }
10 |
11 | let mainWindow
12 | const winURL = process.env.NODE_ENV === 'development'
13 | ? `http://localhost:9080`
14 | : `file://${__dirname}/index.html`
15 |
16 |
17 |
18 | function createWindow () {
19 | /**
20 | * Initial window options
21 | */
22 | mainWindow = new BrowserWindow({
23 | frame:false,
24 | width: 560,
25 | height: 330,
26 | resizable: false,
27 | title:'iMC Tunnel',
28 | // radius: [5, 5, 5, 5],
29 | webPreferences: {
30 | webSecurity: false,
31 | nodeIntegration: true,
32 | defaultFontFamily:{
33 | standard:'Microsoft YaHei'
34 | },
35 | },
36 | })
37 | mainWindow.loadURL(winURL)
38 | // mainWindow.webContents.openDevTools()
39 | mainWindow.setMenu(null)
40 |
41 | if(process.platform === 'win32'){
42 | var trayMenuTemplate = [
43 | {
44 | label: '打开面板',
45 | click: () => {
46 | mainWindow.show();
47 | }
48 | },
49 | {
50 | label: '退出',
51 | click: () => {
52 | app.quit()
53 | }
54 | }
55 | ];
56 |
57 | var trayIcon = nativeImage.createFromPath(`${__dirname}/static/icons/icon.png`)
58 | trayIcon = trayIcon.resize({ width: 256, height: 256 });
59 |
60 | var appTray =new Tray(trayIcon)
61 | var contextMenu = Menu.buildFromTemplate(trayMenuTemplate);
62 | appTray.setToolTip('iMC Tunnel');
63 | appTray.setContextMenu(contextMenu);
64 | appTray.on('click',function(){
65 | mainWindow.setSkipTaskbar(false);
66 | mainWindow.show();
67 | })
68 | appTray.on('right-click', () => {
69 | appTray.popUpContextMenu(trayMenuTemplate);
70 | })
71 | }
72 | }
73 |
74 | app.on('ready', createWindow)
75 |
76 | app.on('window-all-closed', () => {
77 | if (process.platform !== 'darwin') {
78 | app.quit()
79 | }
80 | })
81 |
82 | app.on('activate', () => {
83 | if (mainWindow === null) {
84 | createWindow()
85 | }
86 | })
87 |
88 |
89 | ipcMain.on('minWin',e=>mainWindow.minimize())
90 | ipcMain.on('closeWin',
91 | e=>{
92 | mainWindow.hide();
93 | mainWindow.setSkipTaskbar(true);
94 | e.preventDefault();
95 | })
96 |
97 |
98 |
99 | const shouldQuit = app.makeSingleInstance((commandLine, workingDirectory) => {
100 | if (mainWindow) {
101 | if (mainWindow.isMinimized()) mainWindow.restore()
102 | mainWindow.focus()
103 | mainWindow.show()
104 | }
105 | });
106 | if (shouldQuit) {
107 | app.quit()
108 | }
109 |
110 |
111 | export default app
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "imc_tunnel",
3 | "version": "1.1.0",
4 | "author": "yaoing<853818291@qq.com>",
5 | "homepage": "https://github.com/yaoing/iMC-Tunnel",
6 | "description": "An auto-login and deamon tool with GUI pannel for iMC Portal,powered by vue, electron and element-ui",
7 | "license": "Apache-2.0",
8 | "main": "./dist/electron/main.js",
9 | "scripts": {
10 | "build": "node .electron-vue/build.js && electron-builder",
11 | "build:dir": "node .electron-vue/build.js && electron-builder --dir",
12 | "build:clean": "cross-env buildBUILD_TARGET=clean node .electron-vue/build.js",
13 | "build:web": "cross-env BUILD_TARGET=web node .electron-vue/build.js",
14 | "dev": "node .electron-vue/dev-runner.js",
15 | "pack": "npm run pack:main && npm run pack:renderer",
16 | "pack:main": "cross-env NODE_ENV=production webpack --progress --colors --config .electron-vue/webpack.main.config.js",
17 | "pack:renderer": "cross-env NODE_ENV=production webpack --progress --colors --config .electron-vue/webpack.renderer.config.js",
18 | "postinstall": ""
19 | },
20 | "build": {
21 | "productName": "iMC Tunnel",
22 | "appId": "iMC_Tunnel.yaoring.me",
23 | "directories": {
24 | "output": "build"
25 | },
26 | "files": [
27 | "dist/electron/**/*"
28 | ],
29 | "dmg": {
30 | "contents": [
31 | {
32 | "x": 410,
33 | "y": 150,
34 | "type": "link",
35 | "path": "/Applications"
36 | },
37 | {
38 | "x": 130,
39 | "y": 150,
40 | "type": "file"
41 | }
42 | ]
43 | },
44 | "mac": {
45 | "icon": "static/icons/icon.icns"
46 | },
47 | "win": {
48 | "icon": "static/icons/icon.ico"
49 | },
50 | "linux": {
51 | "icon": "static/icons/256x256.png",
52 | "target": "deb"
53 | }
54 | },
55 | "dependencies": {
56 | "auto-launch": "^5.0.5",
57 | "element-ui": "^2.14.0",
58 | "iconv-lite": "^0.6.2",
59 | "request": "^2.88.2",
60 | "vue": "^2.5.16",
61 | "vue-electron": "^1.0.6",
62 | "vue-router": "^3.0.1"
63 | },
64 | "devDependencies": {
65 | "ajv": "^6.5.0",
66 | "babel-core": "^6.26.3",
67 | "babel-loader": "^7.1.4",
68 | "babel-minify-webpack-plugin": "^0.3.1",
69 | "babel-plugin-transform-runtime": "^6.23.0",
70 | "babel-preset-env": "^1.7.0",
71 | "babel-preset-stage-0": "^6.24.1",
72 | "babel-register": "^6.26.0",
73 | "cfonts": "^2.1.2",
74 | "chalk": "^2.4.1",
75 | "copy-webpack-plugin": "^4.5.1",
76 | "cross-env": "^5.1.6",
77 | "css-loader": "^0.28.11",
78 | "del": "^3.0.0",
79 | "devtron": "^1.4.0",
80 | "electron": "^2.0.4",
81 | "electron-builder": "^22.9.1",
82 | "electron-debug": "^1.5.0",
83 | "electron-devtools-installer": "^2.2.4",
84 | "file-loader": "^1.1.11",
85 | "html-webpack-plugin": "^3.2.0",
86 | "mini-css-extract-plugin": "0.4.0",
87 | "multispinner": "^0.2.1",
88 | "node-loader": "^0.6.0",
89 | "style-loader": "^0.21.0",
90 | "url-loader": "^1.0.1",
91 | "vue-html-loader": "^1.2.4",
92 | "vue-loader": "^15.2.4",
93 | "vue-style-loader": "^4.1.0",
94 | "vue-template-compiler": "^2.5.16",
95 | "webpack": "^4.15.1",
96 | "webpack-cli": "^3.0.8",
97 | "webpack-dev-server": "^3.1.4",
98 | "webpack-hot-middleware": "^2.22.2",
99 | "webpack-merge": "^4.1.3"
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/src/renderer/components/panel.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
22 |
23 |
24 |
25 |
26 | iMC Tunnel
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
79 |
80 |
--------------------------------------------------------------------------------
/.electron-vue/build.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | process.env.NODE_ENV = 'production'
4 |
5 | const { say } = require('cfonts')
6 | const chalk = require('chalk')
7 | const del = require('del')
8 | const { spawn } = require('child_process')
9 | const webpack = require('webpack')
10 | const Multispinner = require('multispinner')
11 |
12 |
13 | const mainConfig = require('./webpack.main.config')
14 | const rendererConfig = require('./webpack.renderer.config')
15 | const webConfig = require('./webpack.web.config')
16 |
17 | const doneLog = chalk.bgGreen.white(' DONE ') + ' '
18 | const errorLog = chalk.bgRed.white(' ERROR ') + ' '
19 | const okayLog = chalk.bgBlue.white(' OKAY ') + ' '
20 | const isCI = process.env.CI || false
21 |
22 | if (process.env.BUILD_TARGET === 'clean') clean()
23 | else if (process.env.BUILD_TARGET === 'web') web()
24 | else build()
25 |
26 | function clean () {
27 | del.sync(['build/*', '!build/icons', '!build/icons/icon.*'])
28 | console.log(`\n${doneLog}\n`)
29 | process.exit()
30 | }
31 |
32 | function build () {
33 | greeting()
34 |
35 | del.sync(['dist/electron/*', '!.gitkeep'])
36 |
37 | const tasks = ['main', 'renderer']
38 | const m = new Multispinner(tasks, {
39 | preText: 'building',
40 | postText: 'process'
41 | })
42 |
43 | let results = ''
44 |
45 | m.on('success', () => {
46 | process.stdout.write('\x1B[2J\x1B[0f')
47 | console.log(`\n\n${results}`)
48 | console.log(`${okayLog}take it away ${chalk.yellow('`electron-builder`')}\n`)
49 | process.exit()
50 | })
51 |
52 | pack(mainConfig).then(result => {
53 | results += result + '\n\n'
54 | m.success('main')
55 | }).catch(err => {
56 | m.error('main')
57 | console.log(`\n ${errorLog}failed to build main process`)
58 | console.error(`\n${err}\n`)
59 | process.exit(1)
60 | })
61 |
62 | pack(rendererConfig).then(result => {
63 | results += result + '\n\n'
64 | m.success('renderer')
65 | }).catch(err => {
66 | m.error('renderer')
67 | console.log(`\n ${errorLog}failed to build renderer process`)
68 | console.error(`\n${err}\n`)
69 | process.exit(1)
70 | })
71 | }
72 |
73 | function pack (config) {
74 | return new Promise((resolve, reject) => {
75 | config.mode = 'production'
76 | webpack(config, (err, stats) => {
77 | if (err) reject(err.stack || err)
78 | else if (stats.hasErrors()) {
79 | let err = ''
80 |
81 | stats.toString({
82 | chunks: false,
83 | colors: true
84 | })
85 | .split(/\r?\n/)
86 | .forEach(line => {
87 | err += ` ${line}\n`
88 | })
89 |
90 | reject(err)
91 | } else {
92 | resolve(stats.toString({
93 | chunks: false,
94 | colors: true
95 | }))
96 | }
97 | })
98 | })
99 | }
100 |
101 | function web () {
102 | del.sync(['dist/web/*', '!.gitkeep'])
103 | webConfig.mode = 'production'
104 | webpack(webConfig, (err, stats) => {
105 | if (err || stats.hasErrors()) console.log(err)
106 |
107 | console.log(stats.toString({
108 | chunks: false,
109 | colors: true
110 | }))
111 |
112 | process.exit()
113 | })
114 | }
115 |
116 | function greeting () {
117 | const cols = process.stdout.columns
118 | let text = ''
119 |
120 | if (cols > 85) text = 'lets-build'
121 | else if (cols > 60) text = 'lets-|build'
122 | else text = false
123 |
124 | if (text && !isCI) {
125 | say(text, {
126 | colors: ['yellow'],
127 | font: 'simple3d',
128 | space: false
129 | })
130 | } else console.log(chalk.yellow.bold('\n lets-build'))
131 | console.log()
132 | }
--------------------------------------------------------------------------------
/.electron-vue/webpack.web.config.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | process.env.BABEL_ENV = 'web'
4 |
5 | const path = require('path')
6 | const webpack = require('webpack')
7 |
8 | const MinifyPlugin = require("babel-minify-webpack-plugin")
9 | const CopyWebpackPlugin = require('copy-webpack-plugin')
10 | const MiniCssExtractPlugin = require('mini-css-extract-plugin')
11 | const HtmlWebpackPlugin = require('html-webpack-plugin')
12 | const { VueLoaderPlugin } = require('vue-loader')
13 |
14 | let webConfig = {
15 | devtool: '#cheap-module-eval-source-map',
16 | entry: {
17 | web: path.join(__dirname, '../src/renderer/main.js')
18 | },
19 | module: {
20 | rules: [
21 | {
22 | test: /\.less$/,
23 | use: ['vue-style-loader', 'css-loader', 'less-loader']
24 | },
25 | {
26 | test: /\.css$/,
27 | use: ['vue-style-loader', 'css-loader']
28 | },
29 | {
30 | test: /\.html$/,
31 | use: 'vue-html-loader'
32 | },
33 | {
34 | test: /\.js$/,
35 | use: 'babel-loader',
36 | include: [ path.resolve(__dirname, '../src/renderer') ],
37 | exclude: /node_modules/
38 | },
39 | {
40 | test: /\.vue$/,
41 | use: {
42 | loader: 'vue-loader',
43 | options: {
44 | extractCSS: true,
45 | loaders: {
46 | sass: 'vue-style-loader!css-loader!sass-loader?indentedSyntax=1',
47 | scss: 'vue-style-loader!css-loader!sass-loader',
48 | less: 'vue-style-loader!css-loader!less-loader'
49 | }
50 | }
51 | }
52 | },
53 | {
54 | test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
55 | use: {
56 | loader: 'url-loader',
57 | query: {
58 | limit: 10000,
59 | name: 'imgs/[name].[ext]'
60 | }
61 | }
62 | },
63 | {
64 | test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
65 | use: {
66 | loader: 'url-loader',
67 | query: {
68 | limit: 10000,
69 | name: 'fonts/[name].[ext]'
70 | }
71 | }
72 | }
73 | ]
74 | },
75 | plugins: [
76 | new VueLoaderPlugin(),
77 | new MiniCssExtractPlugin({filename: 'styles.css'}),
78 | new HtmlWebpackPlugin({
79 | templateParameters(compilation, assets, options) {
80 | return {
81 | compilation: compilation,
82 | webpack: compilation.getStats().toJson(),
83 | webpackConfig: compilation.options,
84 | htmlWebpackPlugin: {
85 | files: assets,
86 | options: options
87 | },
88 | process,
89 | };
90 | },
91 | filename: 'index.html',
92 | template: path.resolve(__dirname, '../src/index.ejs'),
93 | minify: {
94 | collapseWhitespace: true,
95 | removeAttributeQuotes: true,
96 | removeComments: true
97 | },
98 | nodeModules: false
99 | }),
100 | new webpack.DefinePlugin({
101 | 'process.env.IS_WEB': 'true'
102 | }),
103 | new webpack.HotModuleReplacementPlugin(),
104 | new webpack.NoEmitOnErrorsPlugin()
105 | ],
106 | output: {
107 | filename: '[name].js',
108 | path: path.join(__dirname, '../dist/web')
109 | },
110 | resolve: {
111 | alias: {
112 | '@': path.join(__dirname, '../src/renderer'),
113 | 'vue$': 'vue/dist/vue.esm.js'
114 | },
115 | extensions: ['.js', '.vue', '.json', '.css']
116 | },
117 | target: 'web'
118 | }
119 |
120 | /**
121 | * Adjust webConfig for production settings
122 | */
123 | if (process.env.NODE_ENV === 'production') {
124 | webConfig.devtool = ''
125 |
126 | webConfig.plugins.push(
127 | new MinifyPlugin(),
128 | new CopyWebpackPlugin([
129 | {
130 | from: path.join(__dirname, '../static'),
131 | to: path.join(__dirname, '../dist/web/static'),
132 | ignore: ['.*']
133 | }
134 | ]),
135 | new webpack.DefinePlugin({
136 | 'process.env.NODE_ENV': '"production"'
137 | }),
138 | new webpack.LoaderOptionsPlugin({
139 | minimize: true
140 | })
141 | )
142 | }
143 |
144 | module.exports = webConfig
145 |
--------------------------------------------------------------------------------
/.electron-vue/dev-runner.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const chalk = require('chalk')
4 | const electron = require('electron')
5 | const path = require('path')
6 | const { say } = require('cfonts')
7 | const { spawn } = require('child_process')
8 | const webpack = require('webpack')
9 | const WebpackDevServer = require('webpack-dev-server')
10 | const webpackHotMiddleware = require('webpack-hot-middleware')
11 |
12 | const mainConfig = require('./webpack.main.config')
13 | const rendererConfig = require('./webpack.renderer.config')
14 |
15 | let electronProcess = null
16 | let manualRestart = false
17 | let hotMiddleware
18 |
19 | function logStats (proc, data) {
20 | let log = ''
21 |
22 | log += chalk.yellow.bold(`┏ ${proc} Process ${new Array((19 - proc.length) + 1).join('-')}`)
23 | log += '\n\n'
24 |
25 | if (typeof data === 'object') {
26 | data.toString({
27 | colors: true,
28 | chunks: false
29 | }).split(/\r?\n/).forEach(line => {
30 | log += ' ' + line + '\n'
31 | })
32 | } else {
33 | log += ` ${data}\n`
34 | }
35 |
36 | log += '\n' + chalk.yellow.bold(`┗ ${new Array(28 + 1).join('-')}`) + '\n'
37 |
38 | console.log(log)
39 | }
40 |
41 | function startRenderer () {
42 | return new Promise((resolve, reject) => {
43 | rendererConfig.entry.renderer = [path.join(__dirname, 'dev-client')].concat(rendererConfig.entry.renderer)
44 | rendererConfig.mode = 'development'
45 | const compiler = webpack(rendererConfig)
46 | hotMiddleware = webpackHotMiddleware(compiler, {
47 | log: false,
48 | heartbeat: 2500
49 | })
50 |
51 | compiler.hooks.compilation.tap('compilation', compilation => {
52 | compilation.hooks.htmlWebpackPluginAfterEmit.tapAsync('html-webpack-plugin-after-emit', (data, cb) => {
53 | hotMiddleware.publish({ action: 'reload' })
54 | cb()
55 | })
56 | })
57 |
58 | compiler.hooks.done.tap('done', stats => {
59 | logStats('Renderer', stats)
60 | })
61 |
62 | const server = new WebpackDevServer(
63 | compiler,
64 | {
65 | contentBase: path.join(__dirname, '../'),
66 | quiet: true,
67 | before (app, ctx) {
68 | app.use(hotMiddleware)
69 | ctx.middleware.waitUntilValid(() => {
70 | resolve()
71 | })
72 | }
73 | }
74 | )
75 |
76 | server.listen(9080)
77 | })
78 | }
79 |
80 | function startMain () {
81 | return new Promise((resolve, reject) => {
82 | mainConfig.entry.main = [path.join(__dirname, '../src/main/index.dev.js')].concat(mainConfig.entry.main)
83 | mainConfig.mode = 'development'
84 | const compiler = webpack(mainConfig)
85 |
86 | compiler.hooks.watchRun.tapAsync('watch-run', (compilation, done) => {
87 | logStats('Main', chalk.white.bold('compiling...'))
88 | hotMiddleware.publish({ action: 'compiling' })
89 | done()
90 | })
91 |
92 | compiler.watch({}, (err, stats) => {
93 | if (err) {
94 | console.log(err)
95 | return
96 | }
97 |
98 | logStats('Main', stats)
99 |
100 | if (electronProcess && electronProcess.kill) {
101 | manualRestart = true
102 | process.kill(electronProcess.pid)
103 | electronProcess = null
104 | startElectron()
105 |
106 | setTimeout(() => {
107 | manualRestart = false
108 | }, 5000)
109 | }
110 |
111 | resolve()
112 | })
113 | })
114 | }
115 |
116 | function startElectron () {
117 | var args = [
118 | '--inspect=5858',
119 | path.join(__dirname, '../dist/electron/main.js')
120 | ]
121 |
122 | // detect yarn or npm and process commandline args accordingly
123 | if (process.env.npm_execpath.endsWith('yarn.js')) {
124 | args = args.concat(process.argv.slice(3))
125 | } else if (process.env.npm_execpath.endsWith('npm-cli.js')) {
126 | args = args.concat(process.argv.slice(2))
127 | }
128 |
129 | electronProcess = spawn(electron, args)
130 |
131 | electronProcess.stdout.on('data', data => {
132 | electronLog(data, 'blue')
133 | })
134 | electronProcess.stderr.on('data', data => {
135 | electronLog(data, 'red')
136 | })
137 |
138 | electronProcess.on('close', () => {
139 | if (!manualRestart) process.exit()
140 | })
141 | }
142 |
143 | function electronLog (data, color) {
144 | let log = ''
145 | data = data.toString().split(/\r?\n/)
146 | data.forEach(line => {
147 | log += ` ${line}\n`
148 | })
149 | if (/[0-9A-z]+/.test(log)) {
150 | console.log(
151 | chalk[color].bold('┏ Electron -------------------') +
152 | '\n\n' +
153 | log +
154 | chalk[color].bold('┗ ----------------------------') +
155 | '\n'
156 | )
157 | }
158 | }
159 |
160 | function greeting () {
161 | const cols = process.stdout.columns
162 | let text = ''
163 |
164 | if (cols > 104) text = 'electron-vue'
165 | else if (cols > 76) text = 'electron-|vue'
166 | else text = false
167 |
168 | if (text) {
169 | say(text, {
170 | colors: ['yellow'],
171 | font: 'simple3d',
172 | space: false
173 | })
174 | } else console.log(chalk.yellow.bold('\n electron-vue'))
175 | console.log(chalk.blue(' getting ready...') + '\n')
176 | }
177 |
178 | function init () {
179 | greeting()
180 |
181 | Promise.all([startRenderer(), startMain()])
182 | .then(() => {
183 | startElectron()
184 | })
185 | .catch(err => {
186 | console.error(err)
187 | })
188 | }
189 |
190 | init()
191 |
--------------------------------------------------------------------------------
/.electron-vue/webpack.renderer.config.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | process.env.BABEL_ENV = 'renderer'
4 |
5 | const path = require('path')
6 | const { dependencies } = require('../package.json')
7 | const webpack = require('webpack')
8 |
9 | const MinifyPlugin = require("babel-minify-webpack-plugin")
10 | const CopyWebpackPlugin = require('copy-webpack-plugin')
11 | const MiniCssExtractPlugin = require('mini-css-extract-plugin')
12 | const HtmlWebpackPlugin = require('html-webpack-plugin')
13 | const { VueLoaderPlugin } = require('vue-loader')
14 |
15 | /**
16 | * List of node_modules to include in webpack bundle
17 | *
18 | * Required for specific packages like Vue UI libraries
19 | * that provide pure *.vue files that need compiling
20 | * https://simulatedgreg.gitbooks.io/electron-vue/content/en/webpack-configurations.html#white-listing-externals
21 | */
22 | let whiteListedModules = ['vue']
23 |
24 | let rendererConfig = {
25 | devtool: '#cheap-module-eval-source-map',
26 | entry: {
27 | renderer: path.join(__dirname, '../src/renderer/main.js')
28 | },
29 | externals: [
30 | ...Object.keys(dependencies || {}).filter(d => !whiteListedModules.includes(d))
31 | ],
32 | module: {
33 | rules: [
34 | {
35 | test: /\.less$/,
36 | use: ['vue-style-loader', 'css-loader', 'less-loader']
37 | },
38 | {
39 | test: /\.css$/,
40 | use: ['vue-style-loader', 'css-loader']
41 | },
42 | {
43 | test: /\.html$/,
44 | use: 'vue-html-loader'
45 | },
46 | {
47 | test: /\.js$/,
48 | use: 'babel-loader',
49 | exclude: /node_modules/
50 | },
51 | {
52 | test: /\.node$/,
53 | use: 'node-loader'
54 | },
55 | {
56 | test: /\.vue$/,
57 | use: {
58 | loader: 'vue-loader',
59 | options: {
60 | extractCSS: process.env.NODE_ENV === 'production',
61 | loaders: {
62 | sass: 'vue-style-loader!css-loader!sass-loader?indentedSyntax=1',
63 | scss: 'vue-style-loader!css-loader!sass-loader',
64 | less: 'vue-style-loader!css-loader!less-loader'
65 | }
66 | }
67 | }
68 | },
69 | {
70 | test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
71 | use: {
72 | loader: 'url-loader',
73 | query: {
74 | limit: 10000,
75 | name: 'imgs/[name]--[folder].[ext]'
76 | }
77 | }
78 | },
79 | {
80 | test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
81 | loader: 'url-loader',
82 | options: {
83 | limit: 10000,
84 | name: 'media/[name]--[folder].[ext]'
85 | }
86 | },
87 | {
88 | test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
89 | use: {
90 | loader: 'url-loader',
91 | query: {
92 | limit: 10000,
93 | name: 'fonts/[name]--[folder].[ext]'
94 | }
95 | }
96 | }
97 | ]
98 | },
99 | node: {
100 | __dirname: process.env.NODE_ENV !== 'production',
101 | __filename: process.env.NODE_ENV !== 'production'
102 | },
103 | plugins: [
104 | new VueLoaderPlugin(),
105 | new MiniCssExtractPlugin({filename: 'styles.css'}),
106 | new HtmlWebpackPlugin({
107 | templateParameters(compilation, assets, options) {
108 | return {
109 | compilation: compilation,
110 | webpack: compilation.getStats().toJson(),
111 | webpackConfig: compilation.options,
112 | htmlWebpackPlugin: {
113 | files: assets,
114 | options: options
115 | },
116 | process,
117 | };
118 | },
119 | filename: 'index.html',
120 | template: path.resolve(__dirname, '../src/index.ejs'),
121 | minify: {
122 | collapseWhitespace: true,
123 | removeAttributeQuotes: true,
124 | removeComments: true
125 | },
126 | nodeModules: process.env.NODE_ENV !== 'production'
127 | ? path.resolve(__dirname, '../node_modules')
128 | : false
129 | }),
130 | new webpack.HotModuleReplacementPlugin(),
131 | new webpack.NoEmitOnErrorsPlugin()
132 | ],
133 | output: {
134 | filename: '[name].js',
135 | libraryTarget: 'commonjs2',
136 | path: path.join(__dirname, '../dist/electron')
137 | },
138 | resolve: {
139 | alias: {
140 | '@': path.join(__dirname, '../src/renderer'),
141 | 'vue$': 'vue/dist/vue.esm.js'
142 | },
143 | extensions: ['.js', '.vue', '.json', '.css', '.node']
144 | },
145 | target: 'electron-renderer'
146 | }
147 |
148 | /**
149 | * Adjust rendererConfig for development settings
150 | */
151 | if (process.env.NODE_ENV !== 'production') {
152 | rendererConfig.plugins.push(
153 | new webpack.DefinePlugin({
154 | '__static': `"${path.join(__dirname, '../static').replace(/\\/g, '\\\\')}"`
155 | })
156 | )
157 | }
158 |
159 | /**
160 | * Adjust rendererConfig for production settings
161 | */
162 | if (process.env.NODE_ENV === 'production') {
163 | rendererConfig.devtool = ''
164 |
165 | rendererConfig.plugins.push(
166 | new MinifyPlugin(),
167 | new CopyWebpackPlugin([
168 | {
169 | from: path.join(__dirname, '../static'),
170 | to: path.join(__dirname, '../dist/electron/static'),
171 | ignore: ['.*']
172 | }
173 | ]),
174 | new webpack.DefinePlugin({
175 | 'process.env.NODE_ENV': '"production"'
176 | }),
177 | new webpack.LoaderOptionsPlugin({
178 | minimize: true
179 | })
180 | )
181 | }
182 |
183 | module.exports = rendererConfig
184 |
--------------------------------------------------------------------------------
/src/core/tunnel.js:
--------------------------------------------------------------------------------
1 | const request = require('request')
2 | const iconv = require('iconv-lite');
3 |
4 |
5 | async function login(account,password,ip,port){
6 | var url = `http://${ip}:${port}/portal/pws?t=li`
7 | var headers = {
8 | 'User-Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36',
9 | 'Accept':'text/plain, */*; q=0.01',
10 | 'Accept-Language':'zh-CN,zh;q=0.9',
11 | 'Connection':'keep-alive',
12 | 'Host': `${ip}:${port}`
13 | }
14 | var form = {
15 | 'userName':`${account}`,
16 | 'userPwd':Buffer.from(password).toString('base64'),
17 | 'userDynamicPwd':'',
18 | 'userDynamicPwdd':'',
19 | 'serviceType':'',
20 | 'userurl':'',
21 | 'userip':'',
22 | 'basip':'',
23 | 'language':'Chinese',
24 | 'usermac':'null',
25 | 'wlannasid':'',
26 | 'wlanssid':'',
27 | 'entrance':'null',
28 | 'loginVerifyCode':'',
29 | 'userDynamicPwddd':'',
30 | 'customPageId':'0',
31 | 'pwdMode':'0',
32 | 'portalProxyIP':`${ip}`,
33 | 'portalProxyPort':'50200',
34 | 'dcPwdNeedEncrypt':'1',
35 | 'assignIpType':'0',
36 | 'appRootUrl':`http://${ip}:${port}/portal/`,
37 | 'manualUrl':'',
38 | 'manualUrlEncryptKey':''
39 | }
40 |
41 | return new Promise(function (resolve,reject){
42 | request.post(
43 | {
44 | url:url,
45 | headers:headers,
46 | form: form
47 | },function(err,httpResponse,body){
48 | try{
49 | var data = decodeMsg(body)
50 |
51 | if(err)
52 | reject('请求失败')
53 | if(data.errorNumber ==="-1"){
54 | var errorDescription = iconv.decode(data.errorDescription, 'utf-8')
55 | reject(errorDescription)
56 | }
57 |
58 | else if(data.errorNumber ==="1"){
59 |
60 | if(connectionTest())
61 | resolve({
62 | msg:'上线成功',
63 | userDevPort:data.userDevPort,
64 | portalLink:data.portalLink,
65 | serialNo:data.serialNo,
66 | userStatus:data.userStatus
67 | })
68 |
69 | else{
70 | //TODO
71 | }
72 | }
73 |
74 | else
75 | resolve('请求失败')
76 | }catch (e){
77 | // console.log(e,new Date().getTime())
78 | resolve('未知错误')
79 | }
80 |
81 | })
82 | })
83 | }
84 |
85 | async function logout(ip,port){
86 | var url = `http://${ip}:${port}/portal/pws?t=lo`
87 | var headers = {
88 | 'User-Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36',
89 | 'Accept':'text/plain, */*; q=0.01',
90 | 'Accept-Language':'zh-CN,zh;q=0.9',
91 | 'Connection':'keep-alive',
92 | }
93 |
94 | var form = {
95 | language: 'Chinese',
96 | userip:'',
97 | basip:'',
98 | }
99 |
100 | return new Promise(function (resolve,reject){
101 | request.post(
102 | {
103 | url:url,
104 | headers:headers,
105 | form: form
106 | },function(err,httpResponse,body){
107 | try{
108 | var data = decodeMsg(body)
109 | if(data.errorNumber ==="-1"){
110 | var errorDescription = iconv.decode(data.errorDescription, 'utf-8')
111 | resolve(errorDescription)
112 | }
113 |
114 | else if(data.errorNumber ==="1")
115 | if(connectionTest())
116 | resolve('下线成功')
117 |
118 | else{
119 | //TODO
120 | }
121 | else
122 | resolve('请求失败')
123 | }catch (e){
124 | resolve('未知错误')
125 | }
126 |
127 | })
128 | })
129 | }
130 |
131 | async function connectionTest(host='https://www.baidu.com/'){
132 | //"http://i.baidu.com/msg/message/get/" to "https://www.baidu.com/"
133 | return new Promise(function (resolve,reject){
134 | request.get(host,function (err,res){
135 | try {
136 | // console.log(res.statusCode,res.req)
137 | if(!err && res.statusCode===200)
138 | resolve(1)
139 | else
140 | resolve(0)
141 | }catch (err){
142 | reject(0)
143 | }
144 | })
145 | })
146 | }
147 |
148 |
149 | function doHeartBeat(ip,port,userDevPort,userStatus,serialNo){
150 | var url = `http://${ip}:${port}/portal/page/doHeartBeat.jsp?userip=&basip=&
151 | userDevPort=${userDevPort}&userStatus=${userStatus}&serialNo=${serialNo}&language=Chinese&e_d=&t=hb`
152 | var headers = {
153 | 'User-Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36',
154 | 'Accept':'text/plain, */*; q=0.01',
155 | 'Accept-Language':'zh-CN,zh;q=0.9',
156 | 'Connection':'keep-alive',
157 | 'Host': `${ip}:${port}`,
158 | 'Upgrade-Insecure-Requests': 1,
159 | }
160 |
161 | return new Promise(function (resolve,reject){
162 | request.post(
163 | {
164 | url:url,
165 | headers:headers,
166 | },function(err,res){
167 |
168 | if(!err && res.statusCode===200)
169 | resolve(1)
170 |
171 | else
172 | reject(0)
173 |
174 | })
175 | })
176 | }
177 |
178 | function decodeMsg(msg){
179 |
180 | var urlCode,resposeData
181 | urlCode = Buffer.from(msg,'base64')
182 | resposeData = unescape(urlCode)
183 |
184 | return JSON.parse(resposeData)
185 | }
186 |
187 | export default {login,logout,doHeartBeat,connectionTest}
188 |
189 | // connectionTest().then((r)=>{
190 | // console.log(r)
191 | // })
192 |
--------------------------------------------------------------------------------
/src/renderer/components/home.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
12 |
13 |
14 |
15 |
16 |
19 |
20 |
21 | 下线
24 |
25 | {{status ? status : '上线'}}
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
╰( ̄▽ ̄)╭
36 |
(。_。)
37 |
38 |
39 | {{this.aliveRecorder.value}}
40 | {{this.aliveRecorder.unit}}
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
372 |
373 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------