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[@]}" \
|
2023-06-14 08:49:16 +00:00
|
|
|
'-c+[]:CONFIG_DIR:_files' \
|
|
|
|
'--config-dir=[]:CONFIG_DIR:_files' \
|
|
|
|
'-d+[]:DATA_DIR:_files' \
|
|
|
|
'--data-dir=[]:DATA_DIR:_files' \
|
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)' \
|
2023-06-14 08:49:16 +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]' \
|
2023-06-14 08:49:16 +00:00
|
|
|
'-h[Print help]' \
|
|
|
|
'--help[Print help]' \
|
|
|
|
'-V[Print version]' \
|
|
|
|
'--version[Print version]' \
|
2021-05-25 07:10:16 +00:00
|
|
|
":: :_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[@]}" \
|
2023-06-14 08:49:16 +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: ' \
|
2022-01-11 20:18:19 +00:00
|
|
|
'--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]' \
|
2023-06-14 08:49:16 +00:00
|
|
|
'-h[Print help]' \
|
|
|
|
'--help[Print help]' \
|
2021-05-25 07:10:16 +00:00
|
|
|
&& ret=0
|
|
|
|
;;
|
|
|
|
(uninstall)
|
|
|
|
_arguments "${_arguments_options[@]}" \
|
2022-09-24 04:16:35 +00:00
|
|
|
'--yes[Bypass confirmation]' \
|
2023-06-14 08:49:16 +00:00
|
|
|
'-h[Print help]' \
|
|
|
|
'--help[Print help]' \
|
2022-01-11 20:18:19 +00:00
|
|
|
':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)' \
|
2023-06-14 08:49:16 +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]' \
|
2023-06-14 08:49:16 +00:00
|
|
|
'-h[Print help]' \
|
|
|
|
'--help[Print help]' \
|
2022-01-11 20:18:19 +00:00
|
|
|
':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: ' \
|
2023-06-14 08:49:16 +00:00
|
|
|
'--admin=[Make new peer an admin?]:ADMIN:(true false)' \
|
2022-01-11 20:18:19 +00:00
|
|
|
'--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]' \
|
2023-06-14 08:49:16 +00:00
|
|
|
'-h[Print help]' \
|
|
|
|
'--help[Print help]' \
|
2022-01-11 20:18:19 +00:00
|
|
|
':interface:' \
|
2021-05-25 07:10:16 +00:00
|
|
|
&& ret=0
|
|
|
|
;;
|
2022-09-24 04:16:35 +00:00
|
|
|
(disable-peer)
|
|
|
|
_arguments "${_arguments_options[@]}" \
|
2023-06-14 08:49:16 +00:00
|
|
|
'-h[Print help]' \
|
|
|
|
'--help[Print help]' \
|
2022-09-24 04:16:35 +00:00
|
|
|
':interface:' \
|
|
|
|
&& ret=0
|
|
|
|
;;
|
|
|
|
(enable-peer)
|
|
|
|
_arguments "${_arguments_options[@]}" \
|
2023-06-14 08:49:16 +00:00
|
|
|
'-h[Print help]' \
|
|
|
|
'--help[Print help]' \
|
2022-09-24 04:16:35 +00:00
|
|
|
':interface:' \
|
|
|
|
&& 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]' \
|
2023-06-14 08:49:16 +00:00
|
|
|
'-h[Print help]' \
|
|
|
|
'--help[Print help]' \
|
2022-01-11 20:18:19 +00:00
|
|
|
':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]' \
|
2023-06-14 08:49:16 +00:00
|
|
|
'-h[Print help]' \
|
|
|
|
'--help[Print help]' \
|
2022-01-11 20:18:19 +00:00
|
|
|
':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]' \
|
2023-06-14 08:49:16 +00:00
|
|
|
'-h[Print help]' \
|
|
|
|
'--help[Print help]' \
|
2022-01-11 20:18:19 +00:00
|
|
|
':interface:' \
|
2021-05-25 07:10:16 +00:00
|
|
|
&& ret=0
|
|
|
|
;;
|
|
|
|
(completions)
|
|
|
|
_arguments "${_arguments_options[@]}" \
|
2023-06-14 08:49:16 +00:00
|
|
|
'-h[Print help]' \
|
|
|
|
'--help[Print help]' \
|
2022-01-11 20:18:19 +00:00
|
|
|
':shell:(bash elvish fish powershell zsh)' \
|
2021-05-25 07:10:16 +00:00
|
|
|
&& ret=0
|
|
|
|
;;
|
|
|
|
(help)
|
|
|
|
_arguments "${_arguments_options[@]}" \
|
2023-06-14 08:49:16 +00:00
|
|
|
":: :_innernet-server__help_commands" \
|
|
|
|
"*::: :->help" \
|
|
|
|
&& ret=0
|
|
|
|
|
|
|
|
case $state in
|
|
|
|
(help)
|
|
|
|
words=($line[1] "${words[@]}")
|
|
|
|
(( CURRENT += 1 ))
|
|
|
|
curcontext="${curcontext%:*:*}:innernet-server-help-command-$line[1]:"
|
|
|
|
case $line[1] in
|
|
|
|
(new)
|
|
|
|
_arguments "${_arguments_options[@]}" \
|
|
|
|
&& ret=0
|
|
|
|
;;
|
|
|
|
(uninstall)
|
|
|
|
_arguments "${_arguments_options[@]}" \
|
|
|
|
&& ret=0
|
|
|
|
;;
|
|
|
|
(serve)
|
|
|
|
_arguments "${_arguments_options[@]}" \
|
|
|
|
&& ret=0
|
|
|
|
;;
|
|
|
|
(add-peer)
|
|
|
|
_arguments "${_arguments_options[@]}" \
|
|
|
|
&& ret=0
|
|
|
|
;;
|
|
|
|
(disable-peer)
|
|
|
|
_arguments "${_arguments_options[@]}" \
|
|
|
|
&& ret=0
|
|
|
|
;;
|
|
|
|
(enable-peer)
|
|
|
|
_arguments "${_arguments_options[@]}" \
|
|
|
|
&& ret=0
|
|
|
|
;;
|
|
|
|
(rename-peer)
|
|
|
|
_arguments "${_arguments_options[@]}" \
|
|
|
|
&& ret=0
|
|
|
|
;;
|
|
|
|
(add-cidr)
|
|
|
|
_arguments "${_arguments_options[@]}" \
|
|
|
|
&& ret=0
|
|
|
|
;;
|
|
|
|
(delete-cidr)
|
|
|
|
_arguments "${_arguments_options[@]}" \
|
|
|
|
&& ret=0
|
|
|
|
;;
|
|
|
|
(completions)
|
|
|
|
_arguments "${_arguments_options[@]}" \
|
|
|
|
&& ret=0
|
|
|
|
;;
|
|
|
|
(help)
|
|
|
|
_arguments "${_arguments_options[@]}" \
|
2021-05-25 07:10:16 +00:00
|
|
|
&& ret=0
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
esac
|
2023-06-14 08:49:16 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
esac
|
2021-05-25 07:10:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
(( $+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' \
|
2022-09-24 04:16:35 +00:00
|
|
|
'disable-peer:Disable an enabled peer' \
|
|
|
|
'enable-peer:Enable a disabled peer' \
|
2022-01-11 20:18:19 +00:00
|
|
|
'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 "$@"
|
|
|
|
}
|
2023-06-14 08:49:16 +00:00
|
|
|
(( $+functions[_innernet-server__help__add-cidr_commands] )) ||
|
|
|
|
_innernet-server__help__add-cidr_commands() {
|
|
|
|
local commands; commands=()
|
|
|
|
_describe -t commands 'innernet-server help add-cidr commands' commands "$@"
|
|
|
|
}
|
2021-05-25 07:10:16 +00:00
|
|
|
(( $+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 "$@"
|
|
|
|
}
|
2023-06-14 08:49:16 +00:00
|
|
|
(( $+functions[_innernet-server__help__add-peer_commands] )) ||
|
|
|
|
_innernet-server__help__add-peer_commands() {
|
|
|
|
local commands; commands=()
|
|
|
|
_describe -t commands 'innernet-server help add-peer commands' commands "$@"
|
|
|
|
}
|
2021-05-25 07:10:16 +00:00
|
|
|
(( $+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 "$@"
|
|
|
|
}
|
2023-06-14 08:49:16 +00:00
|
|
|
(( $+functions[_innernet-server__help__completions_commands] )) ||
|
|
|
|
_innernet-server__help__completions_commands() {
|
|
|
|
local commands; commands=()
|
|
|
|
_describe -t commands 'innernet-server help completions commands' commands "$@"
|
|
|
|
}
|
2021-05-25 07:10:16 +00:00
|
|
|
(( $+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 "$@"
|
|
|
|
}
|
2023-06-14 08:49:16 +00:00
|
|
|
(( $+functions[_innernet-server__help__delete-cidr_commands] )) ||
|
|
|
|
_innernet-server__help__delete-cidr_commands() {
|
|
|
|
local commands; commands=()
|
|
|
|
_describe -t commands 'innernet-server help delete-cidr commands' commands "$@"
|
|
|
|
}
|
2022-09-24 04:16:35 +00:00
|
|
|
(( $+functions[_innernet-server__disable-peer_commands] )) ||
|
|
|
|
_innernet-server__disable-peer_commands() {
|
|
|
|
local commands; commands=()
|
|
|
|
_describe -t commands 'innernet-server disable-peer commands' commands "$@"
|
|
|
|
}
|
2023-06-14 08:49:16 +00:00
|
|
|
(( $+functions[_innernet-server__help__disable-peer_commands] )) ||
|
|
|
|
_innernet-server__help__disable-peer_commands() {
|
|
|
|
local commands; commands=()
|
|
|
|
_describe -t commands 'innernet-server help disable-peer commands' commands "$@"
|
|
|
|
}
|
2022-09-24 04:16:35 +00:00
|
|
|
(( $+functions[_innernet-server__enable-peer_commands] )) ||
|
|
|
|
_innernet-server__enable-peer_commands() {
|
|
|
|
local commands; commands=()
|
|
|
|
_describe -t commands 'innernet-server enable-peer commands' commands "$@"
|
|
|
|
}
|
2023-06-14 08:49:16 +00:00
|
|
|
(( $+functions[_innernet-server__help__enable-peer_commands] )) ||
|
|
|
|
_innernet-server__help__enable-peer_commands() {
|
|
|
|
local commands; commands=()
|
|
|
|
_describe -t commands 'innernet-server help enable-peer commands' commands "$@"
|
|
|
|
}
|
2021-05-25 07:10:16 +00:00
|
|
|
(( $+functions[_innernet-server__help_commands] )) ||
|
|
|
|
_innernet-server__help_commands() {
|
2023-06-14 08:49:16 +00:00
|
|
|
local commands; commands=(
|
|
|
|
'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' \
|
|
|
|
'disable-peer:Disable an enabled peer' \
|
|
|
|
'enable-peer:Enable a disabled peer' \
|
|
|
|
'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 help commands' commands "$@"
|
|
|
|
}
|
2023-06-14 08:49:16 +00:00
|
|
|
(( $+functions[_innernet-server__help__help_commands] )) ||
|
|
|
|
_innernet-server__help__help_commands() {
|
|
|
|
local commands; commands=()
|
|
|
|
_describe -t commands 'innernet-server help help commands' commands "$@"
|
|
|
|
}
|
|
|
|
(( $+functions[_innernet-server__help__new_commands] )) ||
|
|
|
|
_innernet-server__help__new_commands() {
|
|
|
|
local commands; commands=()
|
|
|
|
_describe -t commands 'innernet-server help new commands' commands "$@"
|
|
|
|
}
|
2021-05-25 07:10:16 +00:00
|
|
|
(( $+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 "$@"
|
|
|
|
}
|
2023-06-14 08:49:16 +00:00
|
|
|
(( $+functions[_innernet-server__help__rename-peer_commands] )) ||
|
|
|
|
_innernet-server__help__rename-peer_commands() {
|
|
|
|
local commands; commands=()
|
|
|
|
_describe -t commands 'innernet-server help rename-peer 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 "$@"
|
|
|
|
}
|
2023-06-14 08:49:16 +00:00
|
|
|
(( $+functions[_innernet-server__help__serve_commands] )) ||
|
|
|
|
_innernet-server__help__serve_commands() {
|
|
|
|
local commands; commands=()
|
|
|
|
_describe -t commands 'innernet-server help serve 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 "$@"
|
|
|
|
}
|
2023-06-14 08:49:16 +00:00
|
|
|
(( $+functions[_innernet-server__help__uninstall_commands] )) ||
|
|
|
|
_innernet-server__help__uninstall_commands() {
|
|
|
|
local commands; commands=()
|
|
|
|
_describe -t commands 'innernet-server help uninstall commands' commands "$@"
|
|
|
|
}
|
2021-05-25 07:10:16 +00:00
|
|
|
(( $+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 "$@"
|
|
|
|
}
|
|
|
|
|
2023-06-14 08:49:16 +00:00
|
|
|
if [ "$funcstack[1]" = "_innernet-server" ]; then
|
|
|
|
_innernet-server "$@"
|
|
|
|
else
|
|
|
|
compdef _innernet-server innernet-server
|
|
|
|
fi
|