mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-11-25 08:28:40 +00:00
chore(remote_judger): user-agent as constant
This commit is contained in:
parent
7bc11120b9
commit
246c7fb615
@ -30,3 +30,6 @@ export interface IBasicProvider {
|
||||
export interface BasicProvider {
|
||||
new (account: RemoteAccount): IBasicProvider;
|
||||
}
|
||||
|
||||
export const USER_AGENT =
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.0.0 Safari/537.36 S2OJ/3.1.0';
|
||||
|
@ -2,7 +2,7 @@ import { JSDOM } from 'jsdom';
|
||||
import superagent from 'superagent';
|
||||
import proxy from 'superagent-proxy';
|
||||
import sleep from '../utils/sleep';
|
||||
import { IBasicProvider, RemoteAccount } from '../interface';
|
||||
import { IBasicProvider, RemoteAccount, USER_AGENT } from '../interface';
|
||||
import Logger from '../utils/logger';
|
||||
|
||||
proxy(superagent);
|
||||
@ -84,10 +84,7 @@ export default class AtcoderProvider implements IBasicProvider {
|
||||
.redirects(0)
|
||||
.ok(res => res.status < 400)
|
||||
.set('Cookie', this.cookie)
|
||||
.set(
|
||||
'User-Agent',
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.0.0 Safari/537.36 S2OJ/3.1.0'
|
||||
);
|
||||
.set('User-Agent', USER_AGENT);
|
||||
if (this.account.proxy) return req.proxy(this.account.proxy);
|
||||
return req;
|
||||
}
|
||||
@ -101,10 +98,7 @@ export default class AtcoderProvider implements IBasicProvider {
|
||||
.redirects(0)
|
||||
.ok(res => res.status < 400)
|
||||
.set('Cookie', this.cookie)
|
||||
.set(
|
||||
'User-Agent',
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.0.0 Safari/537.36 S2OJ/3.1.0'
|
||||
);
|
||||
.set('User-Agent', USER_AGENT);
|
||||
if (this.account.proxy) return req.proxy(this.account.proxy);
|
||||
return req;
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ import superagent from 'superagent';
|
||||
import proxy from 'superagent-proxy';
|
||||
import sleep from '../utils/sleep';
|
||||
import mathSum from 'math-sum';
|
||||
import { IBasicProvider, RemoteAccount } from '../interface';
|
||||
import { IBasicProvider, RemoteAccount, USER_AGENT } from '../interface';
|
||||
import { normalize, VERDICT } from '../verdict';
|
||||
import Logger from '../utils/logger';
|
||||
|
||||
@ -95,10 +95,7 @@ export default class CodeforcesProvider implements IBasicProvider {
|
||||
const req = superagent
|
||||
.get(url)
|
||||
.set('Cookie', this.cookie)
|
||||
.set(
|
||||
'User-Agent',
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.0.0 Safari/537.36 S2OJ/3.1.0'
|
||||
);
|
||||
.set('User-Agent', USER_AGENT);
|
||||
if (this.account.proxy) return req.proxy(this.account.proxy);
|
||||
return req;
|
||||
}
|
||||
@ -110,10 +107,7 @@ export default class CodeforcesProvider implements IBasicProvider {
|
||||
.post(url)
|
||||
.type('form')
|
||||
.set('Cookie', this.cookie)
|
||||
.set(
|
||||
'User-Agent',
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.0.0 Safari/537.36 S2OJ/3.1.0'
|
||||
);
|
||||
.set('User-Agent', USER_AGENT);
|
||||
if (this.account.proxy) return req.proxy(this.account.proxy);
|
||||
return req;
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ import { JSDOM } from 'jsdom';
|
||||
import superagent from 'superagent';
|
||||
import proxy from 'superagent-proxy';
|
||||
import Logger from '../utils/logger';
|
||||
import { IBasicProvider, RemoteAccount } from '../interface';
|
||||
import { IBasicProvider, RemoteAccount, USER_AGENT } from '../interface';
|
||||
import { parseTimeMS, parseMemoryMB } from '../utils/parse';
|
||||
import sleep from '../utils/sleep';
|
||||
|
||||
@ -106,7 +106,10 @@ export default class UOJProvider implements IBasicProvider {
|
||||
logger.debug('get', url);
|
||||
if (!url.includes('//'))
|
||||
url = `${this.account.endpoint || 'https://uoj.ac'}${url}`;
|
||||
const req = superagent.get(url).set('Cookie', this.cookie);
|
||||
const req = superagent
|
||||
.get(url)
|
||||
.set('Cookie', this.cookie)
|
||||
.set('User-Agent', USER_AGENT);
|
||||
if (this.account.proxy) return req.proxy(this.account.proxy);
|
||||
return req;
|
||||
}
|
||||
@ -115,7 +118,11 @@ export default class UOJProvider implements IBasicProvider {
|
||||
logger.debug('post', url, this.cookie);
|
||||
if (!url.includes('//'))
|
||||
url = `${this.account.endpoint || 'https://uoj.ac'}${url}`;
|
||||
const req = superagent.post(url).set('Cookie', this.cookie).type('form');
|
||||
const req = superagent
|
||||
.post(url)
|
||||
.set('Cookie', this.cookie)
|
||||
.set('User-Agent', USER_AGENT)
|
||||
.type('form');
|
||||
if (this.account.proxy) return req.proxy(this.account.proxy);
|
||||
return req;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user