Browse Source

Update dependencies

master
Trevor Slocum 2 months ago
parent
commit
784c75e54c
  1. 4
      README.md
  2. 26
      config.go
  3. 10
      go.mod
  4. 20
      go.sum
  5. 23
      main.go

4
README.md

@ -7,7 +7,7 @@ Host SSH portals to applications
## Demo
Connect to a sshtargate portal which executes the
[cview](https://code.rocketnine.space/tslocum/cview) [presentation demo](https://code.rocketnine.space/tslocum/cview/src/branch/master/demos/presentation/main.go):
[cview](https://code.rocketnine.space/tslocum/cview) [presentation demo](https://code.rocketnine.space/tslocum/cview/1src/branch/master/demos/presentation/main.go):
```bash
ssh cview.rocketnine.space -p 20000
@ -29,7 +29,7 @@ go get code.rocketnine.space/tslocum/sshtargate
## Configure
See [CONFIGURATION.md](https://code.rocketnine.space/tslocum/godoc-static/src/branch/master/CONFIGURATION.md)
See [CONFIGURATION.md](https://code.rocketnine.space/tslocum/sshtargate/src/branch/master/CONFIGURATION.md)
## Support

26
config.go

@ -1,13 +1,5 @@
package main
import (
"fmt"
"io/ioutil"
"log"
"gopkg.in/yaml.v2"
)
type portalConfig struct {
Command string
Host []string `yaml:",flow"`
@ -18,21 +10,3 @@ type appConfig struct {
}
var config = &appConfig{}
func readConfig(configPath string) error {
configData, err := ioutil.ReadFile(configPath)
if err != nil {
return fmt.Errorf("failed to read file: %s", err)
}
err = yaml.Unmarshal(configData, config)
if err != nil {
return fmt.Errorf("failed to parse file: %s", err)
}
if len(config.Portals) == 0 {
log.Println("Warning: No portals are defined")
}
return nil
}

10
go.mod

@ -3,10 +3,10 @@ module code.rocketnine.space/tslocum/sshtargate
go 1.13
require (
code.rocketnine.space/tslocum/ez v0.0.0-20210506054357-569018bd037a
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be
github.com/creack/pty v1.1.11
github.com/gliderlabs/ssh v0.3.2
golang.org/x/crypto v0.0.0-20210415154028-4f45737414dc
golang.org/x/sys v0.0.0-20210419170143-37df388d1f33 // indirect
gopkg.in/yaml.v2 v2.4.0
github.com/creack/pty v1.1.13
github.com/gliderlabs/ssh v0.3.3
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect
)

20
go.sum

@ -1,15 +1,19 @@
code.rocketnine.space/tslocum/ez v0.0.0-20210506054357-569018bd037a h1:Ug5hgK5sM7bdK1gEl/pNLYTtBpFUxCvSCGYkEbUqdmw=
code.rocketnine.space/tslocum/ez v0.0.0-20210506054357-569018bd037a/go.mod h1:SQrM+bQ4eZdyAVTxuF2BNnyAnojHP6Kcmm2vMszoFWw=
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8=
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4=
github.com/creack/pty v1.1.11 h1:07n33Z8lZxZ2qwegKbObQohDhXDQxiMMz1NOUGYlesw=
github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/gliderlabs/ssh v0.3.2 h1:gcfd1Aj/9RQxvygu4l3sak711f/5+VOwBw9C/7+N4EI=
github.com/gliderlabs/ssh v0.3.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
golang.org/x/crypto v0.0.0-20210415154028-4f45737414dc h1:+q90ECDSAQirdykUN6sPEiBXBsp8Csjcca8Oy7bgLTA=
golang.org/x/crypto v0.0.0-20210415154028-4f45737414dc/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
github.com/creack/pty v1.1.13 h1:rTPnd/xocYRjutMfqide2zle1u96upp1gm6eUHKi7us=
github.com/creack/pty v1.1.13/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
github.com/gliderlabs/ssh v0.3.3 h1:mBQ8NiOgDkINJrZtoizkC3nDNYgSaWtxyem6S2XHBtA=
github.com/gliderlabs/ssh v0.3.3/go.mod h1:ZSS+CUoKHDrqVakTfTWUlKSr9MtMFkC4UvtQKD7O914=
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e h1:gsTQYXdTw2Gq7RBsWvlQ91b+aEQ6bXFUngBGuR8sPpI=
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210419170143-37df388d1f33 h1:zah5VTTvBlVRELjcDwGLLaWRHZJQsBtplweVYCii0KM=
golang.org/x/sys v0.0.0-20210419170143-37df388d1f33/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=

23
main.go

@ -6,11 +6,11 @@ import (
"log"
"os"
"os/signal"
"path"
"strings"
"sync"
"syscall"
"code.rocketnine.space/tslocum/ez"
"code.rocketnine.space/tslocum/sshtargate/portal"
"github.com/anmitsu/go-shlex"
)
@ -45,6 +45,14 @@ func main() {
return
}
if configPath == "" {
var err error
configPath, err = ez.DefaultConfigPath("sshtargate")
if err != nil {
log.Fatal(err)
}
}
// TODO: Allow portals to be specified via arguments
// TODO: Catch SIGHUP
@ -60,16 +68,13 @@ func main() {
log.Println("Initializing sshtargate...")
if configPath == "" {
homedir, err := os.UserHomeDir()
if err == nil && homedir != "" {
configPath = path.Join(homedir, ".config", "sshtargate", "config.yaml")
}
err := ez.Deserialize(config, configPath)
if err != nil {
log.Fatalf("failed to read configuration file: %s", err)
}
err := readConfig(configPath)
if err != nil {
log.Fatalf("failed to read configuration file %s: %s", configPath, err)
if len(config.Portals) == 0 {
log.Println("Warning: No portals are defined")
}
for pname, pcfg := range config.Portals {

Loading…
Cancel
Save