-
-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
250 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { BlackSSLProviderConfig } from '../types'; | ||
import { getBlackSSLConfig } from '../utils'; | ||
import Provider from './Provider'; | ||
|
||
export default class BlackSSLProvider extends Provider { | ||
public readonly username: string; | ||
public readonly password: string; | ||
|
||
constructor(config: BlackSSLProviderConfig) { | ||
super(config); | ||
this.username = config.username; | ||
this.password = config.password; | ||
} | ||
|
||
public getNodeList(): ReturnType<typeof getBlackSSLConfig> { | ||
return getBlackSSLConfig(this); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import assert from 'assert'; | ||
import { CustomProviderConfig, PossibleNodeConfigType } from '../types'; | ||
import Provider from './Provider'; | ||
|
||
export default class CustomProvider extends Provider { | ||
public readonly nodeList: ReadonlyArray<PossibleNodeConfigType>; | ||
|
||
constructor(config: CustomProviderConfig) { | ||
super(config); | ||
assert(config.nodeList, 'Lack of nodeList.'); | ||
this.nodeList = config.nodeList; | ||
} | ||
|
||
public async getNodeList(): Promise<ReadonlyArray<PossibleNodeConfigType>> { | ||
return this.nodeList; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import assert from 'assert'; | ||
|
||
import { | ||
NodeFilterType, | ||
NodeNameFilterType, | ||
ProviderConfig, | ||
SupportProviderEnum, | ||
} from '../types'; | ||
|
||
let globalPort: number = 61100; | ||
|
||
export default class Provider { | ||
public readonly type: SupportProviderEnum; | ||
public readonly nodeFilter?: NodeFilterType; | ||
public readonly netflixFilter?: NodeNameFilterType; | ||
public readonly youtubePremiumFilter?: NodeNameFilterType; | ||
private startPort?: number; | ||
|
||
constructor(config: ProviderConfig) { | ||
assert(config.type, 'You must specify a provider type.'); | ||
this.type = config.type; | ||
this.nodeFilter = config.nodeFilter; | ||
this.netflixFilter = config.netflixFilter; | ||
this.youtubePremiumFilter = config.youtubePremiumFilter; | ||
this.startPort = config.startPort; | ||
} | ||
|
||
public get nextPort(): number { | ||
if (this.startPort) { | ||
return this.startPort++; | ||
} | ||
return globalPort++; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { ShadowsocksJsonSubscribeProviderConfig } from '../types'; | ||
import { getShadowsocksJSONConfig } from '../utils'; | ||
import Provider from './Provider'; | ||
|
||
export default class ShadowsocksJsonSubscribeProvider extends Provider { | ||
public readonly url: string; | ||
public readonly udpRelay?: boolean; | ||
|
||
constructor(config: ShadowsocksJsonSubscribeProviderConfig) { | ||
super(config); | ||
this.url = config.url; | ||
this.udpRelay = config.udpRelay; | ||
} | ||
|
||
public getNodeList(): ReturnType<typeof getShadowsocksJSONConfig> { | ||
return getShadowsocksJSONConfig({ | ||
url: this.url, | ||
udpRelay: this.udpRelay, | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { ShadowsocksSubscribeProviderConfig } from '../types'; | ||
import { getShadowsocksSubscription } from '../utils'; | ||
import Provider from './Provider'; | ||
|
||
export default class ShadowsocksSubscribeProvider extends Provider { | ||
public readonly url: string; | ||
public readonly udpRelay?: boolean; | ||
|
||
constructor(config: ShadowsocksSubscribeProviderConfig) { | ||
super(config); | ||
this.url = config.url; | ||
this.udpRelay = config.udpRelay; | ||
} | ||
|
||
public getNodeList(): ReturnType<typeof getShadowsocksSubscription> { | ||
return getShadowsocksSubscription({ | ||
url: this.url, | ||
udpRelay: this.udpRelay, | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { ShadowsocksrSubscribeProviderConfig } from '../types'; | ||
import { getShadowsocksrSubscription } from '../utils'; | ||
import Provider from './Provider'; | ||
|
||
export default class ShadowsocksrSubscribeProvider extends Provider { | ||
public readonly url: string; | ||
|
||
constructor(config: ShadowsocksrSubscribeProviderConfig) { | ||
super(config); | ||
this.url = config.url; | ||
} | ||
|
||
public getNodeList(): ReturnType<typeof getShadowsocksrSubscription> { | ||
return getShadowsocksrSubscription(this); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { V2rayNSubscribeProviderConfig } from '../types'; | ||
import { getV2rayNSubscription } from '../utils'; | ||
import Provider from './Provider'; | ||
|
||
export default class V2rayNSubscribeProvider extends Provider { | ||
public readonly url: string; | ||
|
||
constructor(config: V2rayNSubscribeProviderConfig) { | ||
super(config); | ||
this.url = config.url; | ||
} | ||
|
||
public getNodeList(): ReturnType<typeof getV2rayNSubscription> { | ||
return getV2rayNSubscription(this); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.