Add new `proxy-blocked` flag and update proxy
This commit is contained in:
parent
97f34011fc
commit
d8bbe3bb5e
|
@ -24,7 +24,11 @@ export interface ProviderMakerOptions {
|
|||
}
|
||||
|
||||
export function makeProviders(ops: ProviderMakerOptions) {
|
||||
const features = getTargetFeatures(ops.proxyStreams ? 'any' : ops.target, ops.consistentIpForRequests ?? false);
|
||||
const features = getTargetFeatures(
|
||||
ops.proxyStreams ? 'any' : ops.target,
|
||||
ops.consistentIpForRequests ?? false,
|
||||
ops.proxyStreams ?? false,
|
||||
);
|
||||
const list = getProviders(features, {
|
||||
embeds: getBuiltinEmbeds(),
|
||||
sources: getBuiltinSources(),
|
||||
|
|
|
@ -9,6 +9,10 @@ export const flags = {
|
|||
// The source/embed is blocking cloudflare ip's
|
||||
// This flag is not compatible with a proxy hosted on cloudflare
|
||||
CF_BLOCKED: 'cf-blocked',
|
||||
|
||||
// Streams and sources with this flag wont be proxied
|
||||
// And will be exclusive to the extension
|
||||
PROXY_BLOCKED: 'proxy-blocked',
|
||||
} as const;
|
||||
|
||||
export type Flags = (typeof flags)[keyof typeof flags];
|
||||
|
@ -53,9 +57,14 @@ export const targetToFeatures: Record<Targets, FeatureMap> = {
|
|||
},
|
||||
};
|
||||
|
||||
export function getTargetFeatures(target: Targets, consistentIpForRequests: boolean): FeatureMap {
|
||||
export function getTargetFeatures(
|
||||
target: Targets,
|
||||
consistentIpForRequests: boolean,
|
||||
proxyStreams: boolean,
|
||||
): FeatureMap {
|
||||
const features = targetToFeatures[target];
|
||||
if (!consistentIpForRequests) features.disallowed.push(flags.IP_LOCKED);
|
||||
if (proxyStreams) features.disallowed.push(flags.PROXY_BLOCKED);
|
||||
return features;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,11 +14,11 @@ export function setupProxy(stream: Stream): Stream {
|
|||
: null;
|
||||
|
||||
if (stream.type === 'hls')
|
||||
stream.playlist = `https://swallow.prawnhub.ru/${encodeURIComponent(stream.playlist)}/${headers}`;
|
||||
stream.playlist = `https://proxy.nsbx.ru/hls/${encodeURIComponent(stream.playlist)}/${headers}`;
|
||||
|
||||
if (stream.type === 'file')
|
||||
Object.entries(stream.qualities).forEach((entry) => {
|
||||
entry[1].url = `https://mp4proxy.nsbxru.workers.dev/proxy/${encodeURIComponent(entry[1].url)}/${headers}`;
|
||||
entry[1].url = `https://proxy.nsbx.ru/mp4/${encodeURIComponent(entry[1].url)}/${headers}`;
|
||||
});
|
||||
|
||||
stream.headers = {};
|
||||
|
|
Loading…
Reference in New Issue