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

-p flag for skywire-cli visor & skywire-hypervisor gen-config to generate correct default config for skybian (or package-based installations) #572

Closed
2 tasks done
0pcom opened this issue Oct 22, 2020 · 0 comments

Comments

@0pcom
Copy link
Collaborator

0pcom commented Oct 22, 2020

Feature description

-p flag for skywire-cli visor & skywire-hypervisor gen-config to generate correct default config for skybian (or package-based installations)

example for the hypervisor:

[user@linux  ~]$ skywire-hypervisor gen-config -rpo /etc/skywire-hypervisor.json
[2020-10-20T18:48:15-05:00] INFO [pathutil]: Wrote 713 bytes to /etc/skywire-hypervisor.json
{
	"public_key": "03601fb44cbf660f491cdc2cf56af362503ee34e74008647c135330118e00a0cd0",
	"secret_key": "442cec5049b5dbee3fd90199d5f1c46b8338567ee5d371456e784fb78d67ff1d",
	"db_path": "/var/skywire-hypervisor/users.db",
	"enable_auth": true,
	"cookies": {
		"hash_key": "b8da4b60434c0998310caf44bdcafb52817deb9b43bba8bd2c0a9decb0b491f997daad0b4c24d6c7625ddd1872a1a903dec2ec410cca6828879f3b9a7ea50483",
		"block_key": "46afd5872c3870721d4031455823ece7e95e00569e0464c28b70a845c61b368d",
		"expires_duration": 43200000000000,
		"path": "/",
		"domain": ""
	},
	"dmsg_discovery": "http://dmsg.discovery.skywire.skycoin.com",
	"dmsg_port": 46,
	"http_addr": ":8000",
	"enable_tls": true,
	"tls_cert_file": "/etc/skywire-hypervisor/cert.pem",
	"tls_key_file": "/etc/skywire-hypervisor/key.pem"
}

skywire-cl desired example usage:

skywire-cli visor gen-config -rpo /etc/skywire-visor.json
[2020-10-20T18:35:10-05:00] INFO [visor:config]: Flushing config to file. config_version="v1.0.0" filepath="/etc/skywire-visor.json"
[2020-10-20T18:35:10-05:00] INFO [visor:config]: Flushing config to file. config_version="v1.0.0" filepath="/etc/skywire-visor.json"
[2020-10-20T18:35:10-05:00] INFO [skywire-cli]: Updated file '/etc/skywire-visor.json' to: {
	"version": "v1.0.0",
	"sk": "d1b8bfe66ae3fdfd07ff68d84fa5cf2e5a8d9e6123d8bfa928addd4ffaac6c00",
	"pk": "02ca7612d85a35b351a279363b478b760500137627be436089eeddf4522cc4d08e",
	"dmsg": {
		"discovery": "http://dmsg.discovery.skywire.skycoin.com",
		"sessions_count": 1
	},
	"dmsgpty": {
		"port": 22,
		"authorization_file": "/usr/lib/skycoin/skywire/dmsgpty/whitelist.json",
		"cli_network": "unix",
		"cli_address": "/tmp/dmsgpty.sock"
	},
	"stcp": {
		"pk_table": null,
		"local_address": ":7777"
	},
	"transport": {
		"discovery": "http://transport.discovery.skywire.skycoin.com",
		"address_resolver": "http://address.resolver.skywire.skycoin.com",
		"log_store": {
			"type": "file",
			"location": "/usr/lib/skycoin/skywire/transport_logs"
		},
		"trusted_visors": null
	},
	"routing": {
		"setup_nodes": [
			"0324579f003e6b4048bae2def4365e634d8e0e3054a20fc7af49daf2a179658557"
		],
		"route_finder": "http://routefinder.skywire.skycoin.com",
		"route_finder_timeout": "10s"
	},
	"uptime_tracker": {
		"addr": "http://uptime-tracker.skywire.skycoin.com"
	},
	"launcher": {
		"discovery": {
			"update_interval": "30s",
			"proxy_discovery_addr": "http://service.discovery.skycoin.com"
		},
		"apps": [
			{
				"name": "skychat",
				"args": [
					"-addr",
					":8001"
				],
				"auto_start": true,
				"port": 1
			},
			{
				"name": "skysocks",
				"auto_start": true,
				"port": 3
			},
			{
				"name": "skysocks-client",
				"auto_start": false,
				"port": 13
			},
			{
				"name": "vpn-server",
				"auto_start": false,
				"port": 44
			},
			{
				"name": "vpn-client",
				"auto_start": false,
				"port": 43
			}
		],
		"server_addr": "localhost:5505",
		"bin_path": "/usr/bin/apps",
		"local_path": "/usr/lib/skycoin/skywire/local"
	},
	"hypervisors": ["03601fb44cbf660f491cdc2cf56af362503ee34e74008647c135330118e00a0cd0"
"/path/to/hypervisor-key"],
	"cli_addr": "localhost:3435",
	"log_level": "info",
	"shutdown_timeout": "10s",
	"restart_check_delay": "1s"
}

Describe the feature

Is your feature request related to a problem? Please describe.

I'm always frustrated when it comes to the config files requiring extensive manual editing. I've tried scripting the edits but the format of the config.json file is subject to change. Its possible to improve this situation but it is my belief that changes to the source are necessary.

Describe the solution you'd like

For the hypervisor:, the -p flag in the gen-config command should produce a configuration file with default values that skyimager would produce. If it does exactly as specified then all the complexities of manually editing this file would vanish and automated setup and start at the point of installation can be achieved with postinst or .install scripts depening on the distribution in question.

For the -p flag of skywire-cli visor gen-config, the same as above but with a few caveats:

  • I propose that the path for the dmsgpty authorization file, transport logs, and local path be set to either /usr/lib/skycoin/skywire/ or a subdirectory of this path such as /usr/lib/skycoin/skywire/visor
  • I propose that the hypervisor key should be able to be specified either directly or a path to the file containing the hypervisor keys which should just be a regular text file formatted with one key per line. I don't care if that file supports any kind of commenting. If it must be .json then so be it but a regular text file would be easiest to work with.

If this can be achieved, the hypervisor's key can be distributed as a package to nodes and thus turn a complex manual edit into more or less a single command; i.e. apt install hypervisorkey after this package with the key was created on the hypervisor and added to a local package repository. This would also eliminate the need for skyimager to easily set the hypervisor key in visors.

Describe alternatives you've considered

I have postinst / install scripts for both .deb and archlinux which manually generate and edit the config files. Until the recent 0.3.0 update this was working on arch. It worked when I tested this on armbian but that script needs a bit more work to not cause dpkg to produce error messages. I had already determined that scripted config file edits to the extent which was required would require constant maintenance to adapt to a changing config file format, so I abandoned the effort to do that.

Additional context
Add any other context about the problem here.

Possible implementation
Preliminary ideas to get this done.
If you have all details in mind then provide a checklist

  • Start with the hypevisor gen-config -p flag
  • When done do the skywre-cli visor gen-config -p flag
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants