@@ -56,6 +56,7 @@ exports.login = async function(req, res) {
56
56
res . redirect ( req . protocol + "://" + req . headers . host + "/" + req . body . site + "/info" ) ;
57
57
}
58
58
} else {
59
+ //Factory.clear();
59
60
res . render ( 'login' , { title : 'My Dice Bot' , site :req . params . site , skin :req . session . skin } ) ;
60
61
}
61
62
} catch ( err ) {
@@ -210,6 +211,61 @@ exports.keereg = async function(req, res) {
210
211
}
211
212
} ;
212
213
214
+ exports . proxyload = async function ( req , res ) {
215
+ try {
216
+ let data = '[]' ;
217
+ let filePath = path . resolve ( path . join ( process . execPath , '../proxy.json' ) ) ;
218
+ if ( isMobile ( req ) ) {
219
+ filePath = path . resolve ( path . join ( __dirname , '../../proxy.json' ) ) ;
220
+ }
221
+ if ( process . env . electron ) {
222
+ filePath = path . resolve ( path . join ( config . mydice . path , '/proxy.json' ) ) ;
223
+ }
224
+ if ( fs . existsSync ( filePath ) ) {
225
+ data = fs . readFileSync ( filePath ) ;
226
+ }
227
+ let proxyList = JSON . parse ( data ) ;
228
+ return res . status ( 200 ) . json ( proxyList ) ;
229
+ } catch ( err ) {
230
+ console . log ( err ) ;
231
+ return res . status ( 500 ) . send ( { err : err . toString ( ) } ) ;
232
+ }
233
+ }
234
+
235
+ exports . proxysave = async function ( req , res ) {
236
+ try {
237
+ let proxyList = { } ;
238
+ let data = '[]' ;
239
+ let filePath = path . resolve ( path . join ( process . execPath , '../proxy.json' ) ) ;
240
+ if ( isMobile ( req ) ) {
241
+ filePath = path . resolve ( path . join ( __dirname , '../../proxy.json' ) ) ;
242
+ }
243
+ if ( process . env . electron ) {
244
+ filePath = path . resolve ( path . join ( config . mydice . path , '/proxy.json' ) ) ;
245
+ }
246
+ if ( fs . existsSync ( filePath ) ) {
247
+ data = fs . readFileSync ( filePath ) ;
248
+ }
249
+ proxyList = JSON . parse ( data ) ;
250
+ if ( typeof proxyList !== 'undefined' ) {
251
+ proxyList . forEach ( function ( item , index , object ) {
252
+ if ( item . proxy_name == req . body . proxy_name ) {
253
+ object . splice ( index , 1 ) ;
254
+ }
255
+ } ) ;
256
+ }
257
+ if ( typeof req . body . proxy_name !== 'undefined' ) {
258
+ proxyList . push ( req . body ) ;
259
+ }
260
+ data = JSON . stringify ( proxyList ) ;
261
+ fs . writeFileSync ( filePath , Buffer . from ( data ) ) ;
262
+ return res . status ( 200 ) . json ( 'ok' ) ;
263
+ } catch ( err ) {
264
+ console . log ( err ) ;
265
+ return res . status ( 500 ) . send ( { err : err . toString ( ) } ) ;
266
+ }
267
+ } ;
268
+
213
269
exports . keesave = async function ( req , res ) {
214
270
try {
215
271
let filePath = path . resolve ( path . join ( process . execPath , '../keepass/' ) + req . query . keepassfile + '.kdbx' ) ;
0 commit comments