befw

package
v0.0.0-...-d449664 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 14, 2023 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Overview

*

  • Copyright 2018-2023 Wargaming Group Limited *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.

*

*

  • Copyright 2018-2023 Wargaming Group Limited *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.

*

*

  • Copyright 2018-2023 Wargaming Group Limited *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.

*

*

  • Copyright 2018-2023 Wargaming Group Limited *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.

*

*

  • Copyright 2018-2023 Wargaming Group Limited *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.

*

*

  • Copyright 2018-2023 Wargaming Group Limited *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.

*

*

  • Copyright 2018-2023 Wargaming Group Limited *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.

*

*

  • Copyright 2018-2023 Wargaming Group Limited *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.

*

*

  • Copyright 2018-2023 Wargaming Group Limited *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.

*

*

  • Copyright 2018-2023 Wargaming Group Limited *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.

*

*

  • Copyright 2018-2023 Wargaming Group Limited *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.

*

*

  • Copyright 2018-2023 Wargaming Group Limited *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.

*

*

  • Copyright 2018-2023 Wargaming Group Limited *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.

*

*

  • Copyright 2018-2023 Wargaming Group Limited *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.

*

*

  • Copyright 2018-2023 Wargaming Group Limited *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.

*

*

  • Copyright 2018-2023 Wargaming Group Limited *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.

*

Index

Constants

View Source
const (
	SET_ALLOW = "rules_allow"
	SET_DENY  = "rules_deny"
	V6        = "_v6"
)
View Source
const (
	ENABLE_BIN_CALLS     = false // Allow to execute external commands in tests (such as 'echo')
	ENABLE_IPT_MULTIPORT = false // If true - fill templates based on --dports (allows multiple ports per one rule)
)

Code behavior constants

View Source
const (
	PROTOCOL_TCP = "tcp"
	PROTOCOL_UDP = "udp"
	MAX_PORT     = 65535
)
View Source
const (
	MODE_DEFAULT   serviceMode = iota // Default service mode
	MODE_ENFORCING                    // Enforcing service mode

)

Service modes

View Source
const (
	TAG_ENFORCING string = "enforcing"
	TAG_DEFAULT          = "default"
)
View Source
const (
	REGEXP_IP4_SEG = "(?:25[0-5]|2[0-4][0-9]|(?:1[0-9]|[1-9])?[0-9])"
	REGEXP_IP4     = "(?:" + REGEXP_IP4_SEG + "\\.){3}" + REGEXP_IP4_SEG

	REGEXP_IP6_SEG   = "(?:[0-9a-fA-F]{1,4})"
	REGEXP_IP6_SEG_L = "(?::" + REGEXP_IP6_SEG + ")"
	REGEXP_IP6_SEG_R = "(?:" + REGEXP_IP6_SEG + ":)"
	REGEXP_IP6       = "(?:" + REGEXP_IP6_SEG_R + "{7}" + REGEXP_IP6_SEG + "|" +
		REGEXP_IP6_SEG_R + "{1,7}:" + "|" +
		":" + REGEXP_IP6_SEG_L + "{0,7}" + "|" +
		"::|" +
		REGEXP_IP6_SEG_R + "{1,6}" + REGEXP_IP6_SEG_L + "{1}|" +
		REGEXP_IP6_SEG_R + "{1,5}" + REGEXP_IP6_SEG_L + "{1,2}|" +
		REGEXP_IP6_SEG_R + "{1,4}" + REGEXP_IP6_SEG_L + "{1,3}|" +
		REGEXP_IP6_SEG_R + "{1,3}" + REGEXP_IP6_SEG_L + "{1,4}|" +
		REGEXP_IP6_SEG_R + "{1,2}" + REGEXP_IP6_SEG_L + "{1,5}|" +
		REGEXP_IP6_SEG_R + "{1}" + REGEXP_IP6_SEG_L + "{1,6}|" +
		")"

	REGEXP_NET_32  = "(?:/(?:3[0-2]|[12]?[0-9]))?"
	REGEXP_NET_128 = "(?:/(?:12[0-8]|(?:1[0-1]|[1-9])?[0-9]))?"

	REGEXP_IP4_NET = REGEXP_IP4 + REGEXP_NET_32
	REGEXP_IP6_NET = REGEXP_IP6 + REGEXP_NET_128
)
View Source
const (
	REGEX_BEFW = "^befw/\\S+/(?:" + REGEXP_IP4_NET + "|" + REGEXP_IP6_NET + "|" + "\\$\\S+\\$)$"
)

Variables

View Source
var OverrideConfig = make(map[string]string)

Functions

func DeregisterService

func DeregisterService(configFile, name string) error

func GenerateConfigs

func GenerateConfigs() string

func LegacyServiceFromJson

func LegacyServiceFromJson(data []byte) (*legacyService, error)

DEPRECATED

func NewBPort

func NewBPort(tag string) (*bPort, error)

New BEFW Port by tag

func PanicRecovery

func PanicRecovery()

func PortFromTag

func PortFromTag(tag string) (*legacyBefwPort, error)

DEPRECATED

func PortsAsStrings

func PortsAsStrings(ports []portRange) []string

DEPRECATED

func RegisterService

func RegisterService(configFile, name, protocol string, port int) error

func SendApiCommand

func SendApiCommand(command string) string

func ServiceFromJson

func ServiceFromJson(data []byte) (*bService, error)

Generate bService from JSON

func ShowState

func ShowState(configFile string) string

func StartNFLogger

func StartNFLogger()

func StartService

func StartService(configFile string)

Types

type IptablesRules

type IptablesRules struct {
	Header   string `json:"header"`
	Footer   string `json:"footer"`
	Line     string `json:"rule_service"`
	LineE    string `json:"rule_service_e"`
	Static   string `json:"static_set"`
	NidsLine string `json:"nids_line"`
	Header6  string `json:"header6"`
	Footer6  string `json:"footer6"`
}

Templates of iptables rules

type RefreshMethod

type RefreshMethod int8

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL