Skip to content

Commit fe7f105

Browse files
committed
getlantern#2162 Slight performance optimization on comparing allowed ports
1 parent 14a6b74 commit fe7f105

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

‎src/github.com/getlantern/fronted/server.go‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,14 +211,19 @@ func (server *Server) checkForNonGlobalDestination(addr string) error {
211211
}
212212

213213
func (server *Server) checkForDisallowedPort(addr string) error {
214-
_, port, err := net.SplitHostPort(addr)
214+
_, portString, err := net.SplitHostPort(addr)
215215
if err != nil {
216216
return fmt.Errorf("Unable to split host and port for %v: %v", addr, err)
217217
}
218218

219+
port, err := strconv.Atoi(portString)
220+
if err != nil {
221+
return fmt.Errorf("Unable to convert port %v to integer: %v", portString, err)
222+
}
223+
219224
portAllowed := false
220225
for _, allowed := range server.AllowedPorts {
221-
if port == strconv.Itoa(allowed) {
226+
if port == allowed {
222227
portAllowed = true
223228
break
224229
}

0 commit comments

Comments
 (0)