37 lines
597 B
Go
37 lines
597 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
|
|
BaseURL string
|
|
}
|
|
|
|
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
|
|
}
|