2
2
* Config class for CSGO Server API
3
3
*/
4
4
class config {
5
- constructor ( ) {
6
- this . _userOptions = require ( '../config.js' ) ;
5
+ #userOptions = require ( '../config.js' ) ;
6
+ #screenCommand;
7
+ #csgoCommand;
8
+ #serverTokenCommand;
9
+ #localIp;
7
10
8
- this . _screenCommand = `${ this . _userOptions . screen } -L -Logfile ${ this . _userOptions . screenLog } -dmS ${ this . _userOptions . screenName } ` ;
9
- this . _csgoCommand = `${ this . _userOptions . csgoDir } game/bin/linuxsteamrt64/cs2 -dedicated` ;
10
- this . _serverTokenCommand = `+sv_setsteamaccount ${ this . _userOptions . serverToken } ` ;
11
- this . _localIp = '' ;
11
+ constructor ( ) {
12
+ this . #screenCommand = `${ this . #userOptions. screen } -L -Logfile ${ this . #userOptions. screenLog } -dmS ${ this . #userOptions. screenName } ` ;
13
+ this . #csgoCommand = `${ this . #userOptions. csgoDir } game/bin/linuxsteamrt64/cs2 -dedicated` ;
14
+ this . #serverTokenCommand = `+sv_setsteamaccount ${ this . #userOptions. serverToken } ` ;
15
+ this . #localIp = '' ;
12
16
}
13
- get _csgoArgs ( ) {
14
- return `-console -usercon -ip 0.0.0.0 +sv_logfile 1 -serverlogging +logaddress_add_http "http://${ this . _localIp } :${ this . logPort } /log" ${ this . _userOptions . csgoOptionalArgs } ` ;
17
+ get #csgoArgs ( ) {
18
+ return `-console -usercon -ip 0.0.0.0 +sv_logfile 1 -serverlogging +logaddress_add_http "http://${ this . #localIp } :${ this . #userOptions . logPort } /log" ${ this . #userOptions . csgoOptionalArgs } ` ;
15
19
}
16
20
17
21
get apiToken ( ) {
18
- return this . _userOptions . apiToken ;
22
+ return this . #userOptions . apiToken ;
19
23
}
20
24
get rconPass ( ) {
21
- return this . _userOptions . rconPass ;
25
+ return this . #userOptions . rconPass ;
22
26
}
23
27
24
28
get admins ( ) {
25
- return this . _userOptions . admins ;
29
+ return this . #userOptions . admins ;
26
30
}
27
31
28
32
get workshopCollection ( ) {
29
- return this . _userOptions . workshopCollection ;
33
+ return this . #userOptions . workshopCollection ;
30
34
}
31
35
set workshopCollection ( id ) {
32
- this . _userOptions . workshopCollection = id ;
36
+ this . #userOptions . workshopCollection = id ;
33
37
}
34
38
get workshopMaps ( ) {
35
- return this . _userOptions . workshopMaps ;
39
+ return this . #userOptions . workshopMaps ;
36
40
}
37
41
set workshopMaps ( maps ) {
38
- this . _userOptions . workshopMaps = maps ;
42
+ this . #userOptions . workshopMaps = maps ;
39
43
}
40
44
41
45
get redirectPage ( ) {
42
- if ( this . _userOptions . redirectPage ) {
43
- return this . _userOptions . redirectPage ;
46
+ if ( this . #userOptions . redirectPage ) {
47
+ return this . #userOptions . redirectPage ;
44
48
} else {
45
49
return ( '/gameserver.htm' ) ;
46
50
}
47
51
}
48
52
49
53
get loginValidity ( ) {
50
- return this . _userOptions . loginValidity * 60000 ;
54
+ return this . #userOptions . loginValidity * 60000 ;
51
55
}
52
56
53
57
get httpAuth ( ) {
54
- return this . _userOptions . httpAuth ;
58
+ return this . #userOptions . httpAuth ;
55
59
}
56
60
get httpUser ( ) {
57
- return this . _userOptions . httpUser ;
61
+ return this . #userOptions . httpUser ;
58
62
}
59
63
60
64
get iface ( ) {
61
- return this . _userOptions . iface ;
65
+ return this . #userOptions . iface ;
62
66
}
63
67
64
68
get localIp ( ) {
65
- return this . _localIp ;
69
+ return this . #localIp ;
66
70
}
67
71
set localIp ( ip ) {
68
- this . _localIp = ip ;
72
+ this . #localIp = ip ;
69
73
}
70
74
get host ( ) {
71
- if ( this . _userOptions . host != '' ) {
72
- return this . _userOptions . host ;
75
+ if ( this . #userOptions . host != '' && this . #userOptions . useHttps ) {
76
+ return this . #userOptions . host ;
73
77
} else {
74
- return this . _localIp
78
+ return this . #localIp
75
79
}
76
80
}
77
81
78
82
get apiPort ( ) {
79
- return this . _userOptions . apiPort ;
83
+ return this . #userOptions . apiPort ;
80
84
}
81
85
get socketPort ( ) {
82
- return this . _userOptions . socketPort ;
86
+ return this . #userOptions . socketPort ;
83
87
}
84
88
get logPort ( ) {
85
- return this . _userOptions . logPort ;
89
+ return this . #userOptions . logPort ;
86
90
}
87
91
88
92
get serverCommandline ( ) {
89
- let command = `${ this . _screenCommand } ${ this . _csgoCommand } ${ this . _csgoArgs } ` ;
93
+ let command = `${ this . #screenCommand } ${ this . #csgoCommand } ${ this . #csgoArgs } ` ;
90
94
if ( this . _csgoToken != '' ) {
91
- command = `${ command } ${ this . _serverTokenCommand } ` ;
95
+ command = `${ command } ${ this . #serverTokenCommand } ` ;
92
96
}
93
97
return command ;
94
98
}
95
99
get steamCommand ( ) {
96
- return this . _userOptions . steamExe
100
+ return this . #userOptions . steamExe
97
101
}
98
102
get updateScript ( ) {
99
- if ( this . _userOptions . updateScript != '' ) {
100
- return this . _userOptions . updateScript ;
103
+ if ( this . #userOptions . updateScript != '' ) {
104
+ return this . #userOptions . updateScript ;
101
105
} else {
102
- return `${ this . _userOptions . csgoDir } update_cs2.txt` ;
106
+ return `${ this . #userOptions . csgoDir } update_cs2.txt` ;
103
107
}
104
108
}
105
109
106
110
get webSockets ( ) {
107
- return this . _userOptions . webSockets ;
111
+ return this . #userOptions . webSockets ;
108
112
}
109
113
get useHttps ( ) {
110
- return this . _userOptions . useHttps ;
114
+ return this . #userOptions . useHttps ;
111
115
}
112
116
get scheme ( ) {
113
- return ( this . _userOptions . useHttps ? 'https' : 'http' ) ;
117
+ return ( this . #userOptions . useHttps ? 'https' : 'http' ) ;
114
118
}
115
119
get httpsCertificate ( ) {
116
- return this . _userOptions . httpsCertificate ;
120
+ return this . #userOptions . httpsCertificate ;
117
121
}
118
122
get httpsPrivateKey ( ) {
119
- return this . _userOptions . httpsPrivateKey ;
123
+ return this . #userOptions . httpsPrivateKey ;
120
124
}
121
125
get httpsCa ( ) {
122
- return this . _userOptions . httpsCa ;
126
+ return this . #userOptions . httpsCa ;
123
127
}
124
128
125
129
get corsOrigin ( ) {
126
- return this . _userOptions . corsOrigin ;
130
+ return this . #userOptions . corsOrigin ;
127
131
}
128
132
get sessionSecret ( ) {
129
- return this . _userOptions . sessionSecret ;
133
+ return this . #userOptions . sessionSecret ;
130
134
}
131
135
132
136
script ( type ) {
133
- return this . _userOptions [ `${ type } Script` ] ;
137
+ return this . #userOptions [ `${ type } Script` ] ;
134
138
}
135
139
136
140
get logFile ( ) {
137
- return this . _userOptions . logFile ;
141
+ return this . #userOptions . logFile ;
138
142
}
139
143
get logLevel ( ) {
140
- return this . _userOptions . logLevel ;
144
+ return this . #userOptions . logLevel ;
141
145
}
142
146
get logDays ( ) {
143
- return this . _userOptions . logDays ;
147
+ return this . #userOptions . logDays ;
144
148
}
145
- } ;
149
+ }
146
150
147
151
module . exports = new config ( ) ;
0 commit comments