diff options
Diffstat (limited to 'listener.go')
-rw-r--r-- | listener.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/listener.go b/listener.go index 67a25e7..4163cb9 100644 --- a/listener.go +++ b/listener.go @@ -25,6 +25,19 @@ type ListenConfig struct { StateDir string } +// NewListenConfigCert creates a listener config by unpacking the node ID from +// its certificate. +// The private key must still be specified. +func NewListenConfigCert(cert string) (*ListenConfig, error) { + nodeID, _, err := unpackCert(cert) + if err != nil { + return nil, err + } + return &ListenConfig{ + NodeID: nodeID, + }, nil +} + // Listen announces on the local network address. // // See func net.Dial for a description of the network and address parameters. |