ussher/config.go
2020-09-24 21:55:26 -07:00

36 lines
577 B
Go

package ussher
import (
"io/ioutil"
"net/http"
"golang.org/x/crypto/ssh"
)
type Config struct {
HostKeyPath string
Keystore Keystore
BindAddress string
Port int
HTTPPort int
SSHApps map[string]SSHApp
HTTPMux *http.ServeMux
}
func (c *Config) GetPrivateKey() (ssh.Signer, error) {
bytes, err := ioutil.ReadFile(c.HostKeyPath)
if err != nil {
return nil, err
}
return ssh.ParsePrivateKey(bytes)
}
func (c *Config) CloseApps() error {
for _, v := range c.SSHApps {
err := v.Close()
if err != nil {
return err
}
}
return nil
}