Skip to content

Commit

Permalink
Update socks model
Browse files Browse the repository at this point in the history
  • Loading branch information
wizawu committed Aug 2, 2023
1 parent 2bb73d7 commit 3881239
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 46 deletions.
2 changes: 1 addition & 1 deletion roles/socks/files/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ server.on("connection", conn => {
conn.destroy()
log.warn(`disconnect ${upstream}`)
}
}, 10_000)
}, 3_000)
client.on("connect", () => {
client?.write(clientData1)
})
Expand Down
84 changes: 42 additions & 42 deletions roles/socks/files/model.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,64 +13,64 @@
{
"weights": [
[
-1.2175837755203247,
-0.45541998744010925,
-0.08503229171037674,
0.3043460249900818,
-2.2531166076660156,
3.64547061920166,
-3.461256504058838,
3.0909104347229004
-0.6719041466712952,
0.3218610882759094,
-0.21402058005332947,
2.165517568588257,
-1.0150586366653442,
1.0856897830963135,
2.8789117336273193,
1.9797108173370361
],
[
4.280808448791504,
1.5961995124816895,
0.6780009269714355,
-6.743424892425537,
3.0103087425231934,
-0.5446200370788574,
1.5303043127059937,
0.9939271807670593
3.194882869720459,
2.2611138820648193,
0.12758740782737732,
0.8561663031578064,
1.1846129894256592,
0.19416764378547668,
3.8752665519714355,
-3.463618755340576
],
[
0.24535293877124786,
-2.0886576175689697,
-1.5975322723388672,
-0.6271365880966187,
-0.2703739404678345,
-0.4940747618675232,
-0.7844682335853577,
-1.4814773797988892
-0.21532733738422394,
-0.2869027554988861,
-0.86128169298172,
1.2665141820907593,
-0.1189725250005722,
1.7417198419570923,
0.6922897100448608,
3.1910202503204346
],
[
1.4693071842193604,
-0.49438440799713135,
0.05231418460607529,
-1.3422002792358398,
0.4454313814640045,
-1.1858010292053223,
2.6876089572906494,
-2.6213200092315674
1.1994438171386719,
-4.012736797332764,
0.36342954635620117,
-1.147153615951538,
2.03126859664917,
-1.167452096939087,
7.987868785858154,
-0.30907341837882996
]
],
"biases": [
-3.705306053161621,
-2.4958717823028564,
-0.1374208629131317,
-0.5392635464668274
-1.3691068887710571,
-0.14011022448539734,
-2.8027520179748535,
-0.8253191709518433
]
},
{
"weights": [
[
8.08788776397705,
-5.387092590332031,
1.1619784832000732,
3.871443033218384
-3.7227742671966553,
-3.8498706817626953,
10.598954200744629,
-3.8630099296569824
]
],
"biases": [
-0.6366443037986755
-1.3594900369644165
]
}
],
Expand All @@ -85,7 +85,7 @@
},
"trainOpts": {
"activation": "sigmoid",
"iterations": 50000,
"iterations": 80000,
"errorThresh": 0.005,
"log": true,
"logPeriod": 1000,
Expand Down
2 changes: 1 addition & 1 deletion roles/socks/files/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"scripts": {
"build": "tsc main.ts",
"start": "npm run build && node main.js",
"write": "npm run build && node -e 'require(\"./train.js\").writeData(17); process.exit()'",
"write": "npm run build && node -e 'require(\"./train.js\").writeData(18); process.exit()'",
"train": "npm run build && rm -f model.json && node -e 'require(\"./train.js\").train(); process.exit()'"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion roles/socks/files/switcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function select(upstream: string): store.Backend {
} else {
let prefer = 1
for (const t of [2, 3, 5]) {
const child = spawnSync("curl", `-I -L -k -m 0.${t} http://${upstream}/`.split(" "))
const child = spawnSync("curl", `-I -L -k -m 0.${t} https://${upstream}/`.split(" "))
if (child.status === 0) {
prefer = 0
break
Expand Down
3 changes: 2 additions & 1 deletion roles/socks/files/train.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const data = [
...JSON.parse(fs.readFileSync("./data.15.json", "utf-8")),
...JSON.parse(fs.readFileSync("./data.16.json", "utf-8")),
...JSON.parse(fs.readFileSync("./data.17.json", "utf-8")),
...JSON.parse(fs.readFileSync("./data.18.json", "utf-8")),
]

const net = new brain.NeuralNetwork()
Expand All @@ -34,7 +35,7 @@ export function train() {
output: [it.prefer],
})),
{
iterations: 50000,
iterations: 80000,
log: it => log.debug(it),
logPeriod: 1000,
learningRate: 0.1,
Expand Down

0 comments on commit 3881239

Please sign in to comment.