4747// If iptables is not installed, we can add nftables rules directly to the kernel,
4848// without relying on any binaries.
4949func Init (fwType , configPath , monitorInterval string , bypassQueue bool , qNum uint16 ) (err error ) {
50+ confError := false
51+ if fwType == "" {
52+ confError = true
53+ fwType = nftables .Name
54+ }
55+ if configPath == "" {
56+ confError = true
57+ configPath = config .DefaultConfigFile
58+ }
59+
5060 if fwType == iptables .Name {
5161 fw , err = iptables .Fw ()
5262 if err != nil {
@@ -66,13 +76,14 @@ func Init(fwType, configPath, monitorInterval string, bypassQueue bool, qNum uin
6676 }
6777
6878 if fw == nil {
69- return fmt .Errorf ("Firewall not initialized" )
70- }
71- if configPath == "" {
72- configPath = config .DefaultConfigFile
79+ return fmt .Errorf ("Firewall not initialized. Be sure that you're using latest configuration file. Report it on github if needed." )
7380 }
7481 fw .Stop ()
7582 fw .Init (qNum , configPath , monitorInterval , bypassQueue )
83+ if confError {
84+ log .Error ("Firewall error: the default configuration seem to be outdated (default-config.json). Get latest configuration from github." )
85+ }
86+
7687 queueNum = qNum
7788
7889 log .Info ("Using %s firewall" , fw .Name ())
@@ -149,10 +160,16 @@ func SaveConfiguration(rawConfig []byte) error {
149160
150161// Serialize transforms firewall json configuration to protobuf
151162func Serialize () (* protocol.SysFirewall , error ) {
163+ if fw == nil {
164+ return nil , fmt .Errorf ("firewall not initialized, report please" )
165+ }
152166 return fw .Serialize ()
153167}
154168
155169// Deserialize transforms firewall json configuration to protobuf
156170func Deserialize (sysfw * protocol.SysFirewall ) ([]byte , error ) {
171+ if fw == nil {
172+ return nil , fmt .Errorf ("firewall not initialized, report please" )
173+ }
157174 return fw .Deserialize (sysfw )
158175}
0 commit comments