-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathseash_dictionary.py
1522 lines (1178 loc) · 55.5 KB
/
seash_dictionary.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"""
Author: Alan Loh
Module: A data structure of all the available commands of seash held in a
dictionary of dictionaries format. Also holds the methods for
parsing user command input and executing functions corresponding
to the command.
User input is parsed according to whether or not it follows the structure
of a command's dictionary and its children. When parsing a command word,
it simply checks to see if the user's input string list contains the command word
at the appropriate index respective to the level of command dictionary currently
being iterated. If it is an user argument, however, it will
simply assign the user's inputted string as the key of the respective
argument's dictionary.
Command input is split by white spaces, so except for the case of arguments
located at the end of the command string series, the parser will not taken
into account file names or arguments that are multiple words long. Also,
because of the way the command callback functions pull out user arguments,
arguments of similar type need different 'name' field in its command dictionary
to help distinguish one from the other.
"""
# for access to list of targets
import seash_global_variables
import seash_exceptions
import command_callbacks
"""
Command dictionary entry format:
'(command key)':{'name':'', 'callback':, 'priority':, 'help_text':'', 'children':[
'(command key)' - The expected command word the user is suppose to input to
call the command's function. If a certain type of argument is expected, a general
word in all caps should be enclosed within square brackets that signify the type
of argument needed. For example, '[TARGET]' if a target ID is expected, or
'[FILENAME]' if the name of a file is needed. Frequently used type includes
'[TARGET]' for targets, '[KEYNAME]' for loaded keynames, '[FILENAME]' for files,
and '[ARGUMENT]' for everything else, so unless another category of arguments is
needed, only use those four strings for command keys of arguments in order for
the parser to work correctly.
For general commands like 'browse', however, the key would simply be the same
command word, 'browse'.
In general, the command key should only be a single word from the whole command
string being implemented, and with the exception of Arguments that occur at the
end of the command string, no user-inputted arguments should ever contain spaces.
'name': - The name of the command word. For general commands, it should be
the same as the command key. For arguments, however, the name should be
distinguishable from other potential arguments of the same command key to avoid
conflicts when pulling the user's argument from the input dictionary during
command execution.
'callback': - Reference to the command callback function associated with the
command string up to this point. Only command dictionaries that mark a complete
command string should contain a reference to a callback method. Otherwise, it
should be set to none. Default location of command callback functions is
command_callbacks.py.
'priority' - Gives the command callback function of the dictionary
containing the key 'priority' the priority of being executed first before
executing the main function of the command string. It should be implemented and
assigned True if needed. Otherwise, it should not be added into any other command
dictionary.
An example of how it should work is in the case of 'as [KEYNAME] browse':
A keyname needs to be set before executing 'browse', so the command dictionary of
'[KEYNAME]' has 'priority' in being executed first to set the user's keyname
before executing 'browse's command function.
'help_text' - The text that will be outputted whenever a user accesses the
help function for that command. Not every command dictionary needs a help text
associated with it, so it defaults as a blank string, and if none of the command
dictionaries in the help call holds a help text, it will default at the last
command dictionary that holds one, namely the dictionary associated with 'help'.
'children' - The list of command dictionaries that follows the current one.
This will determine the validity of an command input when parsing. Each user
inputted string is verified that it follows one of the potential chains of
command strings through the series of command dictionaries. Limit only one
argument dictionary per children list to avoid confusion when parsing user
argument input.
For example, in the command 'show resources', the children of the command
dictionary for 'show' will contain the command dictionary 'resources' along with
any other potential command words that can follow 'show'.
"""
seashcommanddict = {
'on':{'name':'on', 'callback':None, 'help_text':"""
on group
on group [command]
Sets the default group for future commands. Most other commands will only
operate on the vessels specified in the default group. The default group is
listed in the seash command prompt 'identity@group !>'. The 'on' command can
also be prepended to another command to set the group for only this command.
Example:
exampleuser@browsegood !> on WAN
exampleuser@WAN !>
exampleuser@browsegood !> on WAN show ip
1.2.3.4
5.6.7.8
exampleuser@browsegood !>
""", 'children':{
'[TARGET]':{'name':'ontarget', 'callback':command_callbacks.on_target, 'priority':True, 'help_text':'', 'children':{
}}
}},
'as':{'name':'as', 'callback':None, 'help_text':"""
as identity
as identity [command]
Sets the default identity for an operation. The credentials (i.e. public
and private key) for this user are used for the following commands. The
default identity is listed in
the seash command prompt 'identity@group !>'. The 'as' command can also
be prepended to another command to set the identity for just this command.
Example:
exampleuser@%all !> as tom
tom@%all !>
exampleuser@browsegood !> as tom browse
(browse output here)
exampleuser@browsegood !>
""", 'children':{
'[KEYNAME]':{'name':'askeyname', 'callback':command_callbacks.as_keyname, 'priority':True, 'help_text':'', 'children':{
}},
}},
'help':{'name':'help', 'callback':command_callbacks.help, 'priority':True, 'help_text':"""
A target can be either a host:port:vesselname, %ID, or a group name.
loadkeys fn [as identity] -- Loads filename.publickey and filename.privatekey
as keyname [command]-- Run a command using an identity (or changes the default).
on target [command] -- Run a command on a target (or changes the default)
add [target] [to group] -- Adds a target to a new or existing group
remove [target] [from group] -- Removes a target from a group
show -- Displays shell state (see 'help show')
set -- Changes the shell or vessels (see 'help set')
browse -- Find vessels I can control
list -- Update and display information about the vessels
upload localfn (remotefn) -- Upload a file
download remotefn (localfn) -- Download a file (to multiple local files)
cat remotefn -- Display the contents of a remote file
delete remotefn -- Delete a file
reset -- Reset the vessel (clear files / log and stop)
run file [args ...] -- Upload a file and start executing it
stop -- Stop an experiment but leave the log / files
help [extended | set | show ]-- Try 'help extended' for more commands
exit -- Exits the shell
See https://seattle.cs.washington.edu/wiki/RepyTutorial for more info!""",
'children':{}
},
'extended':{'name':'extended', 'callback':command_callbacks.help, 'help_text':"""
Extended commands (not commonly used):
move target to group -- Add target to group, remove target from default
loadstate fn -- Load encrypted shell state from a file with the keyname
savestate fn -- Save the shell's state information to a file with the keyname.
genkeys fn [len] [as identity] -- creates new pub / priv keys (default len=1024)
loadpub fn [as identity] -- loads filename.publickey
loadpriv fn [as identity] -- loads filename.privatekey
start file [args ...] -- Start an experiment (doesn't upload)
contact host:port[:vessel] -- Communicate with a node explicitly
update -- Update information about the vessels
split resourcefn -- Split another vessel off (requires owner)
join -- Join vessels on the same node (requires owner)
""", 'children':{}},
'show':{'name':'show', 'callback':command_callbacks.show, 'help_text':"""
show info -- Display general information about the vessels
show users -- Display the user keys for the vessels
show ownerinfo -- Display owner information for the vessels
show advertise -- Display advertisement information about the vessels
show ip [to file] -- Display the ip addresses of the nodes
show hostname -- Display the hostnames of the nodes
show location -- Display location information (countries) for the nodes
show coordinates -- Display the latitude & longitude of the nodes
show owner -- Display a vessel's owner
show targets -- Display a list of targets
show identities -- Display the known identities
show keys -- Display the known keys
show log [to file] -- Display the log from the vessel (*)
show files -- Display a list of files in the vessel (*)
show resources -- Display the resources / restrictions for the vessel (*)
show offcut -- Display the offcut resource for the node (*)
show timeout -- Display the timeout for nodes
show uploadrate -- Display the upload rate which seash uses to estimate
the required time for a file upload
(*) No need to update prior, the command contacts the nodes anew
""", 'children':{
'info':{'name':'info', 'callback':command_callbacks.show_info, 'help_text':"""
show info
This command prints general information about vessels in the default group
including the version, nodeID, etc.
Example:
exampleuser@%1 !> show info
192.x.x.178:1224:v3 has no information (try 'update' or 'list')
exampleuser@%1 !> update
exampleuser@%1 !> show info
192.x.x.178:1224:v3 {'nodekey': {'e': 65537L, 'n': 929411623458072017781884599109L}, 'version': '0.1r', 'nodename': '192.x.x.175'}
""", 'children':{}},
'users':{'pattern':'users', 'name':'users', 'callback':command_callbacks.show_users, 'help_text':"""
show users
This command lists the set of user keys for vessels in the default group.
If the key has been loaded into seash as an identity, this name will be used.
Example:
exampleuser@browsegood !> show users
192.x.x.178:1224:v3 has no information (try 'update' or 'list')
192.x.x.2:1224:v12 has no information (try 'update' or 'list')
192.x.x.2:1224:v3 has no information (try 'update' or 'list')
exampleuser@browsegood !> update
exampleuser@browsegood !> show users
192.x.x.178:1224:v3 (no keys)
192.x.x.2:1224:v12 65537 136475...
192.x.x.2:1224:v3 exampleuser
""", 'children':{}},
'ownerinfo':{'name':'ownerinfo', 'callback':command_callbacks.show_ownerinfo, 'help_text':"""
show ownerinfo
This lists the ownerinfo strings for vessels in the default group. See
'set ownerinfo' for more details
""", 'children':{}},
'advertise':{'name':'advertise', 'callback':command_callbacks.show_advertise, 'help_text':"""
show advertise
This indicates whether the node manager will advertise the vessel's keys in
the advertise services. See 'set advertise' for more details.
""", 'children':{}},
'ip':{'name':'ip', 'callback':command_callbacks.show_ip, 'help_text':"""
show ip
show ip [to file]
This lists the ip addresses of the vessels in the default group. These IP
addresses may be optionally written to a file.
Note that machines behind a NAT, mobile devices, or other systems with
atypical network connectivity may list a host name instead.
Example:
exampleuser@ !> show targets
browsegood ['192.x.x.2:1224:v12', '192.x.x.2:1224:v3', '193.x.x.42:1224:v18', '219.x.x.62:1224:v4']
%4 ['219.x.x.62:1224:v4']
%all ['192.x.x.2:1224:v12', '192.x.x.2:1224:v3', '193.x.x.42:1224:v18', '219.x.x.62:1224:v4']
%1 ['192.x.x.2:1224:v12']
%3 ['193.x.x.42:1224:v18']
%2 ['192.x.x.2:1224:v3']
exampleuser@ !> on browsegood
exampleuser@browsegood !> show ip
192.x.x.2
193.x.x.42
219.x.x.62
""", 'children':{
'to':{'name':'to', 'callback':None, 'help_text':'', 'children':{
'[FILENAME]':{'name':'filename', 'callback':command_callbacks.show_ip_to_file, 'help_text':'', 'children':{}},
}},
'>':{'name':'>', 'callback':None, 'help_text':'', 'children':{
'[FILENAME]':{'name':'filename', 'callback':command_callbacks.show_ip_to_file, 'help_text':'', 'children':{}},
}},
}},
'hostname':{'name':'hostname', 'callback':command_callbacks.show_hostname, 'help_text':"""
show hostname
This lists the DNS host names for the vessels in the default group. If this
information is not available, this will be listed.
Example:
exampleuser@browsegood !> show ip
192.x.x.2
193.x.x.42
219.x.x.62
exampleuser@browsegood !> show hostname
192.x.x.2 is known as Guest-Laptop.home
193.x.x.42 is known as pl2.maskep.aerop.fr
219.x.x.62 has unknown host information
""", 'children':{}},
'location':{'name':'location', 'callback':command_callbacks.show_location, 'help_text':"""
show location
Uses a geo-IP location service to return information about the position of the
nodes in the current group.
Example:
exampleuser@browsegood !> show ip
192.x.x.2
193.x.x.42
219.x.x.62
exampleuser@browsegood !> show location
%1(192.x.x.2): Location unknown
%3(193.x.x.42): Cesson-svign, France
%4(219.x.x.62): Beijing, China
""", 'children':{}},
'coordinates':{'name':'coordinates', 'callback':command_callbacks.show_coordinates, 'help_text':"""
show coordinates
Uses a geo-IP location service to get approximate latitude and longitude
information about nodes in the current group.
Example:
exampleuser@browsegood !> show location
%1(192.x.x.2): Location unknown
%3(193.x.x.42): Cesson-svign, France
%4(219.x.x.62): Beijing, China
exampleuser@browsegood !> show coordinates
%1(192.x.x.2): Location unknown
%3(193.x.x.42): 48.1167, 1.6167
%4(219.x.x.62): 39.9289, 116.3883
""", 'children':{}},
'owner':{'name':'owner', 'callback':command_callbacks.show_owner, 'help_text':"""
show owner
Displays the owner key (or identity if known) for the vessels in the default
group.
Example:
exampleuser@ !> show targets
browsegood ['192.x.x.2:1224:v12', '192.x.x.2:1224:v3', '193.x.x.42:1224:v18', '219.x.x.62:1224:v4']
%4 ['219.x.x.62:1224:v4']
%all ['192.x.x.2:1224:v12', '192.x.x.2:1224:v3', '193.x.x.42:1224:v18', '219.x.x.62:1224:v4']
%1 ['192.x.x.2:1224:v12']
%3 ['193.x.x.42:1224:v18']
%2 ['192.x.x.2:1224:v3']
exampleuser@ !> on browsegood
exampleuser@browsegood !> show owner
192.x.x2:1224:v12 exampleuser pubkey
192.x.x.2:1224:v3 65537 127603...
193.x.x.42:1224:v18 65537 163967...
219.x.x.62:1224:v4 65537 952875...
""", 'children':{}},
'targets':{'name':'targets', 'callback':command_callbacks.show_targets, 'help_text':"""
show targets
Lists the known targets (groups and individual nodes) that commands may be
run on.
Example:
exampleuser@ !> show targets
%all (empty)
exampleuser@ !> browse
['192.x.x.2:1224', '219.x.x.62:1224', '193.x.x.42:1224']
Added targets: %3(193.x.x.42:1224:v18), %4(219.x.x.62:1224:v4), %1(192.x.x.2:1224:v12), %2(192.x.x.2:1224:v3)
Added group 'browsegood' with 4 targets
yaluen@ !> show targets
browsegood ['192.x.x.2:1224:v12', '192.x.x.2:1224:v3', '193.x.x.42:1224:v18', '219.x.x.62:1224:v4']
%4 ['219.x.x.62:1224:v4']
%all ['192.x.x.2:1224:v12', '192.x.x.2:1224:v3', '193.x.x.42:1224:v18', '219.x.x.62:1224:v4']
%1 ['192.x.x.2:1224:v12']
%3 ['193.x.x.42:1224:v18']
%2 ['192.x.x.2:1224:v3']
""", 'children':{}},
'identities':{'name':'identities', 'callback':command_callbacks.show_identities, 'help_text':"""
show identities
Lists the identities loaded into the shell and whether the public or private
keys are loaded. This does not display the keys themselves (see 'show keys').
Example:
!> show identities
!> loadkeys exampleuser
!> loadkeys guest0
!> loadkeys guest1
!> show identities
guest2 PRIV
exampleuser PUB PRIV
guest0 PUB PRIV
guest1 PUB PRIV
""", 'children':{}},
'keys':{'name':'keys', 'callback':command_callbacks.show_keys, 'help_text':"""
show keys
List the actual keys loaded by the shell. To see identity information, see
'show identities'.
Example:
!> show keys
!> loadkeys yaluen
!> loadpub guest0
!> loadpriv guest1
!> show keys
exampleuser {'e': 65537L, 'n': 967699203053798948061567293973111925102424779L} {'q': 130841985099129780748709L, 'p': 739593793918579524787167931524344434698161314501292256851220768397231L, 'd': 9466433905223884723074560052831388470409993L}
guest0 {'e': 65537L, 'n': 9148459067481753275566379538357634516166379961L} None
guest1 None {'q': 121028014346935113507847L, 'p': 107361553689073802754887L, 'd': 127298628609806695961451784003754746302524139001L}
""", 'children':{}},
'log':{'name':'log', 'callback':command_callbacks.show_log, 'help_text':"""
show log [to filename]
Lists the log of operations from the vessel. This log is populated by print
statements and exceptions from the program running in the vessel.
""", 'children':{
'to':{'name':'to', 'callback':None, 'help_text':'', 'children':{
'[FILENAME]':{'name':'filename', 'callback':command_callbacks.show_log_to_file, 'help_text':'', 'children':{}},
}},
}},
'files':{'name':'files', 'callback':command_callbacks.show_files, 'help_text':"""
show files
Lists the names of the files loaded into vessels in the default groups.
This is similar to dir or ls.
Example:
exampleuser@browsegood !> show files
Files on '192.x.x.2:1224:v3': ''
Files on '193.x.x.42:1224:v18': ''
Files on '219.x.x.62:1224:v4': ''
exampleuser@browsegood !> upload example.1.1.repy
exampleuser@browsegood !> show files
Files on '192.x.x.2:1224:v3': 'example.1.1.repy'
Files on '193.x.x.42:1224:v18': 'example.1.1.repy'
Files on '219.x.x.62:1224:v4': 'example.1.1.repy'
""", 'children':{}},
'resources':{'name':'resources', 'callback':command_callbacks.show_resources, 'help_text':"""
show resources
Lists the resources allotted to vessels in the default group.
""", 'children':{}},
'offcut':{'name':'offcut', 'callback':command_callbacks.show_offcut, 'help_text':"""
show offcut
This lists the amount of resources that will be lost by splitting a vessel or
gained by joining two vessels. This is shown on a per-node basis amongst
all vessels in the default group
""", 'children':{}},
'timeout':{'name':'timeout', 'callback':command_callbacks.show_timeout, 'help_text':"""
show timeout
This shows the amount of time the shell will wait for a command to timeout.
Note that commands like 'run' and 'upload' will use both this value and the
uploadrate setting
Example:
!> show timeout
10
""", 'children':{}},
'uploadrate':{'name':'uploadrate', 'callback':command_callbacks.show_uploadrate, 'help_text':"""
show uploadrate
This lists the minimum rate at which the shell should allow uploads to occur.
Uploads to vessels that go slower than this will be aborted. Note that this
is used in combination with the timeout setting.
Example:
!> show uploadrate
102400
""", 'children':{}},
}},
'run':{'name':'run', 'callback':None, 'help_text':"""
run programname [arg1, arg2, ...]
Uploads programname to a vessel and starts it running. (This command is
actually just a short-cut for the 'upload' and 'start' commands). The
arguments listed will be passed to the command when it is started.
Example:
exampleuser@browsegood !> show log
Log from '192.x.x.2:1224:v3':
Log from '193.x.x.42:1224:v18':
Log from '219.x.x.62:1224:v4':
Log from '192.x.x.2:1224:v12':
exampleuser@browsegood !> run example.1.1.repy
exampleuser@browsegood !> show log
Log from '192.x.x.2:1224:v3':
Hello World
Log from '193.x.x.42:1224:v18':
Hello World
Log from '219.x.x.62:1224:v4':
Hello World
Log from '192.x.x.2:1224:v12':
Hello World
""", 'children':{
'[FILENAME]':{'name':'filename', 'callback':command_callbacks.run_localfn, 'help_text':'','children':{
'[ARGUMENT]':{'name':'args', 'callback':command_callbacks.run_localfn_arg, 'help_text':'', 'children':{}},
}},
}},
'add':{'name':'add', 'callback':None, 'help_text':"""
add target [to group]
add to group
Adds a target (a vessel name or group) a group. If the group does not exist,
it is created. This can be used to control which vessels are manipulated by
different commands. The short form 'add target' adds the target to the
default group. The short form 'add to group' adds the default group to
the target.
If the target is already in the group, an error message will be printed.
Example:
exampleuser@%1 !> on new_group
Invalid command input: Target does not exist
exampleuser@%1 !> add to new_group
exampleuser@%1 !> add %2 to new_group
exampleuser@%1 !> on new_group
exampleuser@new_group !> list
ID Own Name Status Owner Information
%1 * 192.x.x.178:1224:v3 Fresh
%2 * 192.x.x.2:1224:v12 Fresh
""", 'children':{
'[TARGET]':{'name':'target', 'callback':command_callbacks.add_target, 'help_text':'', 'children':{
'to':{'name':'to', 'callback':None, 'help_text':'', 'children':{
'[ARGUMENT]':{'name':'args', 'callback':command_callbacks.add_target_to_group, 'help_text':'', 'children':{}},
}},
}},
'to':{'name':'to', 'callback':None, 'help_text':'', 'children':{
'[ARGUMENT]':{'name':'args', 'callback':command_callbacks.add_to_group, 'help_text':'', 'children':{}},
}},
}},
'move':{'name':'move', 'callback':None, 'help_text':"""
move target to group
This is essentially a shortcut for removing the target from the default group
and adding it to group. See 'add' and 'remove' for more information.
""", 'children':{
'[TARGET]':{'name':'target', 'callback':None, 'help_text':'', 'children':{
'to':{'name':'to', 'callback':None, 'help_text':'', 'children':{
'[GROUP]':{'name':'group', 'callback':command_callbacks.move_target_to_group, 'help_text':'', 'children':{}},
}},
}},
}},
'remove':{'name':'remove', 'callback':None, 'help_text':"""
remove target [from group]
remove from group
This command removes a target (vesselname or group) from a group. This means
that future group operations will not include the listed vesselname or group.
The short form 'remove target' removes the target from the default group.
The short form 'remove from group' removes the default group from group.
If the target is not in the group, an error message will be printed.
Example:
exampleuser@new_group !> list
ID Own Name Status Owner Information
%1 * 192.x.x.178:1224:v3 Fresh
%2 * 192.x.x.2:1224:v12 Fresh
%3 192.x.x.2:1224:v3 Fresh
exampleuser@new_group !> on %1
exampleuser@%1 !> remove from new_group
exampleuser@%1 !> remove %2 from new_group
exampleuser@%1 !> on new_group
exampleuser@new_group !> list
ID Own Name Status Owner Information
%3 192.x.x.2:1224:v3 Fresh
""", 'children':{
'[TARGET]':{'name':'target', 'callback':command_callbacks.remove_target, 'help_text':'', 'children':{
'from':{'name':'from', 'callback':None, 'help_text':'', 'children':{
'[GROUP]':{'name':'group', 'callback':command_callbacks.remove_target_from_group, 'help_text':'', 'children':{}},
}},
}},
'from':{'name':'from', 'callback':None, 'help_text':'', 'children':{
'[GROUP]':{'name':'group', 'callback':command_callbacks.remove_from_group, 'help_text':'', 'children':{}},
}},
}},
'set':{'name':'set', 'callback':command_callbacks.set, 'help_text':"""
Commands requiring owner credentials on a vessel:
set users [ identity ... ] -- Change a vessel's users
set ownerinfo [ data ... ] -- Change owner information for the vessels
set advertise [ on | off ] -- Change advertisement of vessels
set owner identity -- Change a vessel's owner
Shell settings:
set timeout count -- Sets the time that seash is willing to wait on a node
set uploadrate speed -- Sets the upload rate which seash will use to estimate
the time needed for a file to be uploaded to a vessel.
The estimated time would be set as the temporary
timeout count during actual process. Speed should be
in bytes/sec.
set autosave [ on | off ] -- Sets whether to save the state after every command.
Set to 'off' by default. The state is saved to a
file called 'autosave_keyname', where keyname is
the name of the current key you're using.
""", 'children':{
'users':{'name':'users', 'callback':None, 'help_text':"""
set users [identity1, identity2, ...]
Sets the user keys for vessels in the default group. The current identity
must own the vessels.
Example:
exampleuser@%1 !> show owner
192.x.x.2:1224:v12 exampleuser pubkey
exampleuser@%1 !> show users
192.x.x.2:1224:v12 65537 136475...
exampleuser@%1 !> set users guest0 guest1 guest2
exampleuser@%1 !> update
exampleuser@%1 !> show users
192.x.x.2:1224:v12 guest0 guest1 guest2
exampleuser@%1 !> on %2
exampleuser@%2 !> show owner
192.x.x.2:1224:v3 65537 127603...
exampleuser@%2 !> set users guest0 guest1
Failure 'Node Manager error 'Insufficient Permissions'' on 192.x.x.2:1224:v3
""", 'children':{
'[ARGUMENT]':{'name':'args', 'callback':command_callbacks.set_users_arg, 'help_text':'', 'children':{}},
}},
'ownerinfo':{'name':'ownerinfo', 'callback':None, 'help_text':"""
set ownerinfo 'string'
This command sets the owner information for each vessel in the default group.
The default identity must own the vessels.
Example:
exampleuser@browsegood !> show owner
192.x.x.2:1224:v12 exampleuser pubkey
192.x.x.2:1224:v3 65537 127603...
exampleuser@browsegood !> show ownerinfo
192.x.x.2:1224:v12 ''
192.x.x.2:1224:v3 ''
exampleuser@browsegood !> set ownerinfo Example owner info
Failure 'Node Manager error 'Insufficient Permissions'' on 192.x.x.2:1224:v3
Added group 'ownerinfogood' with 1 targets and 'ownerinfofail' with 1 targets
exampleuser@browsegood !> update
exampleuser@browsegood !> show ownerinfo
192.x.x.2:1224:v12 'Example owner info'
192.x.x.2:1224:v3 ''
""", 'children':{
'[ARGUMENT]':{'name':'args', 'callback':command_callbacks.set_ownerinfo_arg, 'help_text':'', 'children':{}},
}},
'advertise':{'name':'advertise', 'callback':None, 'help_text':"""
set advertise [on/off]
This setting is changable only by the vessel owner and indicates whether or
not the node's IP / port should be advertised under the owner and user keys.
The default value is on. With this turned off, the 'browse' command will
be unable to discover the vessel.
exampleuser@%1 !> show owner
192.x.x.2:1224:v12 exampleuser pubkey
exampleuser@%1 !> show advertise
192.x.x.2:1224:v12 on
exampleuser@%1 !> set advertise off
exampleuser@%1 !> update
exampleuser@%1 !> show advertise
192.x.x.2:1224:v12 off
exampleuser@%1 !> on %2
exampleuser@%2 !> show owner
192.x.x.2:1224:v3 65537 127603...
exampleuser@%2 !> show advertise
192.x.x.2:1224:v3 on
exampleuser@%2 !> set advertise off
Failure 'Node Manager error 'Insufficient Permissions'' on 192.x.x.2:1224:v3
""", 'children':{
'[ARGUMENT]':{'name':'args', 'callback':command_callbacks.set_advertise_arg, 'help_text':'', 'children':{}},
}},
'owner':{'name':'owner', 'callback':None, 'help_text':"""
set owner identity
This changes the owner key for all vessels in the default group to the
identity specified. This command may only be issued by the vessels' current
owner.
Example:
exampleuser@%1 !> show identities
exampleuser PUB PRIV
guest0 PUB PRIV
guest1 PUB PRIV
exampleuser@%1 !> show owner
192.x.x.2:1224:v12 exampleuser pubkey
exampleuser@%1 !> set owner guest0
exampleuser@%1 !> update
exampleuser@%1 !> show owner
192.x.x.2:1224:v12 guest0 pubkey
exampleuser@%1 !> on %2
exampleuser@%2 !> show owner
192.x.x.2:1224:v3 65537 127603...
exampleuser@%2 !> set owner exampleuser
Failure 'Node Manager error 'Insufficient Permissions'' on 192.x.x.2:1224:v3
""", 'children':{
'[ARGUMENT]':{'name':'args', 'callback':command_callbacks.set_owner_arg, 'help_text':'', 'children':{}},
}},
'timeout':{'name':'timeout', 'callback':None, 'help_text':"""
set timeout timeoutval
This sets the timeout for network related commands. Most commands will then
be aborted on nodes if they are not completed withing the timeoutval number of
seconds. Note that the upload and run commands also use the uploadrate
setting to determine their timeout.
Example:
exampleuser@%1 !> set timeout 1
exampleuser@%1 !> show timeout
1
exampleuser@%1 !> start example.1.1.repy
Failure 'signedcommunicate failed on session_recvmessage with error 'recv() timed out!'' uploading to 193.x.x.42:1224:v18
exampleuser@%1 !> set timeout 10
exampleuser@%1 !> start example.1.1.repy
exampleuser@%1 !> show log
Log from '193.x.x.42:1224:v18':
Hello World
""", 'children':{
'[ARGUMENT]':{'name':'args', 'callback':command_callbacks.set_timeout_arg, 'help_text':'', 'children':{}},
}},
'uploadrate':{'name':'uploadrate', 'callback':None, 'help_text':"""
set uploadrate rate_in_bps
This value is used along with the timeout value to determine when to declare an
upload or run command as failed. The wait time is computed as:
timeout + filesize / rate_in_bps
Thus if the timeout is 10 seconds and rate_in_bps is 102400 (100 KB / s), a 1MB
will attempt to upload for 20 seconds.
Example:
exampleuser@%1 !> set uploadrate 99999999999999
exampleuser@%1 !> set timeout 1
exampleuser@%1 !> upload example.1.1.repy
Failure 'signedcommunicate failed on session_recvmessage with error 'recv() timed out!'' uploading to 193.x.x.42:1224:v18
exampleuser@%1 !> set uploadrate 102400
exampleuser@%1 !> upload example.1.1.repy
exampleuser@%1 !>
""", 'children':{
'[ARGUMENT]':{'name':'args', 'callback':command_callbacks.set_uploadrate_arg, 'help_text':'', 'children':{}},
}},
'autosave':{'name':'autosave', 'callback':None, 'help_text':"""
set autosave [on/off]
When turned on, the shell settings such as keys, targets, timeout value, etc.
will all be persisted to disk after every operation. These are saved in a
file called 'autosave_(user's keyname)', which is encrypted with the default identity. The user
can then restore the shell's state by typing 'loadstate identity'.
Example:
exampleuser@%1 !> set autosave on
exampleuser@%1 !> exit
(restart seash.py)
!> loadkeys exampleuser
!> as exampleuser
exampleuser@ !> loadstate autosave_exampleuser
exampleuser@%1 !>
""", 'children':{
'[ARGUMENT]':{'name':'args', 'callback':command_callbacks.set_autosave_arg, 'help_text':'', 'children':{}},
}},
}},
'browse':{'name':'browse', 'callback':command_callbacks.browse, 'help_text':"""
browse [advertisetype]
This command will use the default identity to search for vessels that can
be controlled. Any vessel with the advertise flag set will be advertised
in at least one advertise service. browse will look into these services
and add any vessels it can contact.
Setting advertisetype will restrict the advertise lookup to only use that
service. Some permitted values for advertisetype are central, DHT, and DOR.
Example:
exampleuser@ !> show targets
%all (empty)
exampleuser@ !> browse
['192.x.x.2:1224', '193.x.x.42:1224', '219.x.x.62:1224']
Added targets: %2(193.x.x.42:1224:v18), %3(219.x.x.62:1224:v4), %1(192.x.x.2:1224:v3)
Added group 'browsegood' with 3 targets
exampleuser@ !> show targets
browsegood ['192.x.x.2:1224:v3', '193.x.x.42:1224:v18', '219.x.x.62:1224:v4']
%3 ['219.x.x.62:1224:v4']
%all ['192.x.x.2:1224:v3', '193.x.x.42:1224:v18', '219.x.x.62:1224:v4']
%1 ['192.x.x.2:1224:v3']
%2 ['193.x.x.42:1224:v18']
""", 'children':{
'[ARGUMENT]':{'name':'args', 'callback':command_callbacks.browse_arg, 'help_text':'', 'children':{}},
}},
'genkeys':{'name':'genkeys', 'callback':None, 'help_text':"""
genkeys keyprefix [as identity]
Generates a new set of keys, writing them to files keyprefix.publickey and
keyprefix.privatekey. It also adds the identity under the name given. If
identity is not specified, keyprefix is used.
Example:
!> genkeys userA as userB
Created identity 'userB'
!> show identities
userB PUB PRIV
!> loadkeys userA
!> show identities
userB PUB PRIV
userA PUB PRIV
""", 'children':{
'[FILENAME]':{'name':'filename', 'callback':command_callbacks.genkeys_filename, 'help_text':'', 'children':{
'[ARGUMENT]':{'name':'args', 'callback':command_callbacks.genkeys_filename_len, 'help_text':'', 'children':{
'as':{'name':'as', 'callback':None, 'help_text':'', 'children':{
'[ARGUMENT]':{'name':'keyname', 'callback':command_callbacks.genkeys_filename_len_as_identity, 'help_text':'', 'children':{}},
}},
}},
'as':{'name':'as', 'callback':None, 'help_text':'', 'children':{
'[ARGUMENT]':{'name':'keyname', 'callback':command_callbacks.genkeys_filename_as_identity, 'help_text':'', 'children':{}},
}},
}},
}},
'loadkeys':{'name':'loadkeys', 'callback':None, 'help_text':"""
loadkeys keyprefix [as identity]
Loads a public key named keyprefix.publickey and a private key named
keyprefix.privatekey. This is a shortcut for the 'loadpub' and 'loadpriv'
operations. If identity is specified, the shell refers to the keys using
this. If not, keyprefix is the identity.
Example:
!> loadkeys exampleuser
!> show identities
exampleuser PUB PRIV
!> as exampleuser
exampleuser@ !>
""", 'children':{
'[FILENAME]':{'name':'filename', 'callback':command_callbacks.loadkeys_keyname, 'help_text':'', 'children':{
'as':{'name':'as', 'callback':None, 'help_text':'', 'children':{
'[ARGUMENT]':{'name':'args', 'callback':command_callbacks.loadkeys_keyname_as, 'help_text':'', 'children':{}},
}},
}},
}},
'loadpub':{'name':'loadpub', 'callback':None, 'help_text':"""
loadpub pubkeyfile [as identity]
Loads a public key named keyprefix.publickey. If identity is specified, the
shell refers to the keys using this. If not, keyprefix is the identity.
Example:
!> loadpub exampleuser
!> show identities
exampleuser PUB
""", 'children':{
'[FILENAME]':{'name':'filename', 'callback':command_callbacks.loadpub_filename, 'help_text':'', 'children':{
'as':{'name':'as', 'callback':None, 'help_text':'', 'children':{
'[ARGUMENT]':{'name':'args', 'callback':command_callbacks.loadpub_filename_as, 'help_text':'', 'children':{}},
}},
}},
}},
'loadpriv':{'name':'loadpriv', 'callback':None, 'help_text':"""
loadpriv privkeyfile [as identity]
Loads a private key named keyprefix.privatekey. If identity is specified, the
shell refers to the keys using this. If not, keyprefix is the identity.
Example:
!> loadpriv exampleuser
!> show identities
exampleuser PRIV
""", 'children':{
'[FILENAME]':{'name':'filename', 'callback':command_callbacks.loadpriv_filename, 'help_text':'', 'children':{
'as':{'name':'as', 'callback':None, 'help_text':'', 'children':{
'[ARGUMENT]':{'name':'args', 'callback':command_callbacks.loadpriv_filename_as, 'help_text':'', 'children':{}},
}},
}},
}},
'list':{'name':'list', 'callback':command_callbacks.list, 'help_text':"""
list
Display status information about a set of vessels. This indicates whether
the vessels are running programs, if the default identity is the owner or
just a user, along with other useful information.
Example:
exampleuser@browsegood !> list
ID Own Name Status Owner Information
%1 * 192.x.x.178:1224:v3 Fresh
%2 * 192.x.x.2:1224:v12 Fresh
%3 192.x.x.2:1224:v3 Fresh
""", 'children':{}},
'upload':{'name':'upload', 'callback':None, 'help_text':"""
upload srcfilename [destfilename]
Uploads a file into all vessels in the default group. The file name that is
created in those vessels is destfilename (or srcfilename by default).
Example:
exampleuser@%1 !> show files
Files on '192.x.x.2:1224:v3': ''
exampleuser@%1 !> upload example.1.1.repy
exampleuser@%1 !> show files
Files on '192.x.x.2:1224:v3': 'example.1.1.repy'
""", 'children':{
'[FILENAME]':{'name':'filename', 'callback':command_callbacks.upload_filename, 'help_text':'', 'children':{
'[ARGUMENT]':{'name':'args', 'callback':command_callbacks.upload_filename_remotefn, 'help_text':'', 'children':{}}
}},
}},
'download':{'name':'download', 'callback':None, 'help_text':"""
download srcfilename [destfilename]
Retrieves a copy of srcfilename from every vessel in the default group. The
file is written as the destfilename.vesselname (with ':' replaced with '_').
If the destfilename is not specified, srcfilename is used instead.
Example:
exampleuser@%1 !> show files
Files on '192.x.x.2:1224:v3': 'example.1.1.repy'
exampleuser@%1 !> download example.1.1.repy
Wrote files: example.1.1.repy.192.x.x.2_1224_v3
yaluen@%1 !> download example.1.1.repy test_download
Wrote files: test_download.192.x.x.2_1224_v3
""", 'children':{
'[FILENAME]':{'name':'filename', 'callback':command_callbacks.download_filename, 'help_text':'', 'children':{
'[ARGUMENT]':{'name':'args', 'callback':command_callbacks.download_filename_localfn, 'help_text':'', 'children':{}}
}},
}},
'delete':{'name':'delete', 'callback':None, 'help_text':"""
delete filename
Erases filename from every vessel in the default group.
Example:
exampleuser@%1 !> show files
Files on '192.x.x.2:1224:v3': 'example.1.1.repy'
exampleuser@%1 !> delete example.1.1.repy
exampleuser@%1 !> show files
Files on '192.x.x.2:1224:v3': ''