… | |
… | |
22 | |
22 | |
23 | # node configuration: node ID |
23 | # node configuration: node ID |
24 | aemp setnodeid <nodeid> # configure the real node id |
24 | aemp setnodeid <nodeid> # configure the real node id |
25 | aemp delnodeid # reset node id to default (= inherit) |
25 | aemp delnodeid # reset node id to default (= inherit) |
26 | |
26 | |
27 | # node configuration: secret |
27 | # node configuration: authentication |
28 | aemp gensecret # generate a random shared secret |
28 | aemp gensecret # generate a random shared secret |
29 | aemp setsecret <secret> # set the shared secret |
29 | aemp setsecret <secret> # set the shared secret |
30 | aemp delsecret # remove the secret (= inherit) |
30 | aemp delsecret # remove the secret (= inherit) |
31 | |
|
|
32 | # node configuration: TLS |
|
|
33 | aemp gencert # generate a random certificate |
31 | aemp gencert # generate a random certificate |
34 | aemp setcert <file> # set a certificate (key.pem + certificate.pem) |
32 | aemp setcert <file> # set a certificate (key.pem + certificate.pem) |
35 | aemp delcert # remove certificate (= inherit) |
33 | aemp delcert # remove certificate (= inherit) |
36 | |
34 | |
37 | # node configuration: seed addresses for bootstrapping |
35 | # node configuration: seed addresses for bootstrapping |
… | |
… | |
50 | aemp setservices initfunc,... # set service functions |
48 | aemp setservices initfunc,... # set service functions |
51 | aemp delservices # clear all services (= inherit) |
49 | aemp delservices # clear all services (= inherit) |
52 | aemp addservice <initfunc> # add an instance of a service |
50 | aemp addservice <initfunc> # add an instance of a service |
53 | aemp delservice <initfunc> # delete one instance of a service |
51 | aemp delservice <initfunc> # delete one instance of a service |
54 | |
52 | |
55 | # profile-specific configuration |
53 | # profile management |
56 | aemp profile <name> <command>... # apply command to profile only |
54 | aemp profile <name> <command>... # apply command to profile only |
57 | aemp setparent <name> # specify a parent profile |
55 | aemp setparent <name> # specify a parent profile |
58 | aemp delparent # clear parent again |
56 | aemp delparent # clear parent again |
59 | aemp delprofile <name> # eradicate the named profile |
57 | aemp delprofile <name> # eradicate the named profile |
60 | aemp showprofile <name> # display given profile |
58 | aemp showprofile <name> # display given profile |
61 | aemp showconfig <name> ... # display effective config |
59 | aemp showconfig <name> ... # display effective config |
62 | |
60 | |
|
|
61 | # node configuration: low-level protocol |
|
|
62 | aemp [set|del]monitor_timeout <seconds> |
|
|
63 | aemp [set|del]connect_interval <seconds> |
|
|
64 | aemp [set|del]framing_format [array] |
|
|
65 | aemp [set|del]auth_offer [array] |
|
|
66 | aemp [set|del]auth_accept [array] |
|
|
67 | aemp [set|del]autocork <boolean> |
|
|
68 | aemp [set|del]nodelay <boolean> |
|
|
69 | |
63 | =head1 DESCRIPTION |
70 | =head1 DESCRIPTION |
64 | |
71 | |
65 | With aemp you can configure various aspects of AnyEvent::MP and its |
72 | With aemp you can configure various aspects of AnyEvent::MP and its |
66 | protocol, send various messages and even run a node. |
73 | protocol, send various messages and even run a node. |
67 | |
74 | |
… | |
… | |
335 | Services are modules (or functions) that are automatically loaded (or |
342 | Services are modules (or functions) that are automatically loaded (or |
336 | executed) when a node starts. They are especially useful when used in |
343 | executed) when a node starts. They are especially useful when used in |
337 | conjunction with F<aemp run>, to configure which services a node should |
344 | conjunction with F<aemp run>, to configure which services a node should |
338 | run. |
345 | run. |
339 | |
346 | |
|
|
347 | Despite the daunting name, services really I<are> nothing more than a |
|
|
348 | module name or a function name with arguments. The "service" aspect comes |
|
|
349 | only from the behaviour of the module or function, which is supposed to |
|
|
350 | implement, well, some kind of service for the node, network etc. |
|
|
351 | |
|
|
352 | Instead of writing a standalone program for each different node type in |
|
|
353 | your network, you can simply put your code into a module, and then let the |
|
|
354 | configuration decide which node runs which "services". This also makes it |
|
|
355 | easy to combine multiple different services within the same node. |
|
|
356 | |
340 | =over 4 |
357 | =over 4 |
341 | |
358 | |
342 | =item setservices <initfunc>... |
359 | =item setservices <initfunc>... |
343 | |
360 | |
344 | Sets or replaces the list of services, which must be specified as a |
361 | Sets or replaces the list of services, which must be specified as a |
… | |
… | |
431 | Shows the I<effective> config, i.e. the values as used by a node started |
448 | Shows the I<effective> config, i.e. the values as used by a node started |
432 | with the given profile name. Any additional key-value pairs specified |
449 | with the given profile name. Any additional key-value pairs specified |
433 | augment the configuration, just as with C<configure>. |
450 | augment the configuration, just as with C<configure>. |
434 | |
451 | |
435 | If all arguments are omitted, show the global default config. |
452 | If all arguments are omitted, show the global default config. |
|
|
453 | |
|
|
454 | =back |
|
|
455 | |
|
|
456 | =head2 LOW-LEVEL TRANSPORT PROTOCOL |
|
|
457 | |
|
|
458 | The low-level transport protocol betwene two nodes also has a number of |
|
|
459 | configurable options, most of which should not be touched unless you know |
|
|
460 | what you are doing. |
|
|
461 | |
|
|
462 | =over 4 |
|
|
463 | |
|
|
464 | =item [set|del]monitor_timeout <seconds> |
|
|
465 | |
|
|
466 | Sets the default monitor timeout, that is, when a connection to a node |
|
|
467 | cannot be established within this many seconds, the node is declared |
|
|
468 | unreachable and all monitors will fire. |
|
|
469 | |
|
|
470 | C<30> seconds are usually a good time span for this. |
|
|
471 | |
|
|
472 | =item [set|del]connect_interval <seconds> |
|
|
473 | |
|
|
474 | When a connection cannot be established successfully within this many |
|
|
475 | seconds, try the next transport address (e.g. the next IP address). If |
|
|
476 | your nodes have a lot of transports, you might have to set this to a low |
|
|
477 | value so that they will actually all be tried within the monitor timeout |
|
|
478 | interval. |
|
|
479 | |
|
|
480 | C<2> is usually a good value, unless you live in new zealand. |
|
|
481 | |
|
|
482 | =item [set|del]framing_format [array] |
|
|
483 | |
|
|
484 | Configures the list of framing formats offered to the other side. This is |
|
|
485 | simply a list of formatted read/write types used with L<AnyEvent::Handle>, |
|
|
486 | in order of decreasing preference. |
|
|
487 | |
|
|
488 | Nodes support both C<json> and C<storable> framing formats for data |
|
|
489 | packets out of the box, and usually choose C<json> because it is first in |
|
|
490 | the list. |
|
|
491 | |
|
|
492 | Example: prefer the C<My::Personal::Format> framing format over JSON over |
|
|
493 | Storable. |
|
|
494 | |
|
|
495 | aemp setframing_format '["My::Personal::Format", "json", "storable"]' |
|
|
496 | |
|
|
497 | =item [set|del]auth_offer [array] |
|
|
498 | |
|
|
499 | Configures the list of authentication types that the node offers to the |
|
|
500 | other side as acceptable, in order of decreasing preference. Only auth |
|
|
501 | methods that the node can actually support will be offered. |
|
|
502 | |
|
|
503 | The default is '["tls_md6_64_256", "hmac_md6_64_256"]' and is usually good |
|
|
504 | enough. |
|
|
505 | |
|
|
506 | =item [set|del]auth_accept [array] |
|
|
507 | |
|
|
508 | Configures the list of authentication types that remote nodes can use to |
|
|
509 | authenticate, in order of decreasing preference. |
|
|
510 | |
|
|
511 | The default is '["tls_md6_64_256", "hmac_md6_64_256", "tls_anon", |
|
|
512 | "cleartext"]' and is usually good enough. |
|
|
513 | |
|
|
514 | =item [set|del]autocork <boolean> |
|
|
515 | |
|
|
516 | Sets the default C<autocork> option value for the L<AnyEvent::Handle> |
|
|
517 | object used by transports. By default, autocorking is off. |
|
|
518 | |
|
|
519 | =item [set|del]nodelay <boolean> |
|
|
520 | |
|
|
521 | Sets the default C<nodelay> option value for the L<AnyEvent::Handle> |
|
|
522 | object used by transports. By default, nodelay is on. |
436 | |
523 | |
437 | =back |
524 | =back |
438 | |
525 | |
439 | =cut |
526 | =cut |
440 | |
527 | |
… | |
… | |
861 | _resolve => sub { |
948 | _resolve => sub { |
862 | print +(join ",", (AnyEvent::MP::Kernel::_resolve shift @ARGV)->recv), "\n"; |
949 | print +(join ",", (AnyEvent::MP::Kernel::_resolve shift @ARGV)->recv), "\n"; |
863 | }, |
950 | }, |
864 | ); |
951 | ); |
865 | |
952 | |
|
|
953 | for my $attr (qw( |
|
|
954 | monitor_timeout connect_interval framing_format auth_offer |
|
|
955 | auth_accept autocork nodelay |
|
|
956 | )) { |
|
|
957 | $CMD{"set$attr"} = sub { |
|
|
958 | @ARGV >= 1 |
|
|
959 | or die "$attr value is missing\n"; |
|
|
960 | |
|
|
961 | $profile->{$attr} = shift @ARGV; |
|
|
962 | ++$cfg->{dirty}; |
|
|
963 | }; |
|
|
964 | $CMD{"del$attr"} = sub { |
|
|
965 | delete $profile->{$attr}; |
|
|
966 | ++$cfg->{dirty}; |
|
|
967 | }; |
|
|
968 | } |
|
|
969 | |
866 | for (keys %CMD) { |
970 | for (keys %CMD) { |
867 | $CMD{$1} = $CMD{$_} if /^set(.*)$/; |
971 | $CMD{$1} = $CMD{$_} if /^set(.*)$/; |
868 | } |
972 | } |
869 | |
973 | |
870 | sub docmd { |
974 | sub docmd { |