mirror of
https://github.com/SukkaW/Surge.git
synced 2026-01-29 01:51:52 +08:00
Protocol/Network rule support
This commit is contained in:
@@ -41,6 +41,7 @@ export class ClashDomainSet extends BaseWriteStrategy {
|
||||
writeSourceIpCidrs = noop;
|
||||
writeSourcePorts = noop;
|
||||
writeDestinationPorts = noop;
|
||||
writeProtocols = noop;
|
||||
writeOtherRules = noop;
|
||||
}
|
||||
|
||||
@@ -80,6 +81,7 @@ export class ClashIPSet extends BaseWriteStrategy {
|
||||
writeSourceIpCidrs = notSupported('writeSourceIpCidrs');
|
||||
writeSourcePorts = notSupported('writeSourcePorts');
|
||||
writeDestinationPorts = noop;
|
||||
writeProtocols = noop;
|
||||
writeOtherRules = noop;
|
||||
}
|
||||
|
||||
@@ -171,5 +173,17 @@ export class ClashClassicRuleSet extends BaseWriteStrategy {
|
||||
appendSetElementsToArray(this.result, port, i => `DST-PORT,${i}`);
|
||||
}
|
||||
|
||||
writeProtocols(protocol: Set<string>): void {
|
||||
// Mihomo only matches UDP/TCP: https://wiki.metacubex.one/en/config/rules/#network
|
||||
|
||||
// protocol has already be normalized and will only contain upppercase
|
||||
if (protocol.has('UDP')) {
|
||||
this.result.push('NETWORK,UDP');
|
||||
}
|
||||
if (protocol.has('TCP')) {
|
||||
this.result.push('NETWORK,TCP');
|
||||
}
|
||||
}
|
||||
|
||||
writeOtherRules = noop;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user