mirror of
https://github.com/samuelthomas2774/nxapi.git
synced 2026-03-21 18:04:10 -05:00
Remove unidentified-script user agent when running the API proxy server
This commit is contained in:
parent
0e7b6e50c4
commit
f24dc2c63c
|
|
@ -14,7 +14,7 @@ import { NotificationManager, PresenceEvent, ZncNotifications } from '../../comm
|
|||
import { product } from '../../util/product.js';
|
||||
import { parseListenAddress } from '../../util/net.js';
|
||||
import { AuthPolicy, AuthToken, ZncPresenceEventStreamEvent } from '../../api/znc-proxy.js';
|
||||
import { addUserAgent } from '../../util/useragent.js';
|
||||
import { addCliFeatureUserAgent } from '../../util/useragent.js';
|
||||
import { ErrorResponse } from '../../api/util.js';
|
||||
|
||||
declare global {
|
||||
|
|
@ -54,7 +54,7 @@ export function builder(yargs: Argv<ParentArguments>) {
|
|||
type Arguments = YargsArguments<ReturnType<typeof builder>>;
|
||||
|
||||
export async function handler(argv: ArgumentsCamelCase<Arguments>) {
|
||||
addUserAgent('http-server');
|
||||
addCliFeatureUserAgent('http-server');
|
||||
|
||||
const storage = await initStorage(argv.dataPath);
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,21 @@ export function addUserAgent(...useragent: string[]) {
|
|||
additional_useragents.push(...useragent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Only used by cli/nso/http-server.ts.
|
||||
* This command is intended to be run automatically and doesn't make any requests itself, so this function removes
|
||||
* the unidentified-script user agent string.
|
||||
*/
|
||||
export function addCliFeatureUserAgent(...useragent: string[]) {
|
||||
if (additional_useragents[0] === 'nxapi-cli' && additional_useragents[1] === 'unidentified-script') {
|
||||
additional_useragents.splice(1, 1, ...useragent);
|
||||
} else if (additional_useragents[0] === 'nxapi-cli') {
|
||||
additional_useragents.splice(1, 0, ...useragent);
|
||||
} else {
|
||||
additional_useragents.splice(0, 0, ...useragent);
|
||||
}
|
||||
}
|
||||
|
||||
let warned_no_useragent = false;
|
||||
|
||||
export function getUserAgent(additional = getAdditionalUserAgents()) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user