Skip to content

Commit

Permalink
feat: new protocol filters
Browse files Browse the repository at this point in the history
  • Loading branch information
geekdada committed Jun 13, 2020
1 parent 1f14408 commit 212892d
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
18 changes: 18 additions & 0 deletions lib/generator/artifact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ import {
chinaBackFilter,
validateFilter,
youtubePremiumFilter as defaultYoutubePremiumFilter,
shadowsocksFilter,
shadowsocksrFilter,
VmessFilter,
V2rayFilter,
SnellFilter,
HttpFilter,
HttpsFilter,
TrojanFilter,
Socks5Filter,
} from '../utils/filter';
import { prependFlag } from '../utils/flag';

Expand Down Expand Up @@ -143,6 +152,15 @@ export class Artifact extends EventEmitter {
singaporeFilter,
taiwanFilter,
chinaBackFilter,
shadowsocksFilter,
shadowsocksrFilter,
VmessFilter,
V2rayFilter,
SnellFilter,
HttpFilter,
HttpsFilter,
TrojanFilter,
Socks5Filter,
toUrlSafeBase64,
toBase64,
encodeURIComponent,
Expand Down
21 changes: 20 additions & 1 deletion lib/utils/filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { deprecate } from 'util';

import { DEP003, DEP004 } from '../misc/deprecation';
import flag, { TAIWAN } from '../misc/flag_cn';
import { NodeNameFilterType, SimpleNodeConfig, SortedNodeNameFilterType } from '../types';
import { NodeNameFilterType, NodeTypeEnum, SimpleNodeConfig, SortedNodeNameFilterType } from '../types';

const showDEP003 = deprecate(_.noop, DEP003, 'DEP003');
const showDEP004 = deprecate(_.noop, DEP004, 'DEP004');
Expand Down Expand Up @@ -214,3 +214,22 @@ export const chinaBackFilter: NodeNameFilterType = item => {
};

export const youtubePremiumFilter: NodeNameFilterType = mergeFilters([usFilter, japanFilter, koreaFilter, hkFilter, singaporeFilter]);

// istanbul ignore next
export const shadowsocksFilter: NodeNameFilterType = item => item.type === NodeTypeEnum.Shadowsocks;
// istanbul ignore next
export const shadowsocksrFilter: NodeNameFilterType = item => item.type === NodeTypeEnum.Shadowsocksr;
// istanbul ignore next
export const VmessFilter: NodeNameFilterType = item => item.type === NodeTypeEnum.Vmess;
// istanbul ignore next
export const V2rayFilter: NodeNameFilterType = item => item.type === NodeTypeEnum.Vmess;
// istanbul ignore next
export const SnellFilter: NodeNameFilterType = item => item.type === NodeTypeEnum.Snell;
// istanbul ignore next
export const HttpFilter: NodeNameFilterType = item => item.type === NodeTypeEnum.HTTP;
// istanbul ignore next
export const HttpsFilter: NodeNameFilterType = item => item.type === NodeTypeEnum.HTTPS;
// istanbul ignore next
export const TrojanFilter: NodeNameFilterType = item => item.type === NodeTypeEnum.Trojan;
// istanbul ignore next
export const Socks5Filter: NodeNameFilterType = item => item.type === NodeTypeEnum.Socks5;

0 comments on commit 212892d

Please sign in to comment.