-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
125 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package api | ||
|
||
import "strings" | ||
|
||
func Hosts(commaHosts string) []string { | ||
hosts := []string{} | ||
|
||
hosts = append(hosts, strings.Split(commaHosts, ",")...) | ||
|
||
return hosts | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package autocert | ||
|
||
import ( | ||
"net" | ||
|
||
"github.com/w-h-a/pkg/security/cert" | ||
goautocert "golang.org/x/crypto/acme/autocert" | ||
) | ||
|
||
type autocertProvider struct { | ||
options cert.CertOptions | ||
} | ||
|
||
func (c *autocertProvider) Options() cert.CertOptions { | ||
return c.options | ||
} | ||
|
||
func (c *autocertProvider) Listener(hosts ...string) (net.Listener, error) { | ||
return goautocert.NewListener(hosts...), nil | ||
} | ||
|
||
func (c *autocertProvider) String() string { | ||
return "autocert" | ||
} | ||
|
||
func NewCertProvider(opts ...cert.CertOption) cert.CertProvider { | ||
options := cert.NewCertOptions(opts...) | ||
|
||
a := &autocertProvider{ | ||
options: options, | ||
} | ||
|
||
return a | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package cert | ||
|
||
import "net" | ||
|
||
type CertProvider interface { | ||
Options() CertOptions | ||
Listener(domains ...string) (net.Listener, error) | ||
String() string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package cert | ||
|
||
import "context" | ||
|
||
type CertOption func(o *CertOptions) | ||
|
||
type CertOptions struct { | ||
Context context.Context | ||
} | ||
|
||
func NewCertOptions(opts ...CertOption) CertOptions { | ||
options := CertOptions{ | ||
Context: context.Background(), | ||
} | ||
|
||
for _, fn := range opts { | ||
fn(&options) | ||
} | ||
|
||
return options | ||
} |