2022-07-01 19:50:09 +02:00
|
|
|
CREATE TABLE schema_migrations (version uint64,dirty bool);
|
|
|
|
CREATE UNIQUE INDEX version_unique ON schema_migrations (version);
|
2022-08-17 21:24:09 +02:00
|
|
|
CREATE TABLE client (
|
2022-09-22 07:02:38 +02:00
|
|
|
clientid varchar(36) NOT NULL,
|
2022-08-17 21:24:09 +02:00
|
|
|
userid varchar(36) NOT NULL,
|
2022-08-27 01:21:19 +02:00
|
|
|
activesessionid varchar(36) NOT NULL,
|
2022-08-17 21:24:09 +02:00
|
|
|
userpublickeybytes blob NOT NULL,
|
2022-10-04 20:45:24 +02:00
|
|
|
userprivatekeybytes blob NOT NULL,
|
|
|
|
winsize json NOT NULL
|
2023-12-27 22:11:53 +01:00
|
|
|
, clientopts json NOT NULL DEFAULT '', feopts json NOT NULL DEFAULT '{}', cmdstoretype varchar(20) DEFAULT 'session', openaiopts json NOT NULL DEFAULT '{}', releaseinfo json NOT NULL DEFAULT '{}');
|
2022-07-01 19:50:09 +02:00
|
|
|
CREATE TABLE session (
|
|
|
|
sessionid varchar(36) PRIMARY KEY,
|
2022-08-08 17:34:59 +02:00
|
|
|
name varchar(50) NOT NULL,
|
|
|
|
sessionidx int NOT NULL,
|
|
|
|
activescreenid varchar(36) NOT NULL,
|
2022-08-17 21:24:09 +02:00
|
|
|
notifynum int NOT NULL,
|
2022-12-25 22:03:11 +01:00
|
|
|
archived boolean NOT NULL,
|
2022-12-25 22:21:48 +01:00
|
|
|
archivedts bigint NOT NULL,
|
2023-03-15 00:37:22 +01:00
|
|
|
sharemode varchar(12) NOT NULL);
|
2022-08-08 17:34:59 +02:00
|
|
|
CREATE TABLE remote_instance (
|
|
|
|
riid varchar(36) PRIMARY KEY,
|
|
|
|
name varchar(50) NOT NULL,
|
2022-07-01 19:50:09 +02:00
|
|
|
sessionid varchar(36) NOT NULL,
|
2023-03-15 00:37:22 +01:00
|
|
|
screenid varchar(36) NOT NULL,
|
2022-08-24 22:21:54 +02:00
|
|
|
remoteownerid varchar(36) NOT NULL,
|
2022-07-01 19:50:09 +02:00
|
|
|
remoteid varchar(36) NOT NULL,
|
2022-11-28 09:13:00 +01:00
|
|
|
festate json NOT NULL,
|
|
|
|
statebasehash varchar(36) NOT NULL,
|
|
|
|
statediffhasharr json NOT NULL
|
|
|
|
);
|
|
|
|
CREATE TABLE state_base (
|
|
|
|
basehash varchar(36) PRIMARY KEY,
|
|
|
|
ts bigint NOT NULL,
|
|
|
|
version varchar(200) NOT NULL,
|
|
|
|
data blob NOT NULL
|
|
|
|
);
|
|
|
|
CREATE TABLE state_diff (
|
|
|
|
diffhash varchar(36) PRIMARY KEY,
|
|
|
|
ts bigint NOT NULL,
|
|
|
|
basehash varchar(36) NOT NULL,
|
|
|
|
diffhasharr json NOT NULL,
|
|
|
|
data blob NOT NULL
|
2022-07-01 19:50:09 +02:00
|
|
|
);
|
|
|
|
CREATE TABLE remote (
|
|
|
|
remoteid varchar(36) PRIMARY KEY,
|
|
|
|
remotetype varchar(10) NOT NULL,
|
2022-08-17 21:24:09 +02:00
|
|
|
remotealias varchar(50) NOT NULL,
|
|
|
|
remotecanonicalname varchar(200) NOT NULL,
|
|
|
|
remoteuser varchar(50) NOT NULL,
|
|
|
|
remotehost varchar(200) NOT NULL,
|
2022-08-21 21:31:29 +02:00
|
|
|
connectmode varchar(20) NOT NULL,
|
2022-10-04 20:45:24 +02:00
|
|
|
autoinstall boolean NOT NULL,
|
2022-08-08 17:34:59 +02:00
|
|
|
sshopts json NOT NULL,
|
2022-08-21 21:31:29 +02:00
|
|
|
remoteopts json NOT NULL,
|
2022-09-14 02:11:36 +02:00
|
|
|
lastconnectts bigint NOT NULL,
|
2022-10-04 20:45:24 +02:00
|
|
|
local boolean NOT NULL,
|
2022-09-14 21:06:55 +02:00
|
|
|
archived boolean NOT NULL,
|
ssh config import (#156)
* create migrations for required database change
This is a first attempt that does not appear to be working properly. It
requires review.
* fix errors in db migrations
The previous commit had an extra json call that broke the update and did
not remove the imported interies during a downgrade.
* change migrations to use column instead of json
It makes more sense to associate the source of a config with the remote
type than the sshopts type. This change makes that clear in the database
structure.
* ensure adding a remote manually tags correctly
Using the usual way of adding a remote should result in a sshconfigsrc
of "waveterm-manual". This will be important for filtering out remotes
installed manually and remotes installed via import
* create basic structure for parsing ssh config
This entails creating a new command, making it possible to query only
the imported remotes from the database, and implementing the logic to
handle all of the updates needed.
This needs improvements in a few areas:
- the /etc/ssh/config needs to be parsed as well
- the logic for editing exisiting imported remotes needs to be written
- error handling needs to be improved
- update packet responses need to be provided
* add sshkey support and implement editing
We now search for the ssh identity keyfile and add it if it is found.
Additionally, the logic to edit previously imported ssh hosts has been
added.
* combine hosts from user and system ssh config
We now check both the user ~/.ssh/config as well as the /etc/ssh/config
for hosts. This loops through each file starting with the user one. For
each host, it selects the first pattern without a wildcard and chooses
that to be the alias. If any future hosts are found to have the same
alias, they are skipped. Errors are raised if neither config file can be
opened or no aliases were found.
* improve logging and error reporting
Error reporting is now shortcircuited in cases of individual remotes in
order to allow the other remotes to continue. These errors are now
printed to logs instead.
* allow imports to edit ssh port
Previously, ssh ports could not be edited after the fact. Unfortunately,
this can cause problems since the port can be changed in an ssh config
file. To address this, we allow imports to change the port if a host
with the same canonical name had previously been imported.
* fix response to parse command
* fix error handline for alias parsing
Small mistake of checking for equality instead of inequality
* fix the ability to overwrite hostName with alias
if ssh_config does not find Hostname, it won't output an error. Now we
compare against the result instead of looking for an error.
* fix the error catching for User and Port
This fixes the same problem where parsing the config doesn't give an
error in the case when nothing is found. As before, this checks for a
blank result instead.
* remove unused code
* remove repeated canonical name check
The logic that checks for an existing canonical name already exists in
the AddRemote function, so it is not needed here.
Secondly, we now only allow edits of previously created remotes if they
have not been archived. If they have, the usual logic for creating a new
remote takes precedence.
Lastly, there is no need to archive a remote that has already been
archived so an additional check has been added.
* allow archives to preserve the SSHConfigSrc
* add log message for archiving of imported remotes
* create variables for string variants
Matches existing code style
* add cleanup for opened files
* move migration 25 to migration 26 (already merged a migration 25)
* fix RemoteRuntimeState in ModelUpdate by moving type to sstore.go. Fix some bugs in remote:parse. Fix key/identityfile, return value, and remote editing (should go through msh). remote sudo. add info messages around parse status
* fix issue with archiving the sshconfigsrc
A bug in RemoteType's FromMap caused the loss of sshconfigsrc during the
conversion. This has been corrected and the schema has been updated.
* fix order of archiving removed imported remotes
Previously, if the canonical name changed, the code would try to create
a new remote before archiving the old one. This did not work if the
alias didn't change. Now we archive first and add a new remote after.
* fix ability to change port when importing config
Importing from sshconfig needs to allow the port to change. This was not
happening because of a bug that has been corrected.
* always use host in place of hostname
Since host is the key actually searched for in the ssh config file,
searching for user@hostName may not actually work. To avoid this, we now
always use user@host instead.
* automatically determine ConnectMode
This aims to select a connection mode based off what is provided in the
ssh config file. It aims for auto connections when possible but will
fall back to manual if we can't easily support it
* remove sshkeysource migration number confilict
Previously had conflicting migration numbers of 26. The change not in
the main branch has been moved to 27 to remove the conflict.
* move sshkeysource migration to migration 28
* add WaveOptions flag parsing for ssh config
This is currently being used to allow users to force manual connect mode
if desired. It will also be used to force skipping options in the future
but that is not complete in this commit.
* implement ignore flag for ssh config parsing
The ignore flag will now archive an imported remote if it previously
existed and not create a new remote in its place.
* fix discovery of identity file
Previously, a ~ in the identity file's path was not expanded to the home
dir. Because of this, files with a ~ were previously identified as
invalid files. By expanding it during the search, this is no longer the
case.
* disable frontend edit button for imported remotes
Imported Remotes should not be editable in waveterm by users. This edit
makes it clear that the button will not work for those cases. Further
edits may be needed to explain why it doesn't work and what to do
instead.
* add backend rejection of updating imported remote
As before, we don't want manual editing of an imported remote inside the
app. This ensures that it can't happen on the backend.
* create tooltips for sshconfig edit/delete buttons
For remotes that are imported, edits are not allowed. This adds a
tooltip that explains what to do instead.
Deleting remotes that are imported is allowed, but they will come back
if the user imports again. The tooltip explains a way to avoid this.
* add logo after name for imported remotes
In the connections screen, there previously was not a way to tell
imported connections from manually created connections. This change adds
a logo after the imported ones to differentiate them.
* small formatting updates
* add import tooltip to connection modal
Added the logo for an imported config to the connection modal. It also
provides a short description when it the mouse hovers over it.
* add button to import ssh config
Make the command into a button for a simple gui interface.
Also ran prettier to clean up some syntax.
* remove strict casing on WaveOptions
WaveOptions was previously very specific about the casing of the ignore
and connectmode subcommands. With this update, the casing is
automatically converted to lowercase and can be ignored.
* add status dot before name in connections screen
* add space and tooltip to connection imported icon
* re-prettier
2023-12-28 20:09:41 +01:00
|
|
|
remoteidx int NOT NULL,
|
|
|
|
statevars json NOT NULL DEFAULT '{}',
|
|
|
|
sshconfigsrc varchar(36) NOT NULL DEFAULT 'waveterm-manual',
|
|
|
|
openaiopts json NOT NULL DEFAULT '{}');
|
2022-07-01 19:50:09 +02:00
|
|
|
CREATE TABLE history (
|
2022-08-11 21:07:41 +02:00
|
|
|
historyid varchar(36) PRIMARY KEY,
|
|
|
|
ts bigint NOT NULL,
|
|
|
|
userid varchar(36) NOT NULL,
|
2022-07-01 19:50:09 +02:00
|
|
|
sessionid varchar(36) NOT NULL,
|
2022-08-11 21:07:41 +02:00
|
|
|
screenid varchar(36) NOT NULL,
|
|
|
|
lineid int NOT NULL,
|
2022-08-28 23:24:05 +02:00
|
|
|
remoteownerid varchar(36) NOT NULL,
|
|
|
|
remoteid varchar(36) NOT NULL,
|
|
|
|
remotename varchar(50) NOT NULL,
|
2022-08-12 08:45:15 +02:00
|
|
|
haderror boolean NOT NULL,
|
2022-08-28 23:24:05 +02:00
|
|
|
cmdstr text NOT NULL,
|
2022-12-20 03:52:08 +01:00
|
|
|
ismetacmd boolean,
|
2023-12-27 22:11:53 +01:00
|
|
|
linenum int NOT NULL DEFAULT 0, exitcode int NULL DEFAULT NULL, durationms int NULL DEFAULT NULL, festate json NOT NULL DEFAULT '{}', tags json NOT NULL DEFAULT '{}', status varchar(10) NOT NULL DEFAULT 'unknown');
|
2023-03-20 20:19:48 +01:00
|
|
|
CREATE TABLE activity (
|
|
|
|
day varchar(20) PRIMARY KEY,
|
|
|
|
uploaded boolean NOT NULL,
|
|
|
|
tdata json NOT NULL,
|
|
|
|
tzname varchar(50) NOT NULL,
|
|
|
|
tzoffset int NOT NULL,
|
|
|
|
clientversion varchar(20) NOT NULL,
|
|
|
|
clientarch varchar(20) NOT NULL
|
|
|
|
, buildtime varchar(20) NOT NULL DEFAULT '-', osrelease varchar(20) NOT NULL DEFAULT '-');
|
2023-02-21 00:42:27 +01:00
|
|
|
CREATE TABLE bookmark (
|
|
|
|
bookmarkid varchar(36) PRIMARY KEY,
|
|
|
|
createdts bigint NOT NULL,
|
|
|
|
cmdstr text NOT NULL,
|
|
|
|
alias varchar(50) NOT NULL,
|
|
|
|
tags json NOT NULL,
|
|
|
|
description text NOT NULL
|
|
|
|
);
|
|
|
|
CREATE TABLE bookmark_order (
|
|
|
|
tag varchar(50) NOT NULL,
|
|
|
|
bookmarkid varchar(36) NOT NULL,
|
|
|
|
orderidx int NOT NULL,
|
|
|
|
PRIMARY KEY (tag, bookmarkid)
|
|
|
|
);
|
2023-03-15 00:37:22 +01:00
|
|
|
CREATE TABLE playbook (
|
|
|
|
playbookid varchar(36) PRIMARY KEY,
|
|
|
|
playbookname varchar(100) NOT NULL,
|
|
|
|
description text NOT NULL,
|
|
|
|
entryids json NOT NULL
|
|
|
|
);
|
|
|
|
CREATE TABLE playbook_entry (
|
|
|
|
entryid varchar(36) PRIMARY KEY,
|
|
|
|
playbookid varchar(36) NOT NULL,
|
|
|
|
description text NOT NULL,
|
|
|
|
alias varchar(50) NOT NULL,
|
|
|
|
cmdstr text NOT NULL,
|
|
|
|
createdts bigint NOT NULL,
|
|
|
|
updatedts bigint NOT NULL
|
|
|
|
);
|
|
|
|
CREATE TABLE cloud_session (
|
|
|
|
sessionid varchar(36) PRIMARY KEY,
|
|
|
|
viewkey varchar(50) NOT NULL,
|
|
|
|
writekey varchar(50) NOT NULL,
|
|
|
|
enckey varchar(100) NOT NULL,
|
|
|
|
enctype varchar(50) NOT NULL,
|
|
|
|
vts bigint NOT NULL,
|
|
|
|
acl json NOT NULL
|
|
|
|
);
|
|
|
|
CREATE TABLE cloud_update (
|
|
|
|
updateid varchar(36) PRIMARY KEY,
|
|
|
|
ts bigint NOT NULL,
|
|
|
|
updatetype varchar(50) NOT NULL,
|
|
|
|
updatekeys json NOT NULL
|
|
|
|
);
|
2023-03-21 05:38:39 +01:00
|
|
|
CREATE TABLE cmd_migrate (
|
2023-03-15 00:37:22 +01:00
|
|
|
sessionid varchar(36) NOT NULL,
|
|
|
|
screenid varchar(36) NOT NULL,
|
2023-03-21 05:38:39 +01:00
|
|
|
cmdid varchar(36) NOT NULL
|
|
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS "screen" (
|
|
|
|
screenid varchar(36) NOT NULL,
|
|
|
|
sessionid varchar(36) NOT NULL,
|
2023-03-15 00:37:22 +01:00
|
|
|
name varchar(50) NOT NULL,
|
|
|
|
screenidx int NOT NULL,
|
|
|
|
screenopts json NOT NULL,
|
|
|
|
ownerid varchar(36) NOT NULL,
|
|
|
|
sharemode varchar(12) NOT NULL,
|
|
|
|
curremoteownerid varchar(36) NOT NULL,
|
|
|
|
curremoteid varchar(36) NOT NULL,
|
|
|
|
curremotename varchar(50) NOT NULL,
|
|
|
|
nextlinenum int NOT NULL,
|
|
|
|
selectedline int NOT NULL,
|
|
|
|
anchor json NOT NULL,
|
|
|
|
focustype varchar(12) NOT NULL,
|
|
|
|
archived boolean NOT NULL,
|
2023-12-27 22:11:53 +01:00
|
|
|
archivedts bigint NOT NULL, webshareopts json NOT NULL DEFAULT 'null', screenviewopts json DEFAULT '{}',
|
2023-03-21 05:38:39 +01:00
|
|
|
PRIMARY KEY (screenid)
|
|
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS "line" (
|
|
|
|
screenid varchar(36) NOT NULL,
|
|
|
|
userid varchar(36) NOT NULL,
|
|
|
|
lineid varchar(36) NOT NULL,
|
|
|
|
ts bigint NOT NULL,
|
|
|
|
linenum int NOT NULL,
|
|
|
|
linenumtemp boolean NOT NULL,
|
|
|
|
linetype varchar(10) NOT NULL,
|
|
|
|
linelocal boolean NOT NULL,
|
|
|
|
text text NOT NULL,
|
|
|
|
ephemeral boolean NOT NULL,
|
|
|
|
contentheight int NOT NULL,
|
|
|
|
star int NOT NULL,
|
|
|
|
archived boolean NOT NULL,
|
2023-09-02 00:21:35 +02:00
|
|
|
renderer varchar(50) NOT NULL, linestate json NOT NULL DEFAULT '{}',
|
2023-03-21 05:38:39 +01:00
|
|
|
PRIMARY KEY (screenid, lineid)
|
|
|
|
);
|
2023-09-02 00:21:35 +02:00
|
|
|
CREATE TABLE screenupdate (
|
|
|
|
updateid integer PRIMARY KEY,
|
2023-03-21 05:38:39 +01:00
|
|
|
screenid varchar(36) NOT NULL,
|
2023-09-02 00:21:35 +02:00
|
|
|
lineid varchar(36) NOT NULL,
|
|
|
|
updatetype varchar(50) NOT NULL,
|
|
|
|
updatets bigint NOT NULL
|
|
|
|
);
|
|
|
|
CREATE TABLE webptypos (
|
|
|
|
screenid varchar(36) NOT NULL,
|
|
|
|
lineid varchar(36) NOT NULL,
|
|
|
|
ptypos bigint NOT NULL,
|
|
|
|
PRIMARY KEY (screenid, lineid)
|
|
|
|
);
|
|
|
|
CREATE INDEX idx_screenupdate_ids ON screenupdate (screenid, lineid);
|
|
|
|
CREATE TABLE IF NOT EXISTS "cmd" (
|
|
|
|
screenid varchar(36) NOT NULL,
|
|
|
|
lineid varchar(36) NOT NULL,
|
2023-03-21 05:38:39 +01:00
|
|
|
remoteownerid varchar(36) NOT NULL,
|
|
|
|
remoteid varchar(36) NOT NULL,
|
|
|
|
remotename varchar(50) NOT NULL,
|
|
|
|
cmdstr text NOT NULL,
|
|
|
|
rawcmdstr text NOT NULL,
|
|
|
|
festate json NOT NULL,
|
|
|
|
statebasehash varchar(36) NOT NULL,
|
|
|
|
statediffhasharr json NOT NULL,
|
|
|
|
termopts json NOT NULL,
|
|
|
|
origtermopts json NOT NULL,
|
|
|
|
status varchar(10) NOT NULL,
|
2023-09-02 00:21:35 +02:00
|
|
|
cmdpid int NOT NULL,
|
|
|
|
remotepid int NOT NULL,
|
|
|
|
donets bigint NOT NULL,
|
|
|
|
exitcode int NOT NULL,
|
|
|
|
durationms int NOT NULL,
|
2023-03-21 05:38:39 +01:00
|
|
|
rtnstate boolean NOT NULL,
|
|
|
|
rtnbasehash varchar(36) NOT NULL,
|
|
|
|
rtndiffhasharr json NOT NULL,
|
2023-09-02 00:21:35 +02:00
|
|
|
runout json NOT NULL,
|
|
|
|
PRIMARY KEY (screenid, lineid)
|
2023-03-24 18:34:07 +01:00
|
|
|
);
|
2023-09-02 00:21:35 +02:00
|
|
|
CREATE TABLE cmd_migrate20 (
|
2023-03-29 21:40:53 +02:00
|
|
|
screenid varchar(36) NOT NULL,
|
|
|
|
lineid varchar(36) NOT NULL,
|
2023-09-02 00:21:35 +02:00
|
|
|
cmdid varchar(36) NOT NULL,
|
2023-03-29 21:40:53 +02:00
|
|
|
PRIMARY KEY (screenid, lineid)
|
|
|
|
);
|
2023-12-27 22:11:53 +01:00
|
|
|
CREATE TABLE session_tombstone (
|
|
|
|
sessionid varchar(36) PRIMARY KEY,
|
|
|
|
deletedts bigint NOT NULL,
|
|
|
|
name varchar(50) NOT NULL
|
|
|
|
);
|
|
|
|
CREATE TABLE screen_tombstone (
|
|
|
|
screenid varchar(36) PRIMARY KEY,
|
|
|
|
sessionid varchar(36) NOT NULL,
|
|
|
|
deletedts bigint NOT NULL,
|
|
|
|
screenopts json NOT NULL,
|
|
|
|
name varchar(50) NOT NULL
|
|
|
|
);
|