5656 Usage : "Create an inbound SIP Trunk" ,
5757 Action : createSIPInboundTrunk ,
5858 ArgsUsage : RequestDesc [livekit.CreateSIPInboundTrunkRequest ](),
59- Flags : []cli.Flag {
59+ Flags : appendSIPMediaFlags ( []cli.Flag {
6060 & cli.StringFlag {
6161 Name : "name" ,
6262 Usage : "Sets a new name for the trunk" ,
6565 Name : "numbers" ,
6666 Usage : "Sets a list of numbers for the trunk" ,
6767 },
68- sipMediaEncFlag (),
6968 & cli.StringFlag {
7069 Name : "auth-user" ,
7170 Usage : "Set username for authentication" ,
@@ -74,14 +73,14 @@ var (
7473 Name : "auth-pass" ,
7574 Usage : "Set password for authentication" ,
7675 },
77- },
76+ }) ,
7877 },
7978 {
8079 Name : "update" ,
8180 Usage : "Update an inbound SIP Trunk" ,
8281 Action : updateSIPInboundTrunk ,
8382 ArgsUsage : RequestDesc [livekit.UpdateSIPInboundTrunkRequest ](),
84- Flags : []cli.Flag {
83+ Flags : appendSIPMediaFlags ( []cli.Flag {
8584 & cli.StringFlag {
8685 Name : "id" ,
8786 Usage : "ID for the trunk to update" ,
@@ -102,7 +101,7 @@ var (
102101 Name : "auth-pass" ,
103102 Usage : "Set password for authentication" ,
104103 },
105- },
104+ }) ,
106105 },
107106 {
108107 Name : "delete" ,
@@ -128,7 +127,7 @@ var (
128127 Usage : "Create an outbound SIP Trunk" ,
129128 Action : createSIPOutboundTrunk ,
130129 ArgsUsage : RequestDesc [livekit.CreateSIPOutboundTrunkRequest ](),
131- Flags : []cli.Flag {
130+ Flags : appendSIPMediaFlags ( []cli.Flag {
132131 & cli.StringFlag {
133132 Name : "name" ,
134133 Usage : "Sets a new name for the trunk" ,
@@ -145,7 +144,6 @@ var (
145144 Name : "destination-country" ,
146145 Usage : "Sets a destination country for the trunk as ISO 3166-1 alpha-2 (https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)" ,
147146 },
148- sipMediaEncFlag (),
149147 & cli.StringSliceFlag {
150148 Name : "numbers" ,
151149 Usage : "Sets a list of numbers for the trunk" ,
@@ -158,14 +156,14 @@ var (
158156 Name : "auth-pass" ,
159157 Usage : "Set password for authentication" ,
160158 },
161- },
159+ }) ,
162160 },
163161 {
164162 Name : "update" ,
165163 Usage : "Update an outbound SIP Trunk" ,
166164 Action : updateSIPOutboundTrunk ,
167165 ArgsUsage : RequestDesc [livekit.UpdateSIPOutboundTrunkRequest ](),
168- Flags : []cli.Flag {
166+ Flags : appendSIPMediaFlags ( []cli.Flag {
169167 & cli.StringFlag {
170168 Name : "id" ,
171169 Usage : "ID for the trunk to update" ,
@@ -198,7 +196,7 @@ var (
198196 Name : "auth-pass" ,
199197 Usage : "Set password for authentication" ,
200198 },
201- },
199+ }) ,
202200 },
203201 {
204202 Name : "delete" ,
@@ -269,7 +267,7 @@ var (
269267 Usage : "Update a SIP Dispatch Rule" ,
270268 Action : updateSIPDispatchRule ,
271269 ArgsUsage : RequestDesc [livekit.UpdateSIPDispatchRuleRequest ](),
272- Flags : []cli.Flag {
270+ Flags : appendSIPMediaFlags ( []cli.Flag {
273271 & cli.StringFlag {
274272 Name : "id" ,
275273 Usage : "ID for the rule to update" ,
@@ -282,7 +280,7 @@ var (
282280 Name : "trunks" ,
283281 Usage : "Sets a new list of trunk IDs" ,
284282 },
285- },
283+ }) ,
286284 MutuallyExclusiveFlags : []cli.MutuallyExclusiveFlags {
287285 {
288286 Flags : [][]cli.Flag {
@@ -484,16 +482,12 @@ func optBoolFlag(cmd *cli.Command, setName string) (bool, bool) {
484482 return cmd .Bool (setName ), true
485483}
486484
487- func sipMediaEncFlag () cli.Flag {
488- return & cli.StringFlag {
489- Name : "media-enc" ,
490- Usage : "Sets media encryption for outbound call" ,
491- }
492- }
493-
494485func appendSIPMediaFlags (flags []cli.Flag ) []cli.Flag {
495486 flags = append (flags ,
496- sipMediaEncFlag (),
487+ & cli.StringFlag {
488+ Name : "media-enc" ,
489+ Usage : "Sets media encryption for outbound call" ,
490+ },
497491 & cli.BoolFlag {
498492 Name : "no-default-codecs" ,
499493 Usage : "Disables a builtin list of default SIP codecs" ,
@@ -600,6 +594,11 @@ func createSIPInboundTrunk(ctx context.Context, cmd *cli.Command) error {
600594 if val , ok := listSetFlag (cmd , "numbers" ); ok {
601595 p .Numbers = val
602596 }
597+ if m , err := parseSIPMediaConfig (cmd ); err == nil {
598+ p .Media = m
599+ } else if err != nil {
600+ return err
601+ }
603602 if enc , err := parseSIPMediaEnc (cmd ); err == nil && enc != nil {
604603 p .MediaEncryption = * enc
605604 } else if err != nil {
@@ -663,6 +662,16 @@ func updateSIPInboundTrunk(ctx context.Context, cmd *cli.Command) error {
663662 if val := cmd .String ("auth-pass" ); val != "" {
664663 req .AuthPassword = & val
665664 }
665+ if m , err := parseSIPMediaConfig (cmd ); err == nil {
666+ req .Media = m
667+ } else if err != nil {
668+ return err
669+ }
670+ if enc , err := parseSIPMediaEnc (cmd ); err == nil && enc != nil {
671+ req .MediaEncryption = enc
672+ } else if err != nil {
673+ return err
674+ }
666675 req .Numbers = listUpdateFlag (cmd , "numbers" )
667676 info , err := cli .UpdateSIPInboundTrunk (ctx , & livekit.UpdateSIPInboundTrunkRequest {
668677 SipTrunkId : id ,
@@ -707,6 +716,11 @@ func createSIPOutboundTrunk(ctx context.Context, cmd *cli.Command) error {
707716 if val := cmd .String ("destination-country" ); val != "" {
708717 p .DestinationCountry = val
709718 }
719+ if m , err := parseSIPMediaConfig (cmd ); err == nil {
720+ p .Media = m
721+ } else if err != nil {
722+ return err
723+ }
710724 if enc , err := parseSIPMediaEnc (cmd ); err == nil && enc != nil {
711725 p .MediaEncryption = * enc
712726 } else if err != nil {
@@ -791,6 +805,16 @@ func updateSIPOutboundTrunk(ctx context.Context, cmd *cli.Command) error {
791805 if val := cmd .String ("auth-pass" ); val != "" {
792806 req .AuthPassword = & val
793807 }
808+ if m , err := parseSIPMediaConfig (cmd ); err == nil {
809+ req .Media = m
810+ } else if err != nil {
811+ return err
812+ }
813+ if enc , err := parseSIPMediaEnc (cmd ); err == nil && enc != nil {
814+ req .MediaEncryption = enc
815+ } else if err != nil {
816+ return err
817+ }
794818 req .Numbers = listUpdateFlag (cmd , "numbers" )
795819 info , err := cli .UpdateSIPOutboundTrunk (ctx , & livekit.UpdateSIPOutboundTrunkRequest {
796820 SipTrunkId : id ,
@@ -1083,6 +1107,16 @@ func updateSIPDispatchRule(ctx context.Context, cmd *cli.Command) error {
10831107 req .Name = & val
10841108 }
10851109 req .TrunkIds = listUpdateFlag (cmd , "trunks" )
1110+ if m , err := parseSIPMediaConfig (cmd ); err == nil {
1111+ req .Media = m
1112+ } else if err != nil {
1113+ return err
1114+ }
1115+ if enc , err := parseSIPMediaEnc (cmd ); err == nil && enc != nil {
1116+ req .MediaEncryption = enc
1117+ } else if err != nil {
1118+ return err
1119+ }
10861120 if val := cmd .String ("direct" ); val != "" {
10871121 if req .Rule != nil {
10881122 return fmt .Errorf ("only one dispatch rule type is allowed" )
0 commit comments