github.com/TeaOSLab/EdgeNode@v1.3.8/internal/firewalls/firewall_mock.go (about) 1 // Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. 2 3 package firewalls 4 5 // MockFirewall 模拟防火墙 6 type MockFirewall struct { 7 } 8 9 func NewMockFirewall() *MockFirewall { 10 return &MockFirewall{} 11 } 12 13 // Name 名称 14 func (this *MockFirewall) Name() string { 15 return "mock" 16 } 17 18 // IsReady 是否已准备被调用 19 func (this *MockFirewall) IsReady() bool { 20 return true 21 } 22 23 // IsMock 是否为模拟 24 func (this *MockFirewall) IsMock() bool { 25 return true 26 } 27 28 // AllowPort 允许端口 29 func (this *MockFirewall) AllowPort(port int, protocol string) error { 30 _ = port 31 _ = protocol 32 return nil 33 } 34 35 // RemovePort 删除端口 36 func (this *MockFirewall) RemovePort(port int, protocol string) error { 37 _ = port 38 _ = protocol 39 return nil 40 } 41 42 // RejectSourceIP 拒绝某个源IP连接 43 func (this *MockFirewall) RejectSourceIP(ip string, timeoutSeconds int) error { 44 _ = ip 45 _ = timeoutSeconds 46 return nil 47 } 48 49 // DropSourceIP 丢弃某个源IP数据 50 func (this *MockFirewall) DropSourceIP(ip string, timeoutSeconds int, async bool) error { 51 _ = ip 52 _ = timeoutSeconds 53 return nil 54 } 55 56 // RemoveSourceIP 删除某个源IP 57 func (this *MockFirewall) RemoveSourceIP(ip string) error { 58 _ = ip 59 return nil 60 }