Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

package defaults with gen-config -p #585

Merged
merged 5 commits into from
Nov 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -164,16 +164,16 @@ build-deploy: ## Build for deployment Docker images
${OPTS} go build ${BUILD_OPTS_DEPLOY} -o /release/apps/skysocks ./cmd/apps/skysocks
${OPTS} go build ${BUILD_OPTS_DEPLOY} -o /release/apps/skysocks-client ./cmd/apps/skysocks-client

package-amd64: install-deps-ui lint-ui build-ui ## Build the debian package.
package-amd64: ## Build the debian package.
scripts/dPKGBUILD.sh amd64

package-arm64: install-deps-ui lint-ui build-ui ## Build the debian package.
package-arm64: ## Build the debian package.
scripts/dPKGBUILD.sh arm64

package-armhf: install-deps-ui lint-ui build-ui ## Build the debian package.
package-armhf: ## Build the debian package.
scripts/dPKGBUILD.sh armhf

all-packages: install-deps-ui lint-ui build-ui
all-packages: ## Build the debian package.
scripts/dPKGBUILD.sh amd64
scripts/dPKGBUILD.sh arm64
scripts/dPKGBUILD.sh armhf
Expand Down
18 changes: 12 additions & 6 deletions cmd/skywire-cli/commands/visor/gen-config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,19 @@ func init() {
}

var (
sk cipher.SecKey
output string
replace bool
testEnv bool
hypervisor bool
sk cipher.SecKey
output string
replace bool
testEnv bool
packageConfig bool
hypervisor bool
)

func init() {
genConfigCmd.Flags().Var(&sk, "sk", "if unspecified, a random key pair will be generated.")
genConfigCmd.Flags().StringVarP(&output, "output", "o", "skywire-config.json", "path of output config file.")
genConfigCmd.Flags().BoolVarP(&replace, "replace", "r", false, "whether to allow rewrite of a file that already exists (this retains the keys).")
genConfigCmd.Flags().BoolVarP(&packageConfig, "package", "p", false, "use defaults for package-based installations")
genConfigCmd.Flags().BoolVarP(&testEnv, "testenv", "t", false, "whether to use production or test deployment service.")
genConfigCmd.Flags().BoolVar(&hypervisor, "hypervisor", false, "whether to generate hypervisor config.")
}
Expand Down Expand Up @@ -58,7 +60,11 @@ var genConfigCmd = &cobra.Command{

// Determine config type to generate.
var genConf func(log *logging.MasterLogger, confPath string, sk *cipher.SecKey, hypervisor bool) (*visorconfig.V1, error)
if testEnv {

// to be improved later
if packageConfig {
genConf = visorconfig.MakePackageConfig
} else if testEnv {
genConf = visorconfig.MakeTestConfig
} else {
genConf = visorconfig.MakeDefaultConfig
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ require (
github.com/xtaci/lossyconn v0.0.0-20200209145036-adba10fffc37 // indirect
go.etcd.io/bbolt v1.3.5
golang.org/x/net v0.0.0-20200625001655-4c5254603344
golang.org/x/sys v0.0.0-20200929083018-4d22bbb62b3c // indirect
golang.org/x/sys v0.0.0-20200929083018-4d22bbb62b3c
golang.zx2c4.com/wireguard v0.0.20200320
nhooyr.io/websocket v1.8.2
)
Expand Down
7 changes: 5 additions & 2 deletions internal/utclient/mock_api_client.go

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

10 changes: 7 additions & 3 deletions pkg/app/appevent/mock_rpc_client.go

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

9 changes: 6 additions & 3 deletions pkg/app/appnet/mock_networker.go

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

10 changes: 7 additions & 3 deletions pkg/app/appserver/mock_proc_manager.go

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

12 changes: 8 additions & 4 deletions pkg/app/appserver/mock_rpc_ingress_client.go

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

10 changes: 7 additions & 3 deletions pkg/routefinder/rfclient/mock_client.go

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

14 changes: 9 additions & 5 deletions pkg/router/mock_router.go

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

14 changes: 9 additions & 5 deletions pkg/setup/mock_id_reserver.go

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

16 changes: 10 additions & 6 deletions pkg/setup/setupclient/mock_route_group_dialer.go

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

19 changes: 13 additions & 6 deletions pkg/skyenv/values.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (

// Constants for skywire root directories.
const (
DefaultSkywirePath = "/opt/skywire"
TestSkywirePath = "."
DefaultSkywirePath = "."
PackageSkywirePath = "/opt/skywire"
)

// Constants for default services.
Expand Down Expand Up @@ -51,7 +51,7 @@ const (
DefaultDmsgPtyCLINet = "unix"
DefaultDmsgPtyCLIAddr = "/tmp/dmsgpty.sock"
DefaultDmsgPtyWhitelist = DefaultSkywirePath + "/dmsgpty/whitelist.json"
TestDmsgPtyWhiteList = TestSkywirePath + "/dmsgpty/whitelist.json"
PackageDmsgPtyWhiteList = PackageSkywirePath + "/dmsgpty/whitelist.json"
)

// Default STCP constants.
Expand Down Expand Up @@ -93,21 +93,28 @@ const (
DefaultAppSrvAddr = "localhost:5505"
AppDiscUpdateInterval = 30 * time.Second
DefaultAppLocalPath = DefaultSkywirePath + "/local"
TestAppLocalPath = TestSkywirePath + "/local"
TestAppBinPath = TestSkywirePath + "/apps"
DefaultAppBinPath = DefaultSkywirePath + "/apps"
DefaultLogLevel = "info"
PackageAppLocalPath = PackageSkywirePath + "/local"
PackageAppBinPath = PackageSkywirePath + "/apps"
)

// Default routing constants
const (
DefaultTpLogStore = DefaultSkywirePath + "/transport_logs"
TestTpLogStore = TestSkywirePath + "/transport_logs"
PackageTpLogStore = PackageSkywirePath + "/transport_logs"
)

// Default hypervisor constants
const (
DefaultHypervisorDB = ".skycoin/hypervisor/users.db"
DefaultEnableAuth = true
DefaultEnableTLS = false
DefaultTLSKey = DefaultSkywirePath + "/ssl/key.pem"
DefaultTLSCert = DefaultSkywirePath + "/ssl/cert.pem"
PackageEnableTLS = true
PackageTLSKey = PackageSkywirePath + "/ssl/key.pem"
PackageTLSCert = PackageSkywirePath + "/ssl/cert.pem"
)

// MustPK unmarshals string PK to cipher.PubKey. It panics if unmarshaling fails.
Expand Down
11 changes: 7 additions & 4 deletions pkg/snet/arclient/mock_api_client.go

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

11 changes: 7 additions & 4 deletions pkg/snet/mock_dialer.go

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

10 changes: 9 additions & 1 deletion pkg/visor/hypervisorconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func GenerateWorkDirConfig(testenv bool) Config {
// GenerateHomeConfig generates a config with default values and uses db from user's home folder.
func GenerateHomeConfig(testenv bool) Config {
c := MakeConfig(testenv)
c.DBPath = filepath.Join(pathutil.HomeDir(), ".skycoin/hypervisor/users.db")
c.DBPath = filepath.Join(pathutil.HomeDir(), skyenv.DefaultHypervisorDB)
return c
}

Expand Down Expand Up @@ -123,6 +123,14 @@ func (c *Config) FillDefaults(testEnv bool) {
}

c.Cookies.FillDefaults()

c.EnableAuth = skyenv.DefaultEnableAuth

c.EnableTLS = skyenv.DefaultEnableTLS

c.TLSCertFile = skyenv.DefaultTLSCert
c.TLSKeyFile = skyenv.DefaultTLSKey

}

// Parse parses the file in path, and decodes to the config.
Expand Down
34 changes: 30 additions & 4 deletions pkg/visor/visorconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,36 @@ func MakeTestConfig(log *logging.MasterLogger, confPath string, sk *cipher.SecKe
conf.Hypervisor.DmsgDiscovery = conf.Transport.Discovery
}

conf.Dmsgpty.AuthFile = skyenv.TestDmsgPtyWhiteList
conf.Transport.LogStore.Location = skyenv.TestTpLogStore
conf.Launcher.LocalPath = skyenv.TestAppLocalPath
conf.Launcher.BinPath = skyenv.TestAppBinPath
return conf, nil
}

// MakePackageConfig acts like MakeDefaultConfig but use package config defaults
func MakePackageConfig(log *logging.MasterLogger, confPath string, sk *cipher.SecKey, hypervisor bool) (*V1, error) {
conf, err := MakeDefaultConfig(log, confPath, sk, hypervisor)
if err != nil {
return nil, err
}

conf.Dmsgpty = &V1Dmsgpty{
Port: skyenv.DmsgPtyPort,
AuthFile: skyenv.PackageDmsgPtyWhiteList,
CLINet: skyenv.DefaultDmsgPtyCLINet,
CLIAddr: skyenv.DefaultDmsgPtyCLIAddr,
}

conf.Transport.LogStore = &V1LogStore{
Type: "file",
Location: skyenv.PackageTpLogStore,
}

conf.Launcher.BinPath = skyenv.PackageAppBinPath
conf.Launcher.LocalPath = skyenv.PackageAppLocalPath

if conf.Hypervisor != nil {
conf.Hypervisor.EnableAuth = skyenv.DefaultEnableAuth
conf.Hypervisor.EnableTLS = skyenv.PackageEnableTLS
conf.Hypervisor.TLSKeyFile = skyenv.PackageTLSKey
conf.Hypervisor.TLSCertFile = skyenv.PackageTLSCert
}
return conf, nil
}
Loading