Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions autocomplete/fish_autocomplete
Original file line number Diff line number Diff line change
Expand Up @@ -632,9 +632,11 @@ complete -x -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcomman
complete -x -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from inbound in inbound-trunk; and not __fish_seen_subcommand_from list create update delete help h' -a 'create' -d 'Create an inbound SIP Trunk'
complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from inbound in inbound-trunk; and __fish_seen_subcommand_from create' -f -l name -r -d 'Sets a new name for the trunk'
complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from inbound in inbound-trunk; and __fish_seen_subcommand_from create' -f -l numbers -r -d 'Sets a list of numbers for the trunk'
complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from inbound in inbound-trunk; and __fish_seen_subcommand_from create' -f -l media-enc -r -d 'Sets media encryption for outbound call'
complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from inbound in inbound-trunk; and __fish_seen_subcommand_from create' -f -l auth-user -r -d 'Set username for authentication'
complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from inbound in inbound-trunk; and __fish_seen_subcommand_from create' -f -l auth-pass -r -d 'Set password for authentication'
complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from inbound in inbound-trunk; and __fish_seen_subcommand_from create' -f -l media-enc -r -d 'Sets media encryption for outbound call'
complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from inbound in inbound-trunk; and __fish_seen_subcommand_from create' -f -l no-default-codecs -d 'Disables a builtin list of default SIP codecs'
complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from inbound in inbound-trunk; and __fish_seen_subcommand_from create' -f -l codecs -r -d 'Sets a list of SIP codecs for outbound call'
complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from inbound in inbound-trunk; and __fish_seen_subcommand_from create' -f -l help -s h -d 'show help'
complete -x -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from inbound in inbound-trunk; and __fish_seen_subcommand_from create; and not __fish_seen_subcommand_from help h' -a 'help' -d 'Shows a list of commands or help for one command'
complete -x -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from inbound in inbound-trunk; and not __fish_seen_subcommand_from list create update delete help h' -a 'update' -d 'Update an inbound SIP Trunk'
Expand All @@ -643,6 +645,9 @@ complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_f
complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from inbound in inbound-trunk; and __fish_seen_subcommand_from update' -f -l numbers -r -d 'Sets a new list of numbers for the trunk'
complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from inbound in inbound-trunk; and __fish_seen_subcommand_from update' -f -l auth-user -r -d 'Set username for authentication'
complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from inbound in inbound-trunk; and __fish_seen_subcommand_from update' -f -l auth-pass -r -d 'Set password for authentication'
complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from inbound in inbound-trunk; and __fish_seen_subcommand_from update' -f -l media-enc -r -d 'Sets media encryption for outbound call'
complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from inbound in inbound-trunk; and __fish_seen_subcommand_from update' -f -l no-default-codecs -d 'Disables a builtin list of default SIP codecs'
complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from inbound in inbound-trunk; and __fish_seen_subcommand_from update' -f -l codecs -r -d 'Sets a list of SIP codecs for outbound call'
complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from inbound in inbound-trunk; and __fish_seen_subcommand_from update' -f -l help -s h -d 'show help'
complete -x -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from inbound in inbound-trunk; and __fish_seen_subcommand_from update; and not __fish_seen_subcommand_from help h' -a 'help' -d 'Shows a list of commands or help for one command'
complete -x -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from inbound in inbound-trunk; and not __fish_seen_subcommand_from list create update delete help h' -a 'delete' -d 'Delete a SIP Trunk'
Expand All @@ -660,10 +665,12 @@ complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_f
complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from outbound out outbound-trunk; and __fish_seen_subcommand_from create' -f -l address -r -d 'Sets a destination address for the trunk'
complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from outbound out outbound-trunk; and __fish_seen_subcommand_from create' -f -l transport -r -d 'Sets a transport for the trunk'
complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from outbound out outbound-trunk; and __fish_seen_subcommand_from create' -f -l destination-country -r -d 'Sets a destination country for the trunk as ISO 3166-1 alpha-2 (https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)'
complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from outbound out outbound-trunk; and __fish_seen_subcommand_from create' -f -l media-enc -r -d 'Sets media encryption for outbound call'
complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from outbound out outbound-trunk; and __fish_seen_subcommand_from create' -f -l numbers -r -d 'Sets a list of numbers for the trunk'
complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from outbound out outbound-trunk; and __fish_seen_subcommand_from create' -f -l auth-user -r -d 'Set username for authentication'
complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from outbound out outbound-trunk; and __fish_seen_subcommand_from create' -f -l auth-pass -r -d 'Set password for authentication'
complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from outbound out outbound-trunk; and __fish_seen_subcommand_from create' -f -l media-enc -r -d 'Sets media encryption for outbound call'
complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from outbound out outbound-trunk; and __fish_seen_subcommand_from create' -f -l no-default-codecs -d 'Disables a builtin list of default SIP codecs'
complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from outbound out outbound-trunk; and __fish_seen_subcommand_from create' -f -l codecs -r -d 'Sets a list of SIP codecs for outbound call'
complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from outbound out outbound-trunk; and __fish_seen_subcommand_from create' -f -l help -s h -d 'show help'
complete -x -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from outbound out outbound-trunk; and __fish_seen_subcommand_from create; and not __fish_seen_subcommand_from help h' -a 'help' -d 'Shows a list of commands or help for one command'
complete -x -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from outbound out outbound-trunk; and not __fish_seen_subcommand_from list create update delete help h' -a 'update' -d 'Update an outbound SIP Trunk'
Expand All @@ -675,6 +682,9 @@ complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_f
complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from outbound out outbound-trunk; and __fish_seen_subcommand_from update' -f -l numbers -r -d 'Sets a new list of numbers for the trunk'
complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from outbound out outbound-trunk; and __fish_seen_subcommand_from update' -f -l auth-user -r -d 'Set username for authentication'
complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from outbound out outbound-trunk; and __fish_seen_subcommand_from update' -f -l auth-pass -r -d 'Set password for authentication'
complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from outbound out outbound-trunk; and __fish_seen_subcommand_from update' -f -l media-enc -r -d 'Sets media encryption for outbound call'
complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from outbound out outbound-trunk; and __fish_seen_subcommand_from update' -f -l no-default-codecs -d 'Disables a builtin list of default SIP codecs'
complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from outbound out outbound-trunk; and __fish_seen_subcommand_from update' -f -l codecs -r -d 'Sets a list of SIP codecs for outbound call'
complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from outbound out outbound-trunk; and __fish_seen_subcommand_from update' -f -l help -s h -d 'show help'
complete -x -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from outbound out outbound-trunk; and __fish_seen_subcommand_from update; and not __fish_seen_subcommand_from help h' -a 'help' -d 'Shows a list of commands or help for one command'
complete -x -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from outbound out outbound-trunk; and not __fish_seen_subcommand_from list create update delete help h' -a 'delete' -d 'Delete SIP Trunk'
Expand Down Expand Up @@ -703,6 +713,9 @@ complete -x -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcomman
complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from dispatch dispatch-rule; and __fish_seen_subcommand_from update' -f -l id -r -d 'ID for the rule to update'
complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from dispatch dispatch-rule; and __fish_seen_subcommand_from update' -f -l name -r -d 'Sets a new name for the rule'
complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from dispatch dispatch-rule; and __fish_seen_subcommand_from update' -f -l trunks -r -d 'Sets a new list of trunk IDs'
complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from dispatch dispatch-rule; and __fish_seen_subcommand_from update' -f -l media-enc -r -d 'Sets media encryption for outbound call'
complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from dispatch dispatch-rule; and __fish_seen_subcommand_from update' -f -l no-default-codecs -d 'Disables a builtin list of default SIP codecs'
complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from dispatch dispatch-rule; and __fish_seen_subcommand_from update' -f -l codecs -r -d 'Sets a list of SIP codecs for outbound call'
complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from dispatch dispatch-rule; and __fish_seen_subcommand_from update' -f -l help -s h -d 'show help'
complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from dispatch dispatch-rule; and __fish_seen_subcommand_from update' -f -l direct -r -d 'Sets a direct dispatch to a specified room'
complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from dispatch dispatch-rule; and __fish_seen_subcommand_from update' -f -l caller -s individual -r -d 'Sets a individual caller dispatch to a new room with a specific prefix'
Expand Down
74 changes: 54 additions & 20 deletions cmd/lk/sip.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ var (
Usage: "Create an inbound SIP Trunk",
Action: createSIPInboundTrunk,
ArgsUsage: RequestDesc[livekit.CreateSIPInboundTrunkRequest](),
Flags: []cli.Flag{
Flags: appendSIPMediaFlags([]cli.Flag{
&cli.StringFlag{
Name: "name",
Usage: "Sets a new name for the trunk",
Expand All @@ -65,7 +65,6 @@ var (
Name: "numbers",
Usage: "Sets a list of numbers for the trunk",
},
sipMediaEncFlag(),
&cli.StringFlag{
Name: "auth-user",
Usage: "Set username for authentication",
Expand All @@ -74,14 +73,14 @@ var (
Name: "auth-pass",
Usage: "Set password for authentication",
},
},
}),
},
{
Name: "update",
Usage: "Update an inbound SIP Trunk",
Action: updateSIPInboundTrunk,
ArgsUsage: RequestDesc[livekit.UpdateSIPInboundTrunkRequest](),
Flags: []cli.Flag{
Flags: appendSIPMediaFlags([]cli.Flag{
&cli.StringFlag{
Name: "id",
Usage: "ID for the trunk to update",
Expand All @@ -102,7 +101,7 @@ var (
Name: "auth-pass",
Usage: "Set password for authentication",
},
},
}),
},
{
Name: "delete",
Expand All @@ -128,7 +127,7 @@ var (
Usage: "Create an outbound SIP Trunk",
Action: createSIPOutboundTrunk,
ArgsUsage: RequestDesc[livekit.CreateSIPOutboundTrunkRequest](),
Flags: []cli.Flag{
Flags: appendSIPMediaFlags([]cli.Flag{
&cli.StringFlag{
Name: "name",
Usage: "Sets a new name for the trunk",
Expand All @@ -145,7 +144,6 @@ var (
Name: "destination-country",
Usage: "Sets a destination country for the trunk as ISO 3166-1 alpha-2 (https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)",
},
sipMediaEncFlag(),
&cli.StringSliceFlag{
Name: "numbers",
Usage: "Sets a list of numbers for the trunk",
Expand All @@ -158,14 +156,14 @@ var (
Name: "auth-pass",
Usage: "Set password for authentication",
},
},
}),
},
{
Name: "update",
Usage: "Update an outbound SIP Trunk",
Action: updateSIPOutboundTrunk,
ArgsUsage: RequestDesc[livekit.UpdateSIPOutboundTrunkRequest](),
Flags: []cli.Flag{
Flags: appendSIPMediaFlags([]cli.Flag{
&cli.StringFlag{
Name: "id",
Usage: "ID for the trunk to update",
Expand Down Expand Up @@ -198,7 +196,7 @@ var (
Name: "auth-pass",
Usage: "Set password for authentication",
},
},
}),
},
{
Name: "delete",
Expand Down Expand Up @@ -269,7 +267,7 @@ var (
Usage: "Update a SIP Dispatch Rule",
Action: updateSIPDispatchRule,
ArgsUsage: RequestDesc[livekit.UpdateSIPDispatchRuleRequest](),
Flags: []cli.Flag{
Flags: appendSIPMediaFlags([]cli.Flag{
&cli.StringFlag{
Name: "id",
Usage: "ID for the rule to update",
Expand All @@ -282,7 +280,7 @@ var (
Name: "trunks",
Usage: "Sets a new list of trunk IDs",
},
},
}),
MutuallyExclusiveFlags: []cli.MutuallyExclusiveFlags{
{
Flags: [][]cli.Flag{
Expand Down Expand Up @@ -484,16 +482,12 @@ func optBoolFlag(cmd *cli.Command, setName string) (bool, bool) {
return cmd.Bool(setName), true
}

func sipMediaEncFlag() cli.Flag {
return &cli.StringFlag{
Name: "media-enc",
Usage: "Sets media encryption for outbound call",
}
}

func appendSIPMediaFlags(flags []cli.Flag) []cli.Flag {
flags = append(flags,
sipMediaEncFlag(),
&cli.StringFlag{
Name: "media-enc",
Usage: "Sets media encryption for outbound call",
},
&cli.BoolFlag{
Name: "no-default-codecs",
Usage: "Disables a builtin list of default SIP codecs",
Expand Down Expand Up @@ -600,6 +594,11 @@ func createSIPInboundTrunk(ctx context.Context, cmd *cli.Command) error {
if val, ok := listSetFlag(cmd, "numbers"); ok {
p.Numbers = val
}
if m, err := parseSIPMediaConfig(cmd); err == nil {
p.Media = m
} else if err != nil {
return err
}
if enc, err := parseSIPMediaEnc(cmd); err == nil && enc != nil {
p.MediaEncryption = *enc
} else if err != nil {
Expand Down Expand Up @@ -663,6 +662,16 @@ func updateSIPInboundTrunk(ctx context.Context, cmd *cli.Command) error {
if val := cmd.String("auth-pass"); val != "" {
req.AuthPassword = &val
}
if m, err := parseSIPMediaConfig(cmd); err == nil {
req.Media = m
} else if err != nil {
return err
}
if enc, err := parseSIPMediaEnc(cmd); err == nil && enc != nil {
req.MediaEncryption = enc
} else if err != nil {
return err
}
req.Numbers = listUpdateFlag(cmd, "numbers")
info, err := cli.UpdateSIPInboundTrunk(ctx, &livekit.UpdateSIPInboundTrunkRequest{
SipTrunkId: id,
Expand Down Expand Up @@ -707,6 +716,11 @@ func createSIPOutboundTrunk(ctx context.Context, cmd *cli.Command) error {
if val := cmd.String("destination-country"); val != "" {
p.DestinationCountry = val
}
if m, err := parseSIPMediaConfig(cmd); err == nil {
p.Media = m
} else if err != nil {
return err
}
if enc, err := parseSIPMediaEnc(cmd); err == nil && enc != nil {
p.MediaEncryption = *enc
} else if err != nil {
Expand Down Expand Up @@ -791,6 +805,16 @@ func updateSIPOutboundTrunk(ctx context.Context, cmd *cli.Command) error {
if val := cmd.String("auth-pass"); val != "" {
req.AuthPassword = &val
}
if m, err := parseSIPMediaConfig(cmd); err == nil {
req.Media = m
} else if err != nil {
return err
}
if enc, err := parseSIPMediaEnc(cmd); err == nil && enc != nil {
req.MediaEncryption = enc
} else if err != nil {
return err
}
req.Numbers = listUpdateFlag(cmd, "numbers")
info, err := cli.UpdateSIPOutboundTrunk(ctx, &livekit.UpdateSIPOutboundTrunkRequest{
SipTrunkId: id,
Expand Down Expand Up @@ -1083,6 +1107,16 @@ func updateSIPDispatchRule(ctx context.Context, cmd *cli.Command) error {
req.Name = &val
}
req.TrunkIds = listUpdateFlag(cmd, "trunks")
if m, err := parseSIPMediaConfig(cmd); err == nil {
req.Media = m
} else if err != nil {
return err
}
if enc, err := parseSIPMediaEnc(cmd); err == nil && enc != nil {
req.MediaEncryption = enc
} else if err != nil {
return err
}
if val := cmd.String("direct"); val != "" {
if req.Rule != nil {
return fmt.Errorf("only one dispatch rule type is allowed")
Expand Down
Loading