Skip to content

Commit

Permalink
Merge pull request #208 from evanlinjin/fix/dmsgpty-ui-https-#206
Browse files Browse the repository at this point in the history
Updated hypervisor to work with TLS and updated to latest dmsg.
  • Loading branch information
jdknives authored Mar 6, 2020
2 parents fa385fa + 86d3d2b commit 90794a5
Show file tree
Hide file tree
Showing 14 changed files with 140 additions and 73 deletions.
14 changes: 11 additions & 3 deletions cmd/hypervisor/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,17 @@ var rootCmd = &cobra.Command{
prepareDmsg(hv, conf)
}

// Serve HTTP.
log.WithField("http_addr", conf.HTTPAddr).Info("Serving HTTP.")
if err := http.ListenAndServe(conf.HTTPAddr, hv); err != nil {
// Serve HTTP(s).
log := log.
WithField("addr", conf.HTTPAddr).
WithField("tls", conf.EnableTLS)
log.Info("Serving hypervisor...")
if conf.EnableTLS {
err = http.ListenAndServeTLS(conf.HTTPAddr, conf.TLSCertFile, conf.TLSKeyFile, hv)
} else {
err = http.ListenAndServe(conf.HTTPAddr, hv)
}
if err != nil {
log.WithError(err).Fatal("Hypervisor exited with error.")
}
log.Info("Good bye!")
Expand Down
6 changes: 3 additions & 3 deletions cmd/skywire-cli/commands/mdisc/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ var availableServersCmd = &cobra.Command{

func printAvailableServers(entries []*disc.Entry) {
w := tabwriter.NewWriter(os.Stdout, 0, 0, 5, ' ', tabwriter.TabIndent)
_, err := fmt.Fprintln(w, "version\tregistered\tpublic-key\taddress\tport\tconns")
_, err := fmt.Fprintln(w, "version\tregistered\tpublic-key\taddress\tavailable-sessions")
internal.Catch(err)
for _, entry := range entries {
_, err := fmt.Fprintf(w, "%s\t%d\t%s\t%s\t%s\t%d\n",
entry.Version, entry.Timestamp, entry.Static, entry.Server.Address, entry.Server.Port, entry.Server.AvailableConnections)
_, err := fmt.Fprintf(w, "%s\t%d\t%s\t%s\t%d\n",
entry.Version, entry.Timestamp, entry.Static, entry.Server.Address, entry.Server.AvailableSessions)
internal.Catch(err)
}
internal.Catch(w.Flush())
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/SkycoinProject/skywire-mainnet
go 1.13

require (
github.com/SkycoinProject/dmsg v0.0.0-20200305081343-7a67392d759d
github.com/SkycoinProject/dmsg v0.0.0-20200306131535-fabb2c8177e9
github.com/SkycoinProject/skycoin v0.27.0
github.com/SkycoinProject/yamux v0.0.0-20191213015001-a36efeefbf6a
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/SkycoinProject/dmsg v0.0.0-20200305081343-7a67392d759d h1:2vjoH2HOsRRvqvXQb2K4uQnqaMRJnYiDpsfCRxixzvs=
github.com/SkycoinProject/dmsg v0.0.0-20200305081343-7a67392d759d/go.mod h1:DzykXMLlx6Fx0fGjZsCIRas/MIvxW8DZpmDA6f2nCRk=
github.com/SkycoinProject/dmsg v0.0.0-20200306131535-fabb2c8177e9 h1:ce/1vcQhEX+8TkwX4PUUE2BVHA4sHNCPf8af7OVhPVE=
github.com/SkycoinProject/dmsg v0.0.0-20200306131535-fabb2c8177e9/go.mod h1:DzykXMLlx6Fx0fGjZsCIRas/MIvxW8DZpmDA6f2nCRk=
github.com/SkycoinProject/skycoin v0.26.0/go.mod h1:xqPLOKh5B6GBZlGA7B5IJfQmCy7mwimD9NlqxR3gMXo=
github.com/SkycoinProject/skycoin v0.27.0 h1:N3IHxj8ossHOcsxLYOYugT+OaELLncYHJHxbbYLPPmY=
github.com/SkycoinProject/skycoin v0.27.0/go.mod h1:xqPLOKh5B6GBZlGA7B5IJfQmCy7mwimD9NlqxR3gMXo=
Expand Down
3 changes: 3 additions & 0 deletions pkg/hypervisor/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ type Config struct {
DmsgDiscovery string `json:"dmsg_discovery"` // Dmsg discovery address.
DmsgPort uint16 `json:"dmsg_port"` // Dmsg port to serve on.
HTTPAddr string `json:"http_addr"` // HTTP address to serve API/web UI on.
EnableTLS bool `json:"enable_tls"` // Whether to enable TLS.
TLSCertFile string `json:"tls_cert_file"` // TLS cert file location.
TLSKeyFile string `json:"tls_key_file"` // TLS key file location.
}

func makeConfig(testenv bool) Config {
Expand Down
2 changes: 1 addition & 1 deletion pkg/snet/snettest/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func createDmsgSrv(t *testing.T, dc disc.APIClient) (srv *dmsg.Server, srvErr <-
require.NoError(t, err)
l, err := nettest.NewLocalListener("tcp")
require.NoError(t, err)
srv = dmsg.NewServer(pk, sk, dc)
srv = dmsg.NewServer(pk, sk, dc, 100)
errCh := make(chan error, 1)
go func() {
errCh <- srv.Serve(l, "")
Expand Down
15 changes: 9 additions & 6 deletions vendor/github.com/SkycoinProject/dmsg/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 15 additions & 15 deletions vendor/github.com/SkycoinProject/dmsg/disc/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 21 additions & 14 deletions vendor/github.com/SkycoinProject/dmsg/disc/entry.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions vendor/github.com/SkycoinProject/dmsg/disc/testing.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 90794a5

Please sign in to comment.