Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions infra/conf/freedom.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ type Noise struct {
}

type FreedomFinalRuleConfig struct {
Action string `json:"action"`
Network *NetworkList `json:"network"`
Port *PortList `json:"port"`
IP *StringList `json:"ip"`
Action string `json:"action"`
Network *NetworkList `json:"network"`
Port *PortList `json:"port"`
IP *StringList `json:"ip"`
BlockDelay *Int32Range `json:"blockDelay"`
}

// Build implements Buildable
Expand Down Expand Up @@ -276,5 +277,12 @@ func (c *FreedomFinalRuleConfig) Build() (*freedom.FinalRuleConfig, error) {
rule.Ip = rules
}

if c.BlockDelay != nil {
rule.BlockDelay = &freedom.Range{
Min: uint64(c.BlockDelay.From),
Max: uint64(c.BlockDelay.To),
}
}

return rule, nil
}
7 changes: 6 additions & 1 deletion infra/conf/freedom_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ func TestFreedomConfig(t *testing.T) {
"action": "block",
"network": "tcp,udp",
"port": "53,443",
"ip": ["10.0.0.0/8", "2001:db8::/32"]
"ip": ["10.0.0.0/8", "2001:db8::/32"],
"blockDelay": "30-60"
}, {
"action": "allow",
"network": ["udp"]
Expand Down Expand Up @@ -85,6 +86,10 @@ func TestFreedomConfig(t *testing.T) {
},
},
},
BlockDelay: &freedom.Range{
Min: 30,
Max: 60,
},
},
{
Action: freedom.RuleAction_Allow,
Expand Down
129 changes: 98 additions & 31 deletions proxy/freedom/config.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions proxy/freedom/config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ message Noise {
string apply_to = 6;
}

message Range {
uint64 min = 1;
uint64 max = 2;
}

enum RuleAction {
Allow = 0;
Block = 1;
Expand All @@ -46,6 +51,7 @@ message FinalRuleConfig {
repeated xray.common.net.Network networks = 2;
xray.common.net.PortList port_list = 3;
repeated xray.common.geodata.IPRule ip = 4;
Range block_delay = 5;
}

message Config {
Expand Down
Loading