Archived
2
0

single port ice using tcp and udp mux (#106)

This commit is contained in:
Miroslav Šedivý
2021-12-03 23:54:07 +01:00
committed by GitHub
parent a213ae400a
commit c97b1fc454
4 changed files with 97 additions and 34 deletions

View File

@ -20,6 +20,8 @@ type WebRTC struct {
EphemeralMin uint16
EphemeralMax uint16
NAT1To1IPs []string
TCPMUX int
UDPMUX int
}
func (WebRTC) Init(cmd *cobra.Command) error {
@ -33,6 +35,16 @@ func (WebRTC) Init(cmd *cobra.Command) error {
return err
}
cmd.PersistentFlags().Int("tcpmux", 0, "single TCP mux port for all peers")
if err := viper.BindPFlag("tcpmux", cmd.PersistentFlags().Lookup("tcpmux")); err != nil {
return err
}
cmd.PersistentFlags().Int("udpmux", 0, "single UDP mux port for all peers")
if err := viper.BindPFlag("udpmux", cmd.PersistentFlags().Lookup("udpmux")); err != nil {
return err
}
cmd.PersistentFlags().String("ipfetch", "http://checkip.amazonaws.com", "automatically fetch IP address from given URL when nat1to1 is not present")
if err := viper.BindPFlag("ipfetch", cmd.PersistentFlags().Lookup("ipfetch")); err != nil {
return err
@ -58,6 +70,8 @@ func (WebRTC) Init(cmd *cobra.Command) error {
func (s *WebRTC) Set() {
s.NAT1To1IPs = viper.GetStringSlice("nat1to1")
s.TCPMUX = viper.GetInt("tcpmux")
s.UDPMUX = viper.GetInt("udpmux")
s.ICELite = viper.GetBool("icelite")
s.ICEServers = []webrtc.ICEServer{}