@ -81,15 +81,18 @@ func (sc *ServeConfig) WebHandlerExists(hp HostPort, mount string) bool {
// GetWebHandler returns the HTTPHandler for the given host:port and mount point.
// GetWebHandler returns the HTTPHandler for the given host:port and mount point.
// Returns nil if the handler does not exist.
// Returns nil if the handler does not exist.
func ( sc * ServeConfig ) GetWebHandler ( hp HostPort , mount string ) * HTTPHandler {
func ( sc * ServeConfig ) GetWebHandler ( hp HostPort , mount string ) * HTTPHandler {
if sc . Web [ hp ] != nil {
if sc == nil || sc . Web [ hp ] == nil {
return sc . Web [ hp ] . Handlers [ mount ]
}
return nil
return nil
}
}
return sc . Web [ hp ] . Handlers [ mount ]
}
// GetTCPPortHandler returns the TCPPortHandler for the given port.
// GetTCPPortHandler returns the TCPPortHandler for the given port.
// If the port is not configured, nil is returned.
// If the port is not configured, nil is returned.
func ( sc * ServeConfig ) GetTCPPortHandler ( port uint16 ) * TCPPortHandler {
func ( sc * ServeConfig ) GetTCPPortHandler ( port uint16 ) * TCPPortHandler {
if sc == nil {
return nil
}
return sc . TCP [ port ]
return sc . TCP [ port ]
}
}
@ -97,7 +100,7 @@ func (sc *ServeConfig) GetTCPPortHandler(port uint16) *TCPPortHandler {
// in TCPForward mode on any port.
// in TCPForward mode on any port.
// This is exclusive of Web/HTTPS serving.
// This is exclusive of Web/HTTPS serving.
func ( sc * ServeConfig ) IsTCPForwardingAny ( ) bool {
func ( sc * ServeConfig ) IsTCPForwardingAny ( ) bool {
if len ( sc . TCP ) == 0 {
if sc == nil || len ( sc . TCP ) == 0 {
return false
return false
}
}
for _ , h := range sc . TCP {
for _ , h := range sc . TCP {
@ -112,7 +115,7 @@ func (sc *ServeConfig) IsTCPForwardingAny() bool {
// in TCPForward mode on the given port.
// in TCPForward mode on the given port.
// This is exclusive of Web/HTTPS serving.
// This is exclusive of Web/HTTPS serving.
func ( sc * ServeConfig ) IsTCPForwardingOnPort ( port uint16 ) bool {
func ( sc * ServeConfig ) IsTCPForwardingOnPort ( port uint16 ) bool {
if sc . TCP [ port ] == nil {
if sc == nil || sc . TCP [ port ] == nil {
return false
return false
}
}
return ! sc . TCP [ port ] . HTTPS
return ! sc . TCP [ port ] . HTTPS
@ -122,14 +125,22 @@ func (sc *ServeConfig) IsTCPForwardingOnPort(port uint16) bool {
// Web/HTTPS on the given port.
// Web/HTTPS on the given port.
// This is exclusive of TCPForwarding.
// This is exclusive of TCPForwarding.
func ( sc * ServeConfig ) IsServingWeb ( port uint16 ) bool {
func ( sc * ServeConfig ) IsServingWeb ( port uint16 ) bool {
if sc . TCP [ port ] == nil {
if sc == nil || sc . TCP [ port ] == nil {
return false
return false
}
}
return sc . TCP [ port ] . HTTPS
return sc . TCP [ port ] . HTTPS
}
}
// IsFunnelOn checks if ServeConfig is currently allowing
// IsFunnelOn checks if ServeConfig is currently allowing
// funnel traffic on for the given host:port.
// funnel traffic for any host:port.
func ( sc * ServeConfig ) IsFunnelOn ( hp HostPort ) bool {
func ( sc * ServeConfig ) IsFunnelOn ( ) bool {
return sc . AllowFunnel [ hp ]
if sc == nil {
return false
}
for _ , b := range sc . AllowFunnel {
if b {
return true
}
}
return false
}
}