2021-05-25 07:10:16 +00:00
|
|
|
#compdef innernet-server
|
|
|
|
|
|
|
|
autoload -U is-at-least
|
|
|
|
|
|
|
|
_innernet-server() {
|
|
|
|
typeset -A opt_args
|
|
|
|
typeset -a _arguments_options
|
|
|
|
local ret=1
|
|
|
|
|
|
|
|
if is-at-least 5.2; then
|
|
|
|
_arguments_options=(-s -S -C)
|
|
|
|
else
|
|
|
|
_arguments_options=(-s -C)
|
|
|
|
fi
|
|
|
|
|
|
|
|
local context curcontext="$curcontext" state line
|
|
|
|
_arguments "${_arguments_options[@]}" \
|
2022-01-11 20:18:19 +00:00
|
|
|
'-c+[]:CONFIG_DIR: ' \
|
|
|
|
'--config-dir=[]:CONFIG_DIR: ' \
|
|
|
|
'-d+[]:DATA_DIR: ' \
|
|
|
|
'--data-dir=[]:DATA_DIR: ' \
|
|
|
|
'--backend=[Specify a WireGuard backend to use. If not set, innernet will auto-select based on availability]:BACKEND:(kernel userspace)' \
|
2022-03-15 02:15:56 +00:00
|
|
|
'--mtu=[Specify the desired MTU for your interface (default: 1280)]:MTU: ' \
|
2022-01-11 20:18:19 +00:00
|
|
|
'-h[Print help information]' \
|
|
|
|
'--help[Print help information]' \
|
|
|
|
'-V[Print version information]' \
|
|
|
|
'--version[Print version information]' \
|
2021-05-25 07:10:16 +00:00
|
|
|
'--no-routing[Whether the routing should be done by innernet or is done by an external tool like e.g. babeld]' \
|
|
|
|
":: :_innernet-server_commands" \
|
|
|
|
"*::: :->innernet-server" \
|
|
|
|
&& ret=0
|
|
|
|
case $state in
|
|
|
|
(innernet-server)
|
|
|
|
words=($line[1] "${words[@]}")
|
|
|
|
(( CURRENT += 1 ))
|
|
|
|
curcontext="${curcontext%:*:*}:innernet-server-command-$line[1]:"
|
|
|
|
case $line[1] in
|
2022-01-11 20:18:19 +00:00
|
|
|
(new)
|
2021-05-25 07:10:16 +00:00
|
|
|
_arguments "${_arguments_options[@]}" \
|
2022-01-11 20:18:19 +00:00
|
|
|
'--network-name=[The network name (ex: evilcorp)]:NETWORK_NAME: ' \
|
|
|
|
'--network-cidr=[The network CIDR (ex: 10.42.0.0/16)]:NETWORK_CIDR: ' \
|
|
|
|
'(--auto-external-endpoint)--external-endpoint=[This server'\''s external endpoint (ex: 100.100.100.100:51820)]:EXTERNAL_ENDPOINT: ' \
|
|
|
|
'--listen-port=[Port to listen on (for the WireGuard interface)]:LISTEN_PORT: ' \
|
2021-05-25 07:10:16 +00:00
|
|
|
'--auto-external-endpoint[Auto-resolve external endpoint]' \
|
2022-01-11 20:18:19 +00:00
|
|
|
'-h[Print help information]' \
|
|
|
|
'--help[Print help information]' \
|
2021-05-25 07:10:16 +00:00
|
|
|
&& ret=0
|
|
|
|
;;
|
|
|
|
(uninstall)
|
|
|
|
_arguments "${_arguments_options[@]}" \
|
2022-01-11 20:18:19 +00:00
|
|
|
'-h[Print help information]' \
|
|
|
|
'--help[Print help information]' \
|
|
|
|
':interface:' \
|
2021-05-25 07:10:16 +00:00
|
|
|
&& ret=0
|
|
|
|
;;
|
|
|
|
(serve)
|
|
|
|
_arguments "${_arguments_options[@]}" \
|
2022-01-11 20:18:19 +00:00
|
|
|
'--backend=[Specify a WireGuard backend to use. If not set, innernet will auto-select based on availability]:BACKEND:(kernel userspace)' \
|
2022-03-15 02:15:56 +00:00
|
|
|
'--mtu=[Specify the desired MTU for your interface (default: 1280)]:MTU: ' \
|
2021-05-25 07:10:16 +00:00
|
|
|
'--no-routing[Whether the routing should be done by innernet or is done by an external tool like e.g. babeld]' \
|
2022-01-11 20:18:19 +00:00
|
|
|
'-h[Print help information]' \
|
|
|
|
'--help[Print help information]' \
|
|
|
|
':interface:' \
|
2021-05-25 07:10:16 +00:00
|
|
|
&& ret=0
|
|
|
|
;;
|
|
|
|
(add-peer)
|
|
|
|
_arguments "${_arguments_options[@]}" \
|
2022-01-11 20:18:19 +00:00
|
|
|
'--name=[Name of new peer]:NAME: ' \
|
|
|
|
'(--auto-ip)--ip=[Specify desired IP of new peer (within parent CIDR)]:IP: ' \
|
|
|
|
'--cidr=[Name of CIDR to add new peer under]:CIDR: ' \
|
|
|
|
'--admin=[Make new peer an admin?]:ADMIN: ' \
|
|
|
|
'--save-config=[Save the config to the given location]:SAVE_CONFIG: ' \
|
|
|
|
'--invite-expires=[Invite expiration period (eg. '\''30d'\'', '\''7w'\'', '\''2h'\'', '\''60m'\'', '\''1000s'\'')]:INVITE_EXPIRES: ' \
|
2021-05-25 07:10:16 +00:00
|
|
|
'--auto-ip[Auto-assign the peer the first available IP within the CIDR]' \
|
|
|
|
'--yes[Bypass confirmation]' \
|
2022-01-11 20:18:19 +00:00
|
|
|
'-h[Print help information]' \
|
|
|
|
'--help[Print help information]' \
|
|
|
|
':interface:' \
|
2021-05-25 07:10:16 +00:00
|
|
|
&& ret=0
|
|
|
|
;;
|
2021-05-31 15:23:14 +00:00
|
|
|
(rename-peer)
|
|
|
|
_arguments "${_arguments_options[@]}" \
|
2022-01-11 20:18:19 +00:00
|
|
|
'--name=[Name of peer to rename]:NAME: ' \
|
|
|
|
'--new-name=[The new name of the peer]:NEW_NAME: ' \
|
2021-05-31 15:23:14 +00:00
|
|
|
'--yes[Bypass confirmation]' \
|
2022-01-11 20:18:19 +00:00
|
|
|
'-h[Print help information]' \
|
|
|
|
'--help[Print help information]' \
|
|
|
|
':interface:' \
|
2021-05-31 15:23:14 +00:00
|
|
|
&& ret=0
|
|
|
|
;;
|
2021-05-25 07:10:16 +00:00
|
|
|
(add-cidr)
|
|
|
|
_arguments "${_arguments_options[@]}" \
|
2022-01-11 20:18:19 +00:00
|
|
|
'--name=[The CIDR name (eg. '\''engineers'\'')]:NAME: ' \
|
|
|
|
'--cidr=[The CIDR network (eg. '\''10.42.5.0/24'\'')]:CIDR: ' \
|
|
|
|
'--parent=[The CIDR parent name]:PARENT: ' \
|
2021-05-25 07:10:16 +00:00
|
|
|
'--yes[Bypass confirmation]' \
|
2022-01-11 20:18:19 +00:00
|
|
|
'-h[Print help information]' \
|
|
|
|
'--help[Print help information]' \
|
|
|
|
':interface:' \
|
2021-05-25 07:10:16 +00:00
|
|
|
&& ret=0
|
|
|
|
;;
|
|
|
|
(delete-cidr)
|
|
|
|
_arguments "${_arguments_options[@]}" \
|
2022-01-11 20:18:19 +00:00
|
|
|
'--name=[The CIDR name (eg. '\''engineers'\'')]:NAME: ' \
|
2021-05-25 07:10:16 +00:00
|
|
|
'--yes[Bypass confirmation]' \
|
2022-01-11 20:18:19 +00:00
|
|
|
'-h[Print help information]' \
|
|
|
|
'--help[Print help information]' \
|
|
|
|
':interface:' \
|
2021-05-25 07:10:16 +00:00
|
|
|
&& ret=0
|
|
|
|
;;
|
|
|
|
(completions)
|
|
|
|
_arguments "${_arguments_options[@]}" \
|
2022-01-11 20:18:19 +00:00
|
|
|
'-h[Print help information]' \
|
|
|
|
'--help[Print help information]' \
|
|
|
|
':shell:(bash elvish fish powershell zsh)' \
|
2021-05-25 07:10:16 +00:00
|
|
|
&& ret=0
|
|
|
|
;;
|
|
|
|
(help)
|
|
|
|
_arguments "${_arguments_options[@]}" \
|
2022-01-18 06:19:53 +00:00
|
|
|
'*::subcommand -- The subcommand whose help message to display:' \
|
2021-05-25 07:10:16 +00:00
|
|
|
&& ret=0
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
(( $+functions[_innernet-server_commands] )) ||
|
|
|
|
_innernet-server_commands() {
|
|
|
|
local commands; commands=(
|
2022-01-11 20:18:19 +00:00
|
|
|
'new:Create a new network' \
|
|
|
|
'uninstall:Permanently uninstall a created network, rendering it unusable. Use with care' \
|
|
|
|
'serve:Serve the coordinating server for an existing network' \
|
|
|
|
'add-peer:Add a peer to an existing network' \
|
|
|
|
'rename-peer:Rename an existing peer' \
|
|
|
|
'add-cidr:Add a new CIDR to an existing network' \
|
|
|
|
'delete-cidr:Delete a CIDR' \
|
|
|
|
'completions:Generate shell completion scripts' \
|
|
|
|
'help:Print this message or the help of the given subcommand(s)' \
|
2021-05-25 07:10:16 +00:00
|
|
|
)
|
|
|
|
_describe -t commands 'innernet-server commands' commands "$@"
|
|
|
|
}
|
|
|
|
(( $+functions[_innernet-server__add-cidr_commands] )) ||
|
|
|
|
_innernet-server__add-cidr_commands() {
|
2022-01-11 20:18:19 +00:00
|
|
|
local commands; commands=()
|
2021-05-25 07:10:16 +00:00
|
|
|
_describe -t commands 'innernet-server add-cidr commands' commands "$@"
|
|
|
|
}
|
|
|
|
(( $+functions[_innernet-server__add-peer_commands] )) ||
|
|
|
|
_innernet-server__add-peer_commands() {
|
2022-01-11 20:18:19 +00:00
|
|
|
local commands; commands=()
|
2021-05-25 07:10:16 +00:00
|
|
|
_describe -t commands 'innernet-server add-peer commands' commands "$@"
|
|
|
|
}
|
|
|
|
(( $+functions[_innernet-server__completions_commands] )) ||
|
|
|
|
_innernet-server__completions_commands() {
|
2022-01-11 20:18:19 +00:00
|
|
|
local commands; commands=()
|
2021-05-25 07:10:16 +00:00
|
|
|
_describe -t commands 'innernet-server completions commands' commands "$@"
|
|
|
|
}
|
|
|
|
(( $+functions[_innernet-server__delete-cidr_commands] )) ||
|
|
|
|
_innernet-server__delete-cidr_commands() {
|
2022-01-11 20:18:19 +00:00
|
|
|
local commands; commands=()
|
2021-05-25 07:10:16 +00:00
|
|
|
_describe -t commands 'innernet-server delete-cidr commands' commands "$@"
|
|
|
|
}
|
|
|
|
(( $+functions[_innernet-server__help_commands] )) ||
|
|
|
|
_innernet-server__help_commands() {
|
2022-01-11 20:18:19 +00:00
|
|
|
local commands; commands=()
|
2021-05-25 07:10:16 +00:00
|
|
|
_describe -t commands 'innernet-server help commands' commands "$@"
|
|
|
|
}
|
|
|
|
(( $+functions[_innernet-server__new_commands] )) ||
|
|
|
|
_innernet-server__new_commands() {
|
2022-01-11 20:18:19 +00:00
|
|
|
local commands; commands=()
|
2021-05-25 07:10:16 +00:00
|
|
|
_describe -t commands 'innernet-server new commands' commands "$@"
|
|
|
|
}
|
2021-05-31 15:23:14 +00:00
|
|
|
(( $+functions[_innernet-server__rename-peer_commands] )) ||
|
|
|
|
_innernet-server__rename-peer_commands() {
|
2022-01-11 20:18:19 +00:00
|
|
|
local commands; commands=()
|
2021-05-31 15:23:14 +00:00
|
|
|
_describe -t commands 'innernet-server rename-peer commands' commands "$@"
|
|
|
|
}
|
2021-05-25 07:10:16 +00:00
|
|
|
(( $+functions[_innernet-server__serve_commands] )) ||
|
|
|
|
_innernet-server__serve_commands() {
|
2022-01-11 20:18:19 +00:00
|
|
|
local commands; commands=()
|
2021-05-25 07:10:16 +00:00
|
|
|
_describe -t commands 'innernet-server serve commands' commands "$@"
|
|
|
|
}
|
|
|
|
(( $+functions[_innernet-server__uninstall_commands] )) ||
|
|
|
|
_innernet-server__uninstall_commands() {
|
2022-01-11 20:18:19 +00:00
|
|
|
local commands; commands=()
|
2021-05-25 07:10:16 +00:00
|
|
|
_describe -t commands 'innernet-server uninstall commands' commands "$@"
|
|
|
|
}
|
|
|
|
|
2022-01-12 22:31:31 +00:00
|
|
|
_innernet-server "$@"
|