/
inject.go
49 lines (42 loc) · 1.11 KB
/
inject.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright 2024 The Funeypot Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package entry
import (
"github.com/funeypot/funeypot/internal/app/config"
"github.com/funeypot/funeypot/internal/app/dashboard"
"github.com/funeypot/funeypot/internal/app/model"
"github.com/funeypot/funeypot/internal/app/server"
"github.com/funeypot/funeypot/internal/pkg/abuseipdb"
"github.com/funeypot/funeypot/internal/pkg/ipgeo"
"github.com/google/wire"
)
var providerSet = wire.NewSet(
newEntrypoint,
wire.FieldsOf(new(*config.Config),
"Database",
"Abuseipdb",
"Dashboard",
"Ssh",
"Http",
"Ftp",
),
model.NewDatabase,
newAbuseipdbClient,
dashboard.NewServer,
server.NewHandler,
server.NewSshServer,
server.NewHttpServer,
server.NewFtpServer,
newCachedIpGeoQuerier,
)
// to suppress "unused" error
var _ = providerSet
func newAbuseipdbClient(cfg config.Abuseipdb) *abuseipdb.Client {
if !cfg.Enabled {
return nil
}
return abuseipdb.NewClient(cfg.Key, cfg.Interval)
}
func newCachedIpGeoQuerier(db *model.Database) ipgeo.Querier {
return model.NewCachedIpGeoQuerier(ipgeo.NewIpapiComQuerier(), db)
}