Move to yaml-based configuration
This commit updates the configuration to be yaml-based and updates the configuration to read in a yaml file.
This commit is contained in:
parent
568c005d15
commit
945329a080
70 changed files with 1150 additions and 350 deletions
|
|
@ -26,7 +26,7 @@ func (ssh2 *SSH2) HandleRoute(ctx context.Context, path string) (http.Handler, e
|
|||
}
|
||||
|
||||
// find the host
|
||||
slug, ok := ssh2.Config.SlugFromHost(r.Host)
|
||||
slug, ok := ssh2.Config.HTTP.SlugFromHost(r.Host)
|
||||
if slug == "" || !ok {
|
||||
httpx.TextInterceptor.Intercept(w, r, httpx.ErrNotFound)
|
||||
return
|
||||
|
|
|
|||
|
|
@ -36,14 +36,15 @@ func (ssh2 *SSH2) handleDirectTCP(srv *ssh.Server, conn *gossh.ServerConn, newCh
|
|||
return
|
||||
}
|
||||
|
||||
slug, ok := ssh2.Config.SlugFromHost(d.DestAddr)
|
||||
slug, ok := ssh2.Config.HTTP.SlugFromHost(d.DestAddr)
|
||||
if !ok || d.DestPort != 22 || !hasPermission(ctx, slug) {
|
||||
newChan.Reject(gossh.Prohibited, "permission denied")
|
||||
return
|
||||
}
|
||||
|
||||
// TODO: move this into an instance function somewhere
|
||||
dest := net.JoinHostPort(slug+"."+ssh2.Config.DefaultDomain+".wisski", "22")
|
||||
// NOTE(twiesing): This should be moved
|
||||
dest := net.JoinHostPort(slug+"."+ssh2.Config.HTTP.PrimaryDomain+".wisski", "22")
|
||||
|
||||
var dialer net.Dialer
|
||||
dconn, err := dialer.DialContext(ctx, "tcp", dest)
|
||||
|
|
|
|||
|
|
@ -80,8 +80,8 @@ func (ssh2 *SSH2) handleConnection(session ssh.Session) {
|
|||
banner := welcomeMessage
|
||||
for _, oldnew := range [][2]string{
|
||||
{"${SLUG}", slug},
|
||||
{"${DOMAIN}", ssh2.Config.DefaultDomain},
|
||||
{"${HOSTNAME}", slug + "." + ssh2.Config.DefaultDomain},
|
||||
{"${DOMAIN}", ssh2.Config.HTTP.PrimaryDomain},
|
||||
{"${HOSTNAME}", slug + "." + ssh2.Config.HTTP.PrimaryDomain},
|
||||
{"${PORT}", strconv.FormatUint(uint64(ssh2.Config.PublicSSHPort), 10)},
|
||||
} {
|
||||
banner = strings.ReplaceAll(banner, oldnew[0], oldnew[1])
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import (
|
|||
)
|
||||
|
||||
func (ssh SSH2) Path() string {
|
||||
return filepath.Join(ssh.Still.Config.DeployRoot, "core", "ssh2")
|
||||
return filepath.Join(ssh.Still.Config.Paths.Root, "core", "ssh2")
|
||||
}
|
||||
|
||||
//go:embed all:ssh2 ssh2.env
|
||||
|
|
@ -24,15 +24,15 @@ func (ssh *SSH2) Stack(env environment.Environment) component.StackWithResources
|
|||
EnvPath: "ssh2.env",
|
||||
|
||||
EnvContext: map[string]string{
|
||||
"DOCKER_NETWORK_NAME": ssh.Config.DockerNetworkName,
|
||||
"HOST_RULE": ssh.Config.DefaultHostRule(),
|
||||
"HTTPS_ENABLED": ssh.Config.HTTPSEnabledEnv(),
|
||||
"DOCKER_NETWORK_NAME": ssh.Config.Docker.Network,
|
||||
"HOST_RULE": ssh.Config.HTTP.DefaultHostRule(),
|
||||
"HTTPS_ENABLED": ssh.Config.HTTP.HTTPSEnabledEnv(),
|
||||
|
||||
"CONFIG_PATH": ssh.Config.ConfigPath,
|
||||
"DEPLOY_ROOT": ssh.Config.DeployRoot,
|
||||
"DEPLOY_ROOT": ssh.Config.Paths.Root,
|
||||
|
||||
"SELF_OVERRIDES_FILE": ssh.Config.SelfOverridesFile,
|
||||
"SELF_RESOLVER_BLOCK_FILE": ssh.Config.SelfResolverBlockFile,
|
||||
"SELF_OVERRIDES_FILE": ssh.Config.Paths.OverridesJSON,
|
||||
"SELF_RESOLVER_BLOCK_FILE": ssh.Config.Paths.ResolverBlocks,
|
||||
|
||||
"SSH_PORT": strconv.FormatUint(uint64(ssh.Config.PublicSSHPort), 10),
|
||||
},
|
||||
|
|
@ -44,6 +44,6 @@ func (ssh *SSH2) Stack(env environment.Environment) component.StackWithResources
|
|||
|
||||
func (ssh SSH2) Context(parent component.InstallationContext) component.InstallationContext {
|
||||
return component.InstallationContext{
|
||||
bootstrap.Executable: ssh.Config.CurrentExecutable(ssh.Environment), // TODO: Does this make sense?
|
||||
bootstrap.Executable: ssh.Config.Paths.CurrentExecutable(ssh.Environment), // TODO: Does this make sense?
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue