Move port defaulting logic to parseURL().

This commit is contained in:
scruzin 2019-01-20 13:33:44 +10:30
parent 89d9bf3eef
commit 0105c76dc5
2 changed files with 10 additions and 11 deletions

View File

@ -121,17 +121,6 @@ func Dial(url string, timeout uint, log Log) (*Conn, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
if c.link.port == 0 {
switch {
case (c.link.protocol & featureSSL) != 0:
c.link.port = 433
c.log(FatalLevel, pkg+"SSL not supported")
case (c.link.protocol & featureHTTP) != 0:
c.link.port = 80
default:
c.link.port = 1935
}
}
c.link.url = rtmpProtocolStrings[c.link.protocol] + "://" + c.link.host + ":" + strconv.Itoa(int(c.link.port)) + "/" + c.link.app c.link.url = rtmpProtocolStrings[c.link.protocol] + "://" + c.link.host + ":" + strconv.Itoa(int(c.link.port)) + "/" + c.link.app
c.link.protocol |= featureWrite c.link.protocol |= featureWrite

View File

@ -99,5 +99,15 @@ func parseURL(addr string) (protocol int32, host string, port uint16, app, playp
} }
} }
if port == 0 {
switch {
case (protocol & featureSSL) != 0:
port = 433
case (protocol & featureHTTP) != 0:
port = 80
default:
port = 1935
}
}
return protocol, host, port, app, playpath, nil return protocol, host, port, app, playpath, nil
} }