Protocol/Network rule support

This commit is contained in:
SukkaW
2025-05-03 22:54:25 +08:00
parent c3e4a1a445
commit 76f56fa0e0
6 changed files with 42 additions and 1 deletions

View File

@@ -17,7 +17,8 @@ interface SingboxHeadlessRule {
port?: number[],
port_range?: string[],
process_name?: string[],
process_path?: string[]
process_path?: string[],
network?: string[]
}
export interface SingboxSourceFormat {
@@ -154,5 +155,16 @@ export class SingboxSource extends BaseWriteStrategy {
}
}
writeProtocols(protocol: Set<string>): void {
this.singbox.network ??= [];
// protocol has already be normalized and will only be uppercase
if (protocol.has('UDP')) {
this.singbox.network.push('udp');
}
if (protocol.has('TCP')) {
this.singbox.network.push('tcp');
}
}
writeOtherRules = noop;
}