Skip to content

Commit

Permalink
Option to specify TLS config for publisher
Browse files Browse the repository at this point in the history
  • Loading branch information
gammazero committed Sep 11, 2023
1 parent cacbccc commit 25fbf44
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions dagsync/ipnisync/option.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ipnisync

import (
"crypto/tls"
"fmt"
"time"

Expand All @@ -16,6 +17,7 @@ type config struct {
streamHost host.Host
requireTLS bool
httpAddrs []string
tlsConfig *tls.Config
}

// Option is a function that sets a value in a config.
Expand Down Expand Up @@ -101,6 +103,14 @@ func WithStreamHost(h host.Host) Option {
}
}

// WithTLSConfig sets the TLS config for the HTTP server.
func WithTLSConfig(tlsConfig *tls.Config) Option {
return func(c *config) error {
c.tlsConfig = tlsConfig
return nil
}
}

type clientConfig struct {
authPeerID bool
streamHost host.Host
Expand Down
1 change: 1 addition & 0 deletions dagsync/ipnisync/publisher.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ func NewPublisher(lsys ipld.LinkSystem, privKey ic.PrivKey, options ...Option) (
StreamHost: opts.streamHost,
ListenAddrs: httpListenAddrs,
InsecureAllowHTTP: !opts.requireTLS,
TLSConfig: opts.tlsConfig,
}
pub.pubHost = publisherHost

Expand Down

0 comments on commit 25fbf44

Please sign in to comment.