-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
72 lines (58 loc) · 1.4 KB
/
server.js
File metadata and controls
72 lines (58 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import http from 'http';
import {resolve} from 'path';
import fs from 'fs';
import url from 'url';
import querystring from 'querystring'
import axios from 'axios';
import keymirror from 'keymirror';
import getmac from 'getmac';
const authAPI = "http://API.slyak.com/auth";
export const StoreConstants = keymirror({
TOKEN: null,
PAC: null
});
const storeData = ({token, pac}) => {
};
const PORTS = {
API: 10601,
HTTP_PROXY: 10602,
SOCKS5_PROXY: 10603
};
const getEquipmentId = () => {
getmac.getMac((err, macAddress) => {
})
};
const configureAuth = () => {
return {
eid: getEquipmentId(),
token: ''
}
};
const createApiServer = () => {
http.createServer((request, response) => {
request.url
}).listen(PORTS.API);
};
const createHttpProxyServer = () => {
http.createServer((request, response) => {
const req = http.request({
port: PORTS.HTTP_PROXY,
path: request.url,
method: request.method,
}, function (req, res) {
res.pipe(response);
}).end()
}).listen(PORTS.HTTP_PROXY);
};
const createSocks5ProxyServer = () => {
};
export const start = () => {
axios.post(authAPI, configureAuth()).then(res => {
storeData(res.data);
createApiServer();
createHttpProxyServer();
createSocks5ProxyServer();
});
};
export const stop = () => {
};