@@ -3,14 +3,17 @@ package builder
3
3
import (
4
4
"errors"
5
5
"fmt"
6
+ "io"
7
+ "net/http"
8
+ "os"
9
+
6
10
"github.com/mariocandela/beelzebub/v3/parser"
7
11
"github.com/mariocandela/beelzebub/v3/plugins"
8
12
"github.com/mariocandela/beelzebub/v3/protocols"
9
- "github.com/mariocandela/beelzebub/v3/protocols/strategies"
13
+ "github.com/mariocandela/beelzebub/v3/protocols/strategies/HTTP"
14
+ "github.com/mariocandela/beelzebub/v3/protocols/strategies/SSH"
15
+ "github.com/mariocandela/beelzebub/v3/protocols/strategies/TCP"
10
16
"github.com/mariocandela/beelzebub/v3/tracer"
11
- "io"
12
- "net/http"
13
- "os"
14
17
15
18
"github.com/prometheus/client_golang/prometheus/promhttp"
16
19
amqp "github.com/rabbitmq/amqp091-go"
@@ -106,9 +109,9 @@ Honeypot Framework, happy hacking!`)
106
109
}()
107
110
108
111
// Init Protocol strategies
109
- secureShellStrategy := & strategies .SSHStrategy {}
110
- hypertextTransferProtocolStrategy := & strategies .HTTPStrategy {}
111
- transmissionControlProtocolStrategy := & strategies .TCPStrategy {}
112
+ secureShellStrategy := & SSH .SSHStrategy {}
113
+ hypertextTransferProtocolStrategy := & HTTP .HTTPStrategy {}
114
+ transmissionControlProtocolStrategy := & TCP .TCPStrategy {}
112
115
113
116
// Init Tracer strategies, and set the trace strategy default HTTP
114
117
protocolManager := protocols .InitProtocolManager (b .traceStrategy , hypertextTransferProtocolStrategy )
@@ -122,7 +125,7 @@ Honeypot Framework, happy hacking!`)
122
125
return err
123
126
} else {
124
127
if len (honeypotsConfiguration ) == 0 {
125
- return errors .New ("No honeypots configuration found" )
128
+ return errors .New ("no honeypots configuration found" )
126
129
}
127
130
b .beelzebubServicesConfiguration = honeypotsConfiguration
128
131
}
@@ -132,20 +135,16 @@ Honeypot Framework, happy hacking!`)
132
135
switch beelzebubServiceConfiguration .Protocol {
133
136
case "http" :
134
137
protocolManager .SetProtocolStrategy (hypertextTransferProtocolStrategy )
135
- break
136
138
case "ssh" :
137
139
protocolManager .SetProtocolStrategy (secureShellStrategy )
138
- break
139
140
case "tcp" :
140
141
protocolManager .SetProtocolStrategy (transmissionControlProtocolStrategy )
141
- break
142
142
default :
143
- log .Fatalf ("Protocol %s not managed" , beelzebubServiceConfiguration .Protocol )
144
- continue
143
+ log .Fatalf ("protocol %s not managed" , beelzebubServiceConfiguration .Protocol )
145
144
}
146
145
147
146
if err := protocolManager .InitService (beelzebubServiceConfiguration ); err != nil {
148
- return errors . New ( fmt .Sprintf ( "Error during init protocol: %s, %s" , beelzebubServiceConfiguration .Protocol , err .Error () ))
147
+ return fmt .Errorf ( "error during init protocol: %s, %s" , beelzebubServiceConfiguration .Protocol , err .Error ())
149
148
}
150
149
}
151
150
0 commit comments