Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/nebula/cmd_resolve.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func ResolveAction(c *cli.Context) error {
boil.Whitelist(models.IPAddressColumns.UpdatedAt), // need to update at least one field to retrieve the ID
boil.Infer(),
); err != nil {
log.WithError(err).Warnln("Could not upsert ip address %s", ipaddr)
log.WithError(err).Warnf("Could not upsert ip address %s\n", ipaddr.Address)
continue
}

Expand All @@ -136,7 +136,7 @@ func ResolveAction(c *cli.Context) error {
models.MultiAddressesXIPAddressColumns.ResolvedAt,
models.MultiAddressesXIPAddressColumns.IPAddressID,
}, boil.None(), boil.Infer()); err != nil {
log.WithError(err).Warnln("Could not add ip address %s to db multi address", ipaddr)
log.WithError(err).Warnf("Could not add ip address %s to db multi address\n", ipaddr.Address)
continue
}
}
Expand Down
10 changes: 9 additions & 1 deletion cmd/nebula/nebula.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ import (
"strings"
"syscall"

_ "net/http/pprof"

"github.com/dennis-tra/nebula-crawler/pkg/config"
log "github.com/sirupsen/logrus"
"github.com/urfave/cli/v2"
"github.com/volatiletech/sqlboiler/v4/boil"
_ "net/http/pprof"
)

var (
Expand Down Expand Up @@ -122,6 +123,13 @@ func main() {
DefaultText: config.DefaultConfig.DatabaseUser,
Value: config.DefaultConfig.DatabaseUser,
},
&cli.StringFlag{
Name: "db-ssl",
Usage: "The sslmode to use when connecting the the database",
EnvVars: []string{"NEBULA_DATABASE_SSL"},
DefaultText: config.DefaultConfig.DatabaseSSL,
Value: config.DefaultConfig.DatabaseSSL,
},
Comment thread
coryschwartz marked this conversation as resolved.
&cli.StringSliceFlag{
Name: "protocols",
Usage: "Comma separated list of protocols that this crawler should look for",
Expand Down
3 changes: 2 additions & 1 deletion deploy/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: "3.9"
services:
nebula_monitor:
image: dennis-tra/nebula-crawler:latest
image: coryschwartz/nebula-crawler:latest
Comment thread
coryschwartz marked this conversation as resolved.
Outdated
container_name: nebula_monitor
restart: always
user: nebula
Expand All @@ -14,6 +14,7 @@ services:
NEBULA_DATABASE_NAME: nebula
NEBULA_DATABASE_USER: nebula
NEBULA_DATABASE_PASSWORD: password # TODO: unsafe
NEBULA_DATABASE_SSL: disable
NEBULA_PROMETHEUS_PORT: 6667
NEBULA_PPROF_PORT: 6100
depends_on:
Expand Down
7 changes: 7 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ var DefaultConfig = Config{
DatabaseName: "nebula",
DatabasePassword: "password",
DatabaseUser: "nebula",
DatabaseSSL: "prefer",
Protocols: []string{"/ipfs/kad/1.0.0", "/ipfs/kad/2.0.0"},
RefreshRoutingTable: false,
}
Expand Down Expand Up @@ -111,6 +112,9 @@ type Config struct {
// Determines the username with which we access the database.
DatabaseUser string

// Postgres SSL mode (should be one supported in https://www.postgresql.org/docs/current/libpq-ssl.html)
DatabaseSSL string

// The list of protocols that this crawler should look for.
Protocols []string

Expand Down Expand Up @@ -273,6 +277,9 @@ func (c *Config) apply(ctx *cli.Context) {
if ctx.IsSet("db-user") {
c.DatabaseUser = ctx.String("db-user")
}
if ctx.IsSet("db-ssl") {
c.DatabaseSSL = ctx.String("db-ssl")
}
if ctx.IsSet("protocols") {
c.Protocols = ctx.StringSlice("protocols")
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/db/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,13 @@ func InitClient(conf *config.Config) (*Client, error) {

// Open database handle
srcName := fmt.Sprintf(
"host=%s port=%d dbname=%s user=%s password=%s sslmode=disable",
"host=%s port=%d dbname=%s user=%s password=%s sslmode=%s",
conf.DatabaseHost,
conf.DatabasePort,
conf.DatabaseName,
conf.DatabaseUser,
conf.DatabasePassword,
conf.DatabaseSSL,
)
dbh, err := sql.Open(driverName, srcName)
if err != nil {
Expand Down