@@ -3,19 +3,47 @@ const fs = require('fs');
3
3
const crypto = require ( 'crypto' ) ;
4
4
const { SocksProxyAgent } = require ( 'socks-proxy-agent' ) ;
5
5
const { v4 : uuidv4 , v3 : uuidv3 } = require ( 'uuid' ) ;
6
- const logger = require ( 'pino' ) ( ) ;
6
+ const pino = require ( 'pino' ) ;
7
+ const logger = pino ( { level : 'info' , transport : { target : 'pino-pretty' } } ) ;
7
8
const config = require ( './configuration' ) ;
8
9
10
+ let CoderMarkPrinted = false ;
11
+
12
+ const cl = {
13
+ gr : '\x1b[32m' ,
14
+ br : '\x1b[34m' ,
15
+ red : '\x1b[31m' ,
16
+ yl : '\x1b[33m' ,
17
+ gb : '\x1b[4m' ,
18
+ rt : '\x1b[0m'
19
+ } ;
20
+
21
+ function CoderMark ( ) {
22
+ if ( ! CoderMarkPrinted ) {
23
+ console . log ( `
24
+ ╭━━━╮╱╱╱╱╱╱╱╱╱╱╱╱╱╭━━━┳╮
25
+ ┃╭━━╯╱╱╱╱╱╱╱╱╱╱╱╱╱┃╭━━┫┃${ cl . gr }
26
+ ┃╰━━┳╮╭┳━┳━━┳━━┳━╮┃╰━━┫┃╭╮╱╭┳━╮╭━╮
27
+ ┃╭━━┫┃┃┃╭┫╭╮┃╭╮┃╭╮┫╭━━┫┃┃┃╱┃┃╭╮┫╭╮╮${ cl . br }
28
+ ┃┃╱╱┃╰╯┃┃┃╰╯┃╰╯┃┃┃┃┃╱╱┃╰┫╰━╯┃┃┃┃┃┃┃
29
+ ╰╯╱╱╰━━┻╯╰━╮┣━━┻╯╰┻╯╱╱╰━┻━╮╭┻╯╰┻╯╰╯${ cl . rt }
30
+ ╱╱╱╱╱╱╱╱╱╱╱┃┃╱╱╱╱╱╱╱╱╱╱╱╭━╯┃
31
+ ╱╱╱╱╱╱╱╱╱╱╱╰╯╱╱╱╱╱╱╱╱╱╱╱╰━━╯
32
+ \n${ cl . gb } ${ cl . yl } getGrass Minner Bot ${ cl . rt } ${ cl . gb } v0.2${ cl . rt }
33
+ ` ) ;
34
+ CoderMarkPrinted = true ;
35
+ }
36
+ }
37
+
9
38
async function connectToWss ( socks5Proxy , userId ) {
10
39
const deviceId = uuidv3 ( socks5Proxy , uuidv3 . DNS ) ;
11
40
logger . info ( deviceId ) ;
12
41
while ( true ) {
13
42
try {
14
43
await new Promise ( resolve => setTimeout ( resolve , Math . random ( ) * 900 + 100 ) ) ;
15
- const customHeaders = {
16
- "User-Agent" : config [ "User-Agent" ]
17
- } ;
18
- const uri = "wss://proxy2.wynd.network:4444/" ;
44
+ const customHeaders = { "User-Agent" : config . UserAgent } ;
45
+ const uriList = [ "wss://proxy2.wynd.network:4444/" , "wss://proxy2.wynd.network:4650/" ] ;
46
+ const uri = uriList [ Math . floor ( Math . random ( ) * uriList . length ) ] ;
19
47
const agent = new SocksProxyAgent ( socks5Proxy ) ;
20
48
const ws = new WebSocket ( uri , {
21
49
agent : agent ,
@@ -25,15 +53,9 @@ async function connectToWss(socks5Proxy, userId) {
25
53
} ,
26
54
rejectUnauthorized : false
27
55
} ) ;
28
-
29
56
ws . on ( 'open' , ( ) => {
30
57
const sendPing = ( ) => {
31
- const sendMessage = JSON . stringify ( {
32
- id : uuidv4 ( ) ,
33
- version : "1.0.0" ,
34
- action : "PING" ,
35
- data : { }
36
- } ) ;
58
+ const sendMessage = JSON . stringify ( { id : uuidv4 ( ) , version : "1.0.0" , action : "PING" , data : { } } ) ;
37
59
logger . debug ( sendMessage ) ;
38
60
ws . send ( sendMessage ) ;
39
61
setTimeout ( sendPing , 110000 ) ;
@@ -68,12 +90,8 @@ async function connectToWss(socks5Proxy, userId) {
68
90
} ) ;
69
91
70
92
await new Promise ( ( resolve , reject ) => {
71
- ws . on ( 'close' , ( ) => {
72
- reject ( new Error ( 'WebSocket closed' ) ) ;
73
- } ) ;
74
- ws . on ( 'error' , ( error ) => {
75
- reject ( error ) ;
76
- } ) ;
93
+ ws . on ( 'close' , ( ) => reject ( new Error ( 'WebSocket closed' ) ) ) ;
94
+ ws . on ( 'error' , ( error ) => reject ( error ) ) ;
77
95
} ) ;
78
96
} catch ( e ) {
79
97
logger . error ( `Error with proxy ${ socks5Proxy } : ${ e . message } ` ) ;
@@ -90,7 +108,6 @@ async function main() {
90
108
const proxyFile = config . proxyFile ;
91
109
const userId = config . userId ;
92
110
const allProxies = fs . readFileSync ( proxyFile , 'utf-8' ) . split ( '\n' ) . filter ( Boolean ) ;
93
-
94
111
let activeProxies = allProxies . sort ( ( ) => 0.5 - Math . random ( ) ) . slice ( 0 , 100 ) ;
95
112
let tasks = new Map ( activeProxies . map ( proxy => [ connectToWss ( proxy , userId ) , proxy ] ) ) ;
96
113
@@ -121,5 +138,5 @@ function removeProxyFromList(proxy) {
121
138
const updatedList = proxyList . filter ( line => line . trim ( ) !== proxy ) ;
122
139
fs . writeFileSync ( proxyFile , updatedList . join ( '\n' ) ) ;
123
140
}
124
-
141
+ CoderMark ( ) ;
125
142
main ( ) . catch ( console . error ) ;
0 commit comments