(sections []wireproxy.RoutineSpawner, infoAddr *string)
| 133 | } |
| 134 | |
| 135 | func lockNetwork(sections []wireproxy.RoutineSpawner, infoAddr *string) { |
| 136 | var rules []landlock.Rule |
| 137 | if infoAddr != nil && *infoAddr != "" { |
| 138 | rules = append(rules, landlock.BindTCP(extractPort(*infoAddr))) |
| 139 | } |
| 140 | |
| 141 | for _, section := range sections { |
| 142 | switch section := section.(type) { |
| 143 | case *wireproxy.TCPServerTunnelConfig: |
| 144 | rules = append(rules, landlock.ConnectTCP(extractPort(section.Target))) |
| 145 | case *wireproxy.HTTPConfig: |
| 146 | rules = append(rules, landlock.BindTCP(extractPort(section.BindAddress))) |
| 147 | case *wireproxy.TCPClientTunnelConfig: |
| 148 | rules = append(rules, landlock.ConnectTCP(uint16(section.BindAddress.Port))) |
| 149 | case *wireproxy.Socks5Config: |
| 150 | rules = append(rules, landlock.BindTCP(extractPort(section.BindAddress))) |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | panicIfError(landlock.V4.BestEffort().RestrictNet(rules...)) |
| 155 | } |
| 156 | |
| 157 | func main() { |
| 158 | s := make(chan os.Signal, 1) |
no test coverage detected