mirror of
https://github.com/aljazceru/ark.git
synced 2025-12-17 20:24:21 +01:00
Rename folders (#97)
* Rename arkd folder & drop cli * Rename ark cli folder & update docs * Update readme * Fix * scripts: add build-all * Add target to build cli for all platforms * Update build scripts --------- Co-authored-by: tiero <3596602+tiero@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
0d8c7bffb2
commit
dc00d60585
46
server/internal/interface/grpc/config.go
Normal file
46
server/internal/interface/grpc/config.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package grpcservice
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"net"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Port uint32
|
||||
NoTLS bool
|
||||
}
|
||||
|
||||
func (c Config) Validate() error {
|
||||
lis, err := net.Listen("tcp", c.address())
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid port: %s", err)
|
||||
}
|
||||
defer lis.Close()
|
||||
|
||||
if !c.NoTLS {
|
||||
return fmt.Errorf("tls termination not supported yet")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c Config) insecure() bool {
|
||||
return c.NoTLS
|
||||
}
|
||||
|
||||
func (c Config) address() string {
|
||||
return fmt.Sprintf(":%d", c.Port)
|
||||
}
|
||||
|
||||
func (c Config) listener() net.Listener {
|
||||
lis, _ := net.Listen("tcp", c.address())
|
||||
|
||||
if c.insecure() {
|
||||
return lis
|
||||
}
|
||||
return tls.NewListener(lis, c.tlsConfig())
|
||||
}
|
||||
|
||||
func (c Config) tlsConfig() *tls.Config {
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user